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); }
}
}
Leave Comment