LoadKeyboardLayout()函数在VB 2010中不起作用

时间:2011-09-30 06:54:25

标签: vb.net keyboard

我想使用我的VB应用程序更改我安装的另一个键盘布局的默认键盘布局。我用Google搜索并找到函数LoadKeyboardLayout()函数来执行此操作。但这是否支持在vb 2010中。当我在下面编写代码时并且没有语法错误。但是当我运行程序时出现一个错误,名为“检测到PInvokeStackImbalance ...” 我怎样才能在vb 2010中解决这个问题。 这是我的代码:

Private Const KLF_ACTIVATE As Long = &H1
Private Const KLF_NOTELLSHELL As Long = &H80
Private Const KLF_REORDER As Long = &H8
Private Const KLF_REPLACELANG As Long = &H10
Private Const KLF_RESET As Long = &H40000000
Private Const KLF_SETFORPROCESS As Long = &H100
Private Const KLF_SHIFTLOCK As Long = &H10000
Private Const KLF_SUBSTITUTE_OK As Long = &H2
Private Const KLF_UNLOADPREVIOUS As Long = &H4

Private Declare Function LoadKeyboardLayout _
Lib "user32.dll" _
Alias "LoadKeyboardLayoutA" ( _
   ByVal pwszKLID As String, _
   ByVal flags As Long) As Long

'Inside a button click event
   LoadKeyboardLayout("00000409", KLF_ACTIVATE)

任何人都可以帮助我......

1 个答案:

答案 0 :(得分:1)

认为你所要做的就是把多头换成整数......

Private Declare Function LoadKeyboardLayout Lib "user32.dll" _ 
Alias "LoadKeyboardLayoutA" ( ByVal pwszKLID As String, _ 
   ByVal flags As Integer) As Integer