本文整理匯總了Python中win32api.GetFileVersionInfo方法的典型用法代碼示例。如果您正苦於以下問題:Python win32api.GetFileVersionInfo方法的具體用法?Python win32api.GetFileVersionInfo怎麽用?Python win32api.GetFileVersionInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類win32api
的用法示例。
在下文中一共展示了win32api.GetFileVersionInfo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_file_version
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import GetFileVersionInfo [as 別名]
def get_file_version(self, path):
info = win32api.GetFileVersionInfo(path, '\\')
ms = info['FileVersionMS']
ls = info['FileVersionLS']
return (win32api.HIWORD(ms), win32api.LOWORD(ms),
win32api.HIWORD(ls), win32api.LOWORD(ls))
示例2: getDllVersion
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import GetFileVersionInfo [as 別名]
def getDllVersion(dllPath):
info = win32api.GetFileVersionInfo(dllPath, '\\')
return '{:d}.{:d}.{:d}.{:d}'.format(
info['FileVersionMS'] // 65536,
info['FileVersionMS'] % 65536,
info['FileVersionLS'] // 65536,
info['FileVersionLS'] % 65536
)
示例3: getFileProperties
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import GetFileVersionInfo [as 別名]
def getFileProperties(fname):
#==============================================================================
"""
Read all properties of the given file return them as a dictionary.
"""
import win32api
propNames = ('Comments', 'InternalName', 'ProductName',
'CompanyName', 'LegalCopyright', 'ProductVersion',
'FileDescription', 'LegalTrademarks', 'PrivateBuild',
'FileVersion', 'OriginalFilename', '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(fname, '\\')
props['FixedFileInfo'] = fixedInfo
props['FileVersion'] = "%d.%d.%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(fname, '\\VarFileInfo\\Translation')[0]
# any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle
# two are language/codepage pair returned from above
strInfo = {}
for propName in propNames:
strInfoPath = u'\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
## print str_info
strInfo[propName] = win32api.GetFileVersionInfo(fname, strInfoPath)
props['StringFileInfo'] = strInfo
except:
pass
return props
# =============================================================================
# Shortcuts, start menu
# =============================================================================