C#控制C++的控制台
用winform控制C++的控制台程序(可以给控制台发送信息并且能得到返回的结果)
------解决方案--------------------
这是msdn另一个例子,启动一个程序,然后向它输入字符,
Process myProcess = new Process();
myProcess.StartInfo.FileName = "Sort.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.Start();
StreamWriter myStreamWriter = myProcess.StandardInput;
// Prompt the user for input text lines to sort.
// Write each line to the StandardInput stream of
// the sort command.
String inputText;
int numLines = 0;
do
{
Console.WriteLine("Enter a line of text (or press the Enter key to stop):");
inputText = Console.ReadLine();
if (inputText.Length > 0)
{
numLines ++;
myStreamWriter.WriteLine(inputText);
}
} while (inputText.Length != 0);
其中,myStreamWriter.WriteLine(inputText);写入的inputText字符串,在Sort.exe里就感觉到好像是键盘输入了inputText字符串一样,