我试图获取 windows
的当前键盘语言语言栏:
我的代码:
Private Sub Form1_InputLanguageChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.InputLanguageChangedEventArgs) Handles Me.InputLanguageChanged
Me.Text = e.InputLanguage.LayoutName
End Sub
此代码只能使用表单语言
我想从语言栏中获取当前的 windows 语言。
我是否需要使用user32.dll?
答案 0 :(得分:0)
修改强>
更改了代码以调用PInvoke GetKeyboardLayoutName(...)。不幸的是,这只是一个数字 - 仍在努力检索正确的名称。
Imports System.Runtime.InteropServices
Imports System.Text
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim sb As New StringBuilder
If GetKeyboardLayoutName(sb) Then
Me.Text = sb.ToString()
End If
End Sub
<DllImport("user32.dll", CharSet:=CharSet.Unicode)>
Private Shared Function GetKeyboardLayoutName(pwszKLID As StringBuilder) As Boolean
End Function