Posted by: Christian Wimmer in: JEDI Windows API Headers
This answer is very easy – just use GetWindowThreadProcessId
JWA declares it as followed:
The function returns an identifier (not a handle) and also may set lpdwProcessId to the identifier (again not a handle!) if it is not nil. Be aware that identifiers aren’t handles, so you must not close them by using CloseHandle. Identifiers are only numbers that makes an object distinguishable from other objects of the same type.
ThreadID : DWORD;
WndHandle : HWND;
WndHandle := FindWindow(…);
ThreadID := GetWindowThreadProcessId(WndHandle, @ProcessID);
Tell me how you liked this blog entry by adding a comment.