Exemplo n.º 1
0
 public void ReadOutput(ConsoleApi.CHAR_INFO[] Buffer, ConsoleApi.COORD BufferSize, ConsoleApi.COORD BufferCoord, ref ConsoleApi.SMALL_RECT Region)
 {
     if (!ConsoleApi.ReadConsoleOutput(hConOut, Buffer, BufferSize, BufferCoord, ref Region))
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
Exemplo n.º 2
0
 public void SetSize(ConsoleApi.COORD Size)
 {
     if (!ConsoleApi.SetConsoleScreenBufferSize(hConOut, Size))
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
Exemplo n.º 3
0
 public ConsoleApi.CONSOLE_SCREEN_BUFFER_INFO GetInfo()
 {
     ConsoleApi.CONSOLE_SCREEN_BUFFER_INFO ret;
     if (!ConsoleApi.GetConsoleScreenBufferInfo(hConOut, out ret))
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
     return(ret);
 }
Exemplo n.º 4
0
        public void Write(ConsoleApi.INPUT_RECORD[] Inputs)
        {
            UInt32 nWritten = 0;

            if (!ConsoleApi.WriteConsoleInput(hConIn, Inputs, (uint)Inputs.Length, out nWritten))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            if (nWritten != Inputs.Length)
            {
                throw new Exception("Not all inputs could be written to console.");
            }
        }
Exemplo n.º 5
0
        public ConsoleInput()
        {
            hConIn = CreateFileApi.CreateFile(
                "CONIN$",
                CreateFileApi.FileAccess.GenericRead | CreateFileApi.FileAccess.GenericWrite,
                CreateFileApi.FileShare.Read,
                IntPtr.Zero,
                CreateFileApi.CreationDisposition.OpenExisting,
                CreateFileApi.FileAttributes.Normal,
                IntPtr.Zero
                );
            if (hConIn.IsInvalid)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }

            uint Mode;

            ConsoleApi.GetConsoleMode(hConIn, out Mode);
            ConsoleApi.SetConsoleMode(hConIn, (uint)(Mode & ~0x0001));      // Disable ENABLE_PROCESSED_INPUT so that Ctrl+C passes through.
        }