mercredi 4 mai 2022

Inno Setup - How to bind a checkbox with a registry key, to check if the key may be written?

I need to create an installer with Inno Setup (version 6.2.1) in which I need to let the user select which file extension he want to associate with the installed app.

To achieve that I needed to create a custom page showing all the checkboxes I needed. This page respects a custom theme required by my company, for that reason I could not use the checkboxes automatically generated by the [Tasks] section.

However I cannot figure out how to associate the checkbox state with the registry key I want to install (or not).

For example, I have the following code:

[Code]
var
  AssocABCCB: TNewCheckBox;

  ...

  procedure InitializeWizard;
  var
    SelectAssocPage: TWizardPage;
  begin
    // select association custom page
    SelectAssocPage := CreateCustomPage(wpLicense, ExpandConstant('{cm:SelectAssocTitle}'), '');

    ...

    // .abc checkbox
    AssocABCCB         := TNewCheckBox.Create(SelectAssocPage);
    AssocABCCB.Align   := alTop;
    AssocABCCB.Caption := ExpandConstant('{cm:AssocABC}');
    AssocABCCB.Parent  := SelectAssocPage.Surface;
    AssocABCCB.OnClick := @AssocABCCBClick;

    ...

  end;

Now I want to use the above checkbox to optionally write a key in the registry, let say something like that:

[Registry]
Root: HKCR; Subkey: "{#KeyAppName}.abc"; Flags: uninsdeletekeyifempty; Check: AssocABCCB.Checked

Of course the above code is not working, it raises a compilation error.

But is there a way to bind the above checkbox with the registry key, in order to determine if the key may be written or not? If yes, how may I achieve that?




Aucun commentaire:

Enregistrer un commentaire