【问题标题】:Inno Setup Remember selected setup type when Uninstallable=noInno Setup 当 Uninstallable=no 时记住选择的安装类型
【发布时间】:2016-02-29 22:26:37
【问题描述】:

我正在创建一个有点非传统的 Inno Setup 安装程序。我正在设置Uninstallable=no,但如果他们将来重新安装,我仍然需要能够记住用户为安装类型选择的内容。我考虑将类型写到我能够做到的文件中。但是,我不确定下次运行安装程序时如何设置类型。这是我存储类型的代码。

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if (CurStep = ssDone) then
    SaveStringToFile('{app}\type.dat', WizardSetupType(false), false);
end;

我知道如何读回这个,但我不确定如何设置类型。

编辑:

这是新代码

procedure CurPageChanged(CurPageID: Integer);
begin
  { We need to manually store and restore the install type since Uninstallable=no }
  if (CurPageID = wpSelectComponents) then
    WizardForm.TypesCombo.ItemIndex := GetIniInt('Settings', 'InstallType', 0, 0, 3, ExpandConstant('{app}\settings.ini'));
  if (CurPageID = wpInstalling) then
    SetIniInt('Settings', 'InstallType', WizardForm.TypesCombo.ItemIndex, ExpandConstant('{app}\settings.ini'));
end;

【问题讨论】:

    标签: inno-setup pascalscript


    【解决方案1】:

    保存WizardForm.TypesCombo.ItemIndex 而不是WizardSetupType,并在恢复选择时将其重新设置。

    恢复WizardForm.TypesCombo.ItemIndex 后,您必须调用WizardForm.TypesCombo.OnChange 来更新组件选择。


    我还建议您使用 INI 文件函数 SetIniIntGetIniInt 而不是 SaveStringToFile


    商店:

    SetIniInt('Settings', 'InstallType', WizardForm.TypesCombo.ItemIndex,
              ExpandConstant('{app}\settings.ini'));
    

    恢复:

    WizardForm.TypesCombo.ItemIndex :=
      GetIniInt('Settings', 'InstallType', 0, 0, 3, ExpandConstant('{app}\settings.ini'));
    { The OnChange is not called automatically when ItemIndex is set programmatically. }
    { We have to call it to update components selection. }
    WizardForm.TypesCombo.OnChange(WizardForm.TypesCombo);
    

    有关最后一行代码的解释,请参阅What does it mean if we type WizardForm.TypesCombo.OnChange(WizardForm.TypesCombo) in Inno Setup?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多