2010-07-01 81 views

回答

4

尝试SummaryInformation.GetProperty(PID_TITLE)SummaryInformation.GetProperty(PID_REVNUMBER)和所有其他字段名可以使用获得的产品版本:

from msilib import * 

def GetMsiProperty(path ,property): 
    db = OpenDatabase(path, MSIDBOPEN_READONLY) 
    view = db.OpenView ("SELECT Value FROM Property WHERE Property='" + property + "'") 
    view.Execute(None) 
    result = view.Fetch() 
    #print dir(result) 
    return result.GetString(1) 


msiVersion = GetMsiProperty(r'C:\path\to.msi' ,"ProductVersion") 

你的Python版本必须高于2.5的上述功能工作。