Share via


Customizing Icons

Microsoft Windows supplies default icons for every item displayed on the desktop and in Windows Explorer. Mass storage devices, such as disk drives, are also assigned default icons. However, these icons often provide little insight to the user as to the contents of the file or what program is associated with it. You can assign a custom icon to a file system folder by creating a Desktop.ini file. This document discusses how to use the registry to associate custom icons with file classes and drive letters.

  • Assigning a Custom Icon to a File Class
  • Assigning a Custom Icon and Label to a Drive Letter

Assigning a Custom Icon to a File Class

By default, all files are displayed on the desktop and in Windows Explorer with default icons. For example, the following illustration shows this icon used with MyDocs4.xyz.

Default icon

All the files displayed in this screen shot contain ANSI text. The reason that the files with the .txt extension do not display the default icon is that .txt has been registered as a file class and assigned a custom icon.

Assigning a custom icon to a file class is a simple matter. Create a subkey, under the key for the application's ProgID, and name it DefaultIcon . Assign it a REG_SZ value containing the fully qualified path for the file with the icon. Any file containing an icon is acceptable, including .ico, .exe, and .dll files. If there is more than one icon in the file, the path should be followed by a comma, and then the index of the icon.

The following illustration shows a custom icon that has been assigned to the .myp file class, which was also used in the example in File Types. The My Documents directory now looks like this:

Custom icon for .myp files

In this example, the icon is in the c:\MyDir\MyProgram.exe file, with an index of two. The registry entry that assigns the custom icon to all .myp files is as shown here.

HKEY_CLASSES_ROOT

  • .myp

MyProgram.1

(Default) = MyProgram Application

  • DefaultIcon

Finally, call SHChangeNotify to notify the Shell to update its cache.

Assigning a Custom Icon and Label to a Drive Letter

For Shell versions 4.71 and later, you can use the registry to replace the standard drive icon with a custom icon. With versions 5.0 and later, you can also add a custom label. Custom drive icons and labels are normally used for removable mass storage devices, such as tape drives, to allow users to easily distinguish them from their system's hard and floppy drives.

To replace the standard drive icon with a custom icon in Windows 2000, add a subkey named for the drive letter to the following key.

HKEY_CLASSES_ROOT

Applications

Explorer.exe

  • Drives

To replace the standard drive icon with a custom icon in all versions of Windows other than Windows 2000, add a subkey named for the drive letter to the following key.

HKEY_LOCAL_MACHINE

Software

Microsoft

Windows

CurrentVersion

Explorer

  • DriveIcons

The drive letter should not be followed by a colon (:). Add a DefaultIcon subkey to the drive letter subkey and set its default value to a string containing the location of the icon. The first part of the string contains the fully-qualified path of the icon's file. If there is more than one icon in the file, the path is followed by a comma, and then by the zero-based index of the icon. If you are using Windows Millennium Edition (Windows Me) or later, add a custom label by adding a DefaultLabel subkey to the drive letter subkey, and setting its default value to a string containing the label.

The following example specifies a custom icon and label for the E: drive. The icon is in the C:\MyDir\MyDrive.exe file with a zero-based index of three.

For Windows 2000:

HKEY_CLASSES_ROOT

Applications

Explorer.exe

Drives

E

  • DefaultIcon
  • DefaultLabel

For all other versions of Windows:

HKEY_LOCAL_MACHINE

Software

Microsoft

Windows

CurrentVersion

Explorer

DriveIcons

E

  • DefaultIcon
  • DefaultLabel

Note  The DefaultLabel key was introduced in Windows Me and Windows 2000. It should not be used with earlier versions of Windows.

In all versions of Windows, if you change a file class or drive icon you must also call SHUpdateImage to notify the Shell to update any icons currently displayed.