windows 程序禁用中文輸入法方法:
1、添加windows頭文件及dll文件
//輸入法相關 #include <imm.h> #pragma comment (lib ,"imm32.lib") //2、禁用: HIMC g_hIMC = NULL;//g_hIMC 用於恢復時使用 g_hIMC = ImmAssociateContext(handle, NULL);//handle 為要禁用的窗口句柄 //3、啟用 ImmAssociateContext(handle, g_hIMC);//handle 為要啟用的窗口句柄
注意:如果是mfc程序,最好在InitInstance() 中加入 ImmDisableIME(GetCurrentThreadId());
windows8或以后版本設置全局輸入法:
HKL m_hKeyLayout = GetKeyboardLayout(GetCurrentThreadId())獲取當前布局 //設置全局輸入法為英文 LoadKeyboardLayout(_T("0x0409"), KLF_ACTIVATE); //英文不再使用,切換回來 ActivateKeyboardLayout(m_hKeyLayout , 0);
原文鏈接:https://blog.csdn.net/hellokandy/article/details/72902715
原文鏈接:https://zhidao.baidu.com/question/1670370529950015427.html