IntPtr WindowHandle = SendMessage(DexpotHandle, DEX_RETURNHWNDFROMPID, IntPtr ProcessID, ref IntPtr SearchFlag)
where
WindowHandle is a Pointer to the return value and is either Zero (no Window found) or a Window Handle.
ProcessID is a Pointer to a Process ID
SearchFlag is a Pointer to a flag value of Zero if only non-visible/non-minimsed Windows should be checked, or non-zero if all Windows are to be checked. Dexpot should replace this flag with a Pointer to a Desktop number (if Handle is non-zero) prior to return.
Patrick will have some idea why I need this function!

Since you already know the Windows Handles for all the Windows open - and presumably store that information in a list of some description - it's a simple matter to get the owning Process ID:
Code: Select all
int ProcessID = 0;
int ThreadID = GetWindowThreadProcessId(hWnd, ref ProcessID);

Mark