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

发布于 2024-12-07 11:47:36 字数 949 浏览 1 评论 0原文

我想使用我的 VB 应用程序更改已安装的另一个键盘布局的默认键盘布局。我在 google 上搜索了这一点并找到 Function 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)

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

I want to change my default keyboard Layout for a installed another Keyboard Layout using my VB application.I googled about this and find Function LoadKeyboardLayout() Function to do that.But Is this support in vb 2010.When I wrote below code and there is no syntax error.But when I run the program there is an error called "PInvokeStackImbalance was detected... "
How can I solve this in vb 2010.
Here is my code:

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)

Can anyone help me...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

李白 2024-12-14 11:47:36

我认为您所要做的就是将长整型转换为整数......

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

I think all you have to do is switch the longs to integers...

Private Declare Function LoadKeyboardLayout Lib "user32.dll" _ 
Alias "LoadKeyboardLayoutA" ( ByVal pwszKLID As String, _ 
   ByVal flags As Integer) As Integer
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文