How to Change Windows Language Programmatically in LabWindows™/CVI

Updated Jun 15, 2023

Reported In

Software

  • LabWindows/CVI

Operating System

  • Windows

Issue Details

I have several languages configured on my Windows machine. How do I change between languages programmatically in LabWindows™/CVI?
 

Solution

If you want to change the Windows language programatically, you will need to use Win32 API (User32.dll).

  1. Select the language identifier that you want to change using the function LoadKeyboardLayoutA
  HKL LoadKeyboardLayoutA(
  LPCSTR pwszKLID,
  UINT   Flags
  );
where pwszKLID is the language identifier to be loaded and Flags specifies how the input locale identifier is loaded. You will need to set Flags as KLF_ACTIVATE (0x00000001) in order load and activate the input locale identifier for the system.
 
  1. Call the function ActivateKeyboardLayout in order to set the input locale identifier for the calling thread or the current process. 
HKL ActivateKeyboardLayout(
  HKL  hkl,
  UINT Flags
);
where hkl and Flags comes from the previous step.

Additional Information

If you want to receive the current Windows language, you can use the function GetKeyboardLayout 
Every Language has it own language identifier. For example, U.S. English has a language identifier of 0x0409, so the primary U.S. English layout is named "00000409".