如何以编程方式读取MSI文件中的属性? [英] How to programmatically read the properties inside an MSI file?
本文介绍了如何以编程方式读取MSI文件中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以读取msi文件中的属性?
Is there any way to read the properties inside the msi file?
例如,给定一个msi文件名称Testpackage.msi
For example given a msi file name Testpackage.msi
我需要找到
productName
PackageCode
version
这将与WMI卸载一起使用
This I am going to use it with WMI uninstall
string objPath = string.Format("Win32_Product.IdentifyingNumber='{0}',Name='{1}',Version='{2}'", "{AC9C1263-2BA8-4863-BE18-01232375CE42}", "testproduct", "10.0.0.0");
更新: 使用Orca是一个不错的选择,如果可以通过编程实现,那么我可以使用它来生成自动发行说明.并在卸载程序中也是如此.
Update: Using Orca is a great option, if this can be achieved programatically, then I can use this to generate automatic release notes. and in un-install program too.
推荐答案
You can use the COM-based API for working with MSI, and do something like
Function GetVersion(ByVal msiName)
Const msiOpenDatabaseModeReadOnly = 0
Dim msi, db, view
Set msi = CreateObject("WindowsInstaller.Installer")
Set db = msi.OpenDataBase(msiName, msiOpenDatabaseModeReadOnly)
Set view = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property` = 'ProductVersion'")
Call view.Execute()
GetVersion = view.Fetch().StringData(1)
End Function
这篇关于如何以编程方式读取MSI文件中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文