将部分代码从 InitializeWizard 移动到 Inno Setup 中的 InitializeSetup 有什么好处吗?

Are there any benefits in moving some of this code from InitializeWizard to InitializeSetup in Inno Setup?

这个问题是这个问题的衍生问题:

这是我的 InitializeWizard:

(* InitializeWizard is called when the wizard is about to begin.
    This is where we add any custom pages into the installation process.
    The relevant XXX_CreatePage methods should be defined BEFORE this method. *)
procedure InitializeWizard();
begin
    dotNetNeeded := not IsDotNetInstalled(net462, 0);
    if (dotNetNeeded) then begin
        if (MsgBox(ExpandConstant('{cm:DotNet_NeedToDownload}'), \
                                            mbConfirmation, MB_OKCANCEL) = IDCANCEL) then begin
            //result := ExpandConstant('{cm:DotNet_InstallAborted}');
            Abort();
        end;
    end;

    bVcRedist64BitNeeded := false;
    if (IsWin64()) then
        bVcRedist64BitNeeded := IsVCRedist64BitNeeded();

    bVcRedist32BitNeeded := IsVCRedist32BitNeeded();

    DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);

    { Support File Progress Monitoring via ListBox }
    { See:  }
    { Start }
    OldStatusLabelWndProc :=
        SetWindowLong(WizardForm.StatusLabel.Handle, GWL_WNDPROC,
            CreateCallback(@StatusLabelWndProc));
    OldFilenameLabelWndProc :=
        SetWindowLong(WizardForm.FilenameLabel.Handle, GWL_WNDPROC,
            CreateCallback(@FilenameLabelWndProc));

    WizardForm.ProgressGauge.Top := WizardForm.FilenameLabel.Top;

    ProgressListBox := TNewListBox.Create(WizardForm);
    ProgressListBox.Parent := WizardForm.ProgressGauge.Parent;
    ProgressListBox.Top :=
        WizardForm.ProgressGauge.Top + WizardForm.ProgressGauge.Height + ScaleY(8);
    ProgressListBox.Width := WizardForm.FilenameLabel.Width;
    ProgressListBox.Height :=
        ProgressListBox.Parent.ClientHeight - ProgressListBox.Top - ScaleY(16);
    ProgressListBox.Anchors := [akLeft, akTop, akRight, akBottom];
    OldProgressListBoxWndProc :=
        SetWindowLong(ProgressListBox.Handle, GWL_WNDPROC,
            CreateCallback(@ProgressListBoxWndProc));
    { Lame way to shrink width of labels to client width of the list box, }
    { so that particularly when the file paths in FilenameLabel are shortened }
    { to fit to the label, they actually fit even to the list box. }
    WizardForm.StatusLabel.Width := WizardForm.StatusLabel.Width - ScaleY(24);
    WizardForm.FilenameLabel.Width := WizardForm.FilenameLabel.Width - ScaleY(24);
    { End }

    AutoBackupPage_InitializeWizard(wpSelectTasks);
end;

这是我的 InitializeSetup:

{ Called just before setup is about to start }
function InitializeSetup(): Boolean;
var
    WinVer: TWindowsVersion;
    WinVerPacked: Int64;
begin
    Result := True;

    ExtractTemporaryFile('{#Skin}');
    LoadVCLStyle(ExpandConstant('{tmp}\{#Skin}'));

    { Are we performing an upgrade? }
    bIsUpgrading := IsUpgrading();

    { Check Windows Version }
    GetWindowsVersionEx(WinVer);
    WinVerPacked := PackVersionComponents(WinVer.Major, WinVer.Minor, WinVer.Build, 0);

    (* Windows must be Win 7 SP1 (6.1.7601), Win 8.1 (6.3.9200) or higher, eg: Win 10 (10.0.10240)
        See: http://www.jrsoftware.org/ishelp/index.php?topic=winvernotes
        Microsoft .Net Framework 4.6.2 will only work with these operating systems. *)
    if (ComparePackedVersion(WinVerPacked, PackVersionComponents(6, 1, 7601, 0)) < 0) or
            ((ComparePackedVersion(WinVerPacked, PackVersionComponents(6, 2, 0, 0)) >= 0) and
            (ComparePackedVersion(WinVerPacked, PackVersionComponents(6, 3, 0, 0)) < 0)) then
    begin
        MsgBox(SetupMessage(msgWindowsVersionNotSupported), mbError, MB_OK);
        Result := False;
    end;
  { Log(Format('Windows Version: %x', [WindowsVersion])); }
end;

将部分代码从 InitializeWizard 移至 InitializeSetup 有什么好处吗?如果是,为什么?

可能没有真正的好处,但我认为:

  • InitializeSetup 用于检查先决条件。它的 API 允许通过返回 False.

    彻底中止安装
  • InitializeWizard 用于调整向导 window。它不应该失败。

相关:Exit from Inno Setup installation from [Code]