[C#]Check processes help.

How do I check for processes in C# and then write to label1 if it is running or not.
Thanks, in advance.

Tell me specifically what program you want to detect. What way are you trying to do it? We can't provide you with everything, you must give us something you already have and we may help you.
 
The System.Diagnostics namespace contains functions that allow you to manage processes, threads, eventlogs and performance information.

The System.Diagnostics.Process object gives you access to functionality enabling you to manage system processes. We will use this object to get a list of running processes.

Add this line to your using list:


PHP:
using System.Diagnostics;

Now you can get a list of the processes with the
PHP:
Process.GetProcesses() method, as seen in this example:


    Process[] processlist = Process.GetProcesses();

    foreach(Process theprocess in processlist){
    Console.WriteLine(“Process: {0} ID: {1}”, theprocess.ProcessName, theprocess.Id);
    }

Some interesting properties of the Process object:

PHP:
p.StartTime (Shows the time the process started)
p.TotalProcessorTime (Shows the amount of CPU time the process has taken)
p.Threads ( gives access to the collection of threads in the process)

just some intressting C# stuff i found on google.
 
I'm using this at the moment it works fine without the IF statement, I don't know why though.
Code:
public void FindProcess()
        {

            foreach (Process checkforprocess in Process.GetProcesses())
            {

                if (checkforprocess.ProcessName.Equals("explorer.exe"))
                {

                    label1.Text = "Running";
                }
                else
                {
                    label1.Text = "Not Running";
                }
                }
        }
 
Back