BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Detect WinXP Login Screen

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Thom A.
Guest





PostPosted: Wed Dec 14, 2005 10:17 pm    Post subject: Detect WinXP Login Screen Reply with quote



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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Dec 14, 2005 11:23 pm    Post subject: Re: Detect WinXP Login Screen Reply with quote




"Thom A." <thoma (AT) gmx (DOT) at> wrote


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
http://support.microsoft.com/default.aspx?scid=kb;en-us;230117

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



Back to top
Thom A.
Guest





PostPosted: Thu Dec 15, 2005 11:40 am    Post subject: Re: Detect WinXP Login Screen Reply with quote



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


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Dec 15, 2005 6:35 pm    Post subject: Re: Detect WinXP Login Screen Reply with quote


"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote


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



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Dec 15, 2005 6:50 pm    Post subject: Re: Detect WinXP Login Screen Reply with quote


"Thom A." <thoma (AT) gmx (DOT) at> wrote


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



Back to top
Thom A.
Guest





PostPosted: Thu Dec 15, 2005 7:20 pm    Post subject: Re: Detect WinXP Login Screen Reply with quote

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


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Dec 15, 2005 9:10 pm    Post subject: Re: Detect WinXP Login Screen Reply with quote


"Thom A." <thoma (AT) gmx (DOT) at> wrote


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



Back to top
Thom A.
Guest





PostPosted: Thu Dec 15, 2005 10:06 pm    Post subject: Re: Detect WinXP Login Screen Reply with quote

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


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.