13

How can I get the list of currently running applications or foreground processes in Windows?

I mean the applications that have a window for real. Not the background services/processes. I want to access the same list a task manager shows when we open it.

Is there a way? Any type of solution is acceptable. Either a command or a .NET code or anything. I just want to get that list programmatically.

Is that even possible?

I tired tasklist but it gives me all the services and processes, even the background ones.

Is there any logic I could implement?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Prasanna Choudhari
  • 189
  • 1
  • 1
  • 13

1 Answers1

28

This may help:

Process[] processes = Process.GetProcesses();
foreach(Process p in processes)
{
    if(!String.IsNullOrEmpty(p.MainWindowTitle))
    {
        listBox1.Items.Add(p.MainWindowTitle);
    }
}
r.mirzojonov
  • 1,209
  • 10
  • 18