2016-12-28 18 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

おかげマーティン。残念ながら、ソースコードを変更しなければ、それは不可能です。 –

関連する問題