简体   繁体   English

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

[英]Inno Setup - Progress bar doesn't show when uninstall

I'm using Inno Setup to create my own installer. 我正在使用Inno Setup来创建自己的安装程序。 When user uninstall app I want delete some folder. 当用户卸载app我要删除一些文件夹。

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? ). 所以我使用CurUninstallStepChanged事件删除文件夹,并用npbstMarquee样式显示“进度条”(基于Inno Setup:如何处理[UninstallDelete]部分的进度条? )。

Here is the code: 这是代码:

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;

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. 但是当我使用unins000.exe只有Caption可以显示,进度条没有显示。
How can I fix it? 我该如何解决?

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? Inno Setup:如何修改长时间运行的脚本,以免它冻结GUI?

Particularly, you can use the AppProcessMessage function from: 特别是,您可以使用以下AppProcessMessage函数:
My SQL server discovery on LAN by listening port (Inno Setup) 通过侦听端口(Inno Setup)在LAN上发现我的SQL服务器

在此输入图像描述

Though with use of DelTree , the interval between calls to AppProcessMessage will be too big to animate the progress bar smoothly. 虽然使用DelTree ,但调用AppProcessMessage之间的间隔太大,无法顺利地为进度条设置动画。 You would have to implement a recursive delete explicitly to allow pumping the queue frequently enough. 您必须明确地实现递归删除以允许足够频繁地抽取队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM