c++ - 获取 MSI 产品属性

标签 c++ windows qt windows-installer

我正在尝试使用以下代码从 MSI 安装文件中获取产品和公司信息,但即使我包含了必要的头文件,我仍然会遇到以下错误。

error: LNK2019: unresolved external symbol _MsiCloseHandle@4 referenced in function.
error: LNK2019: unresolved external symbol _MsiOpenPackageW@8 referenced in function.
error: LNK2019: unresolved external symbol _MsiGetProductPropertyW@16 referenced in function.

我的代码如下(我使用的是QT C++)

#include <Windows.h>
#include <Msi.h>
#include <MsiQuery.h>

LPCWSTR program = L"C:/installer.msi";
MSIHANDLE hProduct = NULL;
LPWSTR pszVersion = NULL;
LPDWORD dwSizeVersion = NULL;
LPCWSTR property = L"IncludeVersion";

MsiOpenPackage( program, &hProduct );
MsiGetProductProperty( hProduct, property, pszVersion, dwSizeVersion );
MsiCloseHandle( hProduct );

知道我遗漏了什么,或者是否有任何其他方法可以从 msi 文件中获取属性。

最佳答案

您需要链接库。

#pragma comment(lib, "msi.lib")

关于c++ - 获取 MSI 产品属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24627957/

相关文章:

PHP ZipArchive 不添加任何文件 (Windows)

c++ - KeyPressEvent 不起作用

C++优先级队列构造函数

c++ - 如何使链接列表按字母顺序打印出其内容?

c++ - 是否有像 docco 这样的 C/C++ 源代码文档生成器?

c++ - wcscat_s 函数 - 缓冲区错误

python - 无法从 python os.path.abspath 获取有效路径名

ios - cordova 在 Windows 上构建 IOS

c++ - QTableView自动调整行高

c++ - QLineWidget returnPressed 信号不工作