C# 使用WMI查找挂起的windows进程,为什么是;“执行状态”;总是空的?
我正在控制台程序中运行以下代码:-C# 使用WMI查找挂起的windows进程,为什么是;“执行状态”;总是空的?,c#,wmi,C#,Wmi,我正在控制台程序中运行以下代码:- var query = string.Format("select * from Win32_Process"); var searcher = new ManagementObjectSearcher(query); var collection = searcher.Get(); foreach (ManagementObject o in collection)
var query = string.Format("select * from Win32_Process");
var searcher = new ManagementObjectSearcher(query);
var collection = searcher.Get();
foreach (ManagementObject o in collection)
{
if(o["CommandLine"] == null) continue;
if (o["ProcessId"] == null) continue;
if( o["ExecutionState"] == null)continue;
var executionState =o["ExecutionState"].ToString();
var commandLine = o["CommandLine"].ToString();
var processId = o["ProcessId"];
Console.WriteLine("{0}: {1} [{2}]",
processId,
executionState,
commandLine);
}
但是,执行状态始终为空。有人知道为什么吗?我试着以管理员的身份运行
使用process explorer,我肯定有一个进程处于挂起状态:-
看起来像是
ExecutionState
没有实现,并且总是null
。我不提,但要提