读取延迟自定义操作中的复选框值
Read Checkbox value in a deferred custom action
我正在开发一个安装程序,我必须在其中添加一个对话框供用户进行一些应用程序配置选择。该对话框显示在安装过程之前,并且只有在安装所需文件后才能应用配置选项。所需文件是某种配置文件,必须根据所选配置进行调整。
顺序如下:
- 启动安装程序
- 选择安装文件夹
- 选择所需配置
- 安装应用程序
- 根据选择的所需配置更改配置
配置对话框将包含 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
始终为空。是否可以在延迟操作中获取复选框的值?如果可以的话,我要怎么做才能得到复选框的值?
由于我是安装程序的新手,所以我不熟悉大写字母实际上具有使用 WiX 创建安装程序的功能这一事实。一旦我完全用大写字母写 MyCheckBoxValue
,它就变成了 public 属性,我设法在延迟的自定义操作中获得它的价值。
我正在开发一个安装程序,我必须在其中添加一个对话框供用户进行一些应用程序配置选择。该对话框显示在安装过程之前,并且只有在安装所需文件后才能应用配置选项。所需文件是某种配置文件,必须根据所选配置进行调整。
顺序如下:
- 启动安装程序
- 选择安装文件夹
- 选择所需配置
- 安装应用程序
- 根据选择的所需配置更改配置
配置对话框将包含 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
始终为空。是否可以在延迟操作中获取复选框的值?如果可以的话,我要怎么做才能得到复选框的值?
由于我是安装程序的新手,所以我不熟悉大写字母实际上具有使用 WiX 创建安装程序的功能这一事实。一旦我完全用大写字母写 MyCheckBoxValue
,它就变成了 public 属性,我设法在延迟的自定义操作中获得它的价值。