private static Icon GetIcon(string fileName, GetFileIconFlags flags) { SHFILEINFO shinfo = new SHFILEINFO(); IntPtr hImgSmall = Shell32.SHGetFileInfo(fileName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), flags); Icon icon = (Icon)System.Drawing.Icon.FromHandle(shinfo.hIcon).Clone(); User32.DestroyIcon(shinfo.hIcon); return icon; }
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, GetFileIconFlags uFlags);