来自C#自定义操作的MsiSetProperty
作者:互联网
action1如何在C#自定义操作中设置MSI属性,到目前为止,我已经有了这个,但是如何获取该句柄?
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
static extern int MsiSetProperty(IntPtr hInstall, string szName, string szValue);
public void SetProperty(string propertyName, string propertyValue)
{
MsiSetProperty(handle, propertyName, propertyValue);
}
我正在通过以下行从WiX呼叫CA
<CustomAction Id="CA1" BinaryKey="ca1.dll" DllEntry="action1" />
而action1看起来像这样
public class CustomActions
{
[CustomAction]
public static ActionResult action1(Session session)
{
session.Log("Begin action1");
SetProperty("xyz", "123");
}
}
解决方法:
您应该可以通过执行以下操作来设置属性:
public class CustomActions
{
[CustomAction]
public static ActionResult action1(Session session)
{
string xyzProperty = "XYZ";
session[xyzProperty] = "ABC";
}
}
在这里查看Christopher Painter的帖子:
http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html
我相信他很快就会对此发表评论.
标签:custom-action,windows-installer,wix,winapi,c 来源: https://codeday.me/bug/20191106/1998838.html