when I use popen to get the output of a command, say dir, it will prompt out a console.
however, can I get the output of a command without the appearance of the console?
I am using Visual C++ and want to make an Library to return the output of some command, say, dir.
With POSIX it should be something like this:
You should off course check return values etc...
I needed to solve this for my full screen OpenGL Windows application, but was unable to prevent the console window popping up. Instead, taking back focus after a short delay seems to work well enough to avoid seeing it.
Update: this apparently doesn't work if the program is launched from Explorer. It is working when launched from Visual Studio.
Assuming Windows (since this is the only platform where this behavior is endemic):
CreatePipe() to create the pipes necessary to communicate, and CreateProcess to create the child process.
This should more than get you on your way to doing what you wish to accomplish.