Chapter 5. Icon Handlers
Icons are defined for a particular file class by adding a
DefaultIcon key under the files association key in
the registry. DefaultIcon is then set to a path
containing the .exe or .dll
that contains the icon to be displayed and the zero-based index of
that icon within the file, if multiple icons are present. Figure 5.1, for example, shows the relevant registry keys
for our example .rad file type, which is
configured to use the second icon in
notepad.exe. Every icon for the file class in
question will have the same icon when this key is registered.
Figure 5-1. Registering the default icon for a file class
Icon handlers allow file objects of the
same type to display different icons on a per-instance basis. This
means that such things as the value of particular file attributes or
state information internal to the file can be conveyed to the user
through the shell. Take the .rad file, for
instance. Using an icon handler, we could display a picture of the
animal represented by the file (for a limited number of animals, of
course), the age of the animal, the gender, or whatever.
How Icon Handlers Work
Icon handlers are required to implement
two interfaces: IPersistFile and
IExtractIcon. These interfaces are interesting
from a programmatic standpoint for several reasons.
IPersistFile is not directly derived from
IUnknown; it’s derived from
IPersist. And as luck ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access