CSJewell has asked for the wisdom of the Perl Monks concerning the following question:

Here's some pseudocode for what I want to do: How do I do it?
... # It is an inside_out object, so #parameters are in %name hashes. } elsif ( $name[$object_id] =~ m{\.dll\z}sm ) { my ( undef, undef, $filename ) = splitpath($name[$object_id] ); # Check for a version resource. # Also check for a version number inside that resource. if (defined $version_number) { my $language = $version_resource->languagecode; $answer = q{<File Id='F_} . $id[$object_id] . q{' Source='} . $filename . q{' DefaultLanguage='} . $language . q{' />}; } else { $answer = q{<File Id='F_} . $id[$object_id] . q{' Source='} . $filename . q{' />}; } } else { ...
  • Comment on How to detect that a Windows DLL has a version resource, and pull data from it.
  • Download Code

Replies are listed 'Best First'.
Re: How to detect that a Windows DLL has a version resource, and pull data from it.
by BrowserUk (Patriarch) on Jul 03, 2009 at 17:00 UTC

    Have a look at Win32::Exe


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      I did that. Got even more lost than I already was just looking at the documentation. Was hoping for other options short of writing the binary-parsing routine myself.

      Although I may have to look again. It was too early in the morning.

      The trick was getting the language code once I got the Win32::Exe object - and it isn't exactly the cleanest code in the world. I had to poke into the object to get it, because there isn't a documented interface for it.
      my $language; my $exe = Win32::Exe->new( $name[$object_id] ); my $vi = $exe->version_info(); if (defined $vi) { # To load the variable used below. $vi->get('OriginalFilename'); $language = hex substr $vi->{'cur_trans'}, 0, 4; # $language is now the language IN DECIMAL. # To get a hex number, drop the 'hex' before the substr. } # use $language if it's defined. ...
Re: How to detect that a Windows DLL has a version resource, and pull data from it.
by Anonymous Monk on Jul 03, 2009 at 17:49 UTC