1
votes

We have a virtual keyboard (for touch screen) which its language layout is configured via the windows default language.

I have seen numerous answers which involves InputLanguageManager and CultureInfo.
They're not useful to me, didn't do the job.

There is this one method - SystemParametersInfo function with the SPI_SETDEFAULTINPUTLANG flag that i'm trying to check.
So far, didn't find any useful usage examples besides this one here, but it changes the keyboard layout from Dvorak to Marshal.

Can you give me an example (hopefully with the SystemParametersInfo) that converts the default system language to en-US?

Edit

A brief clarification.
This program replaces the explorer as windows shell, hence all keyboard settings such as setting default keyboard layout should be handled from my program.
Moreover, my wish is to replace between different installed languages such as English, Swedish, Portuguese and so on..
I don't want to change between Dvorak and Qwerty layout of the keyboard.

The purpose of this post is to ask for examples for changing between different languages and not for layout of English symbols on keyboard.

Thanks!

1
Why don't you just remove the part of the code sample that modifies the layout of the keyboard... - Gnqz
I'll just leave Raymond Chen's advice on the matter, and mention that any application that messed with my language settings would get uninstalled immediately. But I'm sure you have your reasons... - Jeroen Mostert

1 Answers

2
votes
   [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref uint pvParam, uint fWinIni);

    public void Foo()
    {
        uint localeUS = 0x00000409;
        uint localeNL = 0x00000403;
        SetSystemDefaultInputLanguage(localeUS);
    }

    public bool SetSystemDefaultInputLanguage(uint locale)
    {
        return SystemParametersInfo(SPI_SETDEFAULTINPUTLANG, 0, ref locale, 0);
    }

    public uint GetSystemDefaultInputLanguage()
    {
        uint result = uint.MinValue;
        bool retVal = SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, 0, ref result, 0);

        return result;
    }

This seems to work fine for me.

Sources: