Inno Setup uninstall progress bar change event

2019-02-16 02:36发布

问题:

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

回答1:

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?



标签: inno-setup