0

I know that I can use the GetKeyboardLayout function in order to retrieve the current keyboard language. However I am still confused on how to use the return value of this function.

Can someone write down a practical example on how to use it, for example, to check if keyboard is set to English language? (I'm using C++)

Thank you in advance.

Flavio
  • 451
  • 3
  • 26
  • 2
    if (PRIMARYLANGID(hkl & 0xffff) == LANG_ENGLISH) – Hans Passant Jul 29 '16 at 14:47
  • 1
    @HansPassant, thank you for your response. Actually I don't think what you wrote is totally correct, since I get an error ("expression must have integral or unscoped enum type") but it definitely pointed me in the right direction. In my Visual C++ it seem to work correctly this way: if (PRIMARYLANGID(KeyboardLayout) == LANG_ENGLISH) – Flavio Jul 29 '16 at 16:17
  • 1
    Well, don't tell me, just post the correct code to complete your Q+A and accept it as the answer. – Hans Passant Jul 29 '16 at 16:21

1 Answers1

1

Found solution!

HKL KeyboardLayout = GetKeyboardLayout(0);
if (PRIMARYLANGID(KeyboardLayout) == LANG_ENGLISH)
Flavio
  • 451
  • 3
  • 26