Beispiel #1
0
        /// <summary>
        /// Constructs a new Shell object from IDList pointer
        /// </summary>
        /// <param name="idListPtr"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static ShellObject Create(IntPtr idListPtr, ShellContainer parent)
        {
            int retCode = COMNative.Shell.Shell.SHCreateShellItem(
                IntPtr.Zero,
                parent.NativeShellFolder,
                idListPtr, out IShellItem nativeShellItem);

            return(CoreErrorHelper.Succeeded(retCode) ? Create(nativeShellItem) : null);
        }
Beispiel #2
0
        internal ShellFolderItems(ShellContainer nativeShellFolder)
        {
            this.nativeShellFolder = nativeShellFolder;

            HResult hr = nativeShellFolder.NativeShellFolder.EnumObjects(
                IntPtr.Zero,
                ShellFolderEnumerationOptions.Folders | ShellFolderEnumerationOptions.NonFolders,
                out nativeEnumIdList);

            if (!CoreErrorHelper.Succeeded(hr))
            {
                throw hr == HResult.Canceled ? new System.IO.FileNotFoundException() : throw new ShellException(hr);
            }
        }
        /// <summary>Constructs a new Shell object from IDList pointer</summary>
        /// <param name="idListPtr"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        internal static ShellObject Create(IntPtr idListPtr, ShellContainer parent)
        {
            var retCode = ShellNativeMethods.SHCreateShellItem(
                IntPtr.Zero,
                parent.NativeShellFolder,
                idListPtr, out var nativeShellItem);

            if (!CoreErrorHelper.Succeeded(retCode))
            {
                return(null);
            }

            return(ShellObjectFactory.Create(nativeShellItem));
        }
Beispiel #4
0
        /// <summary>
        /// Constructs a new Shell object from IDList pointer
        /// </summary>
        /// <param name="idListPtr"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        internal static ShellObject Create(IntPtr idListPtr, ShellContainer parent)
        {
            IShellItem nativeShellItem;

            int retCode = ShellNativeMethods.SHCreateShellItem(
                IntPtr.Zero,
                parent.NativeShellFolder,
                idListPtr, out nativeShellItem);

            if (CoreErrorHelper.Succeeded(retCode))
            {
                return(ShellObjectFactory.Create(nativeShellItem));
            }
            else
            {
                // Since this is an internal method, return null instead of throwing an exception.
                // Let the caller know we weren't able to create a valid ShellObject with the given PIDL
                return(null);
            }
        }
Beispiel #5
0
        internal ShellFolderItems(ShellContainer nativeShellFolder)
        {
            this.nativeShellFolder = nativeShellFolder;

            HRESULT hr = nativeShellFolder.NativeShellFolder.EnumObjects(
                IntPtr.Zero,
                ShellNativeMethods.SHCONT.SHCONTF_FOLDERS | ShellNativeMethods.SHCONT.SHCONTF_NONFOLDERS,
                out nativeEnumIdList);


            if (!CoreErrorHelper.Succeeded((int)hr))
            {
                if (hr == HRESULT.E_ERROR_CANCELLED)
                {
                    throw new System.IO.FileNotFoundException( );
                }
                else
                {
                    Marshal.ThrowExceptionForHR((int)hr);
                }
            }
        }