@@ -3,9 +3,9 @@ library SvgShellExtensions;
33(* ******************************************************************************
44* Author : Angus Johnson *
55* Version : 1.1 *
6- * Date : 21 January 2022 *
6+ * Date : 14 October 2023 *
77* Website : http://www.angusj.com *
8- * Copyright : Angus Johnson 2022 *
8+ * Copyright : Angus Johnson 2022-2023 *
99* *
1010* Purpose : 64bit Windows Explorer Preview Handler for QOI image files *
1111* *
2727{ $R *.res}
2828
2929const
30- sSurrogateAppId = ' {6D2B5079-2F0B-48DD-AB7F-97CEC514D30B}' ; // 64bit
30+ // Preview Handler Surrogate Host (Prevhost.exe)
31+ // see HKEY_CLASSES_ROOT\AppID
32+ sSurrogateAppId = ' {6D2B5079-2F0B-48DD-AB7F-97CEC514D30B}' ;
3133
3234function GetModuleName : string;
3335var
4547 reg: TRegistry;
4648begin
4749 Result := E_UNEXPECTED; // will fail if not ADMIN
48-
4950 reg := TRegistry.Create(KEY_ALL_ACCESS);
5051 try
5152 reg.RootKey := HKEY_CLASSES_ROOT;
5253 if not reg.OpenKey(extension, true) then Exit;
53- reg.WriteString(' ' , appId);
54+ reg.WriteString(' ' , extFile); // 'svgFile' (see SvgPreview.pas)
5455 reg.CloseKey;
55-
56- if reg.OpenKey(appId+' \Clsid' , true) then
57- begin
58- reg.WriteString(' ' , SID_EXT_ShellExtensions);
59- reg.CloseKey;
60- end ;
61-
62- // REGISTER PREVIEW HANDLER
63- if not reg.OpenKey(appId+' \ShellEx\' +SID_IPreviewHandler, true) then Exit;
64- reg.WriteString(' ' , SID_EXT_ShellExtensions);
56+ if not reg.OpenKey(extFile, true) then Exit;
6557 reg.CloseKey;
66- // REGISTER THUMBNAIL PROVIDER
67- if not reg.OpenKey(appId +' \ShellEx\ ' +SID_IThumbnailProvider , true) then Exit;
68- reg.WriteString(' ' , SID_EXT_ShellExtensions );
58+
59+ if not reg.OpenKey(extFile +' \CLSID ' , true) then Exit;
60+ reg.WriteString(' ' , SID_SVG_ShellHandler );
6961 reg.CloseKey;
7062
71- // //////////////////////////////////////////////////////////////////////////
72- // the following also seems necessary (at least for SVG files)
63+ // REGISTER PREVIEW HANDLER and THUMBNAIL PROVIDER (under .svg)
7364 if not reg.OpenKey(extension+' \ShellEx\' +SID_IPreviewHandler, true) then Exit;
74- reg.WriteString(' ' , SID_EXT_ShellExtensions );
65+ reg.WriteString(' ' , SID_SVG_ShellHandler );
7566 reg.CloseKey;
7667 if not reg.OpenKey(extension+' \ShellEx\' +SID_IThumbnailProvider, true) then Exit;
77- reg.WriteString(' ' , SID_EXT_ShellExtensions );
68+ reg.WriteString(' ' , SID_SVG_ShellHandler );
7869 reg.CloseKey;
79- // //////////////////////////////////////////////////////////////////////////
8070
81- if not reg.OpenKey(' CLSID\' + SID_EXT_ShellExtensions, true) then Exit;
71+ // REGISTER PREVIEW HANDLER and THUMBNAIL PROVIDER (under .svgFile)
72+ if not reg.OpenKey(extFile +' \ShellEx\' +SID_IPreviewHandler, true) then Exit;
73+ reg.WriteString(' ' , SID_SVG_ShellHandler);
74+ reg.CloseKey;
75+ if not reg.OpenKey(extFile +' \ShellEx\' +SID_IThumbnailProvider, true) then Exit;
76+ reg.WriteString(' ' , SID_SVG_ShellHandler);
77+ reg.CloseKey;
78+
79+ if not reg.OpenKey(' CLSID\' + SID_SVG_ShellHandler, true) then Exit;
8280 reg.WriteString(' ' , appDescription);
8381 reg.WriteString(' AppID' , sSurrogateAppId);
8482 reg.CloseKey;
8583
86- reg.OpenKey(' CLSID\' + SID_EXT_ShellExtensions +' \InProcServer32' , true);
84+ reg.OpenKey(' CLSID\' + SID_SVG_ShellHandler +' \InProcServer32' , true);
8785 reg.WriteString(' ' , GetModuleName);
8886 reg.WriteString(' ThreadingModel' , ' Apartment' );
89- reg.WriteString(' ProgId' , appId);
90- reg.WriteString(' VersionIndependentProgID' , appId);
9187 reg.CloseKey;
9288
93- reg.OpenKey(' CLSID\' + SID_EXT_ShellExtensions + ' \ProgId' , true);
94- reg.WriteString(' ' , appId );
89+ reg.OpenKey(' CLSID\' + SID_SVG_ShellHandler + ' \ProgId' , true);
90+ reg.WriteString(' ' , extFile );
9591 reg.CloseKey;
9692
9793 reg.RootKey := HKEY_LOCAL_MACHINE;
98- if reg.OpenKey(' SOFTWARE\Microsoft\Windows\' +
99- ' CurrentVersion\PreviewHandlers' , true) then
94+ if reg.OpenKey(' SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers' , true) then
10095 begin
101- reg.WriteString(SID_EXT_ShellExtensions , appDescription);
96+ reg.WriteString(SID_SVG_ShellHandler , appDescription);
10297 reg.CloseKey;
10398 end ;
99+
104100 finally
105101 reg.Free;
106102 end ;
@@ -121,17 +117,20 @@ begin
121117 reg.RootKey := HKEY_LOCAL_MACHINE;
122118 if reg.OpenKey(' SOFTWARE\Microsoft\Windows\' +
123119 ' CurrentVersion\PreviewHandlers' , true) and
124- reg.ValueExists(SID_EXT_ShellExtensions ) then
125- reg.DeleteValue(SID_EXT_ShellExtensions );
120+ reg.ValueExists(SID_SVG_ShellHandler ) then
121+ reg.DeleteValue(SID_SVG_ShellHandler );
126122
127123 reg.RootKey := HKEY_CLASSES_ROOT;
128124 if reg.KeyExists(extension + ' \ShellEx\' +SID_IPreviewHandler) then
129125 reg.DeleteKey(extension + ' \ShellEx\' +SID_IPreviewHandler);
130126 if reg.KeyExists(extension + ' \ShellEx\' +SID_IThumbnailProvider) then
131127 reg.DeleteKey(extension + ' \ShellEx\' +SID_IThumbnailProvider);
132128
133- reg.DeleteKey(' CLSID\' +SID_EXT_ShellExtensions);
134- reg.DeleteKey(appId);
129+ reg.DeleteKey(' CLSID\' +SID_SVG_ShellHandler);
130+ reg.DeleteKey(extFile+' \ShellEx\' +SID_IPreviewHandler);
131+ reg.DeleteKey(extFile+' \ShellEx\' +SID_IThumbnailProvider);
132+ reg.DeleteKey(extFile+' \Clsid' );
133+
135134 finally
136135 reg.Free;
137136 end ;
0 commit comments