weixin_44866220 2019-04-02 14:51 采纳率: 100%
浏览 530
已采纳

vb 用api函数getmenu和getsubmenu获取vmware菜单返回值为0

图片说明
Option Explicit
Private Declare Function GetMenu Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetMenuItemID Lib "user32.dll" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetSubMenu Lib "user32.dll" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Private Const WM_COMMAND As Long = &H111

Private Sub Command1_Click()

   Dim h1 As Long, h2   As Long, id  As Long
   h1 = FindWindow(vbNullString, "Windows XP Professional - VMware Workstation")

   h2 = GetMenu(h1)          '到这里就不行了,h2返回值是0
   h2 = GetSubMenu(h2, 2)
   id = GetMenuItemID(h2, 1)
   SendMessage h1, WM_COMMAND, id, ByVal 0&

End Sub

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-04-03 00:38
    关注

    说明它的菜单不是windows标准的菜单,而是自己实现的,所以用GetWindow而不是用GetMenu/GetSubMenu

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站