Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get running applications in windows? [duplicate]

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?

like image 824
Prasanna Choudhari Avatar asked Dec 09 '13 12:12

Prasanna Choudhari


People also ask

Why are there multiple of the same processes running?

This is pretty normal as processes takes time to end on task manager after you exit on the program. As for the multiple processes on each application, it is actually normal. Programs run 1 process per tab, extensions and GPU processes.

Why does my Task Manager show multiple processes?

Google chrome uses multi-process architecture to prioritize performance while using the browser. This is the reason why the task manager shows multiple google chrome processes.

Why do programs have multiple processes?

A computer program is a passive collection of instructions, a process is the actual execution of those instructions. Several processes may be associated with the same program; for example, opening up several instances of the same program often means more than one process is being executed.


1 Answers

This may help:

Process[] processes = Process.GetProcesses();
foreach(Process p in processes)
{
    if(!String.IsNullOrEmpty(p.MainWindowTitle))
    {
        listBox1.Items.Add(p.MainWindowTitle);
    }
}
like image 65
r.mirzojonov Avatar answered Oct 23 '22 22:10

r.mirzojonov