I have two independent console applications developed in C++. I was asked to develop a GUI for both of them. In this GUI I collect some parameters that are needed to launch any of these applications. Anyone can give some orientation on integrating the console applications with this GUI? Could it be possible to launch the applications from the GUI and not seeing the console? Can the things that the applications write in the console be redirected to a log file?
Thanks in advance.
To decouple the GUI from the command line tools you have your GUI call the existing programs supplying the proper parameters.
You can use the CreateProcess() API function redirecting its output to a filehandle. That call receives a STARTUPINFO structure where you can specify if the window for the command is shown or not.
Check the links for examples, a complete create process sample can be found here.
That’s the pure Windows API way of doing things.
If you are doing C++/.NET development things are way easier via System.Diagnostics.Process.
If you can choose any language to do it I’d certainly go the .NET way (and even change the language to C#), it’s almost trivial (as it manages all the API calls itself, and you have a sane interface to it)
You can also redirect output via the shell, but that’s fairly inflexible and error prone, IMO.