@Hvd had the correct answer.
File types have a ShellEx key with sub-sections {guid} . Each {guid} key represents a specific InterfaceID .
There are a number of standard shell interfaces that can be associated with a file type:
{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1} IExtractImage{953BB1EE-93B4-11d1-98A3-00C04FB687DA} IExtractImage2{e357fccd-a995-4576-b01f-234630154e96} IThumbnailProvider{8895b1c6-b41f-4c1c-a562-0d564250836f} IPreviewHandler
Unsupported spelling of undocumented registry keys
If I want to find, for example, clsid of the IPreviewHandler associated with the .jpg file, I would look in:
HKEY_CLASSES_ROOT/.jpg/ShellEx/{8895b1c6-b41f-4c1c-a562-0d564250836f} (default) = [clsid]
But this is not the only place I could see. I can also look in:
HKEY_CLASSES_ROOT/.jpg (default) = jpgfile HKEY_CLASSES_ROOT/jpgfile/ShellEx/{8895b1c6-b41f-4c1c-a562-0d564250836f} (default) = [clsid]
But this is not the only place I could see. I can also look in:
HKEY_CLASSES_ROOT/SystemFileAssociations/.jpg/ShellEx/{8895b1c6-b41f-4c1c-a562-0d564250836f} (default) = [clsid]
But this is not the only place I could see. I can also look in:
HKEY_CLASSES_ROOT/SystemFileAssociations/jpegfile/ShellEx/{8895b1c6-b41f-4c1c-a562-0d564250836f} (default) = [clsid]
But this is not the only place I could see. If I think the file is an image, I can also see:
HKEY_CLASSES_ROOT/SystemFileAssociations/image/ShellEx/{8895b1c6-b41f-4c1c-a562-0d564250836f} (default) = [clsid]
How did I find these places? Did I just follow registered and maintained locations? No, I watched the explorer using Process Monitor, since it was hunting for IThumbnailProvider .
Do not use undocumented spells.
So now I want to use the standard shell interface for the file type myself. That means I have to scan places. But why scan these locations without documents, without support. Why incur the wrath of a guy from above things ? Use AssocQueryString :
Guid GetShellClsidForFileType(String fileExtension, Guid interfaceID) {
And so, to get clsid from IPreviewHandler for .xps files:
Guid clsid = GetShellClsidForFileType(".xps", IPreviewHandler);
How to get IPreviewHandler for file extension?
With all of the above, we can now answer the question:
IPreviewHandler GetPreviewHandlerForFileType(String extension) { //Extension: the file type to return IPreviewHandler for (eg ".xps") Guid previewHandlerClassID = GetShellClsidForFileType(extension, IPreviewHandler); //Create the COM object IUnknown unk = CreateComObject(previewHandlerClassID); //Return the actual IPreviewHanler interface (not IUnknown) return (IPreviewhandler)unk; }