Inno Setup记住当Uninstallable = no时选择的安装类型 [英] Inno Setup Remember selected setup type when Uninstallable=no

查看:84
本文介绍了Inno Setup记住当Uninstallable = no时选择的安装类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am creating an Inno Setup installer that is a little non traditional. I am setting Uninstallable=no but I still need to be able to remember what the user selected for the type of install if they reinstall in the future. I thought about writing the type out to a file which I was able to do. I am not sure how to set the type when the installer is run the next time however. Here is my code for storing the type.

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

我知道如何重新阅读此内容,但是我不确定如何设置类型.

I know how to read this back in, but I am not sure how to set the type.

这是新代码

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 ,并在还原选择时将其重新设置.

Save WizardForm.TypesCombo.ItemIndex instead of the WizardSetupType and set it back when restoring the selection.

还原 WizardForm.TypesCombo.ItemIndex 后,您必须调用 WizardForm.TypesCombo.OnChange 来更新组件选择.

After restoring the WizardForm.TypesCombo.ItemIndex you have to call the WizardForm.TypesCombo.OnChange to update the components selection.

我还建议您使用INI文件功能 SetIniInt GetIniInt 代替 SaveStringToFile .

I'd also suggest you use INI file functions SetIniInt and GetIniInt instead of the 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);


有关最后一行代码的说明,请参见如果我们键入WizardForm.TypesCombo.OnChange(WizardForm,这是什么意思.TypesCombo)在Inno设置中?

这篇关于Inno Setup记住当Uninstallable = no时选择的安装类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆