I've written a program in C++. It's just using the console to have it as portable as possible. Unfortunately, many Windows-Users seem not to understand how to use the program (Linux Users are just fine with it :) ). So I'd like to write a GUI for that program. As this needs to run on Windows only, I'd like to write it in C#.
But I want to maintain the GUI apart from the original program. So basically, I need a way to include a compiled *.exe into another program. Is there a way to catch the console output from another program and send inputs to it? Also, can the console of the original program be hidden?
Similar Questions
How To: Execute command line in C#, get STD OUT results
There are a number of ways that you might go about doing this. The System.Diagnostics.Process class has methods that allow you to get access to the Input and Output of the application, you could automate it from there.
Basically you can use the StandardInput and StandardOutput methods to get the output and then interact with the inputs to control the application. The posting in the "Similar Questions" addition to your question shows the first part of that, the StandardOutput portion.
What would be great is if you could extract your program into a C++ library that is then used by a C++ console program. That way to integrate it with C# all you would have to do is define pInvoke entry points into that DLL, and then you could call your code directly from the GUI application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With