Why are the HKL and KLID of the keyboard different?

by Michael S. Kaplan, published on 2005/04/17 17:40 -07:00, original URI: http://blogs.msdn.com/michkap/archive/2005/04/17/409032.aspx

I actually get this question on a regular basis, believe it or not.

People look at the two numbers, see the similarities, and then start assuming they are the same. To review from my old keyboard terminiology post:

The differences are not obvious if you install keyboards via the LoadKeyboardLayout API (by the way, note the pwszKLID parameter name for those who doubted me about the whole KLID thing!). In that case, the same LCID is always used, and if the keyboard is one of the many with KLID values like 00000409 or 00000407 then the HKL value will be the same as KLID, further making people think they are the same. However, there are two times when they can and will be different:

  1. Any time the KLID value is more than just the LANGID -- like 00010439 for the Hindi Traditional keyboard layout or 0003041e for the Thai Pattachote (non-ShiftLock) keyboard layout, the HKL will have a high word of the lower DWORD filled with different information.
  2. Any time the keyboard is assigned via the Text Services Framework UI under a different language than the original keyboard (e.g. installing the US keyboard under the French language), the HKL will be based on the language you chos, not the language implicit in the KLID.

One could say that making the HKL a handle was a waste, especially since it is a waste of 32 bits of space on 64-bit platforms, but I kind of wish we had defined LCIDs in the same way, it allows for a lot more flexibility.

In any case, these two values are based on entirely different principles, and the times that they are the same value are entirely coincidential....


This post brought to you by "Ѐ" (U+0400, a.k.a. CYRILLIC CAPITAL LETTER IE WITH GRAVE)
A letter whose current importance is almost entirely based on its lack of substance in Windows!

no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2008/09/29 What a tangled web we weave when a KLID from an HKL we must receive

2006/10/14 Understanding (and explaining) why English is everywhere

2005/04/25 Limiting the languages of input

go to newer or older post, or back to index or month or day