0

是否可以从之前启动的控制台应用程序中读取控制台缓冲区?
我假设一次有一个正在运行的实例,我可以通过Process.GetProcessesByName()或类似方式找到它。我可以检查一下,它的控制台上已经写了什么吗?

4

1 回答 1

2

At that point it really has nothing to do with the program, but how it's called. If it's called from a shell then it depends on whether or not that shell provides means for an external application to access it's current data. Some might, some might not. The program may not even be called from a shell at all, it could be called from some other type of program that processes the standard input/output entirely differently from how a shell might.

In general I wouldn't expect most shells to provide a means for other processes to go in and grab it's content, so while it might be possible under certain circumstances, it's unlikely to be a good idea.

Instead you should have the program write the output to some location such as a file, memory mapped file, named pipe, database, etc. which is designed to be accessible by another process.

于 2013-11-06T16:01:50.473 回答