MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? [modified]
-
Does anybody knows the solution ??? Kushagra
From MSDN: "Console applications receive shutdown notifications in their handler routines. To register a console handler, use the SetConsoleCtrlHandler function. Service applications receive shutdown notifications in their handler routines. To register a service control handler, use the RegisterServiceCtrlHandlerEx function." Maybe that helps.
-
Hello all, I have made an MFC application with invisible window and invisible in Applications tab of taskmanager designed to run in different sessions depending upon the number of users who are logged into the system. Thus, according to user events the instances used to capture logoff/Shutdown/Logon events for that particular session.Also, I have made one instance of this executable to run in 'SYSTEM' account to capture scheduled shutdown in cases when no user was logged on the machine. However in this case 'WM_QUERYENDSESSION' is never recieved by this running instance of my application which runs in 'SYSTEM' account.Can some one tell me how to abort scheduled shutdown in Windows from an application running in system account , in a case when no user is logged on in the machine. Regards, Kushagra I hate coding but I luv to develop :)
modified on Wednesday, October 21, 2009 9:22 AM
Kushagra Tiwari wrote:
I have made an MFC application with invisible window and invisible in Applications tab of taskmanager .... I have made one instance of this executable to run in 'SYSTEM' account
Does this mean that you have created a service?
Kushagra Tiwari wrote:
how to abort scheduled shutdown in Windows from an application running in system account
Are you certain that you really want to do this even if it's possible? What do you mean by 'scheduled'? Personally I find it suspicious that you have created an application that runs "invisible" from user perspective that aims to block the system from being brought down. I would consider it to be a very anti-social application that I wouldn't want running on any of my machines. However, if an application calls
::ExitWindowsEx()
with theEWK_FORCE
parameter,WM_QUERYENDSESSION
will not be sent - all processes will be terminated and possibly with data lost. How do you distinguish from a 'scheduled' shutdown and one triggered by a user in your message handler or callback? I guess the user won't be able to bring the system down either.... What if your application runs on a machine with UPS; the power is lost and the UPS service wants to bring the system down safely? Will you block it if possible? I guess my question really is "what are to trying to accomplish and why"? There may be a better solution."It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown