SHCreateShellItem() private method

private SHCreateShellItem ( IntPtr pidlParent, [ psfParent, IntPtr pidl, [ ppsi ) : int
pidlParent System.IntPtr
psfParent [
pidl System.IntPtr
ppsi [
return int
        /// <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 #2
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);
            }
        }