none
IPreviewHandler question

    Question

  • I am trying to write a 'universal file viewer' that is to be included in a suite of programs. In order to view the document contents, I am using  the services of ipreviewhandler, which works perfectly well for most files. However, there doesn't seem to be a registered viewer for .TIF files or .JPG on my Windows 7 machine. Explorer however does preview these files (and many others), so how is it doing it. Would I have to write my owner handler for the missing files types in order to use the same code for all files?

    Thanks in advance.

    Thursday, November 10, 2011 9:09 PM

All replies

  • TIF and JPG files are registered as having a PerceivedType of "image" and so use the preview handler registered for images (see http://msdn.microsoft.com/en-us/site/bb776871 ).

    Your application shouldn't need to go through the registry to figure this out on its own though.  It can let the shell do the heavy lifting:

    Get the IQueryAssociations interface for the file and then call IQueryAssociations::GetString to find the CLSID of the appropriate preview handler.

    pQueryAssociation->GetString(ASSOCF_NOUSERSETTINGS, ASSOCSTR_SHELLEXTENSION, szIID_IPreviewHandler, wszCLSID, &cch);
    
    

    --Rob

    Friday, November 11, 2011 3:40 AM