3

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?

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100

1 Answers1

3

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. :)

Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
  • Thanks Rob, it works fine except I'm sure you meant MessageButtons and MessageIcon instead of MessageBoxButtons and MessageBoxIcon. It didn't seem like I'd be able to cast these types back to an InstallMessage type. – Christopher Painter Apr 21 '13 at 21:47
  • I don't see `MessageButtons` or `MessageIcon` defined as enums anywhere. The code above should work when the `System.Windows.Forms` namespace is included. – Rob Mensching Apr 22 '13 at 15:48
  • 1
    MessageButtons and MessageIcons are defined in Microsoft.Deployment.WindowsInstaller. It's in the DTF help file. The help topic says it can be cast to MessageBoxButtons. It should probably also say it can be cast to InstallMessage. – Christopher Painter Apr 22 '13 at 16:29
  • Ahh, yes, they are duplicated there. It's all duplication and will work the same. However, I'll update the answer because they are better option so you don't have to pull in `System.Windows.Forms`. – Rob Mensching Apr 22 '13 at 16:48