c#获取所有进程异常

时间:2016-08-06 13:42:58

标签: c#

我有一个方法可以将Gridview中的每个进程添加为一行(Name,PID,Title,Path ...)

我有64位Windows,但Visual Studio以32位运行。

我已将项目从“任何CPU”更改为“64位”并且我已经尝试了所有平台,但我只获得了一个进程:vshost或者当我使用管理员权限启动应用程序时得到两个:

sqlwriter
winlogon

我很困惑。我该怎么做才能解决问题?

谢谢你的时间!

代码:

  Process[] Proc = Process.GetProcesses();
  foreach(Process Pr in Proc)
  {
      string Name = Pr.ProcessName;
      string PID = Pr.Id.ToString();
      string Title = Pr.MainWindowTitle;
      string Priority = "N/A";
      string Path = "N/A";

      try
      {
          Priority =  Pr.PriorityClass.ToString();
          Path = Pr.Modules[0].FileName;
      }
      catch(Exception) {
      }

0 个答案:

没有答案