class CKbLayout_Class { public: CStringArray mList; CKbLayout_Class() { EnumKbLayoutList(); } public: INT_PTR EnumKbLayoutList() //枚举KeyboardLayout { mList.RemoveAll(); int nSize = GetKeyboardLayoutList(0 , 0); if(nSize != 0) { HKL FAR * lpList = (HKL FAR *)new HKL[nSize]; ZeroMemory(lpList, sizeof(HKL) * nSize); if(GetKeyboardLayoutList(nSize, lpList) == nSize) { for(int i=0; i<nSize; i++) { HKL Val = lpList[i]; CString tmp; tmp.Format( _T("%08X"), Val); mList.Add(tmp); } } delete []lpList; } return mList.GetSize(); } HKL GetDefault_KbLayout() //获取缺省的输入语言 { HKL HKL_Ret = 0; if(! SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, 0, &HKL_Ret, 0)) { TRACE( _T("SPI_GETDEFAULTINPUTLANG Err=%d/n"), GetLastError()); } return HKL_Ret; } BOOL SetDefault_KbLayout(HKL KBL) //设置缺省的输入语言 { HKL HKL_Val = KBL; BOOL bRet = SystemParametersInfo(SPI_SETDEFAULTINPUTLANG, 0, &HKL_Val, SPIF_SENDCHANGE); if(!bRet ) { TRACE( _T("SPI_SETDEFAULTINPUTLANG Err=%d/n"), GetLastError()); } return bRet; } virtual HKL Active_KbLayout(HKL hKBL) //激活指定输入法 { CString szKBL; szKBL.Format( _T("%08X"), hKBL); return Active_KbLayout(szKBL); } virtual HKL Active_KbLayout(LPCTSTR szKBL)//激活指定输入法 { HKL hKL = LoadKeyboardLayout(szKBL, KLF_ACTIVATE); if(hKL == NULL) { TRACE( _T("LoadKeyboardLayout %s Err=%d/n"), szKBL, GetLastError() ); } return hKL; } };