获取MSI产品属性

时间:2014-07-08 09:12:05

标签: 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文件获取属性。

1 个答案:

答案 0 :(得分:3)

您需要链接库。

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