Getting Current Process ID

  • Thread starter Thread starter Lex
  • Start date Start date
L

Lex

I have a Class X that runs as an exe. Is there an easy way to get the
process Id of X as this class is running so that it can pass it along
to another class?

I know how to get all the processes and enumerate. I was hoping there
was some magic where I can say

int processId = GetMyCurrentProcessID()

Regards
 
Use the static GetCurrentProcess() method on the Process class:

int nProcessID = Process.GetCurrentProcess().Id;


Arild
 
Back
Top