Inno Setup-卸载时不显示进度栏 [英] Inno Setup - Progress bar doesn't show when uninstall
问题描述
我正在使用Inno Setup创建自己的安装程序.当用户卸载应用程序时,我想删除一些文件夹.
I'm using Inno Setup to create my own installer. When user uninstall app I want delete some folder.
因此,我使用CurUninstallStepChanged
事件删除文件夹并以npbstMarquee
样式显示进度栏"(基于 Inno Setup:如何处理[UninstallDelete]部分上的进度栏?).
So I use CurUninstallStepChanged
event to delete folder and show "progress bar" with npbstMarquee
style (based on Inno Setup: How to handle progress bar on [UninstallDelete] section?).
这是代码:
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;
如果我使用debug每行,我可以看到进度条正在运行.但是当我使用unins000.exe
时,只有Caption
可以显示,进度条没有显示.
我该如何解决?
If I using debug each line, I can see progress bar running. But when I using unins000.exe
then only Caption
can show, progress bar is not showing.
How can I fix it?
推荐答案
您必须抽取消息队列以显示/设置进度条的动画.
Inno设置:如何修改长时间运行的脚本以使其不会冻结GUI?
You have to pump the message queue to display/animate the progress bar.
Inno Setup: How to modify long running script so it will not freeze GUI?
特别地,您可以从以下位置使用AppProcessMessage
功能:
通过侦听端口(Inno Setup)在局域网上发现我的SQL Server
Particularly, you can use the AppProcessMessage
function from:
My SQL server discovery on LAN by listening port (Inno Setup)
尽管使用DelTree
,对AppProcessMessage
的调用之间的间隔将太大,无法平滑地为进度栏设置动画.您必须显式实现递归删除,以允许足够频繁地泵送队列.
Though with use of DelTree
, the interval between calls to AppProcessMessage
will be too big to animate the progress bar smoothly. You would have to implement a recursive delete explicitly to allow pumping the queue frequently enough.
这篇关于Inno Setup-卸载时不显示进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!