Redmon redirect to a .NET Windows.Forms application

2.9k Views Asked by At

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.

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 starts my program, but then it is stopping. I guess I should read somehow the content it is sending to the program, but how?

1

There are 1 best solutions below

3
On BEST ANSWER

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).

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.