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

GetOpenWithContextMenu() public method

public GetOpenWithContextMenu ( IListItemEx itemArray, IntPtr &iContextMenuPtr, IContextMenu &iContextMenu ) : bool
itemArray IListItemEx
iContextMenuPtr System.IntPtr
iContextMenu IContextMenu
return bool
    public bool GetOpenWithContextMenu(IListItemEx[] itemArray, out IntPtr iContextMenuPtr, out IContextMenu iContextMenu) {
      Guid CLSID_OpenWith = new Guid(0x09799AFB, 0xAD67, 0x11d1, 0xAB, 0xCD, 0x00, 0xC0, 0x4F, 0xC3, 0x09, 0x36);
      Guid iicm = typeof(IContextMenu).GUID;
      Guid iise = typeof(IShellExtInit).GUID;
      if (Ole32.CoCreateInstance(
              ref CLSID_OpenWith,
              IntPtr.Zero,
              Ole32.CLSCTX.INPROC_SERVER,
              ref iicm,
              out iContextMenuPtr) == (int)HResult.S_OK) {
        iContextMenu = Marshal.GetObjectForIUnknown(iContextMenuPtr) as IContextMenu;

        IntPtr iShellExtInitPtr;
        if (Marshal.QueryInterface(
            iContextMenuPtr,
            ref iise,
            out iShellExtInitPtr) == (int)HResult.S_OK) {
          IShellExtInit iShellExtInit = Marshal.GetTypedObjectForIUnknown(iShellExtInitPtr, typeof(IShellExtInit)) as IShellExtInit;

          try {
            IntPtr doPtr;
            iShellExtInit.Initialize(IntPtr.Zero, itemArray.GetIDataObject(out doPtr), 0);

            Marshal.ReleaseComObject(iShellExtInit);
            Marshal.Release(iShellExtInitPtr);
            return true;
          } finally {

          }
        } else {
          if (iContextMenu != null) {
            Marshal.ReleaseComObject(iContextMenu);
            iContextMenu = null;
          }

          return false;
        }
      } else {
        iContextMenuPtr = IntPtr.Zero;
        iContextMenu = null;
        return false;
      }
    }