在完成页面上启用Inno Setup的关闭/取消按钮

时间:2016-04-28 16:07:13

标签: inno-setup

是否可以在Inno Setup表格的最后一页上启用关闭按钮,并添加退出行为?

enter image description here

1 个答案:

答案 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;