Search code examples
windowswindows-vistashutdown

windows os shut down eventhandler


Is there anyway to handle windows os shutdown, and cancel shutting down?

I want to cancel shut down which's processed by user( a planned shut down).

SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED

I look kernel32.dll, but I could not find anything about that.

Thanks.


Solution

  • I don't know if it is still supported but if an application returns 0 in response to a WM_QUERYENDSESSION message, the system will not shut down.