2016-04-28 57 views

回答

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 '[email protected] stdcall'; 

function EnableMenuItem(hMenu: UINT; uIDEnableItem, uEnable: UINT): Boolean; 
    external '[email protected] stdcall'; 

const 
    MF_BYCOMMAND = $0; 
    SC_CLOSE = $F060; 

procedure ExitProcess(exitCode:integer); 
    external '[email protected] 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; 
+1

好极了!有用。谢谢。 –