title: Using combo box to select what paths and registry keys to use
body: <p><strong>Purpose:</strong></p>
  
  <p>With Inno Setup I want to create an installer with a dropdown list in the install wizard.</p>
  
  <p>The choice made in the wizards defines 2 variables:<br>
  One for the folder location and the other for the location in the registry.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>Variables are defined as global in <code>[Code]</code>, but are not used in <code>[Files]</code> and <code>[Registry]</code></p>
  
  <p><strong>Code:</strong></p>
  
  <p>The two variables are: <code>strData1</code> &amp; <code>strData2</code></p>
  
  <p>I was trying to retrieve them with functions: <code>strData1returner</code> &amp; <code>strData2returner</code></p>
  
  <pre class="lang-pascal prettyprint-override"><code>[Setup]
  ...
  
  [Dirs]    
  Name: "C:\Program Files\CompanyName\{code:strData1returner}"
  
  [Files]
  Source: "C:\SomeDll.dll"; \
    DestDir: "C:\Program Files\CompanyName\{code:strData1returner}\"; Flags: ignoreversion;
  
  [Registry]
  Root: HKCU; subkey: "{code:strData2returner}"; flags: createvalueifdoesntexist
  
  [Code]
  var
    Button: TNewButton;
    ComboBox: TNewComboBox;
    CustomPage: TWizardPage;     
    strData1: string;
    strData2: string;
  
  procedure ComboBoxChange(Sender: TObject);
  begin
    case ComboBox.ItemIndex of
      0:
      begin
        strData1 := 'Subfolder';
        strData2 := 'SOFTWARE\CompanyName';
      end;
    end;
  end;
  
  procedure InitializeWizard;
  var
    DescLabel: TLabel;
  begin
    CustomPage := CreateCustomPage(wpSelectDir, 'Caption', 'Description');
  
    DescLabel := TLabel.Create(WizardForm);
    DescLabel.Parent := CustomPage.Surface;
    DescLabel.Left := 0;
    DescLabel.Top := 0;
    DescLabel.Caption := 'Select an item...';
  
    ComboBox := TNewComboBox.Create(WizardForm);
    ComboBox.Parent := CustomPage.Surface;
    ComboBox.Left := 0;
    ComboBox.Top := DescLabel.Top + DescLabel.Height + 6;  
    ComboBox.Width := 220;
    ComboBox.Style := csDropDownList;
    ComboBox.Items.Add('Choice1');
    ComboBox.ItemIndex := 0;
    ComboBox.OnChange := @ComboBoxChange;
  end;
  
  function strData1returner(Param: String): String;
  begin
    Result :=  strData1;
  end;
  
  function strData2returner(Param: String): String;
  begin
    Result :=  strData2;
  end;
  </code></pre>