inno-setup - 将部分代码从 InitializeWizard 移动到 Inno Setup 中的 InitializeSetup 有什么好处吗?
问题描述
这个问题是从这个问题中衍生出来的:
Report installed .NET Framework version during install with 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: https://stackoverflow.com/a/64588818/2287576 }
{ 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
吗?如果是这样,为什么?
解决方案
可能没有真正的好处,但imo:
InitializeSetup
用于检查 preprequities。它的 API 允许通过返回False
.InitializeWizard
用于调整向导窗口。它不应该失败。
推荐阅读
- php - 从 PHP 中的数组中获取每个类别 3 个元素
- spotfire - 禁用或隐藏“查看库”菜单项
- php - 为什么我的 AJAX 没有加载到我的网页上?
- javascript - 使用鼠标轮和 onclick 事件打开新选项卡
- c# - 通过 ExcelDataReader 导入 *.xlsx 数据,受影响的记录数为 0
- angular - 如何在角度 6 中实现 $('button').click(function()
- c# - C#订阅和取消订阅事件 - 从“字符串”
- html - 为什么我的自定义字体不显示(HTML、CSS、BEGINNER)
- javascript - 在 Puppeteer 中进行 Web Scraping 时如何处理验证码?
- spring - 如何修复 ModelAttributes 返回空值?