如何使用获取所有已登录用户的列表

编程入门 行业动态 更新时间:2024-10-27 01:30:39
本文介绍了如何使用获取所有已登录用户的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何使用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

更多推荐

如何使用获取所有已登录用户的列表

本文发布于:2023-11-14 13:23:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587328.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   用户   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!