Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have one requirement which asks me to check if a particular GUI.exe is running and if it is running then I need to bring that GUI to front.

I am using MFC and C++, The problem which I am facing is that I dont know how to check for GUI.exe in my existing MFC application and if Found, then how to bring it to Foreground.

Thanks,
Posted

1 solution

You can find a process by name with CreateToolhelp32Snapshot and Process32First/Process32Next or with EnumProcesses.

There should be existing code to do just that (probably even here on CodeProject).

After that, when you get the process handle, you could try to use MoveWindow or SetWindowPos on the process handle.

good luck.

M.
 
Share this answer
 
Comments
Philippe Mori 6-Sep-11 20:38pm    
Maybe also SetForegroundWindow.

You have to be aware that Windows will prevent a window to be bring to foreground in some case.... mainly so that if you start a application that take time to load and then decide top work on something else before the application is ready, the focus won't change unexpectedly while you are typing in another application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900