Reputation: 4956
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.
Here's the exact C# fragment:
ImageList.Images.Add("Folder", ExtractSystemIconBitmap("imageres.dll", 4));
ImageList.Images.Add("File", ExtractSystemIconBitmap("imageres.dll", 2));
On my Windows 10 it looks OK, but will it work with different Windows versions like Vista, 7, 8 and 8.1?
My program will require at least Windows Vista to run (due to dependency on .NET Framework 4.5).
More precise question is - are those icon indexes constant from Windows Vista to Windows 10? If not - what would be a better approach?
Upvotes: 1
Views: 1943
Reputation: 45173
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.
If you want the system's current folder icons (which may not be the standard ones due to user customization), use SHGetFileInfo
.
Upvotes: 7