'ShutdownBlockReasonDestroy when real power button down

Prevent Shutdown on Windows almost using windows API ShutdownBlockReasonCreate when application received "shutdown signal" ,windows message is 17 (need set AutoEndTasks registry key to 0)

simple test with Notepad,if shutdown from start menu shutdown button,Notepad will prevents it. but if using real power button,windows can not show any prevent UI.

I tested with my application, "close" messages can received ,but can't show prevent UI.

So this is a windows bug or need some special setting on windows?



Solution 1:[1]

at last I found a solution. just need use gpedit.msc Go to “Computer Configuration” >manage template>system>shutdown opption set the only one setting to enable (sorry Chinese literal translation xD)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user15281044