Reputation: 3
I'm implementing the namespace extension which represents the remote file system on the server and I would like to have the icon overlays to show the file state (locked) like in another question here: icon overlay handlers for namespace extension
That question is answered already there and I've done everything as suggested:
Created the additional shell extension with the IShellIconOverlayIdentifier interface implemented: In the IShellIconOverlayIdentifier.GetOverlayInfo I return icon file and icon index. In the IShellIconOverlayIdentifier.IsMemberOf I return S_FALSE to not show my overlay for any other files in the system.
In the main NSE I've implemented the IShellIconOverlay interface and retrieve my icon overlay from the system image list using the SHGetIconOverlayIndex function.
The problem is: SHGetIconOverlayIndex always returns -1.
But! If I return S_OK as the result of IShellIconOverlayIdentifier.IsMemberOf - the SHGetIconOverlayIndex immediately starts to give the correct overlay index! But of course in this case my overlay is added to all the files in the system including my NSE.
The interesting thing that if I return S_FALSE in the subesequent calls of the IShellIconOverlayIdentifier.IsMemberOf - the SHGetIconOverlayIndex still give the correct overlay index the everything became fine: I have overlays in my NSE only...
What I'm doing wrong and how to get this result from the very beginning? Probably the caching issue?..
(Sorry, I couldn't write this as the comment to question being mentioned because I have no enough reputation...)
Upvotes: 0
Views: 912
Reputation: 3317
It looks the problem you have has no correct solution. Maybe I wrong but I think Windows work with using of the following rules:
1) At the start shell has overlay icon list containing default overlay icons only (4 icons, in next version of Windows this value can be larger).
2) When any of overlay icon handlers return S_OK in call of IShellIconOverlayIdentifier.IsMemberOf shell adds its icon to overlay icon list.
3) The max count of overlay icon in shell icon list is 15 (4 default + 11 external).
4) So only 11 first icon handlers returning S_OK will be added to shell icon list. Other will be ingnored.
So even if you rename your registry key to 000 other icon handlers may return S_OK before your handler.
So my recommendation is create full icon with overlay image for your NSE objects.
Upvotes: 1