Wix and MSMQ: MSMQ Discovery

I need to create a message queue if MSMQ is installed. If MSMQ is not installed, then move forward without doing anything.

Is there any way we can detect if MSMQ is installed in the MSMQExtension dll.

I know we can use Registry for the same thing, but the installer will not work if MSMQ is not installed.

+3
source share
2 answers

Create a custom action.

    [DllImport("kernel32")]
    static extern IntPtr LoadLibrary(string file);


    [CustomAction]
    public static ActionResult CheckIfMsmqIsInstalled()
    {
        IntPtr handle = LoadLibrary("Mqrt.dll");
        if (handle == IntPtr.Zero || handle.ToInt32() == 0)
        {
            var msg = String.Format("MSMQ is not installed");
            MessageBox.Show(msg, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return ActionResult.Success;
        }
        return ActionResult.Success;
    }

Register it in your CustomActions.wxs

 <CustomAction Id="CheckIfMsmqIsInstalled"
          BinaryKey="CustomActions"
          DllEntry="CheckIfMsmqIsInstalled" Return="check" Execute="immediate" Impersonate="no"> </CustomAction>
0
source

All Articles