本文介绍了如何使用获取所有已登录用户的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用C#在远程计算机上获取用户名及其活动时间的列表?
How can I get a list of usernames and their activity times on a remote machine, using C#?
例如,如果有一台Windows机器名为"ABC-PC",并且当前有三个活动用户名为"X","Y"和"Z".其中:
For example, if there is a Windows machine named 'ABC-PC' and there are currently three active users on it named 'X', 'Y' and 'Z'. Where:
- "X"当前处于活动状态
- "Y"闲置了最后4分钟
- "Z"闲置了20分钟
我想编写代码来获取我所有这些提到的信息.我肯定有一些.NET API,但是我不确定是哪一个.
I want to write code that fetches me all of these mentioned information. I am sure there is some .NET API but which one is that I am unsure.
推荐答案此查询为您提供所有登录的用户
This query give to you all the logged users
ManagementObjectSearcher query= new ManagementObjectSearcher("SELECT * FROM Win32_UserProfile WHERE Loaded = True");您还具有 Win32_UserProfile
更多推荐
如何使用获取所有已登录用户的列表
发布评论