/// <summary>
        /// Retrieves the IContextMenu for specific items
        /// </summary>
        /// <param name="parent">the parent IShellFolder which contains the items</param>
        /// <param name="pidls">the pidls of the items for which to retrieve the IContextMenu</param>
        /// <param name="icontextMenuPtr">the pointer to the IContextMenu</param>
        /// <param name="iContextMenu">the IContextMenu for the items</param>
        /// <returns>true if the IContextMenu has been retrieved succesfully, false otherwise</returns>
        public static bool GetIContextMenu(
            IShellFolder2 parent,
            IntPtr[] pidls,
            out IntPtr iContextMenuPtr,
            out IContextMenu iContextMenu)
        {
            if (parent.GetUIObjectOf(
                    IntPtr.Zero,
                    (uint)pidls.Length,
                    pidls,
                    ref ShellAPI.IID_IContextMenu,
                    IntPtr.Zero,
                    out iContextMenuPtr) == ShellAPI.S_OK)
            {
                iContextMenu =
                    (IContextMenu)Marshal.GetTypedObjectForIUnknown(
                        iContextMenuPtr, typeof(IContextMenu));

                return(true);
            }
            else
            {
                iContextMenuPtr = IntPtr.Zero;
                iContextMenu    = null;

                return(false);
            }
        }
        private static bool isVistaUp = Environment.OSVersion.Version.Major >= 6; //5 = XP, 6 = Vista

        //http://msdn.microsoft.com/en-us/library/bb761848(VS.85).aspx

        public static bool GetIExtractImage(
            IShellFolder2 parent,
            IntPtr filePidl,
            out IntPtr iExtractImagePtr,
            out IExtractImage iExtractImage)
        {
            if (!isVistaUp)
            {
                throw new NotSupportedException("Require Vista or above.");
            }

            if (parent.GetUIObjectOf(
                    IntPtr.Zero,
                    1,
                    new IntPtr[] { filePidl },
                    ref ShellAPI.IID_IExtractImage,
                    IntPtr.Zero,
                    out iExtractImagePtr) == ShellAPI.S_OK)
            {
                iExtractImage =
                    (IExtractImage)Marshal.GetTypedObjectForIUnknown(
                        iExtractImagePtr, typeof(IExtractImage));

                return(true);
            }
            else
            {
                iExtractImagePtr = IntPtr.Zero;
                iExtractImage    = null;

                return(false);
            }
        }
Ejemplo n.º 3
0
        //http://msdn.microsoft.com/en-us/library/bb761848(VS.85).aspx

        public static bool GetIExtractImage(
            IShellFolder2 parent,
            IntPtr filePidl,
            out IntPtr iExtractImagePtr,
            out IExtractImage iExtractImage)
        {
            if (parent.GetUIObjectOf(
                    IntPtr.Zero,
                    1,
                    new IntPtr[] { filePidl },
                    ref ShellAPI.IID_IExtractImage,
                    IntPtr.Zero,
                    out iExtractImagePtr) == ShellAPI.S_OK)
            {
                iExtractImage =
                    (IExtractImage)Marshal.GetTypedObjectForIUnknown(
                        iExtractImagePtr, typeof(IExtractImage));

                return(true);
            }
            else
            {
                iExtractImagePtr = IntPtr.Zero;
                iExtractImage    = null;

                return(false);
            }
        }
Ejemplo n.º 4
0
        //http://msdn.microsoft.com/en-us/library/bb761848(VS.85).aspx
        public static bool GetIExtractImage(
           IShellFolder2 parent,
            IntPtr filePidl,
           out IntPtr iExtractImagePtr,
           out IExtractImage iExtractImage)
        {
            if (parent.GetUIObjectOf(
                        IntPtr.Zero,
                        1,
                        new IntPtr[] { filePidl },
                        ref ShellAPI.IID_IExtractImage,
                        IntPtr.Zero,
                        out iExtractImagePtr) == ShellAPI.S_OK)
            {
                iExtractImage =
                    (IExtractImage)Marshal.GetTypedObjectForIUnknown(
                        iExtractImagePtr, typeof(IExtractImage));

                return true;
            }
            else
            {
                iExtractImagePtr = IntPtr.Zero;
                iExtractImage = null;

                return false;
            }
        }
Ejemplo n.º 5
0
 public int GetUIObjectOf(IntPtr hwndOwner, uint cidl, IntPtr[] apidl, ref Guid riid, IntPtr rgfReserved, out IntPtr ppv)
 {
     checkDisposed();
     return(_iShellFolder2.GetUIObjectOf(hwndOwner, cidl, apidl, ref riid, rgfReserved, out ppv));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Retrieves the IContextMenu for specific items
        /// </summary>
        /// <param name="parent">the parent IShellFolder which contains the items</param>
        /// <param name="pidls">the pidls of the items for which to retrieve the IContextMenu</param>
        /// <param name="icontextMenuPtr">the pointer to the IContextMenu</param>
        /// <param name="iContextMenu">the IContextMenu for the items</param>
        /// <returns>true if the IContextMenu has been retrieved succesfully, false otherwise</returns>
        public static bool GetIContextMenu(
            IShellFolder2 parent,
            IntPtr[] pidls,
            out IntPtr iContextMenuPtr,
            out IContextMenu iContextMenu)
        {
            if (parent.GetUIObjectOf(
                        IntPtr.Zero,
                        (uint)pidls.Length,
                        pidls,
                        ref ShellAPI.IID_IContextMenu,
                        IntPtr.Zero,
                        out iContextMenuPtr) == ShellAPI.S_OK)
            {
                iContextMenu =
                    (IContextMenu)Marshal.GetTypedObjectForIUnknown(
                        iContextMenuPtr, typeof(IContextMenu));

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

                return false;
            }
        }
Ejemplo n.º 7
0
        //http://msdn.microsoft.com/en-us/library/bb761848(VS.85).aspx
        public static bool GetIExtractImage(
           IShellFolder2 parent,
            IntPtr filePidl,
           out IntPtr iExtractImagePtr,
           out IExtractImage iExtractImage)
        {
            if (!isVistaUp)
                throw new NotSupportedException("Require Vista or above.");

            if (parent.GetUIObjectOf(
                        IntPtr.Zero,
                        1,
                        new IntPtr[] { filePidl },
                        ref ShellAPI.IID_IExtractImage,
                        IntPtr.Zero,
                        out iExtractImagePtr) == ShellAPI.S_OK)
            {
                iExtractImage =
                    (IExtractImage)Marshal.GetTypedObjectForIUnknown(
                        iExtractImagePtr, typeof(IExtractImage));

                return true;
            }
            else
            {
                iExtractImagePtr = IntPtr.Zero;
                iExtractImage = null;

                return false;
            }
        }