Dev
Dev

Reputation: 1561

Getting MSI product properties

I am trying to get the product and company information from the MSI installation file using the below code, but I keep getting below error even though I included the necessary header file.

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.

My code is as below (I am using 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 );

Any ideas what I am missing or Is there any other way to get the properties from msi files.

Upvotes: 1

Views: 1171

Answers (1)

Jerry YY Rain
Jerry YY Rain

Reputation: 4382

you need to link the library.

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

Upvotes: 4

Related Questions