I am piping in on this due to the fact that I have a Windows 10, C++.
application that needs to use two Custom Keyboard Layouts in conjunction with
a Keyboard Filter Driver.
The real answer here is for Microsoft to simply release the source code for the Custom.dll imbedded within an MSKLC installer package. I am surprised that they have not already done so. I am of course not sure where to post such a request and what tags to attach to it or how to word the topic in order to get the appropriate People's top see it.
I have not visited MSND for quite some time now. I am surprised at the limited 'tags' one can apply to a topic. I believe that winapi-general seems to be the only suitable 'tag' to apply to any sort of Win32 based question. It seems this site has become really azure concentric.
When I am done with this post I will post a request for the source code to Custom.dll titles 'MSKLC / Custom.dll Source Code' tagged with winapi-general so you can find it.
What DrakeWu described will work if one simply wants to load the Keyboard Layout and activate it,
but the Keyboard Layout will NOT appear within the Language Bar.
I have two 'Custom' Keyboard 'Installed':
- A Custom Keyboard Created And Installed Via MSKLC. Named: US-Custom
This Keyboard shows up within the Language Bar.
- A Custom Keyboard I created from the KBDUS Sample Layout and 'Installed' as DrakeWu suggested. Named: 'Client-US'.
This Keyboard DOES NOT show up within the Language Bar.
Here is some output:
Initial ActiveKeyBoard:0x04090409
Initial KeyBoardLayoutName:00000409
GetLayoutFromRegistry():SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00000409
Layout Text::US
// This Is 'My' Keyboard Layout.
LoadKeyBoardLayout(00060409,(UINT)0)
LoadedKeyboardLayout:0xFFFE0409
ActivateKeyboardLayout(0xFFFE0409,KLF_SETFORPROCESS)
Last LoadedKeyboardLayout:0x04090409
LoadedKeyboardLayout Now:0xFFFE0409
GetKeyboardLayoutName():00060409
GetLayoutFromRegistry():SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00060409
Layout Text::Client-US
BufferKeyBoard:Client-US
// This Is The Keyboard Created And Installed With MSKLC
LoadKeyBoardLayout(a0000409,(UINT)0)
LoadedKeyboardLayout:0xF0C00409
ActivateKeyboardLayout(0xF0C00409,KLF_SETFORPROCESS)
Last LoadedKeyboardLayout:0xFFFE0409
LoadedKeyboardLayout Now:0xF0C00409
GetKeyboardLayoutName():A0000409
GetLayoutFromRegistry():SYSTEM\CurrentControlSet\Control\Keyboard Layouts\A0000409
Layout Text::US - Custom
BufferKeyBoard:US - Custom
//======================================================================
As a side bar I am annoyed with the fact that is seems impossible to ascertain the appropriate KLID from a HKL:
HKL For MSKLC Keyboard: 0xF0C00409
KLID For MSKLC Keyboard: 0xa0000409
There seems to be no bit manipulation that can produce a0000409 from F0C00409
This makes GetKeyboardLayoutList() useless for my purposes.