develooper Front page | perl.perl6.users | Postings from February 2019

Re: filever.exe sub?

Thread Previous | Thread Next
Bruce Gray
February 1, 2019 00:33
Re: filever.exe sub?
Message ID:

> On Jan 31, 2019, at 12:46 PM, ToddAndMargo via perl6-users <> wrote:
> On 1/29/19 9:53 PM, ToddAndMargo via perl6-users wrote:
>> Hi All,
>> Windows provides a utility called filever.exe which will
>> tell you the revision of and exe file.  (You can also see this
>> through the gui with properties).
>> Currently I run filever.exe through Wine.  It is cumbersome,
>> especially since Wine floods STDERR.  I work around it.
>> Do we have a module for the file's version?  If so, does
>> it run in Linux?
>> If not, does anyone know where the version information is
>> stored in and .exe file so I can write one myself?
>> Many thanks,
>> -T
> Well, I learned it is called "metadata".  And that
> Perl 5 has a module for it, but I can not figure out
> from where they are reading the metadata:

The module loads Ver.xs (pre-compiled during module installation), so the real work is done in Perl 5’s “XS” language, which is a fusion of “C” language and Perl-specific macros.

1. GetFileVersionInfoSize() to get the max size of the memory block (VS_VERSIONINFO) needed by GetFileVersionInfo().
2. malloc() to allocate that memory block.
3. GetFileVersionInfo() to populate VS_VERSIONINFO with the version info.
4. VerQueryValue to read into the VS_VERSIONINFO block, to get the root pointer.

After that, there is basic bit-twiddling to sprintf() the FileVersion and ProductVersion into human-readable format, and store them in the hash that is returned up into Perl.
Hopefully you don't need anything more that those two values; I see that just after them, the source code says:
    /* Brace thyselves */

To call those Windows APIs in Perl 6, you would use NativeCall.

Hope this helps,
Bruce Gray (Util of PerlMonks)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About