Python obtains the file version information. The company name and product name are in the returned dictionary.
Code:
[Python]
#----------------------------------------------------------------------
Def _ getCompanyNameAndProductName (self, file_path ):
"""
Read all properties of the given file return them as a dictionary.
"""
PropNames = ('comments', 'internalname', 'productname ',
'Companyname', 'legalcopyright', 'productversion ',
'Filedescription', 'legaltrademarks ', 'privatebuilt ',
'Fileversion', 'ininalfilename ', 'specialbuild ')
Props = {'fixedfileinfo': None, 'stringfileinfo': None, 'fileversion': None}
Try:
# Backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
FixedInfo = win32api. GetFileVersionInfo (file_path ,'\\')
Props ['fixedfileinfo'] = fixedInfo
Props ['fileversion'] = "% d. % d" % (fixedInfo ['fileversionms']/65536,
FixedInfo ['fileversionms'] % 65536, fixedInfo ['fileversionls']/65536,
FixedInfo ['fileversionls'] % 65536)
# \ VarFileInfo \ Translation returns list of available (language, codepage)
# Pairs that can be used to retreive string info. We are using only the first pair.
Lang, codepage = win32api. GetFileVersionInfo (file_path, '\ VarFileInfo \ translation') [0]
# Any other must be of the form \ StringfileInfo \ % 04X % 04X \ parm_name, middle
# Two are language/codepage pair returned from abve
StrInfo = {}
For propName in propNames:
StrInfoPath = U' \ StringFileInfo \ % 04X % 04X \ % s' % (lang, codepage, propName)
# Print str_info
StrInfo [propName] = win32api. GetFileVersionInfo (file_path, strInfoPath)
Props ['stringfileinfo'] = strInfo
Except t:
Pass
If not props ["StringFileInfo"]:
Return (None, None)
Else:
Return (props ["StringFileInfo"] ["CompanName"], props ["StringFileInfo"] ["ProductName"])
From Xiao Ju's column