簡體   English   中英

根據 Inno Setup 中選定的組件啟動自定義代碼

[英]Launch custom code via according to selected Components in Inno Setup

我的查詢有點類似於通過 Inno Setup 中的任務啟動自定義代碼,除了不是啟動輔助選擇頁面,而是根據選擇的組件運行代碼的變化。 我希望將文本的變體插入(設置)文檔中。 使用上述參考代碼的初步嘗試沒有奏效,我猜是因為 inno 無法在安裝過程的早期搜索文檔的存在。 我打算在下面使用的追加方法。 看來 Append 不支持組件標志。

[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;

使用WizardIsComponentSelected函數 例如在CurStepChanged事件函數中(在ssPostInstallssInstall步驟中)。

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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM