Given:
Process p;
It’s possible for me to do the following:
IntPtr hWnd = p.MainWindowHandle;
This gives me the HWnd for the main window of the main module.
What I would like to do is get the HWnd for the main window of another module in the process, perhaps something like this:
IntPtr hWnd = p.Modules[0].MainWindowHandle;
Is something like this possible? Even if I have to use the Win32API dlls that’s OK.
Modules don’t own windows. A window is owned by a process. Strictly speaking, windows have affinity to the thread which created them. But since visible windows are invariably created by the main GUI thread of a process, it doesn’t hurt to think of windows as being owned by a process.
As it happens, any module within a process could potentially have created the window returned by
MainWindowHandle. So what are asking for doesn’t really make any sense.