1

My query is a little similar to Launch custom code via tasks in Inno Setup except instead of launching a secondary selection page, the variation of code is run depending on component chosen. I wish to insert variations of text into a (settings) doc. Initial attempts using the above reference code did not work, I’m guessing because inno is unable to search for a doc’s existence that early in the install process. The Append approach I was intending to use below. It appears Append does not support component flags.

[Components]
Name: "Adult"; Description: "Adult filters"; Flags: exclusive
Name: "PresetWordFilter"; Description: "Preset Word Filter"; Flags: exclusive
Name: "No_Security"; Description: "No filters"; Flags: exclusive
[Code]
procedure ?
begin
  if ? then
  begin
    FileName := ExpandConstant('{userappdata}\LLL');
    FileName := AddBackslash(FileName) + 'lll.props';
    Lines := TStringList.Create;

    { Load existing lines from file }
    Lines.LoadFromFile(FileName);
    { Add your information to the end of the file }
    Lines.Append('xxx');
    Lines.Append('FILTER_ADULT=true');
    Lines.SaveToFile(FileName);
    Lines.Free;
  end;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Jenn
  • 111
  • 7

1 Answers1

2

Use WizardIsComponentSelected function. For example in the CurStepChanged event function (in ssPostInstall or ssInstall step).

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
    FileName := ExpandConstant('{userappdata}\LLL\lll.props');
    Lines := TStringList.Create;
    { Load existing lines from file }
    Lines.LoadFromFile(FileName);

    if WizardIsComponentSelected('Adult') then
    begin
      Lines.Append('FILTER_ADULT=true');
    end;

    if WizardIsComponentSelected('PresetWordFilter') then
    begin
      Lines.Append('PRESET_WORD_FILTER=true');
    end;

    Lines.SaveToFile(FileName);
    Lines.Free;    
  end;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    I forgot to mention I'm using Inno 5 so I needed to use IsComponentSelected instead. Many thanks. – Jenn Sep 08 '20 at 10:35