1
我正在创建一个非传统的Inno安装程序安装程序。我正在设置Uninstallable=no
,但我仍然需要能够记住用户选择的安装类型,如果他们将来重新安装。我想过把这个类型写到一个我能够做到的文件中。但是,我不确定如何在下次运行安装程序时设置类型。这是我的代码来存储类型。Inno Setup在不可安装的时候记住选择的安装类型=否
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;
我一定会用SetIniInt和GetIniInt,这是完美的。我切换到保存和恢复WizardForm.TypesCombo.ItemIndex。然而,在恢复下拉位置而不是值时,它似乎存在问题,它将从列表中的第一项安装组件。我在原始文章中包含了新代码。 – thecaptain0220
我已经更新了我的答案。 –
请注意,恢复来自'CurPageChanged(wpSelectComponents)'的选择并不理想,因为当您/她返回到“选择组件”页面时,您将覆盖用户的选择。你最好只在第一次调用'CurPageChanged(wpSelectComponents)'的时候。 –