Getting Process ID of a my running process
I have windows mobile application, i want to get by C# code its Process ID (PID) while its running ..
so any one know function that return PID ?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Lalit MRank #1,186 · 1.5K reputationPosted Jan 27, 2010, 1:20 AM EST
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
dominic scanlan2 reputationPosted Apr 1, 2010, 6:38 AM EDT
Process p = Process.GetCurrentProcess();
int i = p.Id;