如何得到我机器上所有正在运行的进程? 
作者:孟宪会 出自:【孟宪会之精彩世界】 发布日期:2003年6月15日 9点4分56秒
--------------------------------------------------------------------------------
 
使用System.Diagnostics名称空间下的static Process.GetProcesses()[C#] 
      Using System.Diagnostics; 
 
     ... 
      foreach ( Process p in Process.GetProcesses() ) 
         Console.WriteLine( p ); // string s = p.ToString(); 
  
[VB.NET] 
 
     Imports System.Diagnostics 
      ... 
     Dim p As Process 
     For Each p In Process.GetProcesses() 
        Console.WriteLine(p) ' string s = p.ToString() 
     Next p  

解决方案 »

  1.   

    System.Diagnostics.Process.GetCurrentProcess().Threads
      

  2.   

    这样就可以了:System.Diagnostics.Process[] arrProcess=System.Diagnostics.Process.GetProcesses("luoyong");
    foreach(System.Diagnostics.Process tmpPcs in arrProcess)//遍历进程数组
    {   
    int Threadcount=0;//线程数
    ListViewItem ViewItem=listView.Items.Add(tmpPcs.ProcessName);
    System.Diagnostics.ProcessThread[] arrThread=new System.Diagnostics.ProcessThread[tmpPcs.Threads.Count];
    tmpPcs.Threads.CopyTo(arrThread, 0);
      foreach( System.Diagnostics.ProcessThread[] thread in arrThread)
      {
       Threadcount++;
      }
      

  3.   

    Try this:
    foreach( System.Diagnostics.ProcessThread thread in arrThread)
      {
       Threadcount++;
      }
      

  4.   

    应该是foreach( System.Diagnostics.ProcessThread thread in arrThread)
      

  5.   

    这样更好:
    System.Diagnostics.Process[] arrProcess=System.Diagnostics.Process.GetProcesses("luoyong");
    foreach(System.Diagnostics.Process tmpPcs in arrProcess)//遍历进程数组
    {   
    int Threadcount=0;//线程数
    ListViewItem ViewItem=listView.Items.Add(tmpPcs.ProcessName);
      foreach( System.Diagnostics.ProcessThread thread in tmpPcs.Threads)
      {
       Threadcount++;
      }
      

  6.   

    To xixigongzhu(夕夕公主) 
       我刚开始学C#,想做一个比windows2000更好的进程管理器,提问后我自己查了好多资料
    基本上问题都解决了,你的方法是对的,多谢了。以后多交流。