Registry conflict between file association and file preview handler

Peter 1 Reputation point
2021-06-24T10:15:37.25+00:00

I have followed instructions for associating a custom file type with my application so that double clicking the file opens the application with that file. I've also followed instructions for creating registry settings for a preview handler for the same file type. Both work fine on their own, but not at the same time. The preview handler doesn't work when the file association open command is included. Here are the registry settings for the file association, which are created by my Inno setup installer following the instructions here.

HKEY_LOCAL_MACHINE\SOFTWARE\Classes.xyz\OpenWithProgids (Default)=""
HKEY_LOCAL_MACHINE\SOFTWARE\Classes.xyz\OpenWithProgids XYZFile.xyz=""
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\XYZFile.xyz (Default)="XYZ File Type"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\XYZFile.xyz\DefaultIcon (Default)="C:\Program Files (x86)\My App\MyApp.exe,1"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\XYZFile.xyz\shell\open\command (Default)=""C:\Program Files (x86)\My App\MyApp.exe" "%1""
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\MyApp.exe\SupportedTypes (Default)=""
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\MyApp.exe\SupportedTypes .xyz=""

Here are the registry settings for the preview handler (64bit machine). These are created by the preview handler dll itself when the installer registers it.

HKEY_LOCAL_MACHINE\SOFTWARE\Classes.xyz (Default)="XYZPreview.xyzfile"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\XYZPreview.xyzfile (Default)="XYZ File Preview Handler"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\XYZPreview.xyzfile\Clsid (Default)="{64644512-C345-469F-B5FB-EB351E20129D}"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\XYZPreview.xyzfile\shellex{8895B1C6-B41F-4C1C-A562-0D564250836F} (Default)="{64644512-C345-469F-B5FB-EB351E20129D}"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D} (Default)="XYZ File Preview Handler"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D} AppId="{534A1E02-D58F-44f0-B58B-36CBED287C7C}"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D} DisableLowILProcessIsolation=1
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ (Default)="C:\Program Files (x86)\My App\XYZPreview.dll"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ ProgID="XYZPreview.xyzfile"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ ThreadingModel="Apartment"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ VersionIndependentProgID="XYZPreview.xyzfile"
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID{64644512-C345-469F-B5FB-EB351E20129D}\ProgID (Default)="XYZPreview.xyzfile"
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers {64644512-C345-469F-B5FB-EB351E20129D}="XYZ File Preview Handler"

With these settings the file opens in the app when I open it from explorer, but the preview in Explorer doesn't work (No preview available). However, if I clear HKEY_LOCAL_MACHINE\SOFTWARE\Classes\XYZFile.xyz\shell\open\command (Default) to an empty string then the preview handler does work, but of course the file doesn't open in the app. Any ideas why this conflict is happening and how I can get both to work?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,417 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Peter 1 Reputation point
    2021-06-26T14:55:08.247+00:00

    I found a solution as follows. Instead of linking the .xyz extension to a ProgID for the preview handler (XYZPreview.xyzfile), I link directly to the CLSID from the extension and removed XYZPreview.xyzfile entirely. Perhaps having two ProgIDs for the extension was causing the conflict (XYZFile.xyz & XYZPreview.xyzfile). The preview handler entries were modified as follows and both the file association and preview handler now work.

    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xyz (Default)=""
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.xyz\shellex\{8895B1C6-B41F-4C1C-A562-0D564250836F} (Default)="{64644512-C345-469F-B5FB-EB351E20129D}"
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D} (Default)="XYZ File Preview Handler"
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D} AppId="{534A1E02-D58F-44f0-B58B-36CBED287C7C}"
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D} DisableLowILProcessIsolation=1
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ (Default)="C:\Program Files (x86)\My App\XYZPreview.dll"
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ ProgID="XYZPreview.xyzfile"
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ ThreadingModel="Apartment"
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D}\InprocServer32\ VersionIndependentProgID="XYZPreview.xyzfile"
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{64644512-C345-469F-B5FB-EB351E20129D}\ProgID (Default)="XYZPreview.xyzfile"
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers {64644512-C345-469F-B5FB-EB351E20129D}="XYZ File Preview Handler"
    
    0 comments No comments