The following is a method to get the real (localized) keyboard layout name for Windows XP onwards as opposed to the ID number.
The reason I give you this method is that the typical API way relies on constants where as this method gets it from YOUR registry @
HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\
look at the subkeys and values under it, e.g. under XP:
00000402
00000405
00000406 etc
The above 8 digit subkey represents a KLID (Keyboard Layout Identifer) for a specific keyboard layout in hexadecimal.
(The API functions will give you this number, hence the need for the constants.
Clicking on these keys gives;
Layout Display Name @%SystemRoot%\system32\input.dll,-5053
Layout File KBDBU.DLL
Layout Text Bulgarian
Layout Display Name = This value only exists in XP and later; it contains a string suitable for interpretation by the SHLoadIndirectString function from SHLWAPI Dll, which is a pointer to a string in a DLL that contains the localized name of the keyboard layout, based on the current UI language.
Layout File = The name of the keyboard layout DLL. This Dll contains the KB layer descriptor, i.e the key names like UP, DOWN etc.
Layout Text = the localized, hard-coded name of the keyboard; for XP and beyond, this is the English name of the keyboard.