如何使用 WMI 获取进程描述? [英] how to get process description using WMI?

查看:65
本文介绍了如何使用 WMI 获取进程描述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WMI 查询来获取所有进程的列表,但我缺少的是进程描述!当我使用描述"属性时,它看起来像这样!

I'm using WMI query to get a list of all processes, but what i missing is process description! It appears like this when i use "Description" property!

Name : chrome.exe            Description : chrome.exe

但应该是

Name : chrome.exe            Description : Google Chrome

那么返回进程描述的属性名称是什么?

So what's the property name that return process description?

public void GetProcesses()
{ 
     ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * From Win32_Process");
     ManagementObjectCollection processList = searcher.Get();
     foreach (ManagementObject obj in processList)
     {
         Console.WriteLine("Name : {0}     Description : {1}",obj["Name"],obj["Description"]);
     }
}

推荐答案

它不是 WMI,但适用于本地机器上的进程.

It is not WMI, but will work for processes on your local machine.

您可能会找到进程的描述 [原文如此],实际上它是可执行文件的描述,使用 GetVersionInfo.比检查 FileDescription 和/或 ProductName 属性.

You may find a description of a process [sic.], actually it is the description of the executable, using GetVersionInfo. Than check the FileDescription and or ProductName properties.

但是请注意,不能保证此信息可用.尽管如此,这可能是您最好的选择.其他工具(例如 sysinternals 进程浏览器)也会显示该信息.

Note however, that there is no guarantee that this information is available. Nevertheless it is probably your best bet. Other tools, like sysinternals process explorer, display that information as well.

这篇关于如何使用 WMI 获取进程描述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆