How to get Process Id using C
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How to get Process Id using C

  1. #1
    Join Date
    Oct 2003
    Location
    India
    Posts
    1

    Question How to get Process Id using C

    Hello,

    My problem is that I wish to extract Process Id using a C/C++ code and that I intend to use AS JNI.
    The code that I want should work on Windows and Solaris using #IFDEF... Please can anyone help me out.

  2. #2
    Join Date
    Sep 2002
    Location
    Belarus - Tirol, Austria
    Posts
    647

    Re: How to get Process Id using C

    Originally posted by aagarg
    Hello,

    My problem is that I wish to extract Process Id using a C/C++ code and that I intend to use AS JNI.
    The code that I want should work on Windows and Solaris using #IFDEF... Please can anyone help me out.
    Of course, Thouse functions depends on system and they are system calls, not part of c/c++ standard.

    For *NIX systems: getpid();
    Win : GetProcessId().
    "UNIX is simple; it just takes a genius to understand its simplicity!"

  3. #3
    Join Date
    Mar 2002
    Posts
    350
    here is one way...

    #ifdef WIN32
    #define getpid _getpid
    #endif

    int pid = getpid();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center