Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
and
div
eof
not
or
xor
Expand Minimize

_getpid

Gets the process identification.

Important note Important

This API cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported with /ZW.

int _getpid( void );

Returns the process ID obtained from the system. There is no error return.

The _getpid function obtains the process ID from the system. The process ID uniquely identifies the calling process.

Routine

Required header

_getpid

<process.h>

For more compatibility information, see Compatibility.

// crt_getpid.c
// This program uses _getpid to obtain
// the process ID and then prints the ID.
 

#include <stdio.h>
#include <process.h>

int main( void )
{
   // If run from command line, shows different ID for 
   // command line than for operating system shell.
    
   printf( "Process id: %d\n", _getpid() );
}
Process id: 3584
Show:
© 2015 Microsoft