2017-05-30 11 views
0

簡単に言えば、pefileモジュールを使用して実行可能ファイルの名前を取得する方法はありますか?また Illustrationpefileを使用してアプリケーション名を取得する

PEFileでは不可能であれば、それは何か他のものでも可能である、:私たちは説明として、ここで何を参照してください、私は名前の意味は何

はありますか?可能であればpywin32を使用せずにできるだけ普遍的にしてください。

ありがとう

答えて

1

あなたは簡単にそれを行うことはできません。私はpywin32を使用することをお勧めします(これはWindows上でのみ動作しますが、それは既に何かがあります)。

あなたが使用することができます(別の答えから盗まれた)

def getFileProperties(fname): 
    """ 
    Reads all properties of the given file return them as a dictionary. 
    """ 
    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 
関連する問題