Extract a correct 16x16 icon assigned to a file?

Posted by a-g on Stack Overflow See other posts from Stack Overflow or by a-g
Published on 2009-07-06T10:01:57Z Indexed on 2010/05/26 13:51 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

I tied SHGetFileInfo and ExtractIconEx, both return a normal 32x32 icon and 16x16 with only 16 colors, and it looks awful. How do I extract a full color icon?

My code

SHFILEINFO shinfo = new SHFILEINFO();
IntPtr hImgSmall = SHGetFileInfo(fileName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON);
Icon icon = (Icon)System.Drawing.Icon.FromHandle(shinfo.hIcon).Clone();
DestroyIcon(shinfo.hIcon);

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET