Change Windows default language using Java application

Can I change the default language of my host system (Windows XP) using a Java application? If so, how can I do this?

+2


a source to share


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


There are no built-in ways provided by the Java SE API. I at least see nothing in the Desktop

API. You will need to grab the OS-native API. Forget Java for this bit, how exactly would you do this without Java? Once cleared up, call a specific API using JNI in Java.



0


a source







All Articles