Hi, I would like to have a program on my PC which records the login and logout times for different users. How easy writing this would be. How do I begin?
From the top of my head you need a Windows service, so start reading about creating a service in C/C++. There are some special considerations in order to properly interact with the Service Manager.
The handler above will get the session ID, and you can use it in a call to WTSQueryUserToken() (http://msdn.microsoft.com/en-us/library/windows/desktop/aa383840(v=vs.85).aspx ) to obtain the logged-on user token, but bear in mind that this function only works if the service is running under NT AUTHORITY\SYSTEM. Finally, you can query the token to obtain the user's information.