Board index » delphi » Associated File icon

Associated File icon

How do I set the icon Windows uses for associated files? By default, it seems that window shrinks the Icon of the application by a few pixels, than pastes it ontop of a "blank" page icon. Can I override this with my own set of Icons? Different Icons even for different file extensions?

-BKN

 

Re:Associated File icon


Quote
> How do I set the icon Windows uses for associated files? By default, it seems that window shrinks the Icon of the application by a few pixels, than pastes it ontop of a "blank" page icon. Can I override this with my own set of Icons? Different Icons even for different file extensions?

Take a look at the registry, this information is stored in
HKEY_CLASSES_ROOT. You need two keys:

One (create this one first) to describe the file type (how is the file
type opened, what icon is used), it's saved in a key with a unique name
which does NOT start with a dot and holds a subkey named 'DefaultIcon',
where the filename to this icon and the icon number is stored (simply
look at existing entries, it's easy to understand, but not all entries
have a DefaultIcon subkey).

A second one (or more than one) that starts with a dot and equals the
file extension(s) you want to register. It holds nothing than the file
type name (you have just created) and optionally a content type
information.

Changes take place when Windows is restarted. If you cannot wait that
long use
SHChangeNotify (SHCNE_ASSOCCHANGED,SHCNF_IDLIST,NIL,NIL);

Jens

Other Threads