If it is a system menu-a pop-up menu of program icons, use GetSystemMenu. Get the main menu handle.
If it is a right-click menu, it is mostly a temporary handle, which is not easy to take. Unless it is a handle generated by the implementation, it is used directly when right-clicking. Then we can know the value of this handle.
Gets the number of menu items. Getmenuitemid getmenuiteminfo getmenusting, etc. Is all the data information of the item for which the menu handle is obtained.
GetSubMenu should be the function you want to get the handle to the submenu. For example, if you want to get the submenu of the pop-up menu, use this to get the handle of the submenu. Then, according to the above function of getting sub-items, get sub-menu information.
(See MSND for details. The explanation above is very detailed and there are examples. )