public static void DisableMenuItems(IntPtr menu, IContextMenu contextMenu, string[] disabledCommands, DisabledMethods method) { if (disabledCommands == null || disabledCommands.Length == 0) { return; } foreach (int cmdID in GetMenuItemID(menu, contextMenu, disabledCommands, MenuIDTypes.CommadID)) { if (cmdID != -1) { switch (method) { case DisabledMethods.Remove: ShellAPI.RemoveMenu(menu, (uint)cmdID, ShellAPI.MFT.BYCOMMAND); break; case DisabledMethods.Gray: ShellAPI.EnableMenuItem(menu, (uint)cmdID, ShellAPI.MF_GRAYED); break; case DisabledMethods.Disable: ShellAPI.EnableMenuItem(menu, (uint)cmdID, ShellAPI.MF_DISABLED); break; } } } }