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

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
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.
 
Back
Top