Re: Determine When a User Logged In

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



See NetUserGetInfo() and usri2_last_logon member in USER_INFO_2 structure.
You will have to use several API calls before using it, such as
GetUserName/GetComputerName/Ex.

Another way is putting your application in HKLM\...\Run at install time with
a command line, like the following:

<AppPath>\MyApp.exe /startup

The Command() function returns the command line options. You can use that to
save the date and time and exit.

The Run entries in HKLM are executed for every user that logs in, including
terminal services and fast user switching.


.