首页 > 解决方案 > 在延迟的自定义操作中读取复选框值

问题描述

我正在开发一个安装程序,我必须为用户添加一个对话框以进行一些应用程序配置选择。该对话框显示在安装过程之前,并且配置选择只能在安装后安装所需文件时应用。所需文件是某种配置文件,必须根据所选配置进行调整。

顺序如下:

  1. 启动安装程序
  2. 选择安装文件夹
  3. 选择所需的配置
  4. 安装应用程序
  5. 根据选择的所需配置更改配置

配置对话框将有 2 个组件:一个复选框和一个下拉列表。目前我正在努力使用复选框并在延迟的自定义操作中读取它的值。此自定义操作在安装完成后执行。

到目前为止,这是我拥有的代码:

<Dialog Id="TempDlgId" ...>
    <Control Id="MyCheckBoxId" Type="CheckBox" ... CheckBoxValue="0" Property="MyCheckBoxValue" Text="Sampe Text"/>
</Dialog>

这是用户选择配置的对话框。

<Custom Action="MyCustomAction.SetProperties" After="InstallFiles">NOT Installed</Custom>
<Custom Action="MyCustomAction" After="MyCustomAction.SetProperties">NOT Installed</Custom>

我为我的自定义操作应用了排序。

<CustomAction Id="MyCustomAction.SetProperties"
              Return="check"
              Execute="immediate"
              Property="MyCustomAction"
              Value="InstallLocation=[DEFAULTWORKINGDIRECTORY];MyCheckBoxValue=[MyCheckBoxValue]"/>
<CustomAction Id="MyCustomAction"
              Return="check"
              Execute="deferred"
              BinaryKey="MyCustomAction.CA.dll"
              Impersonate="yes"
              DllEntry="MyCustomAction"
              HideTarget="no"/>

这是我对自定义操作的定义。

    [STAThread]
    [CustomAction]
    public static ActionResult MyCustomAction(Session session)
    {
        Debugger.Launch();
        var installLocation = session.CustomActionData["InstallLocation"];
        var hasModule = session.CustomActionData["MyCheckBoxValue"];

        return ActionResult.Success;
    }

此代码必须更改已安装应用程序的配置,目前我正在努力获取复选框值。复选框是否选中并不重要,MyCheckBoxValue始终为空。是否可以在延迟操作中获取复选框的值?如果可能,我该怎么做才能获得复选框值?

标签: wixwix3

解决方案


由于我不熟悉安装程序,因此我不熟悉大写字母实际上具有使用 WiX 创建安装程序的功能这一事实。一旦我MyCheckBoxValue完全用大写字母书写,它就变成了一个公共属性,我设法在延迟的自定义操作中获得了它的价值。


推荐阅读