tags:

views:

93

answers:

5

Hi,

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

+1  A: 

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.

Justin Ethier
A: 

Try yo look at here

Simone Margaritelli
A: 

You could include a commandline switch (/g for example) in your C# app that would run your application in a GUI mode rather than console. You would simply evaluate for the argument in your Main function and either launch a Win Form which would accept input and run whatever algorithms or just stick to the console mode. By default your app would run console, or vice-versa if you choose.

Paul Sasik
A: 

Although what you want is probably covered by the duplicate, you asked one specific question that needs answering:

I need a way to include a compiled *.exe into another program

You can't really do this. At best, you can create a library as @Justin Ethier suggests upon which both your GUI and command line tool rely.

Randolpho
+1  A: 

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.

Mitchel Sellers