public static int compareIDs(Object pParentIShellFolder, IntPtr pidl1, IntPtr pidl2) { if (pParentIShellFolder == null) { return(0); } ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pParentIShellFolder; return(folder.CompareIDs(0, pidl1, pidl2)); }
/// <summary> /// Returns an IShellFolder for the desktop /// </summary> public static Object initDesktopFolder() { ShellApi.IShellFolder rootShell = null; // get the root shell folder ShellApi.SHGetDesktopFolder(ref rootShell); return(rootShell); }
public static Object bindToObject(Object parentIShellFolder, IntPtr pIDL) { if (parentIShellFolder == null || pIDL == IntPtr.Zero) { return(null); } ShellApi.IShellFolder folder = (ShellApi.IShellFolder)parentIShellFolder; ShellApi.IShellFolder newFolder = null; folder.BindToObject(pIDL, IntPtr.Zero, ref ShellApi.GUID_ISHELLFOLDER, out newFolder); return(newFolder); }
public static int getAttributes0(Object pParentIShellFolder, IntPtr pIDL, int attrsMask) { if (pParentIShellFolder == null || pIDL == IntPtr.Zero) { return(0); } ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pParentIShellFolder; ShellApi.SFGAOF[] atts = new ShellApi.SFGAOF[] { (ShellApi.SFGAOF)attrsMask }; IntPtr[] pIDLs = new IntPtr[] { pIDL }; folder.GetAttributesOf(1, pIDLs, atts); return((int)atts[0]); }
/// <summary> /// Parses the displayname of a child of a given folder /// </summary> /// <param name="pIShellFolder">The IShellFolder to get the chilf of</param> /// <param name="name">The display name of the child</param> /// <returns>the relative pIDL of the child or IntPrt.Zero in case there is no such child</returns> public static IntPtr parseDisplayName0(Object pIShellFolder, String name) { if (pIShellFolder == null) { return(IntPtr.Zero); } ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pIShellFolder; IntPtr pIDL = new IntPtr(); uint pchEaten; uint pdwAttribute = 0; folder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, name, out pchEaten, out pIDL, ref pdwAttribute); return(pIDL); }
/// <summary> /// Creates an IShellFolder for a special folder /// </summary> /// <param name="desktopIShellFolder">The IShellFolder instance of the Desktop</param> /// <param name="pidl">The desktop relative pIDL of the special folder</param> /// <returns>The IShellFolder for a special folder</returns> public static Object initSpecialFolder(Object desktopIShellFolder, IntPtr pidl) { try { // get desktop instance ShellApi.IShellFolder desktop = (ShellApi.IShellFolder)desktopIShellFolder; // call BindToObject of the desktop ShellApi.IShellFolder specialFolder = null; desktop.BindToObject(pidl, IntPtr.Zero, ref ShellApi.GUID_ISHELLFOLDER, out specialFolder); return(specialFolder); } catch (System.ArgumentException) { return(0); } }
public static Object getEnumObjects(Object pIShellFolder, Boolean isDesktop, Boolean includeHiddenFiles) { if (pIShellFolder == null) { return(null); } ShellApi.IShellFolder folder = (ShellApi.IShellFolder)pIShellFolder; ShellApi.SHCONTF flags = ShellApi.SHCONTF.SHCONTF_FOLDERS | ShellApi.SHCONTF.SHCONTF_NONFOLDERS; if (includeHiddenFiles) { flags |= ShellApi.SHCONTF.SHCONTF_INCLUDEHIDDEN; } ShellApi.IEnumIDList list = null; folder.EnumObjects(IntPtr.Zero, flags, out list); return(list); }
public static String getDisplayNameOf(Object parentIShellFolder, IntPtr relativePIDL, int attrs) { if (parentIShellFolder == null || relativePIDL == IntPtr.Zero) { return(null); } ShellApi.IShellFolder folder = (ShellApi.IShellFolder)parentIShellFolder; ShellApi.STRRET result; uint hRes = folder.GetDisplayNameOf(relativePIDL, (ShellApi.SHGDN)attrs, out result); if (hRes == 0) { StringBuilder name = new StringBuilder(1024); StrRetToBuf(ref result, relativePIDL, name, 1024); string stringName = name.ToString(); return(stringName); } return(null); }
public static IntPtr extractIcon(Object parentIShellFolder, IntPtr relativePIDL, Boolean getLargeIcon) { if (parentIShellFolder == null || relativePIDL == IntPtr.Zero) { return(IntPtr.Zero); } ShellApi.IShellFolder folder = (ShellApi.IShellFolder)parentIShellFolder; Guid guid = new Guid("000214fa-0000-0000-c000-000000000046"); object ppv; if (folder.GetUIObjectOf(IntPtr.Zero, 1, new IntPtr[] { relativePIDL }, ref guid, IntPtr.Zero, out ppv) == 0) { ShellApi.IExtractIcon extractor = (ShellApi.IExtractIcon)ppv; int size = 1024; StringBuilder path = new StringBuilder(size); int piIndex; uint pwFlags; if (extractor.GetIconLocation((uint)ShellApi.GIL.GIL_FORSHELL, path, size, out piIndex, out pwFlags) == 0) { IntPtr hIconL = new IntPtr(); IntPtr hIconS = new IntPtr(); if (extractor.Extract(path.ToString(), (uint)piIndex, out hIconL, out hIconS, (16 << 16) + 32) == 0) { if (getLargeIcon) { ShellApi.DestroyIcon(hIconS); return(hIconL); } else { ShellApi.DestroyIcon(hIconL); return(hIconS); } } } } return(IntPtr.Zero); }