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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top