WindowHandle2PID()

Example Code

function WindowHandle2PID(hWnd: HWND): DWORD; stdcall; // Returns the process identifier (PID) of a window handle (HWND) var dwProcessId: DWORD; Wnd: HWND; begin Wnd := FindWindow('Shell_TrayWnd', nil); if Wnd <> 0 then begin dwProcessId := WindowHandle2PID(Wnd); if dwProcessId <> 0 then begin ShowMessageFmt('Process Id of Window Shell_TrayWnd: [%u]', [dwProcessId]); end; end; end;