public static SHFILEINFO SHGetFileInfo(PIDLIST pidl, SHGFI flags) { var info = new SHFILEINFO(); SHGetFileInfo(pidl, 0, ref info, Marshal.SizeOf(info), SHGFI.PIDL | flags); return(info); }
public static string StrRetToBuf(ref STRRET pstr, PIDLIST pidl) { var sb = new StringBuilder(MAX_PATH); StrRetToBuf(ref pstr, pidl, sb, sb.Capacity); return(sb.ToString()); }
private ImageSource ExtractIcon(NativeShellFolder shellFolder, PIDLIST pidl, int iconSize, GILI iconFlags) { using (NativeExtractIcon extractIcon = shellFolder.GetUIObjectOf <IExtractIcon>(pidl).ToNative()) { string iconFile; int iconIndex; GILR iconResultFlags; if (!extractIcon.GetIconLocation(iconFlags, out iconFile, out iconIndex, out iconResultFlags).GetValueOrDefault()) { return(null); // TODO return default icon, schedule async icon extraction } HICON hicon; // TODO check cache /*if (!iconResultFlags.Has(GILR.NOTFILENAME)) * Native.PrivateExtractIcons(iconFile, iconIndex, iconSize, out hicon, LR.LOADFROMFILE);*/ if (!extractIcon.Extract(iconFile, iconIndex, (ushort)iconSize, out hicon) && !iconResultFlags.Has(GILR.NOTFILENAME)) { Native.PrivateExtractIcons(iconFile, iconIndex, iconSize, out hicon, LR.LOADFROMFILE); } if (hicon == IntPtr.Zero) { return(null); } return(Native.CreateBitmapSourceFromHIcon(hicon)); } }
internal ShellItem(ShellTree tree, ShellItem parent, PIDLIST pidl, NativeShellFolder shellFolder) { _tree = tree; _parent = parent; _pidl = pidl; _shellFolder = shellFolder; _children = _childrenFiles = _childrenFolders = DummyChildren; UpdateAttrs(SFGAO.HASSUBFOLDER | SFGAO.FILESYSTEM | SFGAO.FILESYSANCESTOR | SFGAO.FOLDER); if (!HasSubFolder) { _childrenFolders = NoChildren; } }
private int GetIconIndex(GILI iconAttrs) { if (_iconIndex != UndefinedIconIndex) { return(_iconIndex); } if (IsDesktop) { using (PIDLIST desktopPidl = Native.SHGetKnownFolderIDList(FOLDERID.Desktop)) return(_iconIndex = Native.SHGetFileInfo(desktopPidl, SHGFI.SYSICONINDEX).iIcon); } Dispatcher.InvokeAsync( () => { int iconIndex; using (NativeShellIcon shellIcon = ParentShellFolder.QueryInterface <IShellIcon>().ToNative()) iconIndex = shellIcon != null ? _tree.IconList.GetIconIndex(shellIcon, _pidl, iconAttrs) : UnindexableIconIndex; Set(ref _iconIndex, iconIndex, "IconSmall", "IconLarge", "IconExtraLarge", "IconJumbo"); }, DispatcherPriority.Background); return(NoIconIndex); }
internal static extern bool ILIsEqual([In] PIDLIST pidl1, [In] PIDLIST pidl2);
internal static extern bool ILIsParent([In] PIDLIST pidl1, [In] PIDLIST pidl2, [In] bool fImmediate);
internal static extern PIDLIST ILGetNext([In] PIDLIST pidl);
internal static extern int ILGetSize([In] PIDLIST pidl);
public ImageSource ExtractIcon(NativeShellFolder shellFolder, PIDLIST pidl, SHIL iconSize, GILI iconFlags) { return(ExtractIcon(shellFolder, pidl, IconSizeToPixels(iconSize), iconFlags)); }
/// <summary>Verifies whether a pointer to an item identifier list (PIDL) is a child PIDL, which is a PIDL with exactly one SHITEMID.</summary> /// <param name="pidl">(PCUIDLIST_RELATIVE) A constant, unaligned, relative PIDL that is being checked.</param> /// <returns>Returns TRUE if the given PIDL is a child PIDL; otherwise, FALSE.</returns> /// <remarks>This function does not guarantee that the PIDL is non-NULL or non-empty.</remarks> internal static bool ILIsChild([In] PIDLIST pidl) { return(ILIsEmpty(pidl) || ILIsEmpty(ILNext(pidl))); }
internal static extern PIDLIST ILCombine([In] PIDLIST pidl1, [In] PIDLIST pidl2);
private static extern IntPtr SHGetFileInfo(PIDLIST pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, SHGFI uFlags);
/// <summary>Skips a given number of bytes in a constant, unaligned, relative ITEMIDLIST structure.</summary> /// <param name="pidl">(PCUIDLIST_RELATIVE | PUIDLIST_RELATIVE) A constant, unaligned, relative PIDL in which bytes are to be skipped.</param> /// <param name="cb">The number of bytes to skip.</param> /// <returns>(PCUIDLIST_RELATIVE | PUIDLIST_RELATIVE) When this function returns, if pidl and cb are valid, contains a constant pointer to the ITEMIDLIST structure that results after the skip. Otherwise, the value is meaningless.</returns> internal static PIDLIST ILSkip([In] PIDLIST pidl, int cb) { return(new PIDLIST(IntPtr.Add(pidl.Handle, cb))); }
internal static extern PIDLIST ILCloneFirst([In] PIDLIST pidl);
/// <summary>Retrieves the next SHITEMID structure in an ITEMIDLIST structure.</summary> /// <param name="pidl">(PCUIDLIST_RELATIVE | PUIDLIST_RELATIVE) A constant, unaligned, relative PIDL for which the next SHITEMID structure is being retrieved.</param> /// <returns>(PCUIDLIST_RELATIVE | PUIDLIST_RELATIVE) When this function returns, contains one of three results: If pidl is valid and not the last SHITEMID in the ITEMIDLIST, then it contains a pointer to the next ITEMIDLIST structure. If the last ITEMIDLIST structure is passed, it contains NULL, which signals the end of the PIDL. For other values of pidl, the return value is meaningless.</returns> /// <remarks>To verify if the return value is NULL, use ILIsEmpty.</remarks> internal static PIDLIST ILNext([In] PIDLIST pidl) { return(ILSkip(pidl, pidl.Cb)); }
internal static extern PIDLIST ILAppendID([In] PIDLIST pidl, [In] PIDLIST pmkid, [In] bool fAppend);
/// <summary>Verifies whether an ITEMIDLIST structure is empty.</summary> /// <param name="pidl">(PCUID_RELATIVE) A pointer to the ITEMIDLIST structure to be checked.</param> /// <returns>TRUE if the pidl parameter is NULL or the ITEMIDLIST structure pointed to by pidl is empty; otherwise FALSE.</returns> internal static bool ILIsEmpty([In] PIDLIST pidl) { return(pidl.Handle == IntPtr.Zero || pidl.Cb == 0); }
internal static extern bool ILRemoveLastID([In, Out] ref PIDLIST pidl);
public int GetIconIndex(NativeShellIcon shellIcon, PIDLIST pidl, GILI iconFlags) { return(shellIcon.GetIconOf(pidl, iconFlags)); }
internal static extern void ILSaveToStream([In] IStream pstm, [In] PIDLIST pidl);
public int GetIconOverlayIndex(NativeShellIconOverlay shellIconOverlay, PIDLIST pidl) { return(shellIconOverlay.GetOverlayIconIndex(pidl)); }
private static extern void SHGetKnownFolderIDList([In, MarshalAs(UnmanagedType.LPStruct)] Guid rfid, [In] KF_FLAG dwFlags, [In] IntPtr hToken, [Out] out PIDLIST ppidl);
/// <summary>Clones a full, or absolute, ITEMIDLIST structure.</summary> /// <param name="pidl">(PCUIDLIST_ABSOLUTE) A pointer to the full, or absolute, ITEMIDLIST structure to be cloned.</param> /// <returns>(PCUIDLIST_ABSOLUTE) A pointer to a copy of the ITEMIDLIST structure pointed to by pidl.</returns> internal static PIDLIST ILCloneFull([In] PIDLIST pidl) { return(ILClone(pidl)); }
internal static extern PIDLIST ILFindChild([In] PIDLIST pidlParent, [In] PIDLIST pidlChild);
/// <summary>Clones a child ITEMIDLIST structure.</summary> /// <param name="pidl">(PCUITEMID_CHILD) A pointer to the child ITEMIDLIST structure to be cloned.</param> /// <returns>(PCUITEMID_CHILD) A pointer to a copy of the child ITEMIDLIST structure pointed to by pidl.</returns> internal static PIDLIST ILCloneChild([In] PIDLIST pidl) { return(ILCloneFirst(pidl)); }
public ImageSource GetIcon(NativeShellIcon shellIcon, PIDLIST pidl, SHIL iconSize, GILI iconFlags) { return(GetIconByIndex(iconSize, GetIconIndex(shellIcon, pidl, iconFlags))); }
internal static extern PIDLIST ILFindLastID([In] PIDLIST pidl);
public ImageSource GetIconOverlay(NativeShellIconOverlay shellIconOverlay, PIDLIST pidl, SHIL iconSize) { return(GetIconByIndex(iconSize, GetIconOverlayIndex(shellIconOverlay, pidl))); }
internal static extern void ILFree([In] PIDLIST pidl);