Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a program in another one?

Tags:

c#

hidden

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

like image 415
Roman Avatar asked May 24 '26 00:05

Roman


2 Answers

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.

like image 146
Mitchel Sellers Avatar answered May 26 '26 14:05

Mitchel Sellers


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.

like image 37
Justin Ethier Avatar answered May 26 '26 14:05

Justin Ethier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!