IntPtr WindowHandle = SendMessage(DexpotHandle, DEX_RETURNHWNDFROMPID, IntPtr ProcessID, ref IntPtr SearchFlag)
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! (Process IDs for tasks on Desktops other than the current one are accessible from the list of running processes but Dexpot appears to hide the Windows for Processes not running on the current Desktop. This function is to overcome that problem.)
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);