Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Long, lpMenuItemInfo As MENUITEMINFO) As Long
Private Sub Command1_Click()
Dim strMenu As MENUITEMINFO
Dim hwdMenu As Long, hwdSubMenu As Long
hwdMenu = GetMenu(hwnd)
hwdSubMenu = GetSubMenu(hwdMenu, 0)
MsgBox GetMenuItemCount(hwdSubMenu)
End Sub