Change Windows default language using Java application
2 answers
You can set the default input language using the SystemParametersInfo API .
BOOL WINAPI SystemParametersInfo(
__in UINT uiAction,
__in UINT uiParam,
__inout PVOID pvParam,
__in UINT fWinIni
);
Using JNA is much easier than using JNI. To call this API function in User32.dll using JNA, create an interface:
public interface User32 extends StdCallLibrary
{
User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);
bool SystemParametersInfo(int uiAction, int uiParam, int[] pInt, int fWinIni);
}
You define the LCID in the language you want to change. ( Here's a list from MSDN.) For example, English is 0x409. Then use the LCID in the call SystemParametersInfo
:
int lcid = 0x409;
final int SPI_SETDEFAULTINPUTLANG = 90;
User32.INSTANCE.SystemParamtersInfo(SPI_SETDEFAULTINPUTLANG, 0, new int[] { lcid }, 0);
And after that, your default input language was changed!
+5
a source to share