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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to detect that a user has logged in (Service & NT)

How to detect that a user has logged in (Service & NT)

Scheduled Pinned Locked Moved C / C++ / MFC
linuxtutorialquestionlounge
3 Posts 3 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.
  • E Offline
    E Offline
    EiSl
    wrote on last edited by
    #1

    Hello folks, I know that a service process (under NT/Win2k) should not communicate with GUI, since no user has to be logged in so no shell is available. But... When my service is crashing (unhandled exception), I want my general exception handler sends a messagebox to the user in case there's a user logged in. So... How can I detect if a shell exist (aka: a user is logged in), so I can safely shoot a messagebox. Thanks, EiSl

    N T 2 Replies Last reply
    0
    • E EiSl

      Hello folks, I know that a service process (under NT/Win2k) should not communicate with GUI, since no user has to be logged in so no shell is available. But... When my service is crashing (unhandled exception), I want my general exception handler sends a messagebox to the user in case there's a user logged in. So... How can I detect if a shell exist (aka: a user is logged in), so I can safely shoot a messagebox. Thanks, EiSl

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      hi this might be a dumb technique but I think you can use GetDesktopWindow() and if that returns NULL, that probably means there is no user logged in nish

      1 Reply Last reply
      0
      • E EiSl

        Hello folks, I know that a service process (under NT/Win2k) should not communicate with GUI, since no user has to be logged in so no shell is available. But... When my service is crashing (unhandled exception), I want my general exception handler sends a messagebox to the user in case there's a user logged in. So... How can I detect if a shell exist (aka: a user is logged in), so I can safely shoot a messagebox. Thanks, EiSl

        T Offline
        T Offline
        Tomasz Sowinski
        wrote on last edited by
        #3

        I think you should rather write this info to the Windows Event Log. Anyway, if you need to interact with the desktop, first read 'Interactive Services' in your VC++ help. It should be under Platform SDK/DLLs, Processes, and Threads. Tomasz Sowinski -- http://www.shooltz.com

        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