Newbie: How to read metadata from a windows DLL

F

Frank Foss

Greetings!
If you will forgive a newbie, I'll try to explain what I want to do.
(Googling wasn't really successful in this case, since I don't know where to
begin.)

My company is making software, and part of the release notes are details
about the files included in the release, timestamp, version, checksum, and
so on. This info is gathered in a very manual process:
In Windows Explorer, highlighting the file, ALT+Enter to bring up a
"Properties" window.
In this window, there are tabs, "General","Version", and so on.

What I would like to do, is to write a quick Perl script that will traverse
a directory,
look "inside" each .DLL or what ever type of file, read the metadata
attributes, and write to a file.

I am using ActiveState Perl, 5.6.1 on Windows 2000.

Guess my questions are:
Is there a Perl module that allows me to read this info from the files?
What methods to use?
Examples of code to do this?
Module to compute checksums?

Thanks in advance,
Foz
 
B

Bob Walton

Frank Foss wrote:

....

My company is making software, and part of the release notes are details
about the files included in the release, timestamp, version, checksum, and
so on. This info is gathered in a very manual process:
In Windows Explorer, highlighting the file, ALT+Enter to bring up a
"Properties" window.
In this window, there are tabs, "General","Version", and so on.

What I would like to do, is to write a quick Perl script that will traverse
a directory,
look "inside" each .DLL or what ever type of file, read the metadata
attributes, and write to a file.

I am using ActiveState Perl, 5.6.1 on Windows 2000.

Guess my questions are:
Is there a Perl module that allows me to read this info from the files?


I'm not aware of any, but you might check on CPAN. Maybe something
like Win32::File::Ver ?

http://www.cpan.org

What methods to use?
Examples of code to do this?
Module to compute checksums?


You might check the Digest::MD5 module.



Here is some really kludgy code to return the

version number of a typical DLL file. It works

for both 16-bit and 32-bit DLL's, but knows nothing
of the real file format of a DLL, and could
conceivably be fooled. This is an excerpt from a
program I use to look for "DLL Hell" on my computer.
Start with the full path to the DLL in $fn and the
base file name in $file:


open IN,$fn or die "Oops, couldn't open $fn, $!";
binmode IN;
$in='';while(read(IN,$a,4000)){$in.=$a}
close IN;
if($in=~/\0F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n\0(.{30})/){
$ver=$1;
while($ver=~s/([^\0])\0([^\0])/$1$2/g){};
$ver=~s/^\0+//;
$ver=~s/^([^\0]+).*/$1/;
$file=$file."|$ver";
}
elsif($in=~/\0FileVersion\0(.{30})/){
$ver=$1;
$ver=~s/^\0+//;
$ver=~s/^([^\0]+).*/$1/;
$file=$file."|$ver";
}
else{
$file=$file."|--not specified--";
}
print $file;

You can probably find some more "meta-info" near the places
where the FileVersion appears. HTH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top