Inno Setup ExtractTemporaryFile 导致向导冻结
Inno Setup ExtractTemporaryFile causes wizard to freeze
我制作了自定义页面来根据用户的选择管理特定的 redist 工具安装。
如果用户想要或不安装这些工具,这些工具会链接到用户选中的复选框。
然后只在那里出现一个页面,向用户显示每个工具的安装进度。
我遇到的问题是进度页面仅在完成工具设置的第一个 ExtractTemporaryFile
时显示,显示最后一页就好像它已冻结一样。
我必须让进度页面在 ExtractTemporaryFile
发生之前显示的唯一方法是在任何安装函数之前放置一个 MsgBox
。
但即使在这种情况下,当 ExtractTemporaryFile
启动时,进度条动画也会被冻结,直到 ExtractTemporaryFile
完成...
这是执行此操作的代码部分:
procedure CurPageChanged(CurPageID: Integer);
begin
If CurPageID=PageInstallationPersonnalisee.ID then
begin
ProgressBarLabelPageInstPerso.Caption := 'Initialisation...';
if InstallTool1 = True then
begin
ProgressBarLabelPageInstPerso.Caption := 'Installing InstallTool1...';
F_InstallTool1();
end;
if InstallTool2 = True then
begin
ProgressBarLabelPageInstPerso.Caption := 'Installing InstallTool2...';
F_InstallTool2();
end;
if InstallTool3 = True then
begin
ProgressBarLabelPageInstPerso.Caption := 'Installing InstallTool3...';
F_InstallTool3();
end;
ProgressBarPageInstPerso.Style := npbstMarquee;
//ProgressBarPageInstPerso.Style := npbstNormal;
ProgressBarPageInstPerso.Position := 100;
CancelWithoutPrompt:=True;
WizardForm.Close;
end;
end;
注意ExtractTemporaryFile()
在每个F_InstallTooln()
函数中进行。
设置和文件部分的其他部分可能有帮助:
[Setup]
SolidCompression=no
[Files]
;Temporary redists
Source: "{#MyRessourcesPath}InstallTool1_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy
Source: "{#MyRessourcesPath}InstallTool2_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy
Source: "{#MyRessourcesPath}InstallTool3_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy
这里,页面 PageInstallationPersonnalisee
在第一个 ExtractTemporaryFile
完成之前不会显示...
我知道 ExtractTemporaryFile
会导致 安装过程出现一些延迟 ,但为什么它会导致向导冻结?
所以我的问题是:在我的场景中,有没有办法强制向导刷新,以便他在任何 ExtractTemporaryFile
程序启动之前出现?
ExtractTemporaryFile
真挂精灵表格。正如大多数代码所做的那样。
唯一允许强制 Windows 消息队列被抽取的自定义页面是 TOutputProgressWizardPage
(由 CreateOutputProgressPage
创建)。
你可以这样做:
function NextButtonClick(CurPageID: Integer): Boolean;
var
ProgressPage: TOutputProgressWizardPage;
begin
if CurPageID = wpReady then
begin
ProgressPage := CreateOutputProgressPage('Preparing installations', '');
ProgressPage.Show;
try
ProgressPage.Msg1Label.Caption := 'Installing 1 ...';
ProgressPage.SetProgress(0, 100);
ExtractTemporaryFile('1.exe');
Exec(...);
ProgressPage.Msg1Label.Caption := 'Installing 2 ...';
ProgressPage.SetProgress(33, 100);
ExtractTemporaryFile('2.exe');
Exec(...);
ProgressPage.Msg1Label.Caption := 'Installing 3 ...';
ProgressPage.SetProgress(66, 100);
ExtractTemporaryFile('3.exe');
Exec(...);
ProgressPage.SetProgress(100, 100);
ProgressPage.Hide;
finally
end;
end;
Result := True;
end;
虽然它在现代版本的 Windows 上效果不佳,但如果您不能经常调用 SetProgress
的话,它的进度条带有动画效果。请注意,SetProgress
调用是在幕后抽取消息队列的。所以即使它的参数没有改变,调用它也是有意义的。但是你不能,因为 ExtractTemporaryFile
块。
或者,您可以将部署留在 [Files]
部分,让安装程序从 AfterInstall
event.
执行
[Files]
;Temporary redists
Source: "{#MyRessourcesPath}InstallTool1_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy; AfterInstall: Install1
Source: "{#MyRessourcesPath}InstallTool2_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy; AfterInstall: Install2
Source: "{#MyRessourcesPath}InstallTool3_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy; AfterInstall: Install3
我知道这是一个旧线程,但我遇到了类似的情况,我使用 ExtractTemporaryFile
函数提取的一些文件比其他文件慢得多。
经过一些调查,我在 Inno Setup help pages 上发现了这个:
When solid compression is enabled, be sure to list your temporary files at (or near) the top of the [Files] section. In order to extract an arbitrary file in a solid-compressed installation, Setup must first decompress all prior files (to a temporary buffer in memory). This can result in a substantial delay if a number of other files are listed above the specified file in the [Files] section.
这意味着为了获得最佳性能,您应该将要使用该函数提取的文件移动到[Files]
节。
我制作了自定义页面来根据用户的选择管理特定的 redist 工具安装。
如果用户想要或不安装这些工具,这些工具会链接到用户选中的复选框。 然后只在那里出现一个页面,向用户显示每个工具的安装进度。
我遇到的问题是进度页面仅在完成工具设置的第一个 ExtractTemporaryFile
时显示,显示最后一页就好像它已冻结一样。
我必须让进度页面在 ExtractTemporaryFile
发生之前显示的唯一方法是在任何安装函数之前放置一个 MsgBox
。
但即使在这种情况下,当 ExtractTemporaryFile
启动时,进度条动画也会被冻结,直到 ExtractTemporaryFile
完成...
这是执行此操作的代码部分:
procedure CurPageChanged(CurPageID: Integer);
begin
If CurPageID=PageInstallationPersonnalisee.ID then
begin
ProgressBarLabelPageInstPerso.Caption := 'Initialisation...';
if InstallTool1 = True then
begin
ProgressBarLabelPageInstPerso.Caption := 'Installing InstallTool1...';
F_InstallTool1();
end;
if InstallTool2 = True then
begin
ProgressBarLabelPageInstPerso.Caption := 'Installing InstallTool2...';
F_InstallTool2();
end;
if InstallTool3 = True then
begin
ProgressBarLabelPageInstPerso.Caption := 'Installing InstallTool3...';
F_InstallTool3();
end;
ProgressBarPageInstPerso.Style := npbstMarquee;
//ProgressBarPageInstPerso.Style := npbstNormal;
ProgressBarPageInstPerso.Position := 100;
CancelWithoutPrompt:=True;
WizardForm.Close;
end;
end;
注意ExtractTemporaryFile()
在每个F_InstallTooln()
函数中进行。
设置和文件部分的其他部分可能有帮助:
[Setup]
SolidCompression=no
[Files]
;Temporary redists
Source: "{#MyRessourcesPath}InstallTool1_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy
Source: "{#MyRessourcesPath}InstallTool2_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy
Source: "{#MyRessourcesPath}InstallTool3_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy
这里,页面 PageInstallationPersonnalisee
在第一个 ExtractTemporaryFile
完成之前不会显示...
我知道 ExtractTemporaryFile
会导致 安装过程出现一些延迟 ,但为什么它会导致向导冻结?
所以我的问题是:在我的场景中,有没有办法强制向导刷新,以便他在任何 ExtractTemporaryFile
程序启动之前出现?
ExtractTemporaryFile
真挂精灵表格。正如大多数代码所做的那样。
唯一允许强制 Windows 消息队列被抽取的自定义页面是 TOutputProgressWizardPage
(由 CreateOutputProgressPage
创建)。
你可以这样做:
function NextButtonClick(CurPageID: Integer): Boolean;
var
ProgressPage: TOutputProgressWizardPage;
begin
if CurPageID = wpReady then
begin
ProgressPage := CreateOutputProgressPage('Preparing installations', '');
ProgressPage.Show;
try
ProgressPage.Msg1Label.Caption := 'Installing 1 ...';
ProgressPage.SetProgress(0, 100);
ExtractTemporaryFile('1.exe');
Exec(...);
ProgressPage.Msg1Label.Caption := 'Installing 2 ...';
ProgressPage.SetProgress(33, 100);
ExtractTemporaryFile('2.exe');
Exec(...);
ProgressPage.Msg1Label.Caption := 'Installing 3 ...';
ProgressPage.SetProgress(66, 100);
ExtractTemporaryFile('3.exe');
Exec(...);
ProgressPage.SetProgress(100, 100);
ProgressPage.Hide;
finally
end;
end;
Result := True;
end;
虽然它在现代版本的 Windows 上效果不佳,但如果您不能经常调用 SetProgress
的话,它的进度条带有动画效果。请注意,SetProgress
调用是在幕后抽取消息队列的。所以即使它的参数没有改变,调用它也是有意义的。但是你不能,因为 ExtractTemporaryFile
块。
或者,您可以将部署留在 [Files]
部分,让安装程序从 AfterInstall
event.
[Files]
;Temporary redists
Source: "{#MyRessourcesPath}InstallTool1_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy; AfterInstall: Install1
Source: "{#MyRessourcesPath}InstallTool2_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy; AfterInstall: Install2
Source: "{#MyRessourcesPath}InstallTool3_Setup.exe"; DestDir: "{tmp}"; \
Flags: deleteafterinstall noencryption dontcopy; AfterInstall: Install3
我知道这是一个旧线程,但我遇到了类似的情况,我使用 ExtractTemporaryFile
函数提取的一些文件比其他文件慢得多。
经过一些调查,我在 Inno Setup help pages 上发现了这个:
When solid compression is enabled, be sure to list your temporary files at (or near) the top of the [Files] section. In order to extract an arbitrary file in a solid-compressed installation, Setup must first decompress all prior files (to a temporary buffer in memory). This can result in a substantial delay if a number of other files are listed above the specified file in the [Files] section.
这意味着为了获得最佳性能,您应该将要使用该函数提取的文件移动到[Files]
节。