Reputation: 32133
I'm creating a file manager in VB.NET. I included some icons in the project resources of my application. How can I make it possible for my users to change the icons of files on their desktop, documents, etc. with the icons I have included in VB.NET?
Upvotes: 0
Views: 986
Reputation: 408
"With the above infrastructure in place and with support for the most complicated of all resources, version resource structures, it is possible to extend the library to one of the two dozen other known resource types. We've started with icons.
Extending the library to support icons means implementing the data structures for icon storage and hooking up ResourceInfo callbacks. When ResourceInfo encounters a resource of type 14 (RT_GROUP_ICON), it creates an object of type IconDirectoryResource. The latter creates an IconResource, which loads an DeviceIndependentBitmap.
•An IconDirectoryResource represents RT_GROUP_ICON, a collection of icon resources.
•An IconResource represents a single RT_ICON icon with one or more images.
•An DeviceIndependentBitmap is not a resource, but raw data embedded in the file at an offset defined by the icon resource and represents a single icon bitmap in a .bmp format.
In order to embed an existing icon from a .ico file into an executable (.exe or .dll), we load the .ico file and convert it to a IconDirectoryResource. The structure in a .ico file is similar to the structure of the icon in an executable. The only difference is that the executable headers store the icon ID, while a .ico header contains the offset of icon data. See IconFile and IconFileIcon classes for implementation details. The IconDirectoryResource is written to the target file, then each icon resource is written separately. Note that the current implementation would replace icons with the same Id in the executable, but doesn't delete old icons if you're storing less icon images than the previous number - it probably should since these icons become orphaned.
The ease of extending the library to icons validated our initial design model."
Taken from Ranhiru Cooray's link, for easier viewing purposes. Credit goes to him.
Upvotes: 2