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

查看:28
本文介绍了检索 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() 是一个从 PE 文件(.exe 或 .dll)中读取版本资源信息的函数 与 Windows Installer 一样.这对于使用构建工具(例如 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天全站免登陆