First of all, you should check the result of the LoadKeyboardLayout
function and if it fails, you should check the error returned by the GetLastError
function to determine what is wrong.
But even if this function call succeed, it will activate the input locale identifier, but for your worker thread. As the LoadKeyboardLayout
reference states for the KLF_ACTIVATE
flag (emphasized by me):
KLF_ACTIVATE
If the specified input locale identifier is not already loaded, the function loads and activates the input locale identifier for the current thread.
Although, if you want to load and activate keyboard layout for the whole process, you may try to combine the KLF_ACTIVATE
flag with the KLF_SETFORPROCESS
one:
const
KLF_SETFORPROCESS = $00000100;
begin
if LoadKeyboardLayout('00000429', KLF_ACTIVATE or KLF_SETFORPROCESS) = 0 then
RaiseLastOSError;
end;