Win32::File::VersionInfo - Read program version information on Win32
use Win32::File::VersionInfo; my $foo = GetFileVersionInfo ( "C:\\path\\to\\file.dll" ); if ( $foo ) { print $foo->{FileVersion}, "\n"; my $lang = ( keys %{$foo->{Lang}} )[0] ); if ( $lang ) { print $foo->{Lang}{$lang}{CompanyName}, "\n"; } ... }
Win32::File::VersionInfo - Perl extension for reading the version information resource from files in the Microsoft Portable Executable (PE) format ( including programs, DLLs, fonts, drivers, etc. ).
This module only has one function and it exports it by default.
GetFileVersionInfo takes a path as it's only argument. If for any reason that path cannot be read or the file does not contain a version information resource, then GetFileVersionInfo will return undef. Otherwise it will return a reference to a hash containing the following:
Contains a 4-part dot-separated version string (i.e. 4.0.4331.6). In Windows Explorer, this appears at the top of the Version tab of the Properties dialog.
Contains a 4-part dot-separated version string (i.e. 4.0.4331.6).
A hash with an element set to 1 if the flag is set to true or 0 if the flag set to false. Flags that are unset have no corresponding element (and so should evaluate to false). Possible flags are:
A two part string separated by a slash (e.g. "NT/Win32"). The first part can be one of:
Note: the WINCE value is not defined in older version of winver.h. If you compiled the XS against an older header, then what should be WINCE may instead show up as Unknown. Unknown is a catchall category for anything not defined in winver.h. For best results use the winver.h from the newest Platform SDK.
The second part can be one of:
PM is the OS/2 Presentation Manager. Unknown is a catchall category for anything not defined in winver.h.
Indicates the type of file that contains the Version Information resource. May be one of:
Note that "Versioned Printer Driver" is not defined in older versions of winver.h. See the note for WINCE above. The Unknowns are catchall categories for anything not defined in winver.h.
A 64-bit hex string. I've never seen this set to anything but 0. It's not well documented in the SDK.
This contains all of the above as raw hex strings. It's here if you want to do something unusual, and for debugging purposes. See the code and the Platform SDK documentation for more info.
This contains the language-dependant variable part. It is a hash with an entry for each language-encoding pair in the Version Information resource. Each language entry is also a hash that may contain any or all of the following as strings (presumably UTF-8, but the SDK is not specific on this point):
These are the bulk of what appears in the Version tab in Windows Explorer.
Note that the values of FileVersion and ProductVersion here are strings, where above they were stringified representations of 64-bit unsigned integers.
Usually only one language will appear, and usually that will be "English (United States)".
Realistically, almost nothing ever uses this information, and the only thing that writes it is the linker that created the PE file in the first place. The only reason you'd want this information is if you're terminaly curious or you're writing an installer. Guess which I was?
Look up "GetFileVersionInfo" in the Microsoft Platform SDK, and browse from there.
Alexey Toptygin <alexeyt@cpan.org> http://alexeyt.freeshell.org/
Copyright 2003 by Alexey Toptygin
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Win32::File::VersionInfo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::File::VersionInfo
CPAN shell
perl -MCPAN -e shell install Win32::File::VersionInfo
For more information on module installation, please visit the detailed CPAN module installation guide.