Hello everybody,

The script below uses three Windows API's in version.dll to obtain file version
information.  I have been testing with this command line:

GetFileVersionInfo.pl c:\windows\twunk_32.exe

The basic file information works fine, but there is also a subblock that has me
at the end of my rope.  Been struggling with this for quite awhile.  I would
sure appreciate any tips on how to extract the information it contains.  I'm
confused on whether it is VS_FIXEDFILEINFO or VS_VERSIONINFO that I'm looking
for.  Information on them can be found here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/Wi
ndowsUserInterface/Resources/VersionInformation/VersionInformationReference/Ver
sionInformationStructures/VS_FIXEDFILEINFO.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/Wi
ndowsUserInterface/Resources/VersionInformation/VersionInformationReference/Ver
sionInformationStructures/VS_FIXEDFILEINFO.asp

If I use VS_VERSION_INFO as I've done here (and note the extra underscore),
some unicode characters are printed, and I figure that that clump contains some
info, but I don't know how to extract it.  But VS_FIXEDFILEINFO is the one that
describes the file information I'm trying to get at.

Gary

PS  This all looks fine when I'm sending it.  Hope it doesn't get too messed up
in transit.

#!perl.exe

use Win32::API;

$filename = $ARGV[0];
        
$GetFileVersionInfoSize = new Win32::API(
                                "version.dll", 
                                "GetFileVersionInfoSizeA", 
                                ['P', 'P'], 
                                'N'
                                );
        $lpBufferSize   = 
                $GetFileVersionInfoSize->Call(
                                $filename, 
                                $lpHandle
                                );

$GetFileVersionInfo   = new Win32::API( 
                                "version.dll", 
                                "GetFileVersionInfoA", 
                                ['P', 'N', 'N', 'P'], 
                                'I'
                                );
        $pBlock         = "Z" x $lpBufferSize;
        $one_or_zero    = $GetFileVersionInfo->Call(
                                $filename, 
                                0, 
                                $lpBufferSize, 
                                $pBlock
                                );
        $PAT{RAWBuffer} = $pBlock;      # for debugging

$lpSubBlock = pack("L*", Q);    
$lplpBuffer = "X" x 32;
$puLen      = "Y" x 4;

$VerQueryValue = new Win32::API(
                                "version.dll", 
                                "VerQueryValueA", 
                                ['P', 'P' , 'P', 'P'], 
                                'N'
                                );

if (! $VerQueryValue->Call(
                                $pBlock, 
                                $lpSubBlock, 
                                $lplpBuffer, 
                                $puLen
                                )
) 
{
         print Win32::FormatMessage(Win32::GetLastError);
}

@pattern  = qw(
        VS_VERSION_INFO 
        ProductVersion 
        ProductName 
        OriginalFilename 
        InternalName 
        FileVersion 
        FileDescription 
        CompanyName
);

foreach $p (@pattern) {
        $p              = join("\000", split(//, $p));
        $pBlock         =~ /$p.*[^\001]/;
        ($word, $value) = split(/\000\000\000/,$&);
        $word           =~ s/\000//g;
        $value          =~ s/\000//g;
        $PAT{$word}     = $value;
}

foreach $key (keys (%PAT)) { print "$key" . ":\t\t$PAT{$key}\n"; }

__END__



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to