MessageBoxes using DTF

2020-03-06 03:46发布

问题:

The MsiProcessMessage function doco on MSDN shows this example:

PMSIHANDLE hInstall;
PMSIHANDLE hRec;
MsiProcessMessage(hInstall, 
                  INSTALLMESSAGE(INSTALLMESSAGE_ERROR|MB_ABORTRETRYIGNORE|MB_ICONWARNING),
                  hRec);

How would this be done using Session.Message in DTF? The only overload takes Session.InstallMessage as an argument. I see the MessageBoxButtons enum and I convert both types to In32 and perform a logical or but I'm not sure how to get this back into the API.

Am I missing something or is DTF missing something?

回答1:

I've not done much with DTF but my understanding is that you'd want something like:

Session.Message(InstallMessage.Error | 
                (InstallMessage)((int)MessageButtons.AbortRetryIgnore |
                                 (int)MessageIcon.Warning), 
                record);

Not very pretty. I've formatted the messageType agument to fit better in the text box here. Format in your code as per your coding guidelines. :)