Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WM_QUERYENDSESSION 1

Status
Not open for further replies.

jmnagi

Programmer
Oct 17, 2002
47
GB
hi..

in the MSDN library i see that WM_QUERYENDSESSION is sent when an application calls ExitWindows function. A window receives this message through its WindowProc fuction.

The lParam value in its argument will indicate whether the user wants to log-off or shutdown.

Also, the library suggests that i perform a BITWISE operation to check if lParam value includes ENDSESSION_LOGOFF or SHUTDOWN.

can anyone tell me how to do this ? please reply as soon as you possibly can. thanks. i DON'T KNOW WHAT VALUES TO COMPARE !

br: nagi --
br: nagi
 
hi .. thanks for your quick reply.

yes, i need to receive this message. my dll works fine in Win2000.. but it does not in Win XP pro. i am confused why it does not.

i receive this message alright {i think} and i check for the lParam value

this is what i have in win 2000:
if (lParam == 0) /* system is shutting down */
{
...
clean up everything ..
...
}
else /* user is logging off */
{
...
do something else
...
}

in Win 2000 i am able to clearly identify if the user is logging off or shutting down. i thought it will work fine in XP as well ..

but in XP the code always identifies it as a shutdown .. MSDN library says that i should check for ENDSESISION_LOGOFF and do a bitwise comparison .. but i am not sure how.

br: nagi
--
br: nagi
 
I've tried the following on win2k Server and it works ok.
Did not yet checked on Xp,

maybe XP uses other info flags in lParam and it is not zero
you need to check if the bit marked by ENDSESSION_LOGOFF mask is one.

if(wParam)
{
if( lParam && ENDSESSION_LOGOFF )
{
//it is logoff ... do logof stuf

}else
{
//it is not logoff .... do something else
}
}
 
hi sandrio ...

i had fixed the fault a month back. BUT yes, you are *absolutely* right. the fault is that i had not bit tested the flag.

it has been working properly. thanks for your help.

br: --
br: nagi
 
Hi nagi,

Been verry busy last two months.

Btw do you have any Idea what windows API is available after Shutdown ? I need for example to do something in the very next moment after shutdow is initiated.
I cannot do with an application that monitors WM_QUERYENDSESSION because this app cannot even get started :) (eg: user do not login, but restart the computer)

Thanks in advance!

sandi_ro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top