Solved

Getting NT Status - logged on / off or locked

Posted on 2000-04-12
13
177 Views
Last Modified: 2013-11-20
How can I tell if a computer has someone logged in? I need to write a program that tells if someone is at their desk, the idea being that if they are, they're most likely to also be logged in and not be logged out or locked. I need a "yes" answer from the program for a logged in and a "no" answer for any other state. I can then write this to a web page in my usual way.

Cheers

Dave
0
Comment
Question by:wierd_dave
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +2
13 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2707477
I think U need to have an adapater installed on the end m/c which monitors the events on the end m/c logs them and sends to server (for this U can use sockets)..
Hope this helps
0
 
LVL 3

Accepted Solution

by:
shaig earned 200 total points
ID: 2707532
What if a user is logged in, but away from his computer?

Try a different view:
Detect keyboard and mouse events. If idle for more then a defined time, then declare user as 'away'.   ICQ uses a simulare mechanism.

You can implement this using Win32 hooks.
0
 

Author Comment

by:wierd_dave
ID: 2707572
I can handle him being away! I'm having to put up with an endless stream of students looking for a certain research assistant, so if I can put whether he's in or not on a web page, I'll be a happy chappie.

Would the computer being locked affect the operation of a program?

Dave
0
Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

 
LVL 86

Expert Comment

by:jkr
ID: 2707583
The most compatible way for all MS platforms would be to enumerate the entries in 'HKEY_USERS' - see http://www.sysinternals.com/misc.htm#loggedon for a source code sample...
0
 

Author Comment

by:wierd_dave
ID: 2707863
Looking at this program, it only checks if the computer has a user loged in or not, ragardless of whether it is locked or not. We very rarely log off in this office, preferring to lock so we can still access each others resources.
A locked machine is the best indication that we are not in.
If it's not locked and unused, we've popped to the coffee machine.
If it's logged out, we're probably rebooting or logging back in as an administrator.
If it's locked we've left the building for whatever reason.
0
 
LVL 86

Expert Comment

by:jkr
ID: 2707998
Err - your question was "How can I tell if a computer has someone logged in?".

My answer was the answer to this very question... It's not good practice here to ask questions, reject correct answers along with telling 'no, I wanted to know something else'
0
 

Author Comment

by:wierd_dave
ID: 2708365
OK, I don't appear to have been as clear as I thought I had been. When I said "I need a "yes" answer from the program for a logged in and a "no" answer for any other state." I meant that if the machine is logged in and not locked, then I can assume someone is sat there working. If it is logged off or is logged in to, but has been locked, they probably are not working here.

I know what I meant, I just didn't say it quite right.

Dave
0
 
LVL 3

Expert Comment

by:shaig
ID: 2708775
I still think this is a bad mechanism.
The best way to tell if a user is using his compuetr is to check just that: keyboard and mouse activity.

How does the suggested mechanizm deal with a user that shuts his computer down (vecation, sick, etc.).
0
 

Author Comment

by:wierd_dave
ID: 2708813
I'm working on this activity monitor right now. If the mouse hasn't moved or the keyboard been touched in 15 minutes say, I'll log him as been out.
If he logs out the program will recieve a quit message and he can be instantly log as away.
Indeed it seems simpler this way.
0
 
LVL 3

Expert Comment

by:shaig
ID: 2708841
Yap, thats the idea.
0
 
LVL 32

Expert Comment

by:jhance
ID: 2711375
To detect if there is a logged on interactive user, enumerate the window stations until you find WinSta0.  Then use that handle to enumerate the desktops.  If you find WinSta0\default, then there is an interactive user logged in.  If this desktop doesn't exist, then there is no interactive user logged in.
0
 
LVL 3

Expert Comment

by:shaig
ID: 2711858
So, what will it be wierd dave?
0
 

Author Comment

by:wierd_dave
ID: 2716357
I went for the windows hooks. Placed in a dll they should be able to log all activity from what MSDN tells me.

This has been a thread full of good stuff as far as I'm concerned - cheers to all.

Dave
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question