Suppose there are multiples users currently logged on on Windows. Say, user1
logs on, then switch user
and user2
logs on, (without ma
You can call WTSGetActiveConsoleSessionId to get the terminal services (aka "fast user switching" aka "remote desktop") session ID that is currently active on the physical console.
You can call WTSQuerySessionInformation with WTS_CURRENT_SESSION
for the session identifier and WTSSessionId
for WTSInfoClass
to get the terminal services session ID for the current process.
If the active session ID and the current process session ID are the same, the user corresponding to the current process has the active session on the physical console.
If what you want to know is whether the session that the current process is running in is active (but not necessarily on the physical console) you can instead use the WTSConnectState
option to WTSQuerySessionInformation
.