Custom icons for virtual disks in Explorer

CBFS Connect lets you create a custom icon for your virtual disk. This icon is shown by Windows Explorer.

Via an additional file

If you can present an additional file on the virtual disk, then the method described in MSDN can work for you.

Via shell extension

Custom icons are implemented using icon overlay mechanism and are restricted to 25% of original icon size (except 16x16 icons). This method is better than using additional files, because you might not want to have those additional files visible to the user. Also it's possible to install multiple icons for different disk states (or different disks) and change icons by calling SetIcon/ResetIcon methods.

Overlay icons map as follows:

Icon files must have the following color levels:

Before the icon can be used (set) it needs to be installed using InstallIcon method. This method should be executed by the process running under Administrator account or with elevated rights.

During installation the icon is copied to the temporary file, which will be removed after deinstallation of the icon using UninstallIcon method. Then you can set the icon using SetIcon method.

For custom icons to work you need to include CBFSConnectMntNtf*.dll to the list of modules installed using Install method.

One limitation of Windows is that it supports just 15 overlay icons in the registry and some applications (e.g. OneDrive, Dropbox) install multiple overlays. So there's a competition between applications to display their overlays. The overlays are placed in Windows registry, in this key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers (on 64-bit Windows you need to check HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\explorer\ShellIconOverlayIdentifiers as well). If you need to remove some icons to free space for yours, it's up to your application's installer or the user themselves to do this.