C++ Question

I want to call a Win32 app from another, what shall I do?

I have a Win32 app that creates a simple window, I need to call that program/window from another program (cryengine). My app starts at

int WINAPI WinMain(...)
. What should I do to achieve that? Dynamic Library, .exe, static library ?

I had planned to just call the .exe from my other program. Is it better to use a .dll ?

Answer

You don't have to go the DLL or static library way to just launch your program from another program.

Use CreateProcess, ShellExecute or ShellExecuteEx .

If your program may be already running then you can use FindWindow to get the window of app and send some message using SendMessage to tell the app to activate the window.

However, finding & activating (SetForegroundWindow) will only flash the window button in the taskbar so that it gets user's attention. This is done by Windows so that other apps cannot interrupt and cause usability issues.