代码之家  ›  专栏  ›  技术社区  ›  Cornelis

读取延迟自定义操作中的复选框值

  •  0
  • Cornelis  · 技术社区  · 6 年前

    我正在开发一个安装程序,我必须在其中添加一个对话框,供用户进行一些应用程序配置选择。该对话框显示在分期过程之前,配置选项只能在安装了所需文件的分期之后应用。所需文件是某种配置文件,必须根据所选配置进行调整。

    顺序如下:

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

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

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

    <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 始终为空。是否可以在延迟操作中获取复选框的值?如果可能的话,我需要做什么才能获得复选框值?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Cornelis    6 年前

    由于我对安装程序还不熟悉,所以我不知道大写字母实际上具有使用WiX创建安装程序的功能。我一写 MyCheckBoxValue 完全以大写字母表示,它成为了一个公共属性,我设法在延迟的自定义操作中获得它的值。