Inno Setup-卸载时不显示进度栏

时间:2019-06-24 04:47:51

标签: inno-setup uninstall pascalscript

我正在使用Inno Setup创建自己的安装程序。当用户卸载应用程序时,我想删除一些文件夹。

因此,我使用includeRootFolder: false 事件删除文件夹并以CurUninstallStepChanged样式(基于Inno Setup: How to handle progress bar on [UninstallDelete] section?)显示“进度栏”。

这是代码:

npbstMarquee

如果我使用debug每行,我可以看到进度条正在运行。但是当我使用procedure DeleteFolder(); var FindRec: TFindRec; fullPath: string; tmpMsg: string; StatusText: string; deletePath: string; begin { find all and delete } UninstallProgressForm.ProgressBar.Style := npbstMarquee; StatusText := UninstallProgressForm.StatusLabel.Caption; UninstallProgressForm.StatusLabel.WordWrap := True; UninstallProgressForm.StatusLabel.AutoSize := True; fullPath := 'C:\ProgramData\TestPath'; if FindFirst(ExpandConstant(fullPath + '\*'), FindRec) then try repeat if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin deletePath := AddBackslash(fullPath) + FindRec.Name; tmpMsg := 'Deleting...' + #13#10 + deletePath; UninstallProgressForm.StatusLabel.Caption := tmpMsg; DelTree(deletePath, True, True, True); end; until not FindNext(FindRec); finally UninstallProgressForm.StatusLabel.Caption := StatusText; FindClose(FindRec); end; UninstallProgressForm.ProgressBar.Style := npbstNormal; end; { Uninstall event } procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); begin case CurUninstallStep of usUninstall: begin DeleteFolder(); end; end; end; 时,只有unins000.exe可以显示,进度条没有显示。
我该如何解决?

1 个答案:

答案 0 :(得分:4)

您必须抽取消息队列以显示/设置进度条动画。
Inno Setup: How to modify long running script so it will not freeze GUI?

尤其是,您可以从以下位置使用AppProcessMessage函数:
My SQL server discovery on LAN by listening port (Inno Setup)

enter image description here

尽管使用DelTree,但对AppProcessMessage的调用之间的间隔太大,无法平滑地为进度栏设置动画。您将必须显式实现递归删除,以允许足够频繁地泵送队列。