Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to know programatically that Windows has logged in/Logged Off/Shut Down occured etc?

How to know programatically that Windows has logged in/Logged Off/Shut Down occured etc?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++windows-adminquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amarelia
    wrote on last edited by
    #1

    Hello Friends In my dialoged based MFC programm I need to handle and set certain registry values before windows gets shut down and also immediately after Windows loggs in(i.e immediately after user presses Ctrl+Alt+Del and enterys passwords). I read that it sends some message WM_QUERYENDSESSION or something like that but don't know how to trap that message or how to achieve this? Any such example or any idea please. Thankx and regards in advance. Mahesh

    R D 2 Replies Last reply
    0
    • A Amarelia

      Hello Friends In my dialoged based MFC programm I need to handle and set certain registry values before windows gets shut down and also immediately after Windows loggs in(i.e immediately after user presses Ctrl+Alt+Del and enterys passwords). I read that it sends some message WM_QUERYENDSESSION or something like that but don't know how to trap that message or how to achieve this? Any such example or any idea please. Thankx and regards in advance. Mahesh

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Amarelia wrote:

      but don't know how to trap that message or how to achieve this?

      For the logoff: There is a MFC OnQueryEndSession() wrapper in the class CWnd. Since your Dialog is derived from CWnd, you can do following (assuming VC6++) : Rightclick on your Cdialog class in the class browser : Add Windows Message Handler, In the dialog that pops up change Dialog to Window in the combobox on the bottom right, and then select WM_QUERYENDSESSION in the list. Here you have your wrapper. This implies that your app is alive when windows shutdown. ~RaGE();

      1 Reply Last reply
      0
      • A Amarelia

        Hello Friends In my dialoged based MFC programm I need to handle and set certain registry values before windows gets shut down and also immediately after Windows loggs in(i.e immediately after user presses Ctrl+Alt+Del and enterys passwords). I read that it sends some message WM_QUERYENDSESSION or something like that but don't know how to trap that message or how to achieve this? Any such example or any idea please. Thankx and regards in advance. Mahesh

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Amarelia wrote:

        I need to handle and set certain registry values...immediately after Windows loggs in(i.e immediately after user presses Ctrl+Alt+Del and enterys passwords).

        You can do this with your own GINA DLL, or implement the ISensLogon interface.

        Amarelia wrote:

        I read that it sends some message WM_QUERYENDSESSION or something like that but don't know how to trap that message or how to achieve this?

        I believe you'll want to look for WM_ENDSESSION instead. Windows will send the WM_QUERYENDSESSION message asking applications if it is ok to exit. If any of them respond with a zero value, no further WM_QUERYENDSESSION messages are sent. If all of the applications respond with a non-zero value, Windows will then send a WM_ENDSESSION message.


        "The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb

        T 1 Reply Last reply
        0
        • D David Crow

          Amarelia wrote:

          I need to handle and set certain registry values...immediately after Windows loggs in(i.e immediately after user presses Ctrl+Alt+Del and enterys passwords).

          You can do this with your own GINA DLL, or implement the ISensLogon interface.

          Amarelia wrote:

          I read that it sends some message WM_QUERYENDSESSION or something like that but don't know how to trap that message or how to achieve this?

          I believe you'll want to look for WM_ENDSESSION instead. Windows will send the WM_QUERYENDSESSION message asking applications if it is ok to exit. If any of them respond with a zero value, no further WM_QUERYENDSESSION messages are sent. If all of the applications respond with a non-zero value, Windows will then send a WM_ENDSESSION message.


          "The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb

          T Offline
          T Offline
          Toby Opferman
          wrote on last edited by
          #4

          I wouldn't write a GINA unless nessecary since it will not be portable to Windows Vista. --------------- Windows Login Winlogin (GINA) is being rewritten for Windows Vista to reduce number of necessary processes and components loaded. The new GINA will not be replaceable. A new Credential Provider Model will be used for extensibility. New mechanisms will also be provided to support existing functionality. A new Eventing and Stacking, and Chaining model will be provided. http://www.activewin.com/winvista/thestateofvista.shtml[^] 8bc7c0ec02c0e404c0cc0680f7018827ebee

          D 1 Reply Last reply
          0
          • T Toby Opferman

            I wouldn't write a GINA unless nessecary since it will not be portable to Windows Vista. --------------- Windows Login Winlogin (GINA) is being rewritten for Windows Vista to reduce number of necessary processes and components loaded. The new GINA will not be replaceable. A new Credential Provider Model will be used for extensibility. New mechanisms will also be provided to support existing functionality. A new Eventing and Stacking, and Chaining model will be provided. http://www.activewin.com/winvista/thestateofvista.shtml[^] 8bc7c0ec02c0e404c0cc0680f7018827ebee

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Toby Opferman wrote:

            I wouldn't write a GINA unless nessecary since it will not be portable to Windows Vista.

            I wouldn't either. I was just offering suggestions. Care to offer help on this one?


            "The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups