I'm trying since 2 days to get the user's keyboard type (QWERTY or AZERTY) in C#. I thought about doing it with CultureInfo (localization), but that's definitely not a great workaround.
Any idea?
There's a GetKeyboardLayout method you can use;
public class Program
{
const int KL_NAMELENGTH = 9;
[DllImport("user32.dll")]
private static extern long GetKeyboardLayoutName(
System.Text.StringBuilder pwszKLID);
static void Main(string[] args)
{
StringBuilder name = new StringBuilder(KL_NAMELENGTH);
GetKeyboardLayoutName(name);
Console.WriteLine(name);
}
}
Source; Keyboard Type (Qwerty or Dvorak) detection
MSDN; http://msdn.microsoft.com/en-us/library/windows/desktop/ms646298(v=vs.85).aspx