c++ - Enumerating the available keyboard layouts in Windows -


is possible enumerate available keyboard layouts. available mean user can switch them pressing alt+shift (or whatever chosen shortcut is), i.e. in language bar's menu.

alternatively, checking if specific layout available in language bar useful.


edit:

many @oleg, made function works:

bool isactivekeyboardlayout(dword dwprimarylangid) {     tchar buf[kl_namelength];     getkeyboardlayoutname(buf);      dword dwactivelangid = 0;     _stscanf(buf, _t("%x"), &dwactivelangid);     if (dwprimarylangid == primarylangid(dwactivelangid))         return true;      return false; }  bool iskeyboardlayoutpresent(dword dwprimarylangid)  {     if (isactivekeyboardlayout(dwprimarylangid))         return true;      dword dwthreadid = getcurrentthreadid();     hkl hold = getkeyboardlayout(dwthreadid);     (;;)     {         activatekeyboardlayout((hkl) hkl_next, 0);         if (hold == getkeyboardlayout(dwthreadid))             return false;          if (isactivekeyboardlayout(dwprimarylangid))         {             activatekeyboardlayout(hold, 0);             return true;         }     } } 

the function getkeyboardlayoutlist seems close information need. returned information array of hkl, handle has values

0x04070407 - german 0x04110411 - japanese 0x04190419 - russian 0xe0200411 - japanese

if have language more 1 input methods or more 1 layout 1 language can have more items can see in language bar menu. on 64-bit operation system value 0x04070407 represented 0x0000000004070407.

here can read more input locale identifier , keyboard layouts.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -