Вопрос

I like to show a checkbox in dialog which is unchecked if the DWORD registry value is 0 or checked otherwise.

I understood the checkbox check/uncheck if the property exist or not. Is there a way to change it work with value or conditionally set or remove the property.

Checkbox is always checked as it found value in registry 0 or nonZero and set the property and this is I tried so far -

<Property Id="SOUNDSERVER">
  <RegistrySearch Id="SoundServer"
  Root="HKLM"
  Key="[APPLICATIONHIVE]"
  Name="SoundServer"
  Type="raw"
  Win64="yes" />
</Property>

<SetProperty Id="WIXUI_SOUNDSERVER" After="AppSearch" Value="[SOUNDSERVER]" />
<SetProperty Id="WIXUI_SOUNDSERVERADDR" After="AppSearch" Value="[ACTANTSOUNDSERVERADDR]" />

<Control Id="SoundServerCheck" Type="CheckBox" X="20" Y="148" Width="80" Height="10" Property="WIXUI_SOUNDSERVER" CheckBoxValue="#1" Text="Sound Server">
</Control>
Это было полезно?

Решение

You can check the condition in SetProperty itself. You can use the below condition in your requirement.

 <Property Id="SOUNDSERVER">
    <RegistrySearch Id="SoundServer"   
    Root="HKLM" 
    Key="[APPLICATIONHIVE]" 
    Name="SoundServer" 
    Type="raw" 
    Win64="yes" />
  </Property>

<Property Id="WIXUI_SOUNDSERVER" Value="1" />
<SetProperty Id="WIXUI_SOUNDSERVER" After="AppSearch" Value="{}">
    SOUNDSERVER="#0"
</SetProperty>

<Control Id="SoundServerCheck" Type="CheckBox" X="20" Y="148" Width="80" Height="10" Property="WIXUI_SOUNDSERVER" CheckBoxValue="#1" Text="Sound Server"></Control>

Edit:

Remove WIXUI_SOUNDSERVER property and use the SOUNDSERVER property in all places to uncheck the checkbox while registry does not exist.

 <SetProperty Id="SOUNDSERVER" After="AppSearch" Value="{}">
    (SOUNDSERVER="#0")
    </SetProperty>

<Control Id="SoundServerCheck" Type="CheckBox" X="20" Y="148" Width="80" Height="10" Property="SOUNDSERVER" CheckBoxValue="#1" Text="Sound Server"></Control>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top