问题
I'm trying to implement a shell namespace extension, for the sole purpose of overriding the thumbnail handler (IExtractImage
) in a specific folder. I want everything else to be the same as in a normal folder, and I'd rather not have to reimplement everything that is done in the default implementation of IShellFolder
...
So, is it possible to inherit from this default implementation? If so, how?
Using composition would also be an acceptable solution, but how can I get an instance of the class for a given folder?
回答1:
1) There many shell extensions which can request your files content. For example .ico-file icon handler. Also user can install for example info tip extension which shows ID3 tag from mp3 file and it requests file content too. User can setup additional columns in detail view and some of them request file content. So you must control a lot of details in your shell name space extension.
2) To create a default implementation just call CoCreateInstance(CLSID_ShellFileSystemFolder, nil, CLSCTX_INPROC_SERVER, IID_IShellFolder, ShellFolder).
3) There is a problem. For example:
- Shell queries unknown IShellFolder3 from your NSE.
- Your NSE does not implement IShellFolder3 and NSE queries IShellFolder3 from default implementation and returns the result.
- Shell call IShellFolder3.GetUIObject with IID_IExtractImage and default IShellFolder3 will return installed thumbnail handler.
Also such methods can lead to AV inside Explorer (from my practice).
So I believe that your NSE must implement all known interfaces implemented by default implementation. If you don`t want to change behavior of method just pass the parameters to default implementation. Known (by me) interfaces: IBrowserFrameOptions, IOleCommandTarget, IPersist, IPersistIDList, IPersistFolder, IPersistFolder2, IPersistFolder3, IParentAndItem, IShellFolder, IShellFolder2, IObjectWithFolderEnumMode, IShellDetails, IShellFolderViewCB, IFolderFilter, INameSpaceTreeControlFolderCapabilities, IShellIcon, IShellIconOverlay, IFolderType, IFolderViewSettings, IExplorerPaneVisibility, IPropertyStoreFactory, IPropertyStore, IItemNameLimits, IThumbnailFactory.
4) As i understand you must control requests of following interfaces: IDataObject, IDropTarget, IExtractIconA(W), IExtractImage, IPropertyStore, IPropertyStoreFactory, IShellFolder(2), IQueryInfo.
5) IShellIcon.GetIconOf must return default icon of extension.
6) Also if your folder contains subfolders don`t forget to return your implementation when shell requests IShellFolder(2) of subfolder.
来源:https://stackoverflow.com/questions/27269757/is-it-possible-to-inherit-the-default-ishellfolder-implementation