Reputation: 53
From a service running on a Windows 7 machine, I'd like to be able to determine if there is any interactive user logged on AND active. This should count for users that are logged on locally or via remote-desktop. If a user is logged on locally and locks their machine, that would be considered inactive.
Upvotes: 1
Views: 749
Reputation: 612794
WTSEnumerateSessions
. This gives you a list of session IDs.WTSQuerySessionInformation
for each session ID. Specify WTSSessionInfoEx
for the WTSInfoClass
parameter. This gives you a WTSINFOEX
struct.WTSINFOEX_LEVEL1
struct. From that you can read the session state and check for the session being locked by looking for WTS_SESSIONSTATE_LOCK
in the session flags.Upvotes: 1