我可以信任 imageres.dll 系统图标索引吗? [英] Can I trust imageres.dll system icons indexes?
问题描述
我制作了一个自定义目录树控件,它使用从 imageres.dll
文件中提取的系统图标.我的意思是该文件是从 Windows 目录中读取的,因此根据 Windows 版本,该文件会有多个版本.
I made a custom directory tree control which uses system icons extracted from imageres.dll
file. I mean the file is read from Windows directory, so there will be multiple versions of the file depending on Windows versions.
这是确切的 C# 片段:
Here's the exact C# fragment:
ImageList.Images.Add("Folder", ExtractSystemIconBitmap("imageres.dll", 4));
ImageList.Images.Add("File", ExtractSystemIconBitmap("imageres.dll", 2));
在我的 Windows 10 上它看起来不错,但它是否适用于不同的 Windows 版本,如 Vista、7、8 和 8.1?
On my Windows 10 it looks OK, but will it work with different Windows versions like Vista, 7, 8 and 8.1?
我的程序至少需要 Windows Vista 才能运行(由于依赖于 .NET Framework 4.5).
My program will require at least Windows Vista to run (due to dependency on .NET Framework 4.5).
更准确的问题是 - 从 Windows Vista 到 Windows 10,这些图标索引是否保持不变?如果没有 - 什么是更好的方法?
More precise question is - are those icon indexes constant from Windows Vista to Windows 10? If not - what would be a better approach?
推荐答案
获取图标的正确方法是使用 SHGetStockIconInfo
.它会告诉您图标在当前版本的 Windows 中的位置.
The correct way to get the icons is to use SHGetStockIconInfo
. It will tell you where the icon is in the current version of Windows.
如果你想要系统的当前文件夹图标(由于用户自定义可能不是标准的),使用SHGetFileInfo
.
If you want the system's current folder icons (which may not be the standard ones due to user customization), use SHGetFileInfo
.
这篇关于我可以信任 imageres.dll 系统图标索引吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!