简体   繁体   English

提取分配给文件的正确16x16图标?

[英]Extract a correct 16x16 icon assigned to a file?

I tied SHGetFileInfo and ExtractIconEx, both return a normal 32x32 icon and 16x16 with only 16 colors, and it looks awful. 我绑了SHGetFileInfo和ExtractIconEx,它们都返回一个普通的32x32图标和16x16只有16种颜色,看起来很糟糕。 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);

I tried this example link text and works.....got 16*16 with alpha channel. 我尝试了这个示例链接文本和工作.....得到16 * 16与alpha通道。 Try it. 试试吧。

Did you tried the following? 你试过以下了吗?

Icon LargeIcon = Icon.ExtractAssociatedIcon(fileName);
Icon SmallIcon = new Icon(LargeIcon, 16, 16);

您可以在此处找到有用的操作方法: http//support.microsoft.com/?scid = kb; en -us; 319350&x = 14&y = 9

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM