Getting Current Process ID

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lex

    Getting Current Process ID

    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 = GetMyCurrentPro cessID()

    Regards
  • Arild Bakken

    #2
    Re: Getting Current Process ID

    Use the static GetCurrentProce ss() method on the Process class:

    int nProcessID = Process.GetCurr entProcess().Id ;


    Arild

    "Lex" <deja@homerlex. mailshell.com> wrote in message
    news:c515c12.04 01120916.7cf5f7 46@posting.goog le.com...[color=blue]
    > 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 = GetMyCurrentPro cessID()
    >
    > Regards[/color]


    Comment

    Working...