2016-12-28 38 views
1

继续从Inno Setup remove or edit Installing Application Name display on shut down开始。有没有办法告诉Inno Setup在关闭时不要阻塞并允许Windows正常关闭安装程序?理想情况下,这将在所有屏幕上执行,直到按下安装按钮,然后在安装时再次阻止启用,然后在完成时以及在完成屏幕上再次禁用(即仅在进行更改时阻止)。这是可能的吗?它会如何尝试?Inno Setup在关闭时禁用并启用阻止

回答

2

Inno Setup明确拒绝WM_QUERYENDSESSION消息。如果不修改Inno Setup源代码,您无法做任何事情。

TDummyClass.AntiShutdownHook method

class function TDummyClass.AntiShutdownHook(var Message: TMessage): Boolean; 
begin 
    { This causes Setup/Uninstall/RegSvr to all deny shutdown attempts. 
    - If we were to return 1, Windows will send us a WM_ENDSESSION message and 
     TApplication.WndProc will call Halt in response. This is no good because 
     it would cause an unclean shutdown of Setup, and it would also prevent 
     the right exit code from being returned. 
     Even if TApplication.WndProc didn't call Halt, it is my understanding 
     that Windows could kill us off after sending us the WM_ENDSESSION message 
     (see the Remarks section of the WM_ENDSESSION docs). 
    - SetupLdr denys shutdown attempts as well, so there is little point in 
     Setup trying to handle them. (Depending on the version of Windows, we 
     may never even get a WM_QUERYENDSESSION message because of that.) 
    Note: TSetupForm also has a WM_QUERYENDSESSION handler of its own to 
    prevent CloseQuery from being called. } 
    Result := False; 
    case Message.Msg of 
    WM_QUERYENDSESSION: begin 
     { Return zero, except if RestartInitiatedByThisProcess is set 
      (which means we called RestartComputer previously) } 
     if RestartInitiatedByThisProcess or (IsUninstaller and AllowUninstallerShutdown) then begin 
      AcceptedQueryEndSessionInProgress := True; 
      Message.Result := 1 
     end else 
      Message.Result := 0; 
     Result := True; 
     end; 
{ ... } 

TSetupForm.WMQueryEndSession method

procedure TSetupForm.WMQueryEndSession(var Message: TWMQueryEndSession); 
begin 
    { TDummyClass.AntiShutdownHook in Setup.dpr already denies shutdown attempts 
    but we also need to catch WM_QUERYENDSESSION here to suppress the VCL's 
    default handling which calls CloseQuery. We do not want to let TMainForm & 
    TNewDiskForm display any 'Exit Setup?' message boxes since we're already 
    denying shutdown attempts, and also we can't allow them to potentially be 
    displayed on top of another dialog box that's already displayed. } 

    { Return zero, except if RestartInitiatedByThisProcess is set (which means 
    we called RestartComputer previously) } 
    if RestartInitiatedByThisProcess then 
    Message.Result := 1; 
end; 
+0

感谢马丁。遗憾的是,不修改源代码是不可能的。 –