> On Jan 31, 2019, at 12:46 PM, ToddAndMargo via perl6-users
> <perl6-us...@perl.org> 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:
>
> https://metacpan.org/pod/release/ALEXEYT/Win32-File-Ver-0.02/Ver.pm
The Ver.pm 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.
https://st.aticpan.org/source/ALEXEYT/Win32-File-Ver-0.02/Ver.xs
Calls:
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)