Linkage between App windows and Processes
-
I'm wondering if anyone knows of a reasonable way to jump from an Application Hwnd to an associated processID or vice cersa. I've found much information on enumerating either running applications (EnumWindows) or active processes (PSAPI EnumProcesses, for instance), but I can't see any way to get from a processID I'm interested in to its main window handle or from an application Hwnd to its processID (and from there to its loaded modules). Hopefully I've missed aomething obvious. Suggestions appreciated. AJ
-
I'm wondering if anyone knows of a reasonable way to jump from an Application Hwnd to an associated processID or vice cersa. I've found much information on enumerating either running applications (EnumWindows) or active processes (PSAPI EnumProcesses, for instance), but I can't see any way to get from a processID I'm interested in to its main window handle or from an application Hwnd to its processID (and from there to its loaded modules). Hopefully I've missed aomething obvious. Suggestions appreciated. AJ
Have a look at
GetWindowThreadProcessId
API for the reverse operation, I don't know. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
Have a look at
GetWindowThreadProcessId
API for the reverse operation, I don't know. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
DOH! Thanks much. I shall fume for a while over why MSDN has such retarded search capabilities that it couldn't produce this from looking for "processid" or "process identifier" or "GetWindow", but I'll get over it. It is in the Index if I'd looked there. P.S. Alfonso might just as well have been referring to Mr. Gates.
-
I'm wondering if anyone knows of a reasonable way to jump from an Application Hwnd to an associated processID or vice cersa. I've found much information on enumerating either running applications (EnumWindows) or active processes (PSAPI EnumProcesses, for instance), but I can't see any way to get from a processID I'm interested in to its main window handle or from an application Hwnd to its processID (and from there to its loaded modules). Hopefully I've missed aomething obvious. Suggestions appreciated. AJ
Hi. > I can't see any way to get from a processID I'm > interested in to its main window handle There is no direct way, but you could use a combination of EnumWindows and GetWindowThreadProcessId calls. There is a MSDN article discussing this issue: Get the Main Window, Get EXE Name[^] > .. or from an application Hwnd to its processID This one is trivial through the GetWindowThreadProcessId API.
Kind Regards, Robert Kuster _________________ www.it.rkuster.com
-
DOH! Thanks much. I shall fume for a while over why MSDN has such retarded search capabilities that it couldn't produce this from looking for "processid" or "process identifier" or "GetWindow", but I'll get over it. It is in the Index if I'd looked there. P.S. Alfonso might just as well have been referring to Mr. Gates.
AJarrett wrote:
P.S. Alfonso might just as well have been referring to Mr. Gates
I absolutely agree :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.