In this blog I am trying to make a small demo which is show all running application in C#.

In this article I use the Process property and get all running application use Process.GetProcesses() method below I am creating a demo project which is shows all running application process name with memory size and main window title in a datagridview:-

Steps for creating demo project:-

1.   Create a new project New >> Project (give the appropriate name of project).

2.   Now by default show a form1, in form1 drag and drop a datagridview where shows all running application.

3.    Now double click on the form1 and get the form load event.

4.    In the form load event write the below code.

  private void Form1_Load(object sender, EventArgs e)
foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses()) {
if (p.MainWindowTitle.Length > 0)
string MainWindowName = p.MainWindowTitle.ToString();
string ProcessName = p.ProcessName.ToString();
string MemorySize = p.PrivateMemorySize64.ToString();
dgvApplicationList.Rows.Add(MainWindowName, ProcessName, MemorySize); }

Code Description:-
1.   This is the form load event method.

3.   This is foreach loop, this loop will run while Process.GetProcesses()
method returns values.

5.   This line of code check your main window title length if length is
greater than 0 then if condition body will execute.

7.   This line of code gets the running application main window name and
assign on string MainWindowName variable.

8.    This line of code gets the running application Process name and
assign on string ProcessName variable.

9.    This line of code gets the running application memory size and assign
on string MemorySize variable.

10.   This line of code set the value in datagridview.

Output Screenshot:-

  Modified On Sep-18-2014 01:24:13 PM

Leave Comment