来自 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");
}
}
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);
}
I am calling the CA from WiX with the following line
<CustomAction Id="CA1" BinaryKey="ca1.dll" DllEntry="action1" />
and the action1 looks like this
public class CustomActions
{
[CustomAction]
public static ActionResult action1(Session session)
{
session.Log("Begin action1");
SetProperty("xyz", "123");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够通过执行以下操作来设置属性:
请参阅 Christopher Painter 的帖子:
http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html
我相信他很快就会对此发表评论一。
You should be able to set a property by doing the following:
See Christopher Painter's post here:
http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html
I'm sure he'll be along soon to comment on this one.