次の方法で共有


_getpid

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at _getpid.

Gets the process identification.

Important

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

Syntax

int _getpid( void );  

Return Value

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

Remarks

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

Requirements

Routine Required header
_getpid <process.h>

For more compatibility information, see Compatibility.

Example

// 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  

.NET Framework Equivalent

System::Diagnostics::Process::Id

See Also

Process and Environment Control
_mktemp, _wmktemp