本文介绍了来自C#自定义操作的MsiSetProperty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
action1如何在C#自定义操作中设置MSI属性,到目前为止,我已经有了这个,但是如何获取该句柄?
action1How do I set a MSI property from within a C# custom action, so far I have this but how do I get the handle?
[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
I am calling the CA from WiX with the following line
<CustomAction Id="CA1" BinaryKey="ca1.dll" DllEntry="action1" />
action1看起来像这样
and the action1 looks like this
public class CustomActions
{
[CustomAction]
public static ActionResult action1(Session session)
{
session.Log("Begin action1");
SetProperty("xyz", "123");
}
}
推荐答案
您应该可以通过执行以下操作来设置属性:
You should be able to set a property by doing the following:
public class CustomActions
{
[CustomAction]
public static ActionResult action1(Session session)
{
string xyzProperty = "XYZ";
session[xyzProperty] = "ABC";
}
}
在此处查看Christopher Painter的帖子:
See Christopher Painter's post here:
我确定他会很快就对此发表评论。
I'm sure he'll be along soon to comment on this one.
这篇关于来自C#自定义操作的MsiSetProperty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!