C++ windows console quick edit mode code off (reproduced)

Problem: When writing a console program under Windows under win10, it is found that the program is often blocked.
Reason: Windows Powershell is divided into quick edit mode and standard mode. When in quick edit mode, clicking the console with the mouse will cause the program to be blocked. And the system By default, it is the quick edit mode

Solution: Reset the properties of the console through code.

HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);  
        DWORD mode;  
        GetConsoleMode(hStdin, &mode);  
        mode &= ~ENABLE_QUICK_EDIT_MODE;  //移除快速编辑模式
        mode &= ~ENABLE_INSERT_MODE;      //移除插入模式
        mode &= ~ENABLE_MOUSE_INPUT;
        SetConsoleMode(hStdin, mode);  

Reference link: c++ windows console quick edit mode off - it610.com 

Guess you like

Origin blog.csdn.net/zanglengyu/article/details/125855938