function ThreadHandle2PID(const hThread: THandle): DWORD; stdcall; // Retrieves the Process identifier (ID) of the target Thread handle var dwProcessId: DWORD; begin dwProcessId := ThreadHandle2PID(GetCurrentThread()); ShowMessage(Format('My current Process Id is %u', [dwProcessId])); end;