GetMenuItemCount function determines the number of items in the specified menu. This is a simple wrapper around Win32 function.
$mcount = GetMenuItemCount( $hmenu );
Handle to the menu to be examined
Number of items in the menu