1

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.

Jerry YY Rain
  • 4,134
  • 7
  • 35
  • 52
Dev
  • 1,529
  • 4
  • 24
  • 36

1 Answers1

4

you need to link the library.

#pragma comment(lib, "msi.lib")
Jerry YY Rain
  • 4,134
  • 7
  • 35
  • 52