在 Inno Setup 中提取存档时显示自定义状态消息
Displaying custom status message while extracting archive in Inno Setup
我的应用程序有一个安装文件,它包含 .exe 文件和一个 .zip 文件。
我想要的是:
最近在[Code]
段添加了一个解压zip文件的代码,但是实际上是在安装完成后发生的,而且进度条是100%,所以我想要的是使该代码的(解压缩)过程与进度条一起工作,并向用户显示当前正在提取的内容。
例如:假设提取文件将占用进度条的 50%,其余部分将占用解压缩时的代码部分,以及当前正在提取的状态。
代码如下:
[Code]
procedure InitializeWizard;
begin
ForceDirectories(ExpandConstant('{localappdata}\folder-A\app\folder-B'))
end;
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
procedure unzip(ZipFile, TargetFldr: variant);
var
shellobj: variant;
SrcFldr, DestFldr: variant;
shellfldritems: variant;
begin
if FileExists(ZipFile) then begin
if not DirExists(TargetFldr) then
if not ForceDirectories(TargetFldr) then begin
MsgBox('Can not create folder '+TargetFldr+' !!', mbError, MB_OK);
Exit;
end;
shellobj := CreateOleObject('Shell.Application');
SrcFldr := shellobj.NameSpace(ZipFile);
DestFldr := shellobj.NameSpace(TargetFldr);
shellfldritems := SrcFldr.Items;
DestFldr.CopyHere(
shellfldritems, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
unzip(ExpandConstant('{app}\example.zip'),ExpandConstant('{app}\'));
end;
end;
最简单的解决方案是使用 WizardForm.StatusLabel
:
WizardForm.StatusLabel.Caption := 'Extracting...';
要获得更奇特的解决方案,您可以使用 TOutputProgressWizardPage
。有关甚至显示进度条的示例(尽管通过使用 DLL 进行提取),请参见:
此 post 列出了更多相关示例:
Inno Setup: How to modify long running script so it will not freeze GUI?
我的应用程序有一个安装文件,它包含 .exe 文件和一个 .zip 文件。
我想要的是:
最近在[Code]
段添加了一个解压zip文件的代码,但是实际上是在安装完成后发生的,而且进度条是100%,所以我想要的是使该代码的(解压缩)过程与进度条一起工作,并向用户显示当前正在提取的内容。
例如:假设提取文件将占用进度条的 50%,其余部分将占用解压缩时的代码部分,以及当前正在提取的状态。
代码如下:
[Code]
procedure InitializeWizard;
begin
ForceDirectories(ExpandConstant('{localappdata}\folder-A\app\folder-B'))
end;
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
procedure unzip(ZipFile, TargetFldr: variant);
var
shellobj: variant;
SrcFldr, DestFldr: variant;
shellfldritems: variant;
begin
if FileExists(ZipFile) then begin
if not DirExists(TargetFldr) then
if not ForceDirectories(TargetFldr) then begin
MsgBox('Can not create folder '+TargetFldr+' !!', mbError, MB_OK);
Exit;
end;
shellobj := CreateOleObject('Shell.Application');
SrcFldr := shellobj.NameSpace(ZipFile);
DestFldr := shellobj.NameSpace(TargetFldr);
shellfldritems := SrcFldr.Items;
DestFldr.CopyHere(
shellfldritems, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
unzip(ExpandConstant('{app}\example.zip'),ExpandConstant('{app}\'));
end;
end;
最简单的解决方案是使用 WizardForm.StatusLabel
:
WizardForm.StatusLabel.Caption := 'Extracting...';
要获得更奇特的解决方案,您可以使用 TOutputProgressWizardPage
。有关甚至显示进度条的示例(尽管通过使用 DLL 进行提取),请参见:
此 post 列出了更多相关示例:
Inno Setup: How to modify long running script so it will not freeze GUI?