How to get active process name in C#?
I know that I must use this code:
[DllImport(\"user32.dll\")]
private static extern IntPtr GetForegroundWindow(
Its just need two line of code, you can use linq to get all processes.
var processss = from proc in System.Diagnostics.Process.GetProcesses() orderby proc.ProcessName ascending select proc;
foreach (var item in processss) {
Console.WriteLine(item.ProcessName );
}
Now you have all active process by just on line.