Is this in a deferred CustomAction? If so, you can't use that function as per
the MSI SDK. Otherwise, I'm not sure.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Pallavi Patrutkar
Sent: Thursday, November 23, 2006 22:03
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] MsiGetTargetPath() returns ERROR_INVALID_HANDLE
Hello,
Can anybody tell me how to use MsiGetTargetPath() to get TARGETDIR value from
my installer?
I am calling this method from my DLL. But for the first call, it returns
ERROR_INVALID_HANDLE.
I am using the same handle that is passed to DLL method.
Is there anything wrong with my code?
My code is as follows -
extern "C" UINT __stdcall MyDllMethod(
/*__in*/ MSIHANDLE hInstall
{
TCHAR *szBuf = NULL;
DWORD cch = 0 ;
CStdStringW strCommand(L"");
Log (hInstall, L"MsiGetTargetPath() 1st call returned ERROR_MORE_DATA.");
UINT iRet = MsiGetTargetPathW(hInstall, L"TARGETDIR", L"",&cch); // Here
it returns ERROR_INVALID_HANDLE
if(iRet==ERROR_MORE_DATA)
{
Log (hInstall, L"MsiGetTargetPath() 1st call returned
ERROR_MORE_DATA.");
cch++; // add 1 to include null terminator since MsiGetTargetPath
does not include it on return
szBuf = (TCHAR *) malloc(cch*sizeof(TCHAR));
if(szBuf)
{
if(MsiGetTargetPathW(hInstall, L"TARGETDIR",
szBuf,&cch)==ERROR_SUCCESS)
{
CStdStringW strCommand2(szBuf);
strCommand = strCommand2;
}
free(szBuf);
}
}
CStdStringW strLog(L"");
strLog.Format(L"MsiGetTargetPath() Return Value - %d", iRet);
Log(hInstall, strLog);
return strCommand;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users