Wednesday, January 21, 2009

Process in .NET

We can get processes in a machine by using Process class.


Process[] process = Process.GetProcesses();
foreach (Process pro in process)
{
Console.WriteLine(pro.ProcessName);
}

or processes by name,

Process[] process = Process.GetProcessesByName("devenv");
foreach (Process pro in process)
{
Console.WriteLine(pro.SessionId);
}

0 comments:

Post a Comment