检索MSI文件的版本(使用WiX构建) [英] Retrieving version of an MSI file (built with WiX)

查看:102
本文介绍了检索MSI文件的版本(使用WiX构建)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用WiX创建了一个MSI文件. WiX源文件包含如下版本信息:

I've created an MSI file with WiX. The source WiX file contains the version information like this:

<Product Id="..." 
         Name="..." 
         Language="1033" 
         Version="1.0.0.1" 
         Manufacturer="..." 
         UpgradeCode="...">

MSI文件似乎可以正常工作:它可以安装,卸载,在我增加版本号时进行升级等.

The MSI file seem to work OK: it installs, it uninstalls, it upgrades when I increase the version number, etc.

但是,当我尝试通过调用MsiGetFileVersion()API来获取有关此文件的版本信息时,它将返回错误1006(ERROR_FILE_INVALID 文件不包含版本信息.)

However, when I attempt to get the version information about this file by calling the MsiGetFileVersion() API, it returns error 1006 (ERROR_FILE_INVALID File does not contain version information.)

因此,我的问题是:如何(以编程方式,在C ++中)检索MSI文件的版本号?或者换种说法,版本信息应该放在WiX文件中的什么位置,以便可以通过MsiGetFileVersion()进行检索?

Hence my question: how to (programmatically, in C++) retrieve the version number of an MSI file? Or, to put it another way, where in the WiX file should the version information go in order to be retrievable via MsiGetFileVersion()?

更多信息:Windows XP上的MSI 3.0和Vista上的MSI 4.0会发生相同的错误.

More information: The same error occurs with MSI 3.0 on Windows XP and MSI 4.0 on Vista.

推荐答案

出于完整性考虑,:: MsiGetFileVersion()是从> .这对于使用构建工具(例如 WiX工具集)非常重要,这样它们才能正确填充File/@ Version信息.它不会使您获得MSI的版本信息.如@sascha所示,您可以在属性表中查询"ProductVersion",也可以使用:: MsiGetProductProperty()进行操作.

Just for completeness sake, ::MsiGetFileVersion() is a function that reads the version resource information from a PE file (.exe or .dll) the same way the Windows Installer does. That is important for build tools (such as the WiX toolset) to use so they populate the File/@Version information correctly. It will not get you the version information out of an MSI. As @sascha shows you could query the Property table for the "ProductVersion" or you could use the ::MsiGetProductProperty() which will do the same.

这篇关于检索MSI文件的版本(使用WiX构建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆