Detecting Logoff from a Service
  
PSS ID Number: Q104122
Article last modified on 11-02-1995
 
3.10 3.50
 
WINDOWS NT
 

-------------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Win32 Application Programming Interface (API) included with:
 
    - Microsoft Windows NT versions 3.1 and 3.5
-------------------------------------------------------------------------
 
Sometimes it is handy for a service to know whether or not a user is logged
on to the system. For example, suppose that there are circumstances under
which the service displays a dialog box and waits for the user to respond.
If this is done while the user is logged off, the service is blocked until
the user logs on again.
 
Unfortunately, there is no direct way for a service to detect whether or
not a user is logged on. There is, however, an indirect method. If you
supply MB_DEFAULT_DESKTOP_ONLY as one of the flags in the fuStyle parameter
of MessageBox(), the function will fail if no one is logged on or if a
screen saver is running.
 
Additional reference words: 3.10 3.50
KBCategory: kbprg
KBSubcategory: BseService
=============================================================================
Copyright Microsoft Corporation 1995.
