Inno Setup uninstall progress bar change event

2019-02-16 02:46发布

Is there any event/function like CurInstallProgressChanged for progressbar with CurProgress and MaxProgress values in Uninstall form in Inno Setup?

标签: inno-setup
1条回答
姐就是有狂的资本
2楼-- · 2019-02-16 03:10

There's no native support for this.

What you can do is to setup a timer and watch for changes in the UninstallProgressForm.ProgressBar.Position.

Timer is tricky too. Again, there's no native support. You can use the InnoTools InnoCallback DLL library. But using an external DLL library from an uninstaller is tricky too. See (yours) Load external DLL for uninstall process in Inno Setup.

The code may be like:

[Files]
Source: InnoCallback.dll; DestDir: {app}

[Code]

type
  TTimerProc = procedure(h: LongWord; Msg: LongWord; IdEvent: LongWord; dwTime: LongWord);

procedure TimerProc(h: LongWord; AMsg: LongWord; IdEvent: LongWord; dwTime: LongWord);
begin
  Log(Format(
    'Uninstall progress: %d/%d',
    [UninstallProgressForm.ProgressBar.Position, UninstallProgressForm.ProgressBar.Max]));
end;

function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
  external 'wrapcallback@{%TEMP}\innocallback.dll stdcall uninstallonly delayload';

function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord;
  lpTimerFunc: LongWord): LongWord;
  external 'SetTimer@user32.dll stdcall';

procedure InitializeUninstallProgressForm();
var
  TimerCallback: LongWord;
begin
  if FileCopy(ExpandConstant('{app}\innocallback.dll'),
              ExpandConstant('{%TEMP}\innocallback.dll'), False) then
  begin
    TimerCallback := WrapTimerProc(@TimerProc, 4);
    SetTimer(0, 0, 100, TimerCallback); { every 100 ms }
  end;
end;

For another solution (better but more complicate to implement), see How keep uninstall files inside uninstaller?

查看更多
登录 后发表回答