Redmon重定向到.NET Windows.Forms应用程序 [英] Redmon redirect to a .NET Windows.Forms application

查看:216
本文介绍了Redmon重定向到.NET Windows.Forms应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有趣的任务:编写一个程序来捕获名为的程序中的输入雷德蒙(Redmon).它基本上是一台虚拟打印机,可将输出重定向到程序.

I have an interesting task: to write a program which captures input from the program called Redmon. It is basically a virtual printer which redirects the output to a program.

我安装了Redmon并创建了一个winforms应用程序来捕获输出.但是我被困在这里.我检查了程序收到的内容,并且在参数级别上没有任何内容(主args上的string []为空).

I installed Redmon and created a winforms application to catch the output. But I'm stuck here. I checked what does my program receives and it is nothing on the parameter level (the string[] on main args are empty).

Redmon启动了我的程序,但是随后停止了.我想我应该以某种方式阅读它发送到程序的内容,但是如何?

Redmon starts my program, but then it is stopping. I guess I should read somehow the content it is sending to the program, but how?

推荐答案

我假设Redmon流到stdin-在这种情况下,您必须通过Console.In(如果是字符,则从输入流中读取) -基于)或Console.OpenStandardInput(用于原始二进制流访问).

I would assume that Redmon streams to stdin - in which case you'll have to read from the input stream - either via Console.In (if it is character-based), or Console.OpenStandardInput (for raw binary stream access).

作为从stdin读取内容的简单例子(读取文本行,将它们反转):

As a trivial example of something that reads from stdin (it reads text lines, reversing each):

static void Main() {
    WriteReversedLines(Console.In);
}
static void WriteReversedLines(TextReader reader) {
    string line;
    while ((line = reader.ReadLine()) != null) {
        char[] chars = line.ToCharArray();
        Array.Reverse(chars);
        Console.WriteLine(chars);
    }
}

显然,您需要对二进制数据进行稍微不同的处理,但是从概念上讲,这是相似的.

Obviously you need to treat binary data slightly differently, but conceptually it is similar.

这篇关于Redmon重定向到.NET Windows.Forms应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆