Inno Setup:如何操作Run部分的进度条?

时间:2015-12-17 14:02:39

标签: installer progress-bar inno-setup pascalscript

与此问题类似:
How to set the progress bar value in the [Run] section of the Inno Setup install script?

当Inno设置进入[Run]部分时,进度条显示为100%并停在此位置。

我在这个Run部分安装了很多文件,我希望重新启动进度条并控制它,因为它会安装每个程序。

状态消息很容易更改(StatusMsg),但我失去了一些进展。你能帮帮我吗?

示例:

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""msxml.msi"" /quiet"; \
    StatusMsg: "MSXML..."; Flags: runascurrentuser
Filename: "msiexec.exe"; Parameters: "/i ""capicom_dc_sdk.msi"" /quiet"; \
    StatusMsg: "CAPICOM..."; Flags: runascurrentuser

由于我想在安装过程中控制进度条,我不知道该怎么做。我想可能使用BeforeInstall参数,创建一个代码,通过执行WizardForm.ProgressGauge.Position = 0;AfterInstall参数,相反的WizardForm.ProgressGauge.Position = 100;,将进度条设置为0,但是如何在安装过程中进行更改?

感谢。

1 个答案:

答案 0 :(得分:12)

更新进度条相当困难,而另一个进程正在运行。

我没有意识到这一点,因为你不太可能告诉子安装程序的进度,所以你不知道将进度条更新到什么地方。

除特殊情况外,子安装程序提供API以报告其进度 有关示例,请参阅:

要根据已完成的子安装程序的数量更新进度条,您可以执行以下操作:

[Run]
FileName: "process1"; BeforeInstall: UpdateProgress(0); AfterInstall: UpdateProgress(33)
FileName: "process2"; AfterInstall: UpdateProgress(66)
FileName: "process3"; AfterInstall: UpdateProgress(100)

[Code]

procedure UpdateProgress(Position: Integer);
begin
  WizardForm.ProgressGauge.Position := Position * WizardForm.ProgressGauge.Max div 100;
end;

要将部分进度范围划分为安装文件,其余部分用于运行子安装程序,请参阅
Inno Setup - Prevent extraction of files from setting progress bar to 100%

另一种选择是使用“选取框”(=无限)进度条样式。

请参阅Progress bar control styles

[Run]
FileName: "process1"; BeforeInstall: SetMarqueeProgress(True)
FileName: "process2"
FileName: "process3"; AfterInstall: SetMarqueeProgress(False)

[Code]

procedure SetMarqueeProgress(Marquee: Boolean);
begin
  if Marquee then
  begin
    WizardForm.ProgressGauge.Style := npbstMarquee;
  end
    else
  begin
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
end;

enter image description here

即使没有在官方Microsoft文档中列出,也可以在Windows XP上运行。在Windows XP SP3上测试。

enter image description here