2014-07-08 139 views
1

我想从MSI安装文件中使用下面的代码获取产品和公司信息,但即使包含必要的头文件,我仍然收到以下错误。获取MSI产品属性

error: LNK2019: unresolved external symbol [email protected] referenced in function. 
error: LNK2019: unresolved external symbol [email protected] referenced in function. 
error: LNK2019: unresolved external symbol [email protected] 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文件性质的任何想法。

回答

3

你需要链接库。

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

对于包含此更大的示例,请参阅[此帖子](http://stackoverflow.com/a/22625489/129130) –