Posted 06 December 2002 - 09:15
INSTALLDIR too does not work.
And MsiGetProperty in DLL not work :-(((
#include "windows.h"
#include "msi.h"
#include "msiquery.h"
UINT __stdcall GetInstallDir(MSIHANDLE hInstall)
{
UINT res = ERROR_SUCCESS;
TCHAR* szValueBuf = NULL;
DWORD cchValueBuf = 0;
UINT uiStat = MsiGetProperty(hInstall, TEXT("INSTALLDIR"), TEXT(""), &cchValueBuf);
if (ERROR_MORE_DATA == uiStat)
{
++cchValueBuf; // on output does not include terminating null, so add 1
szValueBuf = new TCHAR[cchValueBuf];
if (szValueBuf)
{
uiStat = MsiGetProperty(hInstall, TEXT("MyProperty"), szValueBuf, &cchValueBuf);
}
}
if (ERROR_SUCCESS != uiStat)
res = ERROR_INSTALL_FAILURE;
else
MessageBox(NULL, szValueBuf, NULL, NULL);
delete [] szValueBuf;
return res;
}