C#列出当前系统所有正在运行的程序

C#列出当前系统所有正在运行的程序

Using System.Diagnostics;
  
foreach (Process p in Process.GetProcesses (System.Environment.MachineName))
{
    if (p.MainWindowHandle! = IntPtr.Zero)
    {
        // Display the user name of the program
        Console.WriteLine (p); / / string s = p.ToString ();
    }
}

编程技巧