![](/img/trans.png)
[英]how to write custom action for a c# installer in visual studio 2010?
[英]change installer properties in C# custom action
如何在C#自定義操作中更改安裝程序屬性?
要訪問WiX屬性,例如使用Property元素設置的屬性,請使用Session對象的索引器。 這是一個例子:
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
string myProperty = session["MY_PROPERTY"];
return ActionResult.Success;
}
設置屬性同樣容易。 您將通過引用具有屬性名稱的鍵來設置值。 這是一個例子:
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session["MY_PROPERTY"] = "abc";
return ActionResult.Success;
}
如果在設置屬性時該屬性不存在,則會創建該屬性。 同樣,您可以通過將其值設置為null來清除屬性。 從自定義操作創建或更改屬性值不會阻止安裝程序在安裝日志中顯示這些屬性。 因此,如果某個屬性包含應該隱藏的信息,那么最好先在WiX標記中聲明它並將其隱藏屬性設置為yes。
<Property Id="MY_PROPERTY" Hidden="yes" />
你不能。 只有Win32 DLL和VBScript 立即操作才具有對安裝程序屬性的寫訪問權限。 任何其他自定義操作類型只能通過其命令行或通過CustomActionData接收屬性。
以下是C ++ DLL自定義操作的教程: http : //www.codeproject.com/KB/install/msicustomaction.aspx
要獲取和設置Windows Installer屬性,可以使用MsiGetProperty()和MsiSetProperty() 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.