現在のプロセスのプロセスIdを取得するには、GetCurrentProcessId()関数を呼び出します。
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
#include <windows.h>
/*
現在のプロセスのプロセスIdを取得する
*/
int _tmain
(
int argc
, _TCHAR* argv[]
)
{
// std::wcoutのロケールを設定
std::wcout.imbue( std::locale( "", std::locale::ctype ) );
// 現在のプロセスのIdを取得する
DWORD dwProcessId = ::GetCurrentProcessId();
// プロセスIdの表示
std::wcout << L"ProcessId = " << dwProcessId << std::endl;
// 処理結果を返す
return( 0 );
}
ProcessId = 24364