internal ShellItem(ShellBrowser browser, ShellAPI.CSIDL specialFolder) { IntPtr pidl = IntPtr.Zero; ShellAPI.SHGetSpecialFolderLocation(IntPtr.Zero, specialFolder, out pidl); // IntPtr shellFolderPtr; this.browser = browser; // if (specialFolder == ShellAPI.CSIDL.DESKTOP) { ShellAPI.SHGetDesktopFolder(out shellFolderPtr); // this.shellFolderPtr = shellFolderPtr; this.shellFolder = (IShellFolder)Marshal.GetTypedObjectForIUnknown(shellFolderPtr, typeof(IShellFolder)); } else { this.shellFolder = GetShellFolderFromPidl(pidl, out shellFolderPtr); // this.parentItem = browser.DesktopItem; } // subFiles = new ShellItemCollection(this); subFolders = new ShellItemCollection(this); pidlRel = new PIDL(pidl, false); ShellAPI.SHFILEINFO info = new ShellAPI.SHFILEINFO(); ShellAPI.SHGetFileInfo(pidlRel.Ptr, 0, ref info, ShellAPI.cbFileInfo, ShellAPI.SHGFI.PIDL | ShellAPI.SHGFI.TYPENAME | ShellAPI.SHGFI.SYSICONINDEX | ShellAPI.SHGFI.DISPLAYNAME); type = info.szTypeName; text = info.szDisplayName; // StringBuilder pathBuilder = new StringBuilder(ShellAPI.MAX_PATH); ShellAPI.SHGetFolderPath( IntPtr.Zero, specialFolder, IntPtr.Zero, ShellAPI.SHGFP.TYPE_CURRENT, pathBuilder); this.path = pathBuilder.ToString(); // if (specialFolder == ShellAPI.CSIDL.DESKTOP) { ShellImageList.SetIconIndex(this, info.iIcon, false); ShellImageList.SetIconIndex(this, info.iIcon, true); // SetAttributesDesktop(this); } else { SetAttributesFolder(this); SetInfo(this); } sortFlag = 1; }
public static extern bool GetMenuItemInfo( IntPtr hMenu, uint uItem, bool fByPos, ref ShellAPI.MENUITEMINFO lpmii);
public static DateTime FileTimeToDateTime(ShellAPI.FILETIME fileTime) { long ticks = (((long)fileTime.dwHighDateTime) << 32) + (long)fileTime.dwLowDateTime; return DateTime.FromFileTimeUtc(ticks); }
internal ShellItem GetSpecialFolderShellItem(ShellAPI.CSIDL rootFolder) { return new ShellItem(this, rootFolder); }