Ejemplo n.º 1
0
 public ConsoleScreenBuffer()
 {
     hConOut = CreateFileApi.CreateFile(
         "CONOUT$",
         CreateFileApi.FileAccess.GenericRead | CreateFileApi.FileAccess.GenericWrite,
         CreateFileApi.FileShare.Write,
         IntPtr.Zero,
         CreateFileApi.CreationDisposition.OpenExisting,
         CreateFileApi.FileAttributes.Normal,
         IntPtr.Zero
         );
     if (hConOut.IsInvalid)
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
Ejemplo n.º 2
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.
        }