How to get time of last log in to Windows by user

G

Guest

I need to find the time that the user started the current windows session
(i.e. when they logged in).
I cannot find how to get the date & time, or amount of time since login.

I need a method that will work for Windows 2000 Pro, Windows XP Pro, Windows
2000 Server (all) and above.
Some of my customers only have single Windows 2000 Professional P.C and no
proper server so I cannot use any method that relies on a Domain Server being
available.

I've got the user name using GetUserName() and the time since System Boot
using PdhOpenQuery() etc.
 
S

Steve Parry

Derek said:
I need to find the time that the user started the current windows session
(i.e. when they logged in).
I cannot find how to get the date & time, or amount of time since login.

I need a method that will work for Windows 2000 Pro, Windows XP Pro,
Windows 2000 Server (all) and above.
Some of my customers only have single Windows 2000 Professional P.C and no
proper server so I cannot use any method that relies on a Domain Server
being available.

I've got the user name using GetUserName() and the time since System Boot
using PdhOpenQuery() etc.


http://www.microsoft.com/technet/sysinternals/SystemInformation/LogonSessions.mspx
 
G

Guest

http://www.microsoft.com/technet/sysinternals/SystemInformation/LogonSessions.mspx

Thanks Steve.
The LogonSessions.exe does get the information and I could use it. But I
would prefer to get the information directly into my Application using the
Windows API. This is neater and means I won't have to install
LogonSessions.exe on to all my customer's PCs or servers.

If this utility can do, presumably there must be way.

p.s. I have to use C for this, can't use Java or .Net.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top