I am a beginner in C ++ (there has always been C #), and I was put in troublooting / update from our inherited program written in C ++.
I have a process name "setup.exe" that works in a window, and I knew how to find its process identifier HANDLE and DWORD. I know that it has a window for sure, but I canβt understand how to bring this window to the foreground, and this is what I am trying to do: Bring the window to the foreground using its process name.
After reading on the Internet, I came up with the following algorithm, which is also not sure if this is the correct way:
- Find the process ID from the process name.
- List all windows belonging to this process ID using EnumWindows
- the above step will give me a window type variable - HWND
- I can set focus or set foreground by passing this HWND variable.
My problem here is the syntax, I really donβt know how to start writing enumwindows, can someone point me to a set of sample code, or if you have a pointer to how I should approach this problem?
Thanks.
Fylix source share