I want to hide the first and the last message of the unisntaller. This code works with a modified version of inno setup (Inno Setup Ultra 5.5.1.ee2) but does not work well to hide the first message (appears briefly and disappears):
function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PansiChar): HWND;
external 'FindWindowExA@user32.dll stdcall';
const
BM_CLICK = $00F5;
var
Timer: TTimer;
msg: string;
Wnd, WndEx: HWND;
procedure OnTimer(Sender: TObject);
begin
Wnd:= FindWindowByWindowName(msg);
if Wnd > 0 then
begin
WndEx:= FindWindowEx(Wnd, 0,'Button', '');
if WndEx > 0 then
begin
PostMessage(WndEx, BM_CLICK, 0, 0);
Timer.Enabled:= False;
end;
end;
end;
function InitializeUninstall:boolean;
begin
Result := True;
msg:= SetupMessage(msgUninstallAppFullTitle);
StringChange(msg, '%1', '{#SetupSetting('AppName')}');
OnTimer(nil);
Timer:= TTimer.Create(nil);
with Timer do
begin
OnTimer:= @OnTimer;
Interval:= 1;
Enabled:= True;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usPostUninstall then
begin
OnTimer(nil);
Timer:= TTimer.Create(nil);
with Timer do
begin
OnTimer:= @OnTimer;
Interval:= 1;
Enabled:= True;
end;
end;
end;
How to modify this code to work correctly with the current official version of Inno Setup and to correctly hide both messages?
First, I must say that I do not agree with this at all. But it's interesting problem anyway, and the implementation might be useful for other, more appropriate cases.
Also you cannot avoid the message to appear briefly. The solution automates the UI, so needs the UI to work. That's one of the reasons I do not like it.
This code uses the InnoTools InnoCallback DLL library to implement a timer. But using an external DLL library from an uninstaller is tricky and has its drawbacks. See Load external DLL for uninstall process in Inno Setup.
The code requires the Unicode Inno Setup.
For a different approach to the problem, see Changing uninstall confirmation prompt.