保存默认为选中注册表的Wix复选框值 [英] Saving a Wix checkbox value that defaults to checked to the registry

查看:124
本文介绍了保存默认为选中注册表的Wix复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Wix创作的安装程序。在UI向导中,有一个默认为选中的复选框。我想将此复选框的值保存到注册表中,以便使用(更简单的版本)

I have an installer authored with Wix. In the UI wizard, there's a checkbox that defaults to checked. I want to save the value of this checkbox to the registry for changes, repairs and upgrades using the (simpler version of the) "Remember Property" pattern described by Rob Mensching.

复选框实施:

<Control Id="httpsCheckBox" Type="CheckBox" CheckBoxValue="true" X="30" Y="119" Width="139" Height="17" Text="Enable HTTPS services" Property="ENABLEHTTPS" />

属性定义:

    <Property Id="ENABLEHTTPS" value="true">
        <RegistrySearch Id="EnableHttpsRegistrySearch" Type="raw" Root="HKLM" Key="SOFTWARE\CompanyName\ProductName" Name="EnableHttps" />
    </Property>

并将属性写入注册表:

    <Component Id="RegistryEntries">
        <RegistryKey Root="HKLM" Key="SOFTWARE\CompanyName\ProductName">
            <RegistryValue Name="EnableHttps" Value="[ENABLEHTTPS]" Type="string" />
        </RegistryKey>
    </Component>

初始安装正常。

下一次运行安装程序时,要为安装程序安装新功能例如,无论注册表设置中的值如何,都始终检查复选框。

The next time the installer is run, to install a new feature for example, the checkbox is always checked regardless of the value in the registry setting.

如果我从属性定义中删除默认值,以便第一次取消选中该复选框安装程序运行,一切工作正常。下一次安装程序运行复选框(和属性)从注册表中有正确的值。

If I remove the default value from the property definition so that the checkbox is unchecked the first time the installer is run, everything works fine. The next time the installer is run the checkbox (and property) have the correct value from the registry.

这就像RegistrySearch不设置属性,如果注册表值空。

It's like the RegistrySearch does not set the property if the registry value is empty.

我做错了什么?或者有更好的方法这样做吗?

Am I doing something wrong? Or is there a better way of doing this?

推荐答案

基本上,如果找不到注册表项,元素将使用默认值或null,体验。

Basically, the element will use the default value if the registry entry is not found or null, and that is what you are experiencing.

请参阅此处的文档: http:// wix.sourceforge.net/manual-wix3/wix_xsd_registrysearch.htm

这里是问题的解决方案:
http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg32524。 html

Here is a solution to the problem: http://www.mail-archive.com/wix-users@lists.sourceforge.net/msg32524.html

    <Property Id="ENABLEHTTPS" >
         <RegistrySearch Id="EnableHttpsRegistrySearch" Type="raw" Root="HKLM" Key="SOFTWARE\CompanyName\ProductName" Name="EnableHttps" />
    </Property>

    <CustomAction Id="SetENABLEHTTPS" Property="ENABLEHTTPS" Value="1" Execute="firstSequence" />

    <Control Id="httpsCheckBox" Type="CheckBox" CheckBoxValue="1" X="30" Y="119" Width="139" Height="17" Text="Enable HTTPS services" Property="ENABLEHTTPS" />

    <InstallUISequence>
        <Custom Action="SetENABLEHTTPS" Before="AppSearch">NOT Installed AND NOT OLDERVERSIONDETECTED</Custom>
    </InstallUISequence>
    <InstallExecuteSequence>
        <Custom Action="SetENABLEHTTPS" Before="AppSearch">NOT Installed AND NOT OLDERVERSIONDETECTED</Custom>
    </InstallExecuteSequence> 

这篇关于保存默认为选中注册表的Wix复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆