getting the main window from a process HANDLE

In my application I'm using the CreateProcess() function from which I get the HANDLE to the process (by the PROCESS_INFORMATION structure).
In a certain situation I need to bring to top the main window of the application which I instanced by the CreateProcess() function.
Is there a way to get the handle of the main window from a HANDLE to process ? (or maybe is there another solussion ?)

Who is Participating?
CindyCConnect With a Mentor Commented:
If you know the class name of the window, juz use
FindWindow( "YourClassName", NULL), which returns the window.
Hope this helps.
There are probably a dozen ways to do this but one method that I'm familiar with is to use the FindWindow() function.
yoavoAuthor Commented:
the problem with FindWindow() is that my application should run on several languages and I dont want to get into translating the process name that I'm running by the providers...
This is not a problem.
You can use only the class name parameter in the FindWindow function. You only need to make sure that your class (from WNDCLASS) is registered correctly. This info is only used internaly and not exposed to the user.
Check out for ways to do it.

The second thing you can do, is to load the window title from the resources of that EXE. It is a bit tricky, but it can be done. Becuase your application support multipile langs I assume you a set of res for each lang. You need to establish the lang the app is running and dig into the resources a bit. Basicaly you load the right string from res and use find window.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.