LoadKeyboardLayout (user32)
Last changed: behrooz[0]az[@]gmail[.]com-89.165.79.12

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern IntPtr LoadKeyboardLayout(string pwszKLID, uint Flags);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

set flags to 1 when trying to change language

set flags to 0 when trying to reverse the change

Sample Code:

LoadKeyboardLayout("00000429", 1);

//commen on 09 August 2010 by yazeed hamdan,

// This is not alternative, this will set the default input language based on installed keyboard layouts, if

//the layout is not installed in regional settings, nothing will happen, but with LoadKeyboardLayout, the input

//language will be installed if it doesnt exist in regional and language settings.

Alternative Managed API:

//switch to Persian(IR) language

InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("fa-IR"));

//switch to English(US) language

InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("En-US"));

Documentation