有没有办法只显示与wmi的活动会话? 问题是Win32_LogonSession还显示了非活动/断开连接的会话。
ManagementScope scope = new ManagementScope(ManagementPath.DefaultPath);
SelectQuery query = new SelectQuery("Win32_LogonSession");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection results = searcher.Get();
foreach (ManagementObject mo in results)
{
PrintWmiObject(mo);
}
这个的输出是这样的
AuthenticationPackage - Kerberos
标题 -描述 -
InstallDate -
LogonId - 10179411
LogonType - 10
姓名 -
StartTime - 20110617083244.547220 + 120
状态 -
答案 0 :(得分:0)
怎么样:
SelectQuery query = new SelectQuery("Select * from Win32_LogonSession Where LogonType = 10")