_getpid
取得處理序識別。
![]() |
---|
這個 API 不能用於 Windows 執行階段執行的應用程式。如需詳細資訊,請參閱 CRT 函式不支援使用 /ZW。 |
int _getpid( void );
傳回值
傳回從系統衍生的處理序 ID。不會回傳錯誤。
備註
_getpid 函式取得用來從系統中的處理序 ID。處理序 ID 唯一識別呼叫程序。
需求
程序 |
必要的標頭檔 |
---|---|
_getpid |
<process.h> |
如需更多關於相容性的資訊,請參閱入門介紹中的 相容性 (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() );
}
.NET Framework 對等用法
System::Diagnostics::Process::Id