Click to See Complete Forum and Search --> : VC++ compiler can't find MsiOpenPackageEx


eug_prog
September 26th, 2006, 02:32 PM
I try to compile my program that calls these MSI functions:

MsiOpenPackageEx()
MsiGetProperty()
MsiCloseHandle()

VC++ compiler can't find the first two - dumps this type of message:

UsingMsiApis\UsingMsiApis.cpp(32) : error C3861: 'MsiOpenPackageEx': identifier not found, even with argument-dependent lookup

I have included in INCLUDE and LIB locations of msi.h and msi.lib.
Since I work on WinXP, I explicitly set _WIN32_MSI to be 200 (though I shouldn't have to).

If you have any ideas why compiler can't find MSI SDK functions, please let me know. I have tried everything that came to my mind - all in vain.

golanshahar
September 26th, 2006, 05:01 PM
Do you have the latest SDK installed? ( PSDK )

BTW you can use dynamic loading here is a sample for ::MsiOpenPackageEx().


typedef UINT (WINAPI *tMsiOpenPackageExA)(LPCTSTR,DWORD,MSIHANDLE);

tMsiOpenPackageExA pMsiOpenPackageExA = 0;
HINSTANCE handle = ::LoadLibrary("Msi.dll");
if ( handle )
pMsiOpenPackageExA = (tMsiOpenPackageExA)::GetProcAddress(handle, "MsiOpenPackageExA");
if ( pMsiOpenPackageExA )
{
// call the function
pMsiOpenPackageExA(....);
}
if ( handle )
::FreeLibrary(handle);


You can do the same thing for the rest of the APIs.

Cheers

eug_prog
October 2nd, 2006, 04:09 PM
I have 2003 PSDK. These should include XP where I am compiling my program. MsiOpenPackageEx() is availbable in MSI v2.0 and up. If I am not mistaken, XP bundles MSI v2.0 by default.

By the way, code linked fine if I used MsiOpenPackage() - which is available in base MSI v1.0 - so I think the issue is still in availability of correct MSI exe/lib.

golanshahar
October 4th, 2006, 03:14 PM
Well I can only offer you my second solution: use dynamic loading ;)

Cheers

wildfrog
October 4th, 2006, 04:08 PM
Since I work on WinXP, I explicitly set _WIN32_MSI to be 200 (though I shouldn't have to).You need to tell the compiler that you work on XP, typically like this:

// set target platform
#define _WIN32_WINNT 0x0501

// include headers
#include <windows.h>
#include <msi.h>
#include <msiquery.h> // for MsiGetProperty

Then you shouldn't need to explicit define _WIN32_MSI, nor use dynmically loading... if you got an up-to-date SDK that is.

- petter