要約すると、インストーラの実行中にコンピュータをシャットダウンすることを決定した場合、ユーザーを確認または防止する必要があります。今私はしばらくの間調査し、以下を考え出しました:Windowsシャットダウンを確認/防止する(NSIS)
${If} ${AtMostWinXP}
System::Call `kernel32::GetModuleHandle(i0)i.r3`
System::Call `user32::CreateWindowEx(i0,t"STATIC",t"MyApp",i0,i0,i0,i0,i0,i$HWNDPARENT,i0,ir3,i0)i.r1`
${ElseIf} ${AtLeastVista}
System::Call `user32::ShutdownBlockReasonCreate(ir1,w"MyApp is running and still needs to clean up before shutting down!")i.r0`
${EndIf}
しかし、上記のスニペットは機能しません。何か不足していますか?最初の二つの呼び出しは、Windows XPおよびそれ以前の第三の呼び出しのために意図されているとして、Windows Vistaのためのものか、後でされ
System::Call `kernel32::GetModuleHandle(i0)i.r3`
System::Call `user32::CreateWindowEx(i0,t"STATIC",t"MyApp",i0,i0,i0,i0,i0,i$HWNDPARENT,i0,ir3,i0)i.r1`
System::Call `user32::ShutdownBlockReasonCreate(ir1,w"MyApp is running and still needs to clean up before shutting down!")i.r0`
が、Windows XPによって無視され、以前の私は(私が持っていると信じている:私はちょうど使用して試してみましたこの理論を支持する証拠はない)。これも機能しません。
また、上記のスニペットの文字列全体を別の言語サポートに使用する代わりに、user32::ShutdownBlockReasonCreate(ir1,w"$(PreventShutdown)")i.r0
を使用することもできます。