#include "stdafx.h" #include <windows.h> #include <iostream> #include <conio.h> using namespace std; // Keyboard layout structure class _KeyboardLayout { public: HKL hBengali; bool bBengali; HKL hEnglish; bool bEnglish; _KeyboardLayout(); } ; _KeyboardLayout::_KeyboardLayout() { // setting default values (as not installed = false) bBengali=false; bEnglish=false; } int main() { _KeyboardLayout KeyboardLayout; // Get layout’s count TCHAR szKeyboard[KL_NAMELENGTH]; int nBuff=::GetKeyboardLayoutList(0, NULL); int nKeyboard; HKL * phkl; if((phkl = new HKL[nBuff])==NULL) { cout<<"Out of Memory !"; return 1; } // Get and parse layout items int x=::GetKeyboardLayoutList(nBuff,phkl); // iterate through list to check needed layouts for(nKeyboard=0; nKeyboard<nBuff; nKeyboard++) { ::ActivateKeyboardLayout(phkl[nKeyboard], KLF_SETFORPROCESS); GetKeyboardLayoutName(szKeyboard); if(wcscmp(szKeyboard,_T("00000445"))==0) { KeyboardLayout.bBengali=true; KeyboardLayout.hBengali=phkl[nKeyboard]; cout<<phkl[nKeyboard]; } if(wcscmp(szKeyboard,_T("00000409"))==0) { KeyboardLayout.bEnglish=true; KeyboardLayout.hEnglish=phkl[nKeyboard]; } } delete [] phkl; if(!KeyboardLayout.bBengali) cout<<"error in bengali layout"; //MessageBox(NULL,_T("Bengali keyboard layout not installed"),_T("Warning"),MB_OK|MB_ICONEXCLAMATION); if(!KeyboardLayout.bEnglish) MessageBox(NULL,_T("English (USA) keyboard layout not installed"),_T("Warning"),MB_OK|MB_ICONEXCLAMATION); else {} cout<<endl<<::LoadKeyboardLayoutW(_T("00000445"),KLF_ACTIVATE | KLF_SETFORPROCESS); if(KeyboardLayout.bBengali) { cout<<endl<<::ActivateKeyboardLayout(HKL(HKL_PREV), KLF_REORDER);} return 0; }
ActivateKeyBoardLayout
LoadKeyboardLayout
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)