Windows file preview - similar to preview pane in explorer
Asked Answered
S

4

6

In Windows 7 (and I think Vista) the Explorer has a preview pane that lets you see the contents for some file types (MS Office, images, etc). Is there any API available that allows you to access this functionality?

I've been using the WindowsAPICodePack which has a ShellFile.Thumbnail, but this seems to only expose the thumbnail icon for file types that Explorer is able to view. For instance, for a Word file it only displays the MS Word icon, where Explorer can actually preview the contents of the file. It does work like I want for image types, but not for other types of files.

Scouting answered 4/3, 2011 at 2:17 Comment(0)
P
4

IPreviewHandler

Pentha answered 4/3, 2011 at 2:53 Comment(1)
This is a link-only answer, which is discouraged. Please include the relevant parts of the linked resource to make it an answer.Bartram
C
2

Sample code (though hard to read... have to highlight the text) is here: Hosting vista/office 2007 previewers in winform application

Candleberry answered 4/3, 2011 at 14:7 Comment(0)
B
1

For simple text previews you can also add a Registry key

[HKEY_CLASSES_ROOT\.ext]
"PerceivedType"="text"

For more complex stuff, Microsoft provides the Shell Interface IPreviewHandler [MSDN] that you can implement as a COM object to provide a custom preview. There is a C++ example [MSDN] available as well.

The object will be initialized via IInitializeWithFile [MSDN] or IInitializeWithStream [MSDN]

Once you implemented it, you need to register it on your system [MSDN] for different file type like this:

HKEY_CLASSES_ROOT
   xyzfile
      shellex
         {8895b1c6-b41f-4c1c-a562-0d564250836f}
            (Default) = [REG_SZ] {<Class-ID-of-your-COM-object>}
Bartram answered 28/4, 2015 at 9:26 Comment(0)
D
0

A commercial ready-to-use preview control for .Net based on IPreviewHandler can be found here.

Debor answered 18/12, 2013 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.