I found this tutorial on how getting Idle time of the user Idle Time.
The problem is that it will only work if the application runs on the user.
And my application runs on SYSTEM.
How can I get the idle time? or if PC is idle?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As I understood, you are okay with the result of GetLastInputInfo function. Thus I would suggest the following.
Now, suppose you have executable A that runs under Local System account. Create executable B that will gather relevant system information (with the help of GetLastInputInfo). Next, run executable B from executable A using this class which uses CreateProcessAsUser function with the logged user token (unfortunately I was unable to find stackoverflow question in which it was published):
Next, you need to find a way for sending gathered information from executable B to executable A. There are numerous methods to do this. One of those is .Net Remoting. However you can go with creating an intermediate XML or even text file.
Maybe it is not the best way to solve your problem, but if you will need more Local System <-> Logged User interactions, you have a pattern to follow.