Home > DeveloperSection > Blogs > How to show all application in C#

How to show all application in C#


C# C# 
Ratings:
0 Comment(s)
 1492  View(s)
Rate this:

How to show all application in C#

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.

1.  private void Form1_Load(object sender, EventArgs e)

2.  {

3.  foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses())

4.  {

5.  if (p.MainWindowTitle.Length > 0)

6.  {

7.  string MainWindowName = p.MainWindowTitle.ToString();

8.  string ProcessName = p.ProcessName.ToString();

9.  string MemorySize = p.PrivateMemorySize64.ToString();

10. dgvApplicationList.Rows.Add(MainWindowName, ProcessName, MemorySize);

11. }

12. }

13. }

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:-


Don't want to miss updates? Please click the below button!

Follow MindStick