2011-03-08 21 views
3

如果安裝了MSMQ,我必須創建一個消息隊列。如果未安裝MSMQ,則無需執行任何操作。Wix和MSMQ:MSMQ檢測

有沒有辦法,我們可以發現MSMQ是否安裝在MSMQExtension dll中。

我知道,我們可以使用相同的註冊表,但如果未安裝MSMQ,安裝程序將失敗。

回答

0

創建自定義操作。

[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; 
    } 

註冊在你CustomActions.wxs

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