效果图:
部分代码如下:
[C#] 纯文本查看 复制代码 //获取进程的基本信息
private string GetProcessBasicInfo(Process p)
{
string info = "";
try
{
info += "------------------进程标识信息---------------\n";
info += "进程的唯一标识符(Id):\t" + p.Id + "\n";
info += "关联进程的本机句柄(Handle):\t" + p.Handle + "\n";
info += "打开的句柄数(HandleCount):\t" + p.HandleCount + "\n";
info += "关联进程的基本优先级(BasePriority):\t" + p.BasePriority + "\n";
info += "\n------------------进程运行信息---------------\n";
info += "进程启动的时间(StartTime):\t" + p.StartTime + "\n";
info += "进程正在其上运行的计算机名称(MachineName):\t" + p.MachineName + "\n";
info += "进程的主窗口标题(MainWindowTitle):\t" + p.MainWindowTitle + "\n";
info += "进程主窗口的窗口句柄(MainWindowHandle):\t" + p.MainWindowHandle + "\n";
info += "进程的用户界面当前是否响应(Responding):\t" + p.Responding + "\n";
info += "进程的终端服务会话标识符(SessionId):\t" + p.SessionId + "\n";
info += "进程终止时是否应激发 Exited 事件(EnableRaisingEvents):\t" + p.EnableRaisingEvents + "\n";
info += "\n---------------进程运行时操作系统提供的服务---------------\n";
info += "可安排此进程中的线程在其上运行的处理器(ProcessorAffinity):\t" + p.ProcessorAffinity + "\n";
info += "进程允许的最大工作集大小(MaxWorkingSet):\t" + p.MaxWorkingSet + "\n";
info += "进程允许的最小工作集大小(MinWorkingSet):\t" + p.MinWorkingSet + "\n";
info += "分配给此进程的未分页的系统内存大小(NonpagedSystemMemorySize):\t" + p.NonpagedSystemMemorySize64 + "\n";
info += "分页的内存大小(PagedMemorySize):\t" + p.PagedMemorySize64 + "\n";
info += "分页的系统内存大小(PagedSystemMemorySize):\t" + p.PagedSystemMemorySize64 + "\n";
info += "峰值分页内存大小(PeakPagedMemorySize):\t" + p.PeakPagedMemorySize64 + "\n";
info += "峰值虚拟内存大小(PeakVirtualMemorySize):\t" + p.PeakVirtualMemorySize64 + "\n";
info += "进程的峰值工作集大小(PeakWorkingSet):\t" + p.PeakWorkingSet64 + "\n";
info += "专用内存大小(PrivateMemorySize):\t" + p.PrivateMemorySize64+ "\n";
info += "进程的虚拟内存大小(VirtualMemorySize):\t" + p.VirtualMemorySize64 + "\n";
info += "物理内存使用情况(WorkingSet):\t" + p.WorkingSet64 + "\n";
info += "进程的特权处理器时间(PrivilegedProcessorTime):\t" + p.PrivilegedProcessorTime + "\n";
info += "进程的总的处理器时间(TotalProcessorTime):\t" + p.TotalProcessorTime + "\n";
info += "进程的用户处理器时间(UserProcessorTime):\t" + p.UserProcessorTime + "\n";
}
catch (Win32Exception e)
{
MessageBox.Show(e.Message);
}
catch (InvalidOperationException e)
{
MessageBox.Show(e.Message);
}
ClearAllInformation();
return info;
}
案例源码下载:
|