开发者

Send Ctrl+C to process

开发者 https://www.devze.com 2023-01-09 07:57 出处:网络
I have to se开发者_开发知识库nd to send Ctrl+C to console process created from my C# application. I have found a lot of similar threads but haven\'t found a solutaion (tried CreateProcess, GenerateCon

I have to se开发者_开发知识库nd to send Ctrl+C to console process created from my C# application. I have found a lot of similar threads but haven't found a solutaion (tried CreateProcess, GenerateConsoleCtrlEvent, etc.). Is there any working example?


The key CRTL + C is ASCII 3 (in decimal)

myProcess.StartInfo.FileName = "Sort.exe";
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.Start();
StreamWriter myStreamWriter = myProcess.StandardInput;
myStreamWriter.WriteLine(inputText);

Ref: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号