答案 0 :(得分:1)
启用关闭按钮很容易,使用EnableMenuItem
WinAPI function。另请参阅Inno Setup Disable close button (X)。
很难让关闭按钮实际工作。 Inno Setup窗口不能在“完成”页面上关闭。唯一的方法可能是使用ExitProcess
WinAPI function强制中止该过程。请参阅Exit from Inno Setup Installation from [code]。
完整的代码是:
function GetSystemMenu(hWnd: THandle; bRevert: Boolean): THandle;
external 'GetSystemMenu@user32.dll stdcall';
function EnableMenuItem(hMenu: UINT; uIDEnableItem, uEnable: UINT): Boolean;
external 'EnableMenuItem@user32.dll stdcall';
const
MF_BYCOMMAND = $0;
SC_CLOSE = $F060;
procedure ExitProcess(exitCode:integer);
external 'ExitProcess@kernel32.dll stdcall';
procedure FormClose(Sender: TObject; var Action: TCloseAction);
begin
Log('Exiting by user after installation');
ExitProcess(1);
end;
procedure CurPageChanged(CurPageID: Integer);
var
Menu: THandle;
begin
if CurPageID = wpFinished then
begin
{ Enable "close" button }
Menu := GetSystemMenu(WizardForm.Handle, False);
EnableMenuItem(Menu, SC_CLOSE, MF_BYCOMMAND);
{ Make the "close" button working }
WizardForm.OnClose := @FormClose;
end;
end;