Home > Back-end >  How to use qt or c function the power button to turn it off to stop the Windows
How to use qt or c function the power button to turn it off to stop the Windows

Time:09-22

Now I need to press the power button before the system shutdown, execute a program, I finished my program execution, to let the system shutdown, I use the qt override winEventFilter function to obtain the system shutdown signal, but not intercept down, the system will shut down, beg god for help, very urgent, online, etc., please answer,,,,,,,,

CodePudding user response:

Great god quickly come out, I really very urgent

CodePudding user response:

Windows all top-level Windows when shutdown will want to broadcast a message WM_QUERYENDSESSION, can distinguish between the lParam parameter is turned off or the cancellation of the user (lParam ENDSESSION_LOGOFF) when the cancellation of the user, and then Windows will wait until all the applications to the news returns TRUE will be shut down, therefore, as long as our application's handling of the news returns FALSE, Windows will not shut down,

I want to know how to let this message returns false??????????

Crying is dizzy in the toilet! ~

CodePudding user response:

 bool MyMainWindow: : winEvent (MSG, MSG * long * result) 
{
The switch (MSG - & gt; Message)
{
Case WM_QUERYENDSESSION:
{
* the result=0;
break;
}
.

CodePudding user response:

Can provide the complete code??

reference ccrun reply: 3/f
 bool MyMainWindow: : winEvent (MSG, MSG * long * result) 
{
The switch (MSG - & gt; Message)
{
Case WM_QUERYENDSESSION:
{
* the result=0;
break;
}
.


Can provide the complete code?? thank you

CodePudding user response:

This is not very clear, even how all?
  • Related