Use OverlayIdentifiers icons in namespace extension

586 Views Asked by At

I develop namespace extension for windows explorer. In my extension I use overlay icons, I implemented the interface: IShellIconOverlay

int GetOverlayIndex(IntPtr pidl, out int iconIndex);
int GetOverlayIconIndex(IntPtr pidl, out int iconIndex);

In that function I use the function SHGetIconOverlayIndex to get icon overlay index in the image list from dll location and index.

My problem is that I have already icons in the list of Overlay Identifiers registry from another extension that I use and I want to use the same icons from my overlay icon extension to my namespace extension. Currently the SHGetIconOverlayIndex function create new slot in the image list and it is well known that windows have limits of 14-15 overlay icons.

So How can I recycle my icons between those two extensions?

2

There are 2 best solutions below

2
On

If 'SHGetIconOverlayIndex' function gives you a limited system imagelist, why not load icons from Overlay icon extension's resources using 'LoadLibrary'->'FindResource' or use 'ExtractIcon'. You can create your own imagelist in namespace extension and add your overlay image to this imagelist as overlay using 'ImageList_SetOverlayImage'.

0
On

MSDN says about SHGetIconOverlayIndex:

Note After the image has been loaded into the system image list during initialization, it cannot be changed. The file name and index specified by pszIconPath and iIconIndex are used only to identify the icon overlay. SHGetIconOverlayIndex cannot be used to modify the system image list.

So just pass filename and index to SHGetIconOverlayIndex. Window will not create new slot and will use already created by overlay icon handler.