本文整理汇总了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
# =============================================================================