|
-
Mar 12th, 2002, 11:42 AM
#1
Thread Starter
Hyperactive Member
I am SHUT DOWN and out of ideas
Here's the situation. My program needs to distinguish between when the computer is logging off and when the computer is doing a shutdown or restart. The only two scenarios I care about are log off and other(i.e. Shutdown, Restart, forced restart, whatever). How can I track this? Can I subclass the form to monitor for some shutdown message that contains the information for which type of shutdown it is? Is it possible to simply handle this somehow with an API call placed in the form queryunload event or something similiar? I am very open to suggestions. Thank you for any help you can give.
Joe
-
Mar 12th, 2002, 01:19 PM
#2
Junior Member
If a Windows session is closed the system sends the WM_QUERYENDSESSION - Message to every application.
The lParam value of this message is a flag that shows if the user wants to logoff or if the system is going to shut down (or to reboot).
You can use the SetWindowLong function to tell Windows the address of your custom function that handles the WM_* - messages.
Last edited by Raptor; Mar 12th, 2002 at 01:26 PM.
VB 6.0; VC++ 6.0; PERL; PASCAL; BASIC; PHP4; HTML; mySQL
-
Mar 12th, 2002, 01:41 PM
#3
Thread Starter
Hyperactive Member
Thank you...
I just found the information I needed. In order to distinguish, you must look at the value of the lparam. The lparam contains a bitmask that contains the type of shutdown. The constant I needed to test to see if it was part of the bitmask was ENDSESSION_LOGOFF(&H80000000). This constant denotes that the computer was logging off and not shutting down. If you have any questions as how to subclass the form to track for the message or how to use bitmasks, feel free to ask.
Joe
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|