Is it possible to determine the current user from the global keyboard in .NET.

I want to create a keyboard and mouse hook that will be launched as a Windows service. I want to monitor the activities of various users who use the system throughout the day. that is, which users are active at what time.

Is it possible to determine which user will receive events? (The service will work as a separate user, so getCurrentUser is not suitable)

+3
source share
4 answers

No, Environment.UserName does not work - the hook procedure is not called in the context of the input receiver.

, , - _LL, , , .NET, - . , , Windows , / . , - _LL.

+1

@TcKs - Um, ?

0

:

WTSGetActiveConsoleSessionId . :

WTSGetActiveConsoleSessionId , . - , . , , .

WTSQueryUserToken, , .

, :

, .

, , .

0

I do not know about these hooks - do they receive events from Remote Desktop keyboards? If they get only the local keyboard, then I think you need to find the owner of WinSta0.

-2
source

Source: https://habr.com/ru/post/1697365/


All Articles