A piece of code:
[DllImport("user32.dll", SetLastError = true)] public static extern ushort GetKeyboardLayout([In] int idThread); [DllImport("user32.dll", SetLastError = true)] public static extern int GetWindowThreadProcessId([In] IntPtr hWnd,[Out, Optional] IntPtr lpdwProcessId); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr GetForegroundWindow(); public static string mss; static ushort GetKeyboardLayout() { return GetKeyboardLayout(GetWindowThreadProcessId(GetForegroundWindow(), IntPtr.Zero)); } Now when i try to get keyboard layout
ushort lang = GetKeyboardLayout(); mss = lang.ToString(); TextBox1.Text = "Первоначальная раскладка: " + mss + "\n"; It does not show Rus or Eng but in figures such as 1049 etc.
How to fix it?