lJoel Posted December 9, 2013 Share Posted December 9, 2013 Hi, I am using the following code to detect and block shutdowns on XP: RegisterShutdownBlocker() Func CancelShutdown($hWndGUI, $MsgID, $WParam, $LParam) return False EndFunc Func RegisterShutdownBlocker() ; $WM_QUERYENDSESSION, xp GUIRegisterMsg(0x11, "CancelShutdown") ; Vista, W7, etc $shutdownBlocker = GUICreate("PreventShutdown",250,0) DllCall("User32.dll", "int", "ShutdownBlockReasonCreate", "hwnd", $shutdownBlocker, "wstr", "Unload joebox") EndFunc This works perfectly fine in most cases. However I experienced that the block (AutoIt terminates after the return False call) does not work if the shutdown is initiated with: #include <stdio.h> int main(int argc, char* argv[]) { DWORD a = 0; BroadcastSystemMessage(2, &a ,0x11, 0, 1); return 0; } Any ideas how to handle / block the WM_QUERYENDSESSION broadcast case correctly? -- Joe Link to comment Share on other sites More sharing options...
Bowmore Posted December 9, 2013 Share Posted December 9, 2013 (edited) ShutdownBlockReasonCreate only works on Windows Vista or greater and only for desktop applications. You should check for errors after the DLL call. Edited December 9, 2013 by Bowmore "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
JohnOne Posted December 9, 2013 Share Posted December 9, 2013 Any ideas how to handle / block the WM_QUERYENDSESSION broadcast case correctly? If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now