Ruby ruby GetStdHandle 如何关闭快速编辑模式 ?

sevk · 2021年12月13日 · 最后由 LuzUeki28006 回复于 2025年03月11日 · 321 次阅读
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);

我想把这个代码写成 Ruby 的,但是 GetStdHandle 的参数 STD_INPUT_HANDLE 是多少?查了半天,没找到. 有其它办法吗?

用 C 语言暂时解决了问题:

disable_quick_edit.cpp :

#include<conio.h>
#include<iostream>
#include<windows.h>
using namespace std;

int main(){
    HANDLE hInput;
    DWORD prev_mode;
    hInput = GetStdHandle(STD_INPUT_HANDLE);
    GetConsoleMode(hInput, &prev_mode); 
    SetConsoleMode(hInput, prev_mode & ENABLE_EXTENDED_FLAGS);
    return 0;
}

编译命令:

cd /d C:\Program Files\Microsoft Visual Studio 10.0\VC

vcvarsall.bat

cl.exe /EHsc  disable_quick_edit.cpp

得到 disable_quick_edit.exe , 执行一下这个 31 KB 的 exe 就行。

foodle, A must-read that teaches important lessons. This is quite helpful, so please accept my gratitude.

@pooh in korea The I think the "hInput = GetStdHandle(STD_INPUT_HANDLE);" is incorrect. Or at least it does not work for me.

We learned useful things from your blog that we can use. Your post has a lot of great tips Happy wheels.

Safety and quality assurance and supervision: Safety and quality are the cornerstone of the development of the full body sex doll. For fat sex dolls, safety and quality issues are particularly important due to their use scenarios and close contact with the human body.

需要 登录 后方可回复, 如果你还没有账号请 注册新账号