public static List <MenuItem> GetMenuItems(IntPtr hMenu) { List <MenuItem> mil = new List <MenuItem>(); for (int i = 0; i < WindowsAPI.GetMenuItemCount(hMenu); i++) { byte[] s = new byte[20]; MenuControllerUnmanaged.GetMenuItemString(hMenu, i, s); StringBuilder sb = new StringBuilder(20); for (int j = 0; j < s.Length; j++) { char c = Convert.ToChar(s[j]); if (c == '\t') { break; } if (c != '\0' && c != '&') { sb.Append(Convert.ToChar(s[j])); } } MenuItem mi = new MenuItem(); mi.hMenu = hMenu; mi.text = sb.ToString().Trim(); mi.isToggle = MenuControllerUnmanaged.IsCheckMarksItem(hMenu, i); mi.isDisabled = MenuControllerUnmanaged.IsDisabled(hMenu, i); mil.Add(mi); } return(mil); }
public static void ClickMenuItem(IntPtr hMenu, int index, int hWnd) { MenuControllerUnmanaged.ClickMenuItem(hWnd, hMenu, index); }