# Retrieve a HWND in C++



## -Fabez- (Jul 28, 2008)

I am trying to run an external executable, returning its HWND so i can change its title programaticaly. At the moment the user has to type in the current window title after the external program is run to get the HWND. This is a problem because it needs to be done automaticaly. I am open to any suggestions that would help towards solving this problem.


----------



## -Fabez- (Jul 28, 2008)

Bump!


----------



## jpshortstuff (Oct 19, 2007)

How are you running the external executable?

Looking at the API, the CreateProcess function looks a bit like what you need. One of the parameters is a pointer to a PROCESS_INFORMATION structure that receives info about the process once it is running, including a handle to the process. 

Is that any use?


----------



## -Fabez- (Jul 28, 2008)

Thanks for that i have changed all of my WinExec's now  It returns a Process id that I have to do some looping with, but it works, thank you


----------



## jpshortstuff (Oct 19, 2007)

No probs 

Is the handle to the process not one of the members of the PROCESS_INFORMATION structure?


----------



## -Fabez- (Jul 28, 2008)

It is, but then I need to convert it into a HWND, which is where the looping comes in.


----------

