Exemplo n.º 1
0
        private static void DisbleQuickEditMode()
        {
            const int  STD_INPUT_HANDLE       = -10;
            const uint ENABLE_PROCESSED_INPUT = 0x0001;
            const uint ENABLE_QUICK_EDIT_MODE = 0x0040;
            const uint ENABLE_INSERT_MODE     = 0x0020;

            IntPtr hStdin = SafeNativeMethods.GetStdHandle(STD_INPUT_HANDLE);

            SafeNativeMethods.GetConsoleMode(hStdin, out uint mode);
            mode &= ~ENABLE_PROCESSED_INPUT; //禁用ctrl+c
            mode &= ~ENABLE_QUICK_EDIT_MODE; //移除快速编辑模式
            mode &= ~ENABLE_INSERT_MODE;     //移除插入模式
            SafeNativeMethods.SetConsoleMode(hStdin, mode);
        }