views:

36

answers:

1

To determine the name of the active keyboard layout, one can get its "numeric name" by invoking GetKeyboardLayoutName and then looking it up under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\{0}\Layout Text.

However, inexplicably, there appears to be no way to convert the locale identifiers returned by GetKeyboardLayoutList into the "numeric names" suitable for lookup in the registry.

Is there any way to retrieve the Layout Text of all installed keyboard layouts without activating each one to do so?

For example, for United States-International, GetKeyboardLayoutList returns f0010809 on my system but the name is stored under 00020409 (which can be verified by activating f0010809 and calling GetKeyboardLayoutName - which will return 00020409).

A: 

There doesn't seem to be an API for this. However, the work-around of briefly switching to the layout just to determine its "numeric name" works perfectly, with no noticeable side-effects.

Might not be so good in a multi-threaded app where the user may be typing while this happens though!

romkyns