public static System.Drawing.Icon GetSmallIcon(string file) { ShellIcon.SHFILEINFO shinfo = new ShellIcon.SHFILEINFO(); IntPtr hImgSmall = ShellIcon.Win32.SHGetFileInfo(file, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), ShellIcon.Win32.SHGFI_ICON | ShellIcon.Win32.SHGFI_SMALLICON); if (shinfo.hIcon != IntPtr.Zero) { System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon); return myIcon; } return null; }
public static extern IntPtr SHGetFileInfo( string pszPath, uint dwFileAttributes, ref ShellIcon.SHFILEINFO psfi, uint cbFileInfo, uint uFlags);