當前位置: 首頁>>代碼示例>>Python>>正文


Python win32api.GetFileVersionInfo方法代碼示例

本文整理匯總了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)) 
開發者ID:cloudbase,項目名稱:cloudbase-init,代碼行數:8,代碼來源:windows.py

示例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
	) 
開發者ID:adamrehn,項目名稱:ue4-docker,代碼行數:10,代碼來源:verify-host-dlls.py

示例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
# ============================================================================= 
開發者ID:winpython,項目名稱:winpython,代碼行數:44,代碼來源:utils.py


注:本文中的win32api.GetFileVersionInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。