BExplorer.Shell.ShellContextMenu.RemoveDuplicatedSeparators C# (CSharp) Method

RemoveDuplicatedSeparators() private method

private RemoveDuplicatedSeparators ( ContextMenu mnu ) : void
mnu System.Windows.Forms.ContextMenu
return void
    private void RemoveDuplicatedSeparators(ContextMenu mnu) {
      var duplicatedSeparators = new List<int>();
      int newCount = User32.GetMenuItemCount(mnu.Handle);
      for (int i = 0; i < newCount - 1; i++) {
        var info = new MENUITEMINFO();
        info.cbSize = (uint)Marshal.SizeOf(info);
        info.fMask = MIIM.MIIM_FTYPE | MIIM.MIIM_DATA | MIIM.MIIM_STRING | MIIM.MIIM_SUBMENU;
        if (User32.GetMenuItemInfo(mnu.Handle, i, true, ref info)) {
          var isSep = (info.fType & 2048) != 0;
          if (isSep) {
            var info2 = new MENUITEMINFO();
            info2.cbSize = (uint)Marshal.SizeOf(info2);
            info2.fMask = MIIM.MIIM_FTYPE | MIIM.MIIM_DATA | MIIM.MIIM_STRING | MIIM.MIIM_SUBMENU;
            if (User32.GetMenuItemInfo(mnu.Handle, i + 1, true, ref info2)) {
              var isSep2 = (info2.fType & 2048) != 0;
              if (isSep2) {
                duplicatedSeparators.Add(i + 1);
              }
            }
          }
        }
      }
      duplicatedSeparators.Reverse();
      duplicatedSeparators.ForEach(a => User32.DeleteMenu(mnu.Handle, a, MF.MF_BYPOSITION));
    }
    private void RemoveDefaultExplorerItems(ContextMenu mnu, Control control, ref MENUITEMINFO itemInfo) {