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

标签 inno-setup uninstallation pascalscript

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

所以我使用 CurUninstallStepChanged删除文件夹并显示“进度条”的事件 npbstMarquee样式(基于 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;


如果我使用调试每一行,我可以看到进度条正在运行。但是当我使用 unins000.exe那么只有Caption可以显示,进度条不显示。
我该如何解决?

最佳答案

您必须抽取消息队列以显示/动画进度条。
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 的调用间隔将太大而无法平滑地为进度条设置动画。您必须显式地实现递归删除,以允许足够频繁地抽取队列。

关于inno-setup - Inno Setup - 卸载时不显示进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56729989/

相关文章:

inno-setup - Inno Setup 和 VC Redistributable 并优雅地处理退出代码 3010

inno-setup - 使用 Inno Setup 从文件中读取所需位置的字节

inno-setup - 如何检测旧安装并提供删除?

windows-installer - 作为 msi 安装的一部分,如何卸载以前的版本?

eclipse - 如何从Juno卸载Egit功能?

android - 处理Android应用程序卸载

inno-setup - 在 Inno Setup 中更改任务列表框和其他控件的背景颜色

inno-setup - Inno Setup 可以检测到可以模拟 x64 的 ARM64 硬件上的 Windows11 吗?

.net - 如何签署我的 VB.NET 应用程序?

.net - “检查”功能在 Inno Setup 中多次执行