FsExtractCustomIcon
FsExtractCustomIcon is called when a file/directory is displayed in the file list. It can be used to specify a custom icon for that file/directory. This function is new in version 1.1. It requires Total Commander >=5.51, but is ignored by older versions.
Declaration:
int __stdcall FsExtractCustomIcon(char* RemoteName, int ExtractFlags, HICON* TheIcon);
Description of parameters:
RemoteName This is the full path to the file or directory whose icon is to be retrieved. When extracting an icon, you can return an icon name here - this ensures that the icon is only cached once in the calling program. The returned icon name must not be longer than MAX_PATH characters (including terminating 0!). The icon handle must still be returned in TheIcon!
ExtractFlags Flags for the extract operation. A combination of the following:
FS_ICONFLAG_SMALL Requests the small 16x16 icon
FS_ICONFLAG_BACKGROUND The function is called from the background thread (see note below)
TheIcon Here you need to return the icon handle.
Return value:
The function has to return one of the following values:
FS_ICON_USEDEFAULT No icon is returned. The calling app should show the default icon for this file type.
FS_ICON_EXTRACTED An icon was returned in TheIcon. The icon must NOT be freed by the calling app, e.g. because it was loaded with LoadIcon, or the DLL handles destruction of the icon.
FS_ICON_EXTRACTED_DESTROY An icon was returned in TheIcon. The icon MUST be destroyed by the calling app, e.g. because it was created with CreateIcon(), or extracted with ExtractIconEx().
FS_ICON_DELAYED This return value is only valid if FS_ICONFLAG_BACKGROUND was NOT set. It tells the calling app to show a default icon, and request the true icon in a background thread. See note below.
Important note:
If you return FS_ICON_DELAYED, FsExtractCustomIcon() will be called again from a background thread at a later time. A critical section is used by the calling app to ensure that FsExtractCustomIcon() is never entered twice at the same time. This return value should be used for icons which take a while to extract, e.g. EXE icons. In the fsplugin sample plugin, the drive icons are returned immediately (because they are stored in the plugin itself), but the EXE icons are loaded with a delay. If the user turns off background loading of icons, the function will be called in the foreground with the FS_ICONFLAG_BACKGROUND flag.