How to Register a Windows Preview Handler with an MSI Package

Written by Renato Ivanescu · December 3rd, 2026 · 7min read

Have you ever wondered how File Explorer shows a file’s content in the Preview Pane?

The key is a preview handler, a COM component compiled as a DLL that Windows loads to preview the file.

Here’s an example with a PDF opened in the Preview Pane:

Preview Pane of a PDF file

In this tutorial we’ll use Advanced Installer to build an MSI that installs a WPF application together with its preview handler. The installer will register the handler for .xyz files.

Create Your App and the Preview Handler DLL

For this tutorial, we’ve prepared two components:

  1. ViewerApp: a sample WPF application created in Visual Studio. It opens plain text files that have the .xyz custom extension. For simplicity, we’ve published the app as a single self-contained executable.
  2. XyzPreviewHandler.dll: a native COM DLL that shows the content of .xyz files in the Preview Pane. Windows loads the handler into the prevhost.exe process and File Explorer communicates with it through its COM interfaces.

NoteYou can find both components on our GitHub repo here. It also includes the Advanced Installer project (.aip) that we’ll configure by the end of this tutorial.

Create the Installer Project

After you build the app and the DLL, it’s time to create the installer project in Advanced Installer:

1. On the Start page, select the Professional template (or higher) and then click Create New Project

2. Navigate to the Product Details page and set the basic information about the installer, such as the product name, version, the publisher, or other information

3. Open the Install Parameters page and set:

a. Package type: we set it to a 64-bit package, as the app and the DLL are both 64-bit also.

b. Installation type: let’s select Per-machine only so the handler will be available to all users on the machine.

NoteWindows also supports per-user registrations. In that scenario, the COM class and file association entries go under HKEY_CURRENT_USER\Software\Classes instead of HKEY_LOCAL_MACHINE\Software\Classes. The preview handler list goes under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\PreviewHandlers.

Add the Application Resources

After you configure the package details, open the Files and Folders page and add the application resources and the DLL.

In our scenario, we’ll add:

  • ViewerApp.exe from the publish output (the single, self-contained executable)
  • XyzPreviewHandler.dll

Create the .xyz File Association

Now, associate .xyz files with ViewerApp.exe:

  1. Navigate to the File Associations page
  2. Click New Extension
  3. Advanced Installer will add a ProgID with an extension under it. Right-click the ProgID, select Rename, and set its name to XyzFile. Keep this name in mind, as we’ll use it when we register the preview handler.
  4. Select the extension, set its name to xyz and configure it to point to ViewerApp.exe. Optionally, you can configure .xyz files with a description and an icon.
xyz file association with ViewerApp.exe

Register the COM Class

Windows needs to know that the preview handler’s class exists and which DLL implements it.

You can register the class directly from the COM page in Advanced Installer:

1. Navigate to the COM page.

2. Click the New Class button

3. In the dialog that opens, select the XyzPreviewHandler.dll and click OK

4. Rename the new class with the handler’s CLSID. The CLSID must match the class ID compiled into your DLL. Our demo sample uses {CC12C1A5-7B5B-4367-8D3E-EBCEF1D697B9}.

5. Configure the following properties on the Class tab:

a. File: XyzPreviewHandler.dll

b. Context: InprocServer32

c. Threading Model: Apartment (the COM threading model used by the handler)

d. ProgId: XyzFile (the ProgId created on the File Associations page)

e. Description: Xyz Preview Handler (a descriptive name for the COM class)

COM new class configuration

Add the Preview Handler Entries in the Registry

The COM class registration is not enough for File Explorer to use the handler.

In addition, we need to tell Windows how to run the class and which file type it previews. For this, we have to add some registry entries separately.

To add the registry entries, navigate to the Registry page in Advanced Installer. Be aware that the entries must be written to the registry view that matches the DLL’s architecture. Our DLL is 64-bit, so they will go in the 64-bit view. For a 32-bit DLL on 64-bit Windows, it is the 32-bit registry view (under WOW6432Node).

We need to add three sets of registry entries.

1. Preview host settings

The entries tell Windows which preview host runs the handler. Add them under the HKEY_CLASSES_ROOT\CLSID\{YOUR-CLSID} key created from the COM page. In our sample it is {CC12C1A5-7B5B-4367-8D3E-EBCEF1D697B9}.

COM registry key details

The relevant values are:

  • DisplayName: a display name for the handler.
  • AppID: identifies the Windows preview host (prevhost.exe) used to run the handler.

When the handler matches the Windows architecture, use {6D2B5079-2F0B-48DD-AB7F-97CEC514D30B}. For a 32-bit handler installed on 64-bit Windows, use {534A1E02-D58F-44F0-B58B-36CBED287C7C}.

2. Link between .xyz files and the handler

The COM class tells Windows which DLL implements the handler, but not which files it previews. This registry entry makes the connection. Add it under HKEY_CLASSES_ROOT\XyzFile\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}.

Link between .xyz files and the handler
  • XyzFile is the ProgID created in the file association, so the name must match it exactly
  • {8895b1c6-b41f-4c1c-a562-0d564250836f} is the ID of the IPreviewHandler interface and tells Windows that this subkey points to a preview handler. It never changes.
  • (Default): the CLSID of the handler

3. Add the handler to the list

This entry adds the handler to the list of preview handlers installed on the system. Add it under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers.

Add handler to the application
  • The name is the handler’s CLSID, and the data is its display name.
  • The entry goes under HKEY_LOCAL_MACHINE because the package is per-machine. For a per-user install, it goes under HKEY_CURRENT_USER.

To add the three registry entries, you have two available options.

Option 1: Import a .reg file that contains the entries

With Advanced Installer you can import the reg file into the project. The package then writes those entries on the target machines at install time.

For our sample, you can use the XyzPreviewHandler.reg file in the GitHub repository. It contains the three sets of entries mentioned above.

To import it:

  1. On the Registry page, click Import REG and select Import File
  2. Select the XyzPreviewHandler.reg file. The keys will appear under HKEY_CLASSES_ROOT and HKEY_LOCAL_MACHINE.
  3. Click Show COM Registry on the toolbar because Advanced Installer hides the COM entries by default. Without it, you cannot see the DisplayName and AppID under the CLSID key.

Option 2: Add the entries manually

You can also create the three sets of entries described above one by one on the Registry page:

  1. Select the root key (HKEY_CLASSES_ROOT or HKEY_LOCAL_MACHINE) where you need to add the key
  2. Use the New Key option to create each key
  3. With a key selected, click the New Value button to add its value

Build, Install, Test

Once the setup project is ready, build it to generate the MSI installer. Then, run the MSI to install the app.

After the app is installed, you need an .xyz file for testing. You can create one or download the test file from the GitHub repository.

Copy the file to any folder and turn on the Preview Pane from the View menu. Select the test file and its content should appear in the pane on the right.

xyz file preview handler

ImportantThere’s also an MSIX version if you want to check it out: How to Package and Register a Windows Preview Handler with MSIX.

Conclusion

File Explorer can show a file's content in the Preview Pane without opening the corresponding app. For this, the preview handler for that file type must be registered in Windows.

With Advanced Installer, you can create an MSI that registers the preview handler at install time and removes it on uninstall. You can set up all the configurations from its graphical interface without writing any custom scripts.

NoteCheck out Advanced Installer through our 30-day full feature free trial.

Written by
See author's page
Renato Ivanescu

Renato is a technical writer for Advanced Installer and an assistant professor at the University of Craiova. He is currently a PhD. student, and computers and information technology are his areas of interest. He loves innovation and takes on big challenges.

Comments: