如何分辨Process对象(System.Diagnostics.Process)的各种详细信息 [英] How to tell various details of a Process object (System.Diagnostics.Process)

查看:68
本文介绍了如何分辨Process对象(System.Diagnostics.Process)的各种详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在从System.Diagnostics.Process.GetProcesses()获取Process对象,我想知道一些事情.

I am obtaining Process objects form System.Diagnostics.Process.GetProcesses(), and I want to know a few things.

我希望能够以多种方式对流程进行分类:

I want to be able to categorize a process in various ways:

应用程序,后台进程,系统进程,服务

Application, Background Process, System Process, Service

申请"的标准是它有一个主窗口,标题中带有文本,即if(p.MainWindowTitle.Trim().Count> 0),则进程的类型为Application.

My criteria for "Application" is that it has a mainwindow with text in the title, i.e., if (p.MainWindowTitle.Trim().Count > 0), then the type of process is Application.

为所有其他进程分配了背景进程"类型.那么,如何确定一个进程是系统进程还是服务?

All other process are assigned type Background Process. So how do I tell if a process is a System Process or a Service?

如果有帮助,我正在制作一种新型的任务管理器.谢谢!

If it helps, I am making a new type of task manager. Thanks!

推荐答案

我认为您需要使用Intptr来获取类型.这是核实我的结果的很长的路要走.

I think you need to use Intptr to get the type. Here is a long way of verrifying my results.

使用此网页作为GetProcess类的参考.

Use this webpage for reference for GetProcess Class.

http://msdn.microsoft.com/en-us/library/ccf1tfx0.aspx

我认为该类使用的是kernal32.dll,它返回具有所有属性的结构.有时使用网络库很难找到想要的属性.这两个网页可能会有帮助.您可以获取信息 通过手柄.

I think the class is using the kernal32.dll which returns back a structure with all the properties.  It is sometimes hard to find th eproperties you are looking for using the Net Library.  these two webpage might help.  You can get the information through the handle.

http://msdn.microsoft.com/zh-cn/library/windows/desktop/ms686331(v = vs.85).aspx

http://msdn.microsoft.com/zh-cn/library/windows/desktop/ms684298(v = vs.85).aspx

请仔细阅读下面的网页.这是STARTUPINFO结构.

Read carefully this webpage below which says below. This is the STARTUPINFO structure.

" GetProcessesByName 创建一组 Process 组件,其关联的进程资源共享可执行文件文件传递给该方法."

"GetProcessesByName creates an array of Process components whose associated process resources share the executable file you pass to the method."

http://msdn.microsoft.com/en-us/library/1f3ys1f9.aspx

此页面获取句柄

http://msdn.microsoft.com/en-us/library/system .diagnostics.process.aspx

转到处理页面

http://msdn.microsoft.com/en-us/library /system.diagnostics.process.handle.aspx

它引用 系统. IntPtr

It references System.IntPtr

http://msdn.microsoft.com/en-us/library/system.intptr .aspx

使用Intptr,您可以获得项目的类型

Using the Intptr you can get the type of the item

http://msdn.microsoft.com/en-us/library/system .object.gettype.aspx


这篇关于如何分辨Process对象(System.Diagnostics.Process)的各种详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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