Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
[DllImport("user32")]
public static extern bool GetKeyboardLayoutName(IntPtr pwszKLID);
System.Text.StringBuilder locale = new System.Text.StringBuilder(new string(' ', 256));
int length;
string keyboardLanguage;
length = GetKeyboardLayoutName(locale);
keyboardLanguage = locale.ToString().Substring(0, length);
Alternative Managed API:
Do you know one? Please contribute it!
///For using "imm32.dll"'s functions.
const int GCL_REVERSECONVERSION = 0x0002;
Mapping of all keyboard layout IDs on Windows 7 to their respective names
[DllImport("Imm32.dll")]
public static extern IntPtr ImmGetContext(IntPtr hWnd);
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Input;
namespace DesktopDictation.DeviceButtonMappings
[DllImport("User32.dll")]
public static extern IntPtr GetKeyboardLayout(int idThread);
[DllImport("Imm32.dll")]
public static extern int ImmGetConversionList(
IntPtr hKL,
IntPtr hIMC,
string lpSrc,
IntPtr lpDst,
int dwBufLen,
int uFlag
);
[DllImport("Imm32.dll")]
public static extern bool ImmReleaseContext(IntPtr hWnd,IntPtr hIMC);
[StructLayout(LayoutKind.Sequential)]
public class CANDIDATELIST
{
public int dwSize;
public int dwStyle;
public int dwCount;
public int dwSelection;
public int dwPageStart;
public int dwPageSize;
public int dwOffset;
}
public string[] GetReverseConversion(string AText)
{
string[] strList = null;
if (AText.Length > 0)
{
public class KeyboardLayout
{
const int KL_NAMELENGTH = 9;
[DllImport("user32.dll")]
private static extern long GetKeyboardLayoutName(StringBuilder pwszKLID);
public static string GetLayoutCode()
IntPtr hIMC = ImmGetContext(this.Handle);
IntPtr hKL = GetKeyboardLayout(0);
int dwSize = ImmGetConversionList(hKL,hIMC,AText,IntPtr.Zero,0,GCL_REVERSECONVERSION);
if (dwSize > 0)
{
var name = new StringBuilder(KL_NAMELENGTH);
GetKeyboardLayoutName(name);
return name.ToString();
IntPtr BufList = Marshal.AllocHGlobal(dwSize);
try
{
ImmGetConversionList(hKL,hIMC,AText,BufList,dwSize,GCL_REVERSECONVERSION);
CANDIDATELIST list = new CANDIDATELIST();
Marshal.PtrToStructure(BufList,list);
byte[] buf = new byte[dwSize];
Marshal.Copy(BufList,buf,0,dwSize);
Marshal.FreeHGlobal(BufList);
int os = list.dwOffset;
string str = System.Text.Encoding.Default.GetString(buf,os,buf.Length-os-3);
char[] par = "\0".ToCharArray();
strList = str.Split(par);
}
finally
{
ImmReleaseContext(this.Handle,hIMC);
}
}
public static String MapLayoutName(string code = null)
{
if (code == null)
code = GetLayoutCode();
switch (code)
{
case "0000041C":
return "Albanian";
case "00000401":
return "Arabic (101)";
case "00010401":
return "Arabic (102)";
case "00020401":
return "Arabic (102) Azerty";
case "0000042B":
return "Armenian eastern";
case "0001042B":
return "Armenian Western";
case "0000044D":
return "Assamese - inscript";
case "0000082C":
return "Azeri Cyrillic";
case "0000042C":
return "Azeri Latin";
case "0000046D":
return "Bashkir";
case "00000423":
return "Belarusian";
case "0000080C":
return "Belgian French";
case "00000813":
return "Belgian (period)";
case "0001080C":
return "Belgian (comma)";
case "00000445":
return "Bengali";
case "00010445":
return "Bengali - inscript (legacy)";
case "00020445":
return "Bengali - inscript";
case "0000201A":
return "Bosnian (cyrillic)";
case "00030402":
return "Bulgarian";
case "00000402":
return "Bulgarian(typewriter)";
case "00010402":
return "Bulgarian (latin)";
case "00020402":
return "Bulgarian (phonetic)";
case "00040402":
return "Bulgarian (phonetic traditional)";
case "00011009":
return "Canada Multilingual";
case "00001009":
return "Canada French";
case "00000C0C":
return "Canada French (legacy)";
case "00000404":
return "Chinese (traditional) - us keyboard";
case "00000804":
return "Chinese (simplified) -us keyboard";
case "00000C04":
return "Chinese (traditional, hong kong s.a.r.) - us keyboard";
case "00001004":
return "Chinese (simplified, singapore) - us keyboard";
case "00001404":
return "Chinese (traditional, macao s.a.r.) - us keyboard";
case "00000405":
return "Czech";
case "00020405":
return "Czech programmers";
case "00010405":
return "Czech (qwerty)";
case "0000041A":
return "Croatian";
case "00000439":
return "Deanagari - inscript";
case "00000406":
return "Danish";
case "00000465":
return "Divehi phonetic";
case "00010465":
return "Divehi typewriter";
case "00000413":
return "Dutch";
case "00000425":
return "Estonian";
case "00000438":
return "Faeroese";
case "0000040B":
return "Finnish";
case "0001083B":
return "Finnish with sami";
case "0000040C":
return "French";
case "00011809":
return "Gaelic";
case "00000437":
return "Georgian";
case "00020437":
return "Georgian (ergonomic)";
case "00010437":
return "Georgian (qwerty)";
case "00000407":
return "German";
case "00010407":
return "German (ibm)";
case "0000046F":
return "Greenlandic";
case "00000468":
return "Hausa";
case "0000040D":
return "Hebrew";
case "00010439":
return "Hindi traditional";
case "00000408":
return "Greek";
case "00010408":
return "Greek (220)";
case "00030408":
return "Greek (220) latin";
case "00020408":
return "Greek (319)";
case "00040408":
return "Greek (319) latin";
case "00050408":
return "Greek latin";
case "00060408":
return "Greek polyonic";
case "00000447":
return "Gujarati";
case "0000040E":
return "Hungarian";
case "0001040E":
return "Hungarian 101 key";
case "0000040F":
return "Icelandic";
case "00000470":
return "Igbo";
case "0000085D":
return "Inuktitut - latin";
case "0001045D":
return "Inuktitut - naqittaut";
case "00001809":
return "Irish";
case "00000410":
return "Italian";
case "00010410":
return "Italian (142)";
case "00000411":
return "Japanese";
case "0000044B":
return "Kannada";
case "0000043F":
return "Kazakh";
case "00000453":
return "Khmer";
case "00000412":
return "Korean";
case "00000440":
return "Kyrgyz cyrillic";
case "00000454":
return "Lao";
case "0000080A":
return "Latin america";
case "00000426":
return "Latvian";
case "00010426":
return "Latvian (qwerty)";
case "00010427":
return "Lithuanian";
case "00000427":
return "Lithuanian ibm";
case "00020427":
return "Lithuanian standard";
case "0000046E":
return "Luxembourgish";
case "0000042F":
return "Macedonian (fyrom)";
case "0001042F":
return "Macedonian (fyrom) - standard";
case "0000044C":
return "Malayalam";
case "0000043A":
return "Maltese 47-key";
case "0001043A":
return "Maltese 48-key";
case "0000044E":
return "Marathi";
case "00000481":
return "Maroi";
case "00000450":
return "Mongolian cyrillic";
case "00000850":
return "Mongolian (mongolian script)";
case "00000461":
return "Nepali";
case "00000414":
return "Norwegian";
case "0000043B":
return "Norwegian with sami";
case "00000448":
return "Oriya";
case "00000463":
return "Pashto (afghanistan)";
case "00000429":
return "Persian";
case "00000415":
return "Polish (programmers)";
case "00010415":
return "Polish (214)";
case "00000816":
return "Portuguese";
case "00000416":
return "Portuguese (brazillian abnt)";
case "00010416":
return "Portuguese (brazillian abnt2)";
case "00000446":
return "Punjabi";
case "00010418":
return "Romanian (standard)";
case "00000418":
return "Romanian (legacy)";
case "00020418":
return "Romanian (programmers)";
case "00000419":
return "Russian";
case "00010419":
return "Russian (typewriter)";
case "0002083B":
return "Sami extended finland-sweden";
case "0001043B":
return "Sami extended norway";
case "00000C1A":
return "Serbian (cyrillic)";
case "0000081A":
return "Serbian (latin)";
case "0000046C":
return "Sesotho sa Leboa";
case "00000432":
return "Setswana";
case "0000045B":
return "Sinhala";
case "0001045B":
return "Sinhala -Wij 9";
case "0000041B":
return "Slovak";
case "0001041B":
return "Slovak (qwerty)";
case "00000424":
return "Slovenian";
case "0001042E":
return "Sorbian extended";
case "0002042E":
return "Sorbian standard";
case "0000042E":
return "Sorbian standard (legacy)";
case "0000040A":
return "Spanish";
case "0001040A":
return "Spanish variation";
case "0000041D":
return "Swedish";
case "0000083B":
return "Swedish with sami";
case "00000807":
return "Swiss german";
case "0000100C":
return "Swiss french";
case "0000045A":
return "Syriac";
case "0001045A":
return "Syriac phonetic";
case "00000428":
return "Tajik";
case "00000449":
return "Tamil";
case "00000444":
return "Tatar";
case "0000044A":
return "Telugu";
case "0000041E":
return "Thai Kedmanee";
case "0002041E":
return "Thai Kedmanee (non-shiftlock)";
case "0001041E":
return "Thai Pattachote";
case "0003041E":
return "Thai Pattachote (non-shiftlock)";
case "00000451":
return "Tibetan (prc)";
case "0001041F":
return "Turkish F";
case "0000041F":
return "Turkish Q";
case "00000442":
return "Turkmen";
case "00000422":
return "Ukrainian";
case "00020422":
return "Ukrainian (enhanced)";
case "00000809":
return "United Kingdom";
case "00000452":
return "United Kingdom Extended";
case "00000409":
return "United States";
case "00010409":
return "United States - dvorak";
case "00030409":
return "United States - dvorak left hand";
case "00050409":
return "United States - dvorak right hand";
case "00004009":
return "United States - india";
case "00020409":
return "United States - international";
case "00000420":
return "Urdu";
case "00010480":
return "Uyghur";
case "00000480":
return "Uyghur (legacy)";
case "00000843":
return "Uzbek cyrillic";
case "0000042A":
return "Vietnamese";
case "00000485":
return "Yakut";
case "0000046A":
return "Yoruba";
case "00000488":
return "Wolof";
ByVal is a VB keyword that specifies a variable to be passed as a parameter BY VALUE. In other words, if the function or sub changes the value of the internal variable, it does not change the value of the external variable that was passed to it.
4/25/2007 3:19:55 AM - josep1er@cmich.edu-141.209.229.179
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).