Quote Originally Posted by TBBW View Post
ps, how do I posts the code more readable..
Use code tags (surround your code with [ CODE] [/ CODE] minus the spaces). Go back an edit your code - you'll see that I've added code tags.

As far as your code, I would use CreateProcess to start setup.exe rather than _spawnlp. This would allow you to retrieve the process id.

From there you can use the pid to restrict looking for windows only in your process. You can use EnumWindows as I've explained earlier to get the top level windows and GetWindowThreadProcessID to find the top level window for the setup.exe process.

From there you can find any window in your process from the top level window. I've explained all this in post #4. To identify a dialog with 5 child edit windows, get the top level window, use FindWindow with the class name, title and parent hWnd. Once you have the dialog, then use FindWindowEx with the parent dialog hwnd and the class of "EDIT". You keep calling FindWindowEx in succession, the first time passing in the parent hWnd, and each subsequent time passing in the hWnd to the edit box you've found. When you've found 5 of them on a single dialog you know you have the correct dialog.

You had mentioned earlier that setup spawns multiple processes. You can handle this scenario by tracking the running processes. What you do is get a list of running processes, and flag all these processes as base processes. Then you start your test application and periodicly update the process list. Any new processes will be processes that you've created (directly or indirectly). Since it's helpful to always have the top level window as a starting point, you generally want to retrieve the top level windows for each process in the list - that way you can use it later if you need to.

This may sound like a lot of work, but it isn't too bad. Take a look at the ModuleTest.zip file in my reply here: http://www.codeguru.com/forum/showthread.php?t=440881

Pretty much all the code is there that snaps the processes and retrieves their top level windows.