How to abort shutdown in Windows (XP|Vista) programatically?

前端 未结 2 1753
别那么骄傲
别那么骄傲 2020-12-06 07:02

I want to be able to 1. detect (and, if needed 2. abort) OS shutdown from my application, preferably by using the Windows API.

I know that it is possible to abort sh

2条回答
  •  温柔的废话
    2020-12-06 07:32

    From MSDN:

    The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero.

    So, my application's WindowProc now processes the WM_QUERYENDSESSION message and returns 0.

    Didn't expect it to be this simple; as a bonus, it also works on Windows 2000.

提交回复
热议问题