_getpid
取得處理序識別碼。
重要
這個 API 不能用於在 Windows 執行階段中執行的應用程式。 如需詳細資訊,請參閱 CRT functions not supported in Universal Windows Platform apps (通用 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