reference:plugins:vfs_plugins:vfs_getfileicon

VFS_GetFileIcon(
     HANDLE:hVFSData,
     LPVFSFUNCDATA:lpFuncData,
     LPTSTR:lpszFile,
     LPINT:lpiSysIconIndex,
     HICON*:phLargeIcon,
     HICON*:phSmallIcon,
     LPBOOL:lpfDestroyIcons,
     LPTSTR:lpszCacheName,
     int:cchCacheNameMax,
     LPINT:lpiCacheIndex
)
→ BOOL

Arguments

hVFSData

[in] The handle to the namespace instance data

lpFuncData

[in] unused

lpszFile

[in] A null-terminated string containing the full pathname of the file to retrieve the icon for.

lpiSysIconIndex

[out] Points to an integer to receive the index of the file's icon in the system image list.

phLargeIcon

[out] Points to an HICON to receive the large icon for the file

phSmallIcon

[out] Points to an HICON to receive the small icon for the file

lpfDestroyIcons

[out] Points to a BOOL that you can set to TRUE to indicate the supplied icons are to be destroyed

lpszCacheName

[out] Points to a buffer for you to supply a unique name used to cache the supplied icons

cchCacheNameMax

[in] Maximum size of buffer in characters

lpiCacheIndex

[out] Points to an integer to receive an index value used to cache the supplied icons

Return value

If you can return an icon for the specified file you should store the icon information in the appropriate parameters and return TRUE. If your plugin cannot return an icon you should return FALSE.

Description

The VFS_GetFileIcon function is called to retrieve the icon for a file or folder in your plugin's namespace.

You can either use the lpiSysIconIndex parameter to return an index to an icon in the system image list, or phLargeIcon and phSmallIcon to return actual icons. To use the system image list, simply store the index value in lpiSysIconIndex and return TRUE.

To return icon images you must place the HICON handles in the supplied phLargeIcon and phSmallIcon parameters. If you want Opus to destroy the icons with DestroyIcon you should set lpfDestroyIcons to TRUE - otherwise, set lpfDestroyIcons to FALSE if you want to destroy the icons yourself. Note though that if you do not ask Opus to destroy them they must remain valid for as long as your namespace instance handle is valid (that is, until Opus destroys it with VFS_Destroy.)

Opus is able to cache icon images returned in this manner to save memory. To take advantage of this, copy a unique name into the buffer pointed to by lpszCacheName. For example, you could use a UUID or a combination of your plugin's name and a random number for the cache name. You can also provide a cache index in the lpiCacheIndex parameter.