The problem with this is that we don't know the parent window, so I pass in NULL, and in some cases, the message box pops up behind the installer.
I came across the function MsiProcessMessage which can be used for logging and displaying message boxes.
I have added these functions to my custom action, but when I call the function, no message box is displayed. The message _is_ written to the log, but not shown to the user.
Here's the code
Code: Select all
void MsiMessage(MSIHANDLE hInstall, INSTALLMESSAGE level, const char* szMessage)
{
if (strlen(szMessage) == 0)
return;
//Create a record with only one field
PMSIHANDLE hRec = MsiCreateRecord(2);
//Handle problem creating record
if (hRec == NULL)
return;
MsiRecordSetString(hRec, 0, _T("[1]"));
MsiRecordSetString(hRec, 1, szMessage);
DWORD lCount = 256;
TCHAR buf[256];
MsiFormatRecord(hInstall, hRec, buf, &lCount);
MsiProcessMessage(hInstall, level, hRec);
}
Code: Select all
char buf[256];
LoadString(hInstance, IDS_SERIAL_INVALID_MSG, buf, 256);
MsiMessage(hInstall, INSTALLMESSAGE_USER, buf);
Has anyone else successfully managed to get MsiProcessMessage to display a message box? Alternatively, is there a way to get hold of the window handle of the installer?
As always, any help gratefully recieved!
mat.