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?
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)