Inno Setup 当 Uninstallable=no 时记住选择的安装类型
Inno Setup Remember selected setup type when Uninstallable=no
我正在创建一个有点非传统的 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;
保存 WizardForm.TypesCombo.ItemIndex
而不是 WizardSetupType
并在恢复选择时将其重新设置。
恢复 WizardForm.TypesCombo.ItemIndex
后,您必须调用 WizardForm.TypesCombo.OnChange
更新组件选择。
我还建议您使用 INI 文件函数 SetIniInt
and GetIniInt
而不是 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);
最后一行代码的解释,见
我正在创建一个有点非传统的 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;
保存 WizardForm.TypesCombo.ItemIndex
而不是 WizardSetupType
并在恢复选择时将其重新设置。
恢复 WizardForm.TypesCombo.ItemIndex
后,您必须调用 WizardForm.TypesCombo.OnChange
更新组件选择。
我还建议您使用 INI 文件函数 SetIniInt
and GetIniInt
而不是 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);
最后一行代码的解释,见