Is there a way to get a IProcess from a windows Handle?
I can only find things like
MadKernel.Window(hWnd).OwnerProcess;
Is that the window I am looking at or the Owner of that window.. I am looking for the IProcess for the window matching the hWnd.
Any way to get that? I am willing to bet I missed something..
Thanks
Jeff Lawton
Windows Handle -> IProcess.Handle
-
- Posts: 7
- Joined: Tue Jul 20, 2004 8:20 pm
- Location: Sacramento, CA
- Contact:
Re: Windows Handle -> IProcess.Handle
That's exactly the solution.Jeff_Lawton wrote:Is there a way to get a IProcess from a windows Handle?
I can only find things like
MadKernel.Window(hWnd).OwnerProcess;
-
- Posts: 7
- Joined: Tue Jul 20, 2004 8:20 pm
- Location: Sacramento, CA
- Contact:
Re: Windows Handle -> IProcess.Handle
What about doing the reverse? Lets say I wanted a windows handle from an IProcess so I could do something like :madshi wrote:That's exactly the solution.Jeff_Lawton wrote:Is there a way to get a IProcess from a windows Handle?
I can only find things like
MadKernel.Window(hWnd).OwnerProcess;
SetForegroundWindow(hWnd);
I have tried stuff like - Process.Handle.Handle, but this doesn't seem to give the correct windows handle.
Thanks for the help.
Jeff Lawton
"IProcess.Handle" gives you a process handle, what else did you expect? The name already sais it, it's a handle of the IProcess.
You need to understand that each process can have none, one or a multitude of windows. There is not "the one" window of a process. There never was. Well, in real life most processes do have only one main window. But this is just a design decision, Windows doesn't force a specific main window count per process.
If you are looking for the main window(s) of a process, you should first of all loop through IProcess.TaskbarWindows. These are windows which are shown in the taskbar. Most processes have one there or none. Some few processes may have more than one there. The process with no "taskbar windows" might have "main" windows which are not listed in the taskbar instead. You'll need to loop through IProcess.Windows_ to find those.
You need to understand that each process can have none, one or a multitude of windows. There is not "the one" window of a process. There never was. Well, in real life most processes do have only one main window. But this is just a design decision, Windows doesn't force a specific main window count per process.
If you are looking for the main window(s) of a process, you should first of all loop through IProcess.TaskbarWindows. These are windows which are shown in the taskbar. Most processes have one there or none. Some few processes may have more than one there. The process with no "taskbar windows" might have "main" windows which are not listed in the taskbar instead. You'll need to loop through IProcess.Windows_ to find those.