9.3.8. Пример интеграции службы RobotNET Shell

sdk\c-sharp\shell\shell\Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;

using RobotNET.SDK;

namespace RoboShell
{
    class Program
    {
        static void Main( string[] args )
        {
            Console.WriteLine( string.Format( "Program started!" ) );

            if( args.Count() > 1 )
            {
                string addr = args[0];
                string pass = args[1];
                string std = args.Count() > 2 ? args[2] : null;

                try
                {
                    if( std != null )
                    {
                        MemoryStream ms = new MemoryStream();
                        using( Shell shell = new Shell( addr, pass, std, true, false, uint.MaxValue ) )
                        {
                            shell.ShellIt( ms );
                        }
                        ms.Seek( 0, SeekOrigin.Begin );
                        StreamReader r = new StreamReader( ms, Encoding.GetEncoding( 866 ) );
                        string result = r.ReadToEnd();
                        Console.Write( result );
                    }
                    else
                    {
                        Console.SetWindowSize( 80, 40 );
                        Console.SetBufferSize( 80, 40 );
                        using( Shell shell = new Shell( addr, pass, std, true, false, uint.MaxValue ) )
                        {
                            shell.ShellIt( Shell.GetConsoleStdOut(), Shell.GetConsoleStdIn() );
                        }
                    }
                }
                catch( Exception e )
                {
                    Console.WriteLine( e.ToString() );
                }
            }
            Console.WriteLine( string.Format( "Program finished!" ) );
        }
    }
}