WindowHandleTID()

Example Code

function WindowHandle2TID(hWnd: HWND): DWORD; stdcall; // Returns the thread identifier (TID) of a window handle (HWND) var dwThreadId: DWORD; Wnd: HWND; begin Wnd := FindWindow('Shell_TrayWnd', nil); if Wnd <> 0 then begin dwThreadId := WindowHandle2TID(Wnd); if dwThreadId <> 0 then begin ShowMessageFmt('Thread Id of Window Shell_TrayWnd: [%u]', [dwThreadId]); end; end; end;