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. Windows API
  4. How to capture the logon and logoff events in Windows Vista?

How to capture the logon and logoff events in Windows Vista?

Scheduled Pinned Locked Moved Windows API
tutorialquestion
14 Posts 5 Posters 2 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.
  • V Offline
    V Offline
    Vaibhav Deshpande 0
    wrote on last edited by
    #1

    Hi!! to all, I have sucessfully created a service which runs on Windows Vista and calls my application (without UAC dialogbox to apper) when first user logged in. Now I m stucking at a point as, I logoff or switch user after login (ie my service is running and my application is already invoked in the first users session), the application is not launched ie executed in the new logged on users account. I have used handlerEx function to capture the on session change event but I m unable to capture the login, logoff events. My service is running on the LocalSystem Account and my service type is SERVICE_WIN32_OWN_PROCESS. Please give me suggession to overcome this difficulty. With regards, Vaibhav Deshpande.

    M 1 Reply Last reply
    0
    • V Vaibhav Deshpande 0

      Hi!! to all, I have sucessfully created a service which runs on Windows Vista and calls my application (without UAC dialogbox to apper) when first user logged in. Now I m stucking at a point as, I logoff or switch user after login (ie my service is running and my application is already invoked in the first users session), the application is not launched ie executed in the new logged on users account. I have used handlerEx function to capture the on session change event but I m unable to capture the login, logoff events. My service is running on the LocalSystem Account and my service type is SERVICE_WIN32_OWN_PROCESS. Please give me suggession to overcome this difficulty. With regards, Vaibhav Deshpande.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Vaibhav Deshpande wrote:

      I have used handlerEx function to capture the on session change event but I m unable to capture the login, logoff events.

      What if, after you call RegisterServiceCtrlHandlerEx() to set your HandlerEx() function, you call SetServiceStatus() with SERVICE_ACCEPT_SESSIONCHANGE in the dwControlsAccepted field of the SEVICE_STATUS struct?  Do you get the notifications then? Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      V J 2 Replies Last reply
      0
      • M Mark Salsbery

        Vaibhav Deshpande wrote:

        I have used handlerEx function to capture the on session change event but I m unable to capture the login, logoff events.

        What if, after you call RegisterServiceCtrlHandlerEx() to set your HandlerEx() function, you call SetServiceStatus() with SERVICE_ACCEPT_SESSIONCHANGE in the dwControlsAccepted field of the SEVICE_STATUS struct?  Do you get the notifications then? Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        V Offline
        V Offline
        Vaibhav Deshpande 0
        wrote on last edited by
        #3

        Thank you Sir!!!! Its working. Now I can capture the login, logoff, console connect,disconnect events. Using SERVICE_ACCEPT_SESSIONCHANGE I am able to capture the events in the HandlerEx function. Thanks again. With regards, Vaibhav Deshpande.

        M 1 Reply Last reply
        0
        • V Vaibhav Deshpande 0

          Thank you Sir!!!! Its working. Now I can capture the login, logoff, console connect,disconnect events. Using SERVICE_ACCEPT_SESSIONCHANGE I am able to capture the events in the HandlerEx function. Thanks again. With regards, Vaibhav Deshpande.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Vaibhav Deshpande wrote:

          Thank you Sir!!!!

          You're welcome!  And you can call me Mark ;P

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          J 1 Reply Last reply
          0
          • M Mark Salsbery

            Vaibhav Deshpande wrote:

            Thank you Sir!!!!

            You're welcome!  And you can call me Mark ;P

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            J Offline
            J Offline
            JudyL_MD
            wrote on last edited by
            #5

            Sir Mark :laugh:

            M 1 Reply Last reply
            0
            • J JudyL_MD

              Sir Mark :laugh:

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              :doh:  ;P

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              J 1 Reply Last reply
              0
              • M Mark Salsbery

                :doh:  ;P

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                J Offline
                J Offline
                JudyL_MD
                wrote on last edited by
                #7

                Sorry, was watching the first Star Wars last weekend, and your comment was straight out of the movie Judy

                M 1 Reply Last reply
                0
                • J JudyL_MD

                  Sorry, was watching the first Star Wars last weekend, and your comment was straight out of the movie Judy

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  :-D

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  1 Reply Last reply
                  0
                  • M Mark Salsbery

                    Vaibhav Deshpande wrote:

                    I have used handlerEx function to capture the on session change event but I m unable to capture the login, logoff events.

                    What if, after you call RegisterServiceCtrlHandlerEx() to set your HandlerEx() function, you call SetServiceStatus() with SERVICE_ACCEPT_SESSIONCHANGE in the dwControlsAccepted field of the SEVICE_STATUS struct?  Do you get the notifications then? Mark

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    J Offline
                    J Offline
                    jamalhaider
                    wrote on last edited by
                    #9

                    Hi, I am trying to develop Win logOn Notification for Vista. My RegisterServiceCtrlHandlerEx() successfully set my HandelrEx() function however I am not able to receive Lock, Logon and logoff events. Moreover as suggested I am also calling SetServiceStatus() with SERVICE_ACCEPT_SESSIONCHANGE in the dwControlsAccepted field of the SEVICE_STATUS struct. The only notification I am getting at the moment in my HandlerEx() fuction is SERVICE_STOPPED. I am using C# for development. Please help me.

                    M 1 Reply Last reply
                    0
                    • J jamalhaider

                      Hi, I am trying to develop Win logOn Notification for Vista. My RegisterServiceCtrlHandlerEx() successfully set my HandelrEx() function however I am not able to receive Lock, Logon and logoff events. Moreover as suggested I am also calling SetServiceStatus() with SERVICE_ACCEPT_SESSIONCHANGE in the dwControlsAccepted field of the SEVICE_STATUS struct. The only notification I am getting at the moment in my HandlerEx() fuction is SERVICE_STOPPED. I am using C# for development. Please help me.

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #10

                      If you're using C#, then using the .NET service classes should be easier... Override ServiceBase.OnSessionChange(). Mark

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      J M 2 Replies Last reply
                      0
                      • M Mark Salsbery

                        If you're using C#, then using the .NET service classes should be easier... Override ServiceBase.OnSessionChange(). Mark

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        J Offline
                        J Offline
                        jamalhaider
                        wrote on last edited by
                        #11

                        Thanks Mark :) It works like a charm. Thanks again.

                        1 Reply Last reply
                        0
                        • M Mark Salsbery

                          If you're using C#, then using the .NET service classes should be easier... Override ServiceBase.OnSessionChange(). Mark

                          Mark Salsbery Microsoft MVP - Visual C++ :java:

                          M Offline
                          M Offline
                          Moshe Yada
                          wrote on last edited by
                          #12

                          Hi, I'm also encountering this problem. However, I'm using C++ ... Any idea? Thanks in advance, Moshe.

                          M M 2 Replies Last reply
                          0
                          • M Moshe Yada

                            Hi, I'm also encountering this problem. However, I'm using C++ ... Any idea? Thanks in advance, Moshe.

                            M Offline
                            M Offline
                            Mark Salsbery
                            wrote on last edited by
                            #13

                            Moshe Yada wrote:

                            I'm also encountering this problem. However, I'm using C++ ...

                            You mean not getting session change events in your service? If so, does this[^] help? Mark

                            Mark Salsbery Microsoft MVP - Visual C++ :java:

                            1 Reply Last reply
                            0
                            • M Moshe Yada

                              Hi, I'm also encountering this problem. However, I'm using C++ ... Any idea? Thanks in advance, Moshe.

                              M Offline
                              M Offline
                              Moshe Yada
                              wrote on last edited by
                              #14

                              "I am trying to develop Win logOn Notification for Vista. My RegisterServiceCtrlHandlerEx() successfully set my HandelrEx() function however I am not able to receive Lock, Logon and logoff events. Moreover as suggested I am also calling SetServiceStatus() with SERVICE_ACCEPT_SESSIONCHANGE in the dwControlsAccepted field of the SEVICE_STATUS struct. The only notification I am getting at the moment in my HandlerEx() fuction is SERVICE_STOPPED." I am using C++ with a generated code using VS2005 of Win32Service, so I call RegisterServiceCtrlHandlerEx() and SetServiceStatus() from within OnStart(). Thanks in advance for your help, Moshe

                              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