如何使用SHELL32.DLL中的图像在我的C#项目? [英] How can I use the images within shell32.dll in my C# project?
本文介绍了如何使用SHELL32.DLL中的图像在我的C#项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用SHELL32.DLL中的图像在我的C#项目?
How can I use the images within shell32.dll in my C# project?
推荐答案
您可以从这个code DLL中提取图标:
You can extract icons from a DLL with this code:
public class IconExtractor
{
public static Icon Extract(string file, int number, bool largeIcon)
{
IntPtr large;
IntPtr small;
ExtractIconEx(file, number, out large, out small, 1);
try
{
return Icon.FromHandle(largeIcon ? large : small);
}
catch
{
return null;
}
}
[DllImport("Shell32.dll", EntryPoint = "ExtractIconExW", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons);
}
...
form.Icon = IconExtractor.Extract("shell32.dll", 42, true);
当然,你需要知道图像的DLL中的指数...
Of course you need to know the index of the image in the DLL...
这篇关于如何使用SHELL32.DLL中的图像在我的C#项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文