小编Vic*_*nus的帖子

如何从控制台应用程序(如Far)接收颜色输出?

我有一些代码:

cmdProcess = new Process();
var procStartInfo = new ProcessStartInfo( "cmd", "/k "C:\\Program Files (x86)\\Far Manager\\Far.exe"" );

procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardInput = true;
procStartInfo.UseShellExecute = false;

procStartInfo.CreateNoWindow = true;
cmdProcess.OutputDataReceived += ( s, e ) => {
       callbackFn(e.Data + "\n");
};
cmdProcess.StartInfo = procStartInfo;

cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
Run Code Online (Sandbox Code Playgroud)

但是使用此代码,我只能启动该过程并获得某些东西,但不能完全实现,也不能获得颜色。我也尝试了该ReceiveConsoleOutput功能,并且只收到空白缓冲区。使用WinAPI,我只能启动控制台,而没有其他功能-我不太了解。但是我不反对WinAPI示例,因为我认为我的问题可以用它解决。如果有人可以帮助我,我将不胜感激。

PS:对不起,英语不好。

c# console winapi c#-4.0

3
推荐指数
2
解决办法
1032
查看次数

标签 统计

c# ×1

c#-4.0 ×1

console ×1

winapi ×1