Process window
-
Hi everybody. When i get the list of processes ids, with the EnumProcess function, how i can get the window asociated with a process? For example, if i have the process id 08937 i want to call a function GetWindow(08937) and it gives me a handle to the asociated window (HWND)
-
Hi everybody. When i get the list of processes ids, with the EnumProcess function, how i can get the window asociated with a process? For example, if i have the process id 08937 i want to call a function GetWindow(08937) and it gives me a handle to the asociated window (HWND)
Processes may not have created windows, and processes may create many windows. You can loop through all the top level windows using EnumChildWindows() with the desktop window as the parent: GetDesktopWindow(). And use this function: DWORD GetWindowThreadProcessId(HWND hWnd,LPDWORD lpdwProcessId); Then compare lpdwProcessId with the list of ProcessIds from EnumProcesses. If it is in the list, then the HWND from the EnumChildWindows proc is what you need. Maybe someone else knows of a better approach, maybe one simple api function to do all this! this is this.