Discussion:
Using MsiProcessMessage in a C++ Custom Action
(too old to reply)
Mike
2004-04-02 21:51:46 UTC
Permalink
I have written a custom action that uses MsiProcessMessage to write an item to
the log file. This custom action successfully writes to the log when I
sequence it in one of the sequence tables. However, when calling this custom
action from a dialog event, the action runs successfully but no message is
logged. I wrote a sample function to investigate this behavior further. Here
is the function I used for testing.

UINT __stdcall WriteToLog(MSIHANDLE hInstall)
{
MSIHANDLE hRecord;
UINT uiStat;
hRecord = MsiCreateRecord(1);
uiStat = MsiRecordSetString(hRecord,1,"Mike's Test Log Message");
uiStat = MsiRecordSetString(hRecord,0,"[1]");
uiStat = MsiProcessMessage(hInstall,INSTALLMESSAGE_INFO,hRecord);
MsiCloseHandle(hRecord);
return ERROR_SUCCESS;
}

When it runs from a sequence table, uiStat=1 after the MsiProcessMessage call,
indicating success. When called from a dialog event the return is 0,
indicating no action was taken. Any insight into the cause of this behavior
would be appreciated.

Thanks,
Mike
legalize+ (Rich [Microsoft Windows Installer MVP])
2004-04-03 00:01:27 UTC
Permalink
[Please do not mail me a copy of your followup]
Post by Mike
I have written a custom action that uses MsiProcessMessage to write an item to
the log file. This custom action successfully writes to the log when I
sequence it in one of the sequence tables. However, when calling this custom
action from a dialog event, the action runs successfully but no message is
logged. [...]
This just doesn't seem right to me. We were logging all kinds of
stuff from DoAction events in the ControlEvent table in order to debug
our complex UI. What are the ControlEvent rows for the control where
you're trying to write to the log?
--
"The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ:
<http://www.xmission.com/~legalize/book/>
Pilgrimage: Utah's annual demoparty
<http://pilgrimage.scene.org>
Birrd
2004-04-03 07:02:48 UTC
Permalink
Below is the ControlEvent row I'm using for this action.

"Select_Destination_Dialog","Next","DoAction","WriteToLog","1","3"

I don't believe this is a problem with the control event. The custom
action is definitely running because the log shows the following.

First call - from InstallUISequence table:
Action start 1:31:06: WriteToLog.
MSI (c) (2C:30): Creating MSIHANDLE (1) of type 790542 for thread 2864
Mike's Test Log Message
Action ended 1:31:07: WriteToLog. Return value 1

Second call - from control event:
Action start 1:31:19: WriteToLog.
Action ended 1:31:19: WriteToLog. Return value 1.

I may have found the cause of the problem. I did some debugging and
noticed that the MSIHANDLE for the install that is passed into my
function is different for the call made in the InstallUISequence table
than it is for the call from the control event.

The custom action can still perform other tasks with the install handle
passed to me from a control event. I can get/set properties and query
the active database, but I cannot write to the log. I have a feeling
this is related to the difference in install handles passed in, but I'm
not sure how to fix it.

-Mike
Dennis Bareis
2004-04-05 05:48:06 UTC
Permalink
Hi,
Post by Birrd
Below is the ControlEvent row I'm using for this action.
"Select_Destination_Dialog","Next","DoAction","WriteToLog","1","3"
I don't believe this is a problem with the control event. The custom
action is definitely running because the log shows the following.
Now I'm pretty sure my VBSCRIPT custom action launched by "DoAction"
does log, however this is what the "DoAction" doco says:

Note that custom actions launched by the DoAction control event
cannot send messages with MsiProcessMessage or Message method.

Bye,
Dennis
Mike
2004-04-05 06:15:33 UTC
Permalink
I searched the MsiProcessMessage help up and down for that type of
exception, but didn't think to look at the DoAction ControlEvent topic.
It appears that it is supported with Windows Installer on Windows Server
2003. Unfortunately, that doesn't help me in my situation as I have to
handle OSes back to Win98.

Thanks for the help Rich and Dennis,
Mike
Mike
2004-04-05 17:47:15 UTC
Permalink
Dennis,

BTW, I retested this using a VBScript custom action with the Message method and
it worked for me as well. I guess you just can't use MsiProcessMessage. (All
of my testing was done with Windows Installer 2.0.)

-Mike

Loading...