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

Inno Setup - Progress bar doesn't show when uninstall

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

所以我使用 CurUninstallStepChanged 事件删除文件夹并以 npbstMarquee 样式显示 "progress bar"(基于 )。

代码如下:

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 时,只有 Caption 可以显示,进度条不显示。
我该如何解决?

您必须将消息队列推送到 display/animate 进度条。
Inno Setup: How to modify long running script so it will not freeze GUI?

特别是,您可以使用 AppProcessMessage 函数来自:

虽然使用 DelTree,但调用 AppProcessMessage 之间的间隔太大,无法流畅地设置进度条动画。您将必须显式实现递归删除以允许足够频繁地抽取队列。