4

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 - ケルベロス

キャプション -

説明 -

インストール日 -

ログオン ID - 10179411

ログオンタイプ - 10

名前 -

開始時刻 - 20110617083244.547220+120

状態 -

4

1 に答える 1

0

どうですか:

SelectQuery query = new SelectQuery("Select * from Win32_LogonSession Where LogonType = 10")
于 2011-10-14T09:20:50.010 に答える