来自 C# 自定义操作的 MsiSetProperty

发布于 2024-09-11 09:55:05 字数 709 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2024-09-18 09:55:05

您应该能够通过执行以下操作来设置属性:

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

我相信他很快就会对此发表评论一。

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文