Entry
.dll and .exe file version information
Jul 5th, 2000 10:02
Nathan Wallace, Hans Nowak, Snippet 280, emuller@painewebber.com
"""
Packages: operating_systems.windows
"""
"""
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.
"""
import win32api
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.
"""
if __name__ == "__main__":
print FileVer("c:/", "command.com")