use Win32::File::Ver qw(ver print_ansi convert_raw_ver); $file = "c:\\windows\\system\\wininet.dll";
$ver = ver($file); print_ansi($file);
print "Calculated FileVersion: ". convert_raw_ver( $ver->{RawVersionInfo}[0], $ver->{RawVersionInfo}[1] )."\n"; print "Calculated ProductVersion: ". convert_raw_ver( $ver->{RawVersionInfo}[2], $ver->{RawVersionInfo}[3] )."\n";
The current version of Win32::File::Ver is available at:
http://www.dux.ru/guest/fno/perl/
$version = ver( $file_path );
This function returns a hash ref or undef on errors. The keys of the %$version hash are:
CompanyName \ FileDescription | InternalName | The ame values as you see in the windows explorer LegalCopyright | property sheet OriginalFilename | ProductName / FileOS - one of the following values: UNKNOWN, WINDOWS32, NT, NT_WINDOWS32, WINDOWS16, DOS, DOS_WINDOWS16, DOS_WINDOWS32, OS216, OS232, PM16, PM32, OS216_PM16, OS232_PM32 Specifies the operating system for which this file was designed.
For example "NT_WINDOWS32" means that file was designed for the Win32 API running on Windows NT, "OS232_PM32" means OS/2-32 with PM-32 etc. FileType - one of the following values: UNKNOWN, APP, DLL, DRV, FONT, VXD, STATIC_LIB Probably the correctness is not guaranteed.
FileSubtype - if FileType is DRV one of the following UNKNOWN, PRINTER, KEYBOARD, LANGUAGE, DISPLAY, MOUSE, NETWORK, SYSTEM, INSTALLABLE, SOUND, COMM, INPUTMETHOD if FileType is FONT UNKNOWN, RASTER, VECTOR, or TRUETYPE if FileType is VXD FileSubtype contains the virtual device identifier included in the virtual device control block .
FileVersion - the same as in the Properties sheet, free format, anything including "1,0,0,1" etc.
ProductVersion - the same for the product version
RawVersionInfo - referer to array that contains raw digital version info, kinda "real version".
Elements of this array are: $dwFileVersionMS, $dwFileVersionLS, $dwProductVersionMS, $dwProductVersionLS, $dwFileFlagsMask, $dwFileFlags, $dwFileOS, $dwFileType, $dwFileSubtype, $dwFileDateMS, $dwFileDateLS
All values are 32-bit digital. For more info look at the Win32 SDK - VS_FIXEDFILEINFO structure. You can convert raw file and product versions to the "Microsoft version style" - how I understood it ;) - with the convert_raw_ver() function
Flags - referer to array that contains none, one or more of the following values: DEBUG, PRERELEASE, PATCHED, PRIVATEBUILD, INFOINFERRED, SPECIALBUILD версия для печати
$microsoft_style_string = convert_raw_ver( $versionMS, $versionLS );
OK. What's ``M$ style''? 64 bits are splited to 4 16-bit numbers. Each of them is converted to decimal number. If the 3rd of these 4 numbers is zero, the third part is omitted. The 1st and the 4th parts are at least 1 digit long, the second one - at least 2 digits long (with zero-padding).
Look into the code for (not much) more.
perl -MWin32::File::Ver=print_ansi -e print_ansi filename
If called within the program this function requires one argument
print_ansi($file_path);
The Flags data are being printed if there is at least one element in @{$ver->{Flags}} array.
This function is handy to print to MS DOS console on localized machines.
This module requires:
Win32::API module by Aldo Calpini.
enum.pm (1.014 or later, no compilations) by Byron Brummer (aka Zenin)
0.02 One small fix that solves the problem with more then 8 bytes long lang_charset
Septemer 8, 1999.
Thanks to Brad Turner for poining out one problem in v.0.01
http://www.dux.ru/guest/fno/perl/
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.