I've got a function called ShellAndWait that does a very good job of launching a third party application, then waiting for said application to close before continuing.
It works by using the "Shell" api function, then getting the handle that was returned by the Shell function and doing an OpenProcess(PROCESS_QUERY_INFORMATION, False, <handle>), then calling GetExitCodeProcess in a loop until the shelled program exits.
All is well, that function works great.
Unfortunately, I now want to do exactly the same thing, but with a program that I did not launch myself. How do I get the process handle of a third-party application that I didn't launch?
Alternatively, how could I do a loop that peeks at the list of things in the Task Manager and waits until a certain name drops off that list? Note: The app in question is not a visible window, it sits in the system tray as a tiny icon next to the clock. So trolling for visible window names will not work, I must look at actual running processes as they are listed in the task manager.