Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
IPreviewHandler (shlwapi)
This interface describes the API implemented by preview handlers. When a handler for a given file type is installed on a system, the shell or custom apps can use it to display the contents of these files in their window. Preview handlers usually do not allow in-place editing and may not display all the information contained in the file (for example, macros inside Office documents are ignored by their preview handlers)

C# Signature:




public interface IPreviewHandler


    void SetWindow(IntPtr hwnd, ref RECT rect);
    void SetRect(ref RECT rect);
    void DoPreview();
    void Unload();

    void SetFocus();
    void QueryFocus(out IntPtr phwnd);

    uint TranslateAccelerator(ref MSG pmsg);


VB Signature:


User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!


This interface does NOT have a way to tell the preview handler what file it should show!! For this reason, all preview handler COM objects must also support at least one of IInitializeWithFile or IInitializeWithStream, which is how they get this crucial piece of information.

Tips & Tricks:

You can use this interface to leverage previewers already installed on a system to display a document preview in a Windows Forms app.

In case you want a ready-to-use control for .Net based on IPreviewHandler check out this:

Sample Code:

Please add some!


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version