0
Process p = Process.GetCurrentProcess();
int i = p.Id;
0
use this code sample to get PID
using System.Diagnostics;
private void GetProcessStatus()
{
try
{
//If you know the name of the process
Process[] myProcesses = Process.GetProcessesByName("mspaint");
//If you know the PID of the process use the commented line below
//Process[] myProcesses = Process.GetProcessById("2341");
//Check to see if the process array length is greater than 0
if(myProcesses.Length > 0)
{
MessageBox.Show("The Process Microsoft Paint(mspaint) is currently
running.", "Process Status", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show("The Process Microsoft Paint(mspaint) is currently NOT
running.", "Process Status", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
catch(Exception ex)
{
MessageBox.Show("An Exception Occoured: " + ex.Message, "Process Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
check also