如题

解决方案 »

  1.   

    可以用Menu APIMenuHandle = GetMenu( frm.Hwnd )
    GetAllMenu MenuHandlePrivate Sub GetAllMenu(ByVal hMenu As Long)
        Dim nItemID As Long
        Dim nItemIDCount As Long
        Dim nIndex As Long
        Dim cMenuItemInfo As MENUITEMINFO    If nSystemMenu = hMenu Then Exit Sub
        
        With cMenuItemInfo
            .cbSize = Len(cMenuItemInfo)
            .fMask = MIIM_FTYPE Or MIIM_SUBMENU Or MIIM_ID
        End With
        nItemIDCount = GetMenuItemCount(hMenu)
        
        For nIndex = 0 To nItemIDCount - 1
            GetMenuItemInfo hMenu, nIndex, True, cMenuItemInfo
            If cMenuItemInfo.hSubMenu <> 0 Then
                GetAllMenu cMenuItemInfo.hSubMenu
            End If
            GetMenuString hMenu, hMenuID, sTmp, MAX_PATH, 0
            ' 得到菜单标题
            GetCaption = left(sTmp, InStr(1, sTmp, Chr(0)) - 1)
        Next
        
    End Sub
      

  2.   

    如果是别的程序,先用 FindWindow 找到窗口句柄,其他的一样