我正在尝试从imageres.dll中提取图标,具体来说是“My Computer”或“This PC”图标。问题在于,在Win7和Win10之间,图标编号会发生变化。然而,图标组不会变(109)。有没有一种方法可以获取该图标组,然后让计算机决定使用该组中的哪个图标,就像它确定我的应用程序使用哪个图标一样?
以下是我使用的代码以通过索引获取特定图标:
谢谢。
以下是我使用的代码以通过索引获取特定图标:
public class GetIcon {
public static Icon Extract(string file, int number) {
IntPtr large;
IntPtr small;
ExtractIconEx(file, number, out large, out small, 1);
try {
return Icon.FromHandle(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);
}
谢谢。