In C# there's a control you can add which seems to deal with processes. I need to run a for loop through all of the processes (what I need to process count for) and I need to check each process's name.
Thanks Vikram, but how exactly do you use a directive I tried a namespace but it errors. Sorry about the newbie questions =P, just started two days ago.
The using directive is something you add at the top of the source code file before the class and namespace declaration in order to import a namespace. You could also place it within the namespace.
If you create a new Windows Form application and open the Form1.cs file which was created and scroll to the top, you will see the using directives placed there for some of the Namespaces.
In this particular case, you can simply add the line:
I just checked the Process Control in .NET v2.0 - that represents one process and you cannot loop through all processes using an instance of that Control.
In case you want to loop through all processes, you would need to call the static method "Process.GetProcesses()" on the same class.
Here is a code snippet to loop through all Processes on your machine. (You need to add a using directive for the namespace "System.Diagnostics".
Getting process count?
Main D. Tork
Logifire
Cowski
rniyas
The using directive is something you add at the top of the source code file before the class and namespace declaration in order to import a namespace. You could also place it within the namespace.
If you create a new Windows Form application and open the Form1.cs file which was created and scroll to the top, you will see the using directives placed there for some of the Namespaces.
In this particular case, you can simply add the line:
using System.Diagnostics;
as the first line in your source code file.
Also read: http://msdn.microsoft.com/library/default.asp url=/library/en-us/csspec/html/vclrfcsharpspec_9_3_2.asp
for better understanding.
Regards,
Vikram
Mahmoud Amereh
I just checked the Process Control in .NET v2.0 - that represents one process and you cannot loop through all processes using an instance of that Control.
In case you want to loop through all processes, you would need to call the static method "Process.GetProcesses()" on the same class.
Here is a code snippet to loop through all Processes on your machine. (You need to add a using directive for the namespace "System.Diagnostics".
Process[] objArrProcesses = Process.GetProcesses();
foreach (Process objProcess in objArrProcesses)
{
MessageBox.Show(objProcess.ProcessName);
}
Also the length of the objArrProcesses array gives you the count of Processes on the machine.
Regards,
Vikram
pcdog
Could you please elaborate a bit What's a process control, by the way