/// <summary> /// Returns a Image from a file system path /// </summary> /// <param name="path">The path can be a fully qualified path name, non-existent file, or file extension</param> /// <param name="size">The size of the bitmap to return</param> /// <param name="style">The style of the bitmap to retrieve</param> /// <param name="attributes">Extra attributes to specify for the path</param> /// <returns></returns> public static Image GetImageFromPath(string path, IconSizes size, IconStyles style, FileAttributes attributes) { SHFILEINFO shfi = new SHFILEINFO(); uint uFlags = SHGFI_ICON; uFlags |= (uint)size; uFlags |= (uint)style; if (attributes != 0) { uFlags |= SHGFI_USEFILEATTRIBUTES; } SHGetFileInfo(path, (int)attributes, ref shfi, (uint)Marshal.SizeOf(shfi), uFlags); Image image = (Image)Bitmap.FromHicon(shfi.hIcon).Clone(); DeleteObject(shfi.hIcon); return(image); }
/// <summary> /// Returns a Image from a file system path /// </summary> /// <param name="path">The path can be a fully qualified path name, non-existent file, or file extension</param> /// <param name="size">The size of the bitmap to return</param> /// <param name="style">The style of the bitmap to retrieve</param> /// <param name="attributes">Extra attributes to specify for the path</param> /// <returns></returns> public static Image GetImageFromPath(string path, IconSizes size, IconStyles style, FileAttributes attributes) { SHFILEINFO shfi = new SHFILEINFO(); uint uFlags = SHGFI_ICON; uFlags |= (uint)size; uFlags |= (uint)style; if (attributes != 0) uFlags |= SHGFI_USEFILEATTRIBUTES; SHGetFileInfo(path, (int)attributes, ref shfi, (uint)Marshal.SizeOf(shfi), uFlags); Image image = (Image)Bitmap.FromHicon(shfi.hIcon).Clone(); DeleteObject(shfi.hIcon); return image; }
/// <summary> /// Initializes a new instance of the ShellImageListManager class /// </summary> public ShellImageListManager() { _extensions = new Hashtable(); _size = IconSizes.ShellIconSize; _style = IconStyles.NormalIconStyle; }
/// <summary> /// Initializes a new instance of the ShellImageListManager class /// </summary> protected ShellImageListManager() { _extensions = new Hashtable(); _size = IconSizes.ShellIconSize; _style = IconStyles.NormalIconStyle; }