代码之家  ›  专栏  ›  技术社区  ›  Charles Gargent

来自C自定义操作的msisettroperty

  •  3
  • Charles Gargent  · 技术社区  · 16 年前

    操作1如何从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" />
    

    行动1是这样的

    public class CustomActions
    {
        [CustomAction]
        public static ActionResult action1(Session session)
        {
            session.Log("Begin action1");
            SetProperty("xyz", "123");
        }
    } 
    
    1 回复  |  直到 16 年前
        1
  •  4
  •   fletcher    16 年前

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

    public class CustomActions 
    { 
        [CustomAction] 
        public static ActionResult action1(Session session) 
        { 
            string xyzProperty = "XYZ";
    
            session[xyzProperty] = "ABC";
        } 
    } 
    

    见克里斯托弗·派特的帖子:

    http://blog.deploymentengineering.com/2008/05/deployment-tools-foundation-dtf-custom.html

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

    推荐文章