Newbie: How to read metadata from a windows DLL

Discussion in 'Perl Misc' started by Frank Foss, Aug 16, 2003.

  1. Frank Foss

    Frank Foss Guest

    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
     
    Frank Foss, Aug 16, 2003
    #1
    1. Advertising

  2. Frank Foss

    Bob Walton Guest

    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.


    >

    ....


    > Foz



    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.
    --
    Bob Walton
     
    Bob Walton, Aug 16, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    8,783
  2. John Doe
    Replies:
    6
    Views:
    6,607
    Scott Allen
    Feb 12, 2005
  3. Brett Selleck

    Schema Metadata not a Metadata Schema

    Brett Selleck, Sep 4, 2003, in forum: XML
    Replies:
    1
    Views:
    416
    Andy Dingley
    Sep 4, 2003
  4. Thomas W

    Read Picasa metadata using Python?

    Thomas W, Aug 17, 2006, in forum: Python
    Replies:
    1
    Views:
    396
    jay graves
    Aug 17, 2006
  5. Xd Ork

    Read Database Metadata

    Xd Ork, Nov 27, 2008, in forum: Ruby
    Replies:
    4
    Views:
    119
    Xd Ork
    Nov 28, 2008
Loading...

Share This Page