How can I create a hidden disposable console app and communicate with it?
I wrote a small console application to wrap a third party DLL that is having problems. I am calling this from a GUI application using _popen and I just want to read the value from the standard console output. This will briefly display an unwanted console window.
I know this can be avoided by using a specific STARTUPINFO configuration with CreateProcess. However, I would rather put the fix in a console application and still use _popen. Creating a child process using the Windows subsystem (i.e. WinMain instead of the main one) does not cause the console window to disappear. Apparently the console is dedicated by the operating system to facilitate messaging.
Please note that the third party DLL is unstable but required to interact with proprietary hardware. Therefore, any approach loads the DLL in the memory space of the GUI applications inappropriate.
source to share
1) I support the idea of running it with STARTUPINFO to hide the window. This is a SOP on Windows, so it will work better than trying to force a Unix SOP on. Moreover, you may want to see the result when testing individually.
2) Or you can create a graphical application that never displays a window. This is a console application without a console.
change
Link This article shows you how to do the second option.
change
Ok, if you want to send information to parents, the easiest way is to write a file. One way to preserve this order is for the parent password to pass in a unique filename as a command line parameter to which the child is written. The parent can control the file and act on its contents.
There are many alternatives. Pipes will be called the closest to the two approaches discussed so far, but you can also use various forms of IPC, including socket.
However, you cannot access stdin / stdout / stderr without a console. You can run with the console hidden, but it actually has one.
change
Does lua allow the executable to be run directly rather than via cmd.exe?
source to share