Hi i need to log the details of user login in Windows such as login time, login date and day etc and write it to a text log file... okay, i can get all these details with GetSystemTime() API.. but, i dont know how to get the logon and logoff events.

I know the Run key method in registry and startup folder method.. but those things wont solve my problem because i need to log these things each time user logs in and logs off.

I need to write the textfile if current user logs off(not shutdown) and after sometime he logs on(without restart/shutdown).

can anyone please help me... thanks in advance