- CGM Preview Handler. Adds full-preview (zoom, pan, and rotate) of CGM files within Windows File Explorer (installed as an plugin). SDI offers a CGM viewer for Chrome, Firefox, Edge, and HTML5 browsers (no plugin required). How to use CGM Preview Handler.
- Making Sure That 'PDF Preview Handler' is Enabled In Outlook, navigate through “File Options Trust Center Trust Center settings Attachment Handling” and: Make sure that “Turn off Attachment Preview” box is unchecked.
- Windows and Office Preview Handler Pack is one such custom previewers or preview handlers that provides support for.cs.aspx and.sql source codes. With the handler pack installed, you can just click on the file ending with extension of.cs.aspx and.sql with preview pane on, and instantly view the file content in the preview pane.
Preview handlers are called when an item is selected to show a lightweight, rich, read-only preview of the file's contents in the view's reading pane. This is done without launching the file's associated application.
This topic discusses the following topics:
Preview PDF document PDF document can be previewed in thumbnail when it is not opened via the PDF Preview Handler interface in Microsoft Windows 10. C# (CSharp) IPreviewHandler - 9 examples found. These are the top rated real world C# (CSharp) examples of IPreviewHandler extracted from open source projects. You can rate examples to help us improve the quality of examples.
Preview Handler Architecture
A preview handler is a hosted application. Hosts include the Windows Explorer in Windows Vista or Microsoft Outlook 2007. Hosts implement IPreviewHandlerFrame as a method of communication between the preview handler and the host.
The preview handler itself implements these interfaces:
- IPreviewHandlerVisuals (Optional)
Your handler is called through its IObjectWithSite, which returns an IUnknown pointer through which you request an IPreviewHandlerFrame object to interact with the host.
Server Model Options
Preview handlers always run out of process. There are two methods of implementing this:
- A preview handler can be built as an in-process server but run through an out-of-process surrogate host. This is the preferred method. The system provides a surrogate host for this in the Prevhost.exe file. Preview handlers built by this method are not compatible with Outlook 2007 on Windows XP. However, these same handlers will work in Windows Explorer and Outlook 2007 running on Windows Vista.
- A preview handler can be built as a local Component Object Model (COM) server. This is not recommended for several reasons. First, implementation of an in-process server is easier. More importantly, implementation as an in-process server provides greater control over the lifetime of the handler object, which allows for better cleanup and efficiency.
By default, preview handlers run in a low integrity level (IL) process for security reasons. You can optionally disable running as a low IL process by setting the following value in the registry. However, it is not recommended to do so. Systems could eventually be configured to reject any process that is not low IL.
Different preview handlers share the same process by default. Two instances of Prevhost.exe can be running simultaneously; one for handlers running as low IL processes, one for handlers that have opted out of that behavior.
Initialization
As with thumbnail and property handlers, it is strongly recommended that you initialize your handler with a stream. You can initialize through a file or item if necessary, but streams provide the most secure way to implement a handler. Initialization through a stream ensures file integrity and the stability benefits to the system of running the handler as a low IL process, such as protecting the system from buffer overruns, limiting where a handler can write information, and limiting communication with other windows.
If you must initialize with a file or Shell item, store the file path or a reference to the IShellItem. Do not read data from these sources until IPreviewHandler::DoPreview is called.
In general, initialization should not do any heavy work such as composing and storing a preview image. For optimal efficiency, that sort of processing should not be done until the preview is called for.
Preview Handler Close
Preview Handler Data Flow
The data flow in the preview process follows the general path shown here. The host can be thought of as Windows Explorer in Windows Vista or Outlook 2007.
- The preview handler is initialized, preferably with a stream.
- The view window is passed from the host to the handler through IPreviewHandler::SetWindow.
- At this point, the handler should do nothing more until IPreviewHandler::DoPreview is called.
- The preview is displayed in the reading pane through a call to IPreviewHandler::DoPreview.
- The size of the window is set through IPreviewHandler::SetRect.
- The window is resized when needed through IPreviewHandler::SetRect.
- The preview is unloaded and its resources released when it is no longer needed, through a call to IPreviewHandler::Unload.
Debugging a Preview Handler
If you have followed the recommendations to implement your preview handler as an in-process server, to debug your preview handler, you can attach to Prevhost.exe. As mentioned earlier, be aware that there could be two instances of Prevhost.exe, one for normal low IL processes and one for those handlers that have opted out of running as a low IL process.
If you do not find Prevhost.exe in your list of available processes, it probably has not been loaded at that point. Clicking on a file for a preview loads the surrogate and it should then appear as an attachable process.
Providing Your Own Process for a Preview Handler
If you want to force the creation of a new process for your handler rather than running under the default process, create a new subkey for your handler under AppID and set its DllSurrogate entry to 'Prevhost.exe'. Use that AppID subkey instead of the default Prevhost.exe AppID.
By providing a new process, the handler can avoid running under a shared process as it would do by default. This could allow you, for example, to ensure the specific version of the common language runtime (CLR) in the process. This is required if you are building a managed implementation of a preview handler.
Note
32-bit preview handlers should use AppID {534A1E02-D58F-44f0-B58B-36CBED287C7C} when installed on 64-bit operating systems.
Related topics
-->This topic explains how to register a preview handler associated with a given data type. For the purposes of illustration, examples in this topic use a .xyz file type. Registration of a preview handler is a standard file association-based registration.
Instructions
Step 1:
First, a file name extension is associated with a ProgID. The following entry associates the xyzfile ProgID subkey with the .xyz file name extension.
The xyzfile ProgID subkey is stored with the other ProgIDs as shown here:
Each preview handler ProgID subkey contains a subkey named shellex that contains a subkey always named {8895b1c6-b41f-4c1c-a562-0d564250836f}. The presence of that subkey tells the system that the handler is a preview handler.
The default value of the {8895b1c6-b41f-4c1c-a562-0d564250836f} subkey is the class identifier (CLSID) of your handler. An example of the xyzfile ProgID subkey is shown here, associating a handler of CLSID {ec3a629a-a47c-4245-bc78-b4b63d0e3154}.
Step 2:
Next, add the subkey under CLSID for your preview handler. An example is shown here. An explanation of individual entries follows.
The default value for your subkey (here, {ec3a629a-a47c-4245-bc78-b4b63d0e3154}) is not required or used. However, setting it to a nonlocalized string can help you to debug registration issues.
The minus sign (-101) in the .dll resource in the DisplayName entry exists for legacy reasons. The Icon entry, on the other hand, does not require a minus sign.
The AppID value gives a reference to the AppID of the application associated with the file name extension (stored under HKEY_CLASSES_ROOTAPPID. The value used here—{6d2b5079-2f0b-48dd-ab7f-97cec514d30b}—is the ID of the Prevhost.exe surrogate host. 32-bit preview handlers should use AppID {534A1E02-D58F-44f0-B58B-36CBED287C7C} when installed on 64-bit operating systems.
The entries under the InprocServer32 subkey include a reference back to the file name extension's ProgID subkey as well as an entry for a VersionIndependentProgID.
Step 3:
Finally, the preview handler must be added to the list of all preview handlers. This list is used as an optimization by the system to enumerate all registered preview handlers for display purposes. Again, the default value is not required, it simply aids in the debugging process.
Note
Preview Handler Error
In Windows 7, if the application is installed for all users of the computer, use HKEY_LOCAL_MACHINE; if for only one user, use HKEY_CURRENT_USER.