Results 1 to 3 of 3

Thread: I am SHUT DOWN and out of ideas

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    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

  2. #2
    Junior Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    21
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    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
  •  



Click Here to Expand Forum to Full Width