c++winapiserviceuser-activity

Is it possible to know last user activity from a Windows service?


I have a Windows service program (written using C++) that is required to perform an energy saving power operation at a certain time of the day. I need to find out if a user might be at the terminal at the time when the power operation is performed and if he/she is, postpone it then. So my question is, how do you know the moment of the last user activity from a Windows service (running as a local system)?

PS. By user activity I mean keyboard and mouse activity.


Solution

  • Each user session will have to run a background app within its session that communicates with the service, then the app can report the last activity time so the service can make decisions based on that.