.dll and .exe file version informaton

emuller at painewebber.com emuller at painewebber.com
Sat Nov 13 20:06:21 CET 1999


I am not a C programmer, but I did come up with a very stupid hack (see
below). This hack requires that the executable filever.exe be either in
the current path or the current directory. filever.exe is part of the
NT Resource Kit.

def FileVer(path,file):
        import win32pipe
        import string
        verdata = {}
        curDir = win32api.GetFullPathName('.')
        progPath = "FILEVER.EXE" + " /V \"" + win32api.GetFullPathName
(path) + "\\" + file + "\""
        myPipe = win32pipe.popen(progPath ,'r')
        verRaw = myPipe.read()
        # split the raw data into lines....
        lines = string.split(verRaw,"\012\011")
        #There was only basic data, parse that
        verdata['attributes'] = lines[0][0:5]
        verdata['Short OS'] = lines[0][6:10]
        verdata['Short FileType'] = lines[0][11:14]
        verdata['Short Language'] = lines[0][15:18]
        verdata['Short Version'] = string.strip(string.strip(lines[0]
[19:34]))
        verdata['Short Mode'] = lines[0][35:38]
        verdata['Size'] = string.strip(lines[0][39:49])
        verdata['Date'] = lines[0][50:60]
        verdata['Filename'] = string.strip(lines[0][61:])
        if len(lines) <> 1:
                del lines[0]
                for line in lines:
                        list = string.split(line,"\011")
                        if len(list) == 1:
                                continue
                        else:
                                verdata[list[0]] = string.strip(list[len
(list)-1])

        return verdata


If any one uses this, let me know, if anyone fixes a bug please let me
know as well.

In article <C6XW3.10409$Xd2.618639 at typhoon.nyroc.rr.com>,
  "Darrell" <news at dorb.com> wrote:
> Given the win32 calls it wouldn't be too hard to wrap them up in an
> extension module.
>
> --
> --Darrell
> <edwardm_painewebber at my-deja.com> wrote in message
> news:80ha4a$pmg$1 at nnrp1.deja.com...
> > It looks like they are not available yet....
> > In article <816010E2456BD111A48700805FBBE2EEFDF793 at ex-quebec-
> > u1.baan.com>,
> >   Gaetan Corneau <Gaetan_Corneau at baan.com> wrote:
> > > > go-ahead-just-*try*-to-write-a-program-to-do-that<wink>-ly
y'rs  -
> > tim
> > >
> > > If you really want to do it in a program, take a look at the
following
> > > functions in the help:
> > > GetFileVersionInfo
> > > VerQueryValue
> > > QueryField
> > >
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list