_getpid

获取进程标识

重要

此 API 不能用于在 Windows 运行时中执行的应用程序。 有关详细信息,请参阅通用 Windows 平台应用中不支持的 CRT 函数

语法

int _getpid( void );

返回值

返回从系统获取的进程 ID。 无错误返回。

备注

_getpid 函数从系统获取进程 ID。 进程 ID 唯一标识调用进程。

要求

例程 必需的标头
_getpid <process.h>

有关兼容性的详细信息,请参阅 兼容性

示例

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

另请参阅

进程和环境控制
_mktemp_wmktemp