public static int PopUpSystemContextMenu(IDLWrapper idlw, Point pntShow, ref IContextMenu2 pIContextMenu2, IntPtr hwndParent, bool fCanRemove) { IShellFolder ppv = null; int num5; try { IntPtr ptr; if ((!idlw.Available || (PInvoke.SHBindToParent(idlw.PIDL, ExplorerGUIDs.IID_IShellFolder, out ppv, out ptr) != 0)) || (ppv == null)) { return(-1); } IntPtr[] apidl = new IntPtr[] { ptr }; uint rgfReserved = 0; Guid riid = ExplorerGUIDs.IID_IContextMenu; object obj2; ppv.GetUIObjectOf(IntPtr.Zero, (uint)apidl.Length, apidl, ref riid, ref rgfReserved, out obj2); if (pIContextMenu2 != null) { Marshal.ReleaseComObject(pIContextMenu2); pIContextMenu2 = null; } pIContextMenu2 = obj2 as IContextMenu2; if (pIContextMenu2 == null) { return(-2); } ContextMenu menu = new ContextMenu(); uint uFlags = 0; if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { uFlags |= 0x100; } pIContextMenu2.QueryContextMenu(menu.Handle, 0, 1, 0xffff, uFlags); if (fCanRemove) { PInvoke.AppendMenu(menu.Handle, 0x800, IntPtr.Zero, null); PInvoke.AppendMenu(menu.Handle, 0, new IntPtr(0xffff), QTUtility.ResMain[0x19]); } if ((idlw.HasPath && (idlw.Path.Length > 3)) && (idlw.IsFileSystemFolder || idlw.IsFileSystemFile)) { if (!fCanRemove) { PInvoke.AppendMenu(menu.Handle, 0x800, IntPtr.Zero, null); } PInvoke.AppendMenu(menu.Handle, 0, new IntPtr(0xfffe), QTUtility.ResMain[0x1a]); } uint num3 = PInvoke.TrackPopupMenu(menu.Handle, 0x100, pntShow.X, pntShow.Y, 0, hwndParent, IntPtr.Zero); int num4 = -3; switch (num3) { case 0: num4 = 0xfffd; break; case 0xffff: menu.Dispose(); return(0xffff); case 0xfffe: if (idlw.HasPath) { try { string directoryName = Path.GetDirectoryName(idlw.Path); if (Directory.Exists(directoryName)) { IntPtr currentHandle = QTUtility.instanceManager.CurrentHandle; if (PInvoke.IsWindow(currentHandle)) { QTUtility2.SendCOPYDATASTRUCT(currentHandle, (IntPtr)0x10, directoryName, IntPtr.Zero); num4 = 0xfffe; } else { Process.Start(directoryName); num4 = -4; } } } catch { SystemSounds.Asterisk.Play(); } } break; default: { CMINVOKECOMMANDINFO structure = new CMINVOKECOMMANDINFO(); structure.cbSize = Marshal.SizeOf(structure); structure.fMask = 0; structure.hwnd = hwndParent; structure.lpVerb = (IntPtr)((num3 - 1) & 0xffff); structure.lpParameters = IntPtr.Zero; structure.lpDirectory = IntPtr.Zero; structure.nShow = 1; structure.dwHotKey = 0; structure.hIcon = IntPtr.Zero; num4 = pIContextMenu2.InvokeCommand(ref structure); break; } } menu.Dispose(); num5 = num4; } catch { num5 = -1; } finally { if (ppv != null) { Marshal.ReleaseComObject(ppv); } } return(num5); }