What I want to do: Run an application the user selects and close it later after some event occurs.
What I learned so far: I can use CreateToolhelp32Snapshot and Process32First(etc) to freeze the current processes/modules data of the running applications. I know from the modules data I can compare the EXE file name to the one I know I executed, so now I
got the application's PROCESS ID, now I want to use that process ID to get the HWND for that application main window (or vice versa, get a process id according to a HWND)
I dont want to use the TerminateProcess because I want to send the program a WM_CLOSE, not unconditional termination.
In short, I want the way to get an application's main HWND from its process ID. I see it happening in Spy++ when I choose a window and can go to its Process information.