Board index » cppbuilder » Detect WinXP Login Screen

Detect WinXP Login Screen


2005-12-15 06:17:48 AM
cppbuilder84
I use the following code to detect when a screen saver has been started,
and when it was stopped:
global variable:
----------------
BOOL ScreensaverRunning = false; // global variable
periodic poll:
--------------
BOOL bOn=FALSE;
BOOL b=SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, NULL, &bOn,
FALSE);
BOOL ScreensaverOn = b && bOn;
if (ScreensaverOn != ScreensaverRunning)
{
ScreensaverRunning = ScreensaverOn;
if (ScreensaverOn) Trace(Application,"Screen Saver activated");
else Trace(Application,"Screen Saver stopped");
}
Now this tells me that a screen saver has been stopped, but it doesn't
detect whether the Windows XP login screen, or the Login window is
visible. Is there a way to detect this, either?
Thomas
 
 

Re:Detect WinXP Login Screen

"Thom A." < XXXX@XXXXX.COM >wrote in message
Quote
I use the following code to detect when a screen saver
has been started, and when it was stopped:
That approach is dependant on the screen saver executable actually doing
what it is supposed to be doing - notifying the OS that the screen saver is
running. On NT-based systems, at least, a more reliable approach would be
to use OpenDesktop() to see if the "Screen-saver" desktop is actually
running. Do note, however, that there is a known bug in NT 4.0 SP4:
BUG: OpenDesktop ("screen-saver",...) Returns a Valid Handle When the
Screen Saver Is Not Running
support.microsoft.com/default.aspx
Quote
Now this tells me that a screen saver has been stopped, but it doesn't
detect whether the Windows XP login screen, or the Login window is
visible. Is there a way to detect this, either?
Use OpenDesktop() to open the "WinLogin" desktop. In case WinLogin
continues to exist while the user is working, you may have to use
OpenInputDesktop() instead and then use GetUserObjectInformation() to see if
the active desktop's name is "WinLogin".
Gambit
 

Re:Detect WinXP Login Screen

Quote
Use OpenDesktop() to open the "WinLogin" desktop. In case WinLogin
continues to exist while the user is working, you may have to use
OpenInputDesktop() instead and then use GetUserObjectInformation() to see if
the active desktop's name is "WinLogin".
Well, it didn't work as expected, but I can use it:
HWND hDesktop = OpenInputDesktop(0,false,DESKTOP_READOBJECTS);
returns a valid handle if the desktop is visible or a screen-saver is
running, but returns hDesktop = 0, when the login screen is shown.
Still, this solves my problem. Thanks for your help, Gambit!!
Thomas
 

{smallsort}

Re:Detect WinXP Login Screen

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
Use OpenDesktop() to open the "WinLogin" desktop. In case
WinLogin continues to exist while the user is working, you may have
to use OpenInputDesktop() instead and then use
GetUserObjectInformation() to see if the active desktop's name is
"WinLogin".
Small typo - the desktop is named "WinLogon", not WinLogin".
Gambit
 

Re:Detect WinXP Login Screen

"Thom A." < XXXX@XXXXX.COM >wrote in message
Quote
HWND hDesktop = OpenInputDesktop(0,false,DESKTOP_READOBJECTS);

returns a valid handle if the desktop is visible or a screen-saver is
running, but returns hDesktop = 0, when the login screen is shown.
Did you call GetLastError() to find out why?
Also, it is possible for OpenInputDesktop() to fail if the associated
workstation is in the process of shutting down while the user is logging
out.
Also, you did not specify what kind of application is running your code. If
it is a non-interactive service, for example, then OpenInputDesktop() will
always fail by default since a non-interactive service is not run in the
same workstation as the one that runs the WinLogon desktop. Only desktops
in the "WinSta0" desktop can receive input, so you would have to use
OpenWindowStation() and SetProcessWorkStation() to put your application into
the "WinSta0" workstation before you can do anything with input-enabled
desktops, such as "WinLogon".
What EXACTLY are you trying to accomplish by detecting the WinLogin screen?
Gambit
 

Re:Detect WinXP Login Screen

Quote
What EXACTLY are you trying to accomplish by detecting the WinLogin screen?
I have written a standard Windows application - nothing exceptional.
However, it seems to cause a problem that makes it difficult for very
few WinXP users to log on again after the screen-saver had been
activated, and a logon is required.
I therefore want to detect when the WinXP Logon Screen becomes visible,
and suspend the process that causes the problem until the user has
logged himself into Windows again.
The problem itself is very strange: Although my software does not make
use of any functions that might move the mouse cursor, some part of my
software seems to reset the mouse cursor to one and the same position
about every second - but only as long as the Logon Screen is visible!!!
That's really annoying, because some users have notebooks with
touchpads, and therefore need more than a second to target and activate
the password field! The result is, that they try to hit this field for
minutes, until they finally succeed by pure fortune!
Really, I'm at a loss trying to find this bug: There's not even a single
line of code in the whole program that interferes with the mouse's
movements... :-(
Thomas
 

Re:Detect WinXP Login Screen

"Thom A." < XXXX@XXXXX.COM >wrote in message
Quote
However, it seems to cause a problem that makes it difficult for
very few WinXP users to log on again after the screen-saver
had been activated, and a logon is required.
Can you be a little more specific?
Quote
I therefore want to detect when the WinXP Logon Screen becomes
visible, and suspend the process that causes the problem until the
user has logged himself into Windows again.
What exactly are you doing during your process that you want to suspend?
Quote
The problem itself is very strange: Although my software does not
make use of any functions that might move the mouse cursor, some
part of my software seems to reset the mouse cursor to one and the
same position about every second - but only as long as the Logon
Screen is visible!!!
Are you absolutely sure that it is your software that is responsible, and
not the screen saver itself or anything else?
Gambit
 

Re:Detect WinXP Login Screen

Quote
What exactly are you doing during your process that you want to suspend?

Are you absolutely sure that it is your software that is responsible, and
not the screen saver itself or anything else?
I still don't know what causes the problem, so I need to create
extensive trace files that - hopefully - will hint to the problem.
All I know is that, the problem occurs only when my software is running.
Now I have to find out which part of the software actually causes the
problem!
Thomas