2828; ==============================;
2929
3030 Unicode true
31+ ManifestDPIAware true
3132 Name " uChmViewer"
3233 OutFile " ${INSTALLER_FILE}"
3334
@@ -157,7 +158,7 @@ SectionEnd
157158
158159
159160; ==============================;
160- ; dependencies ;
161+ ; Dependencies ;
161162; ==============================;
162163
163164Section " -Install Dependencies"
@@ -171,3 +172,56 @@ Section "un.Install Dependencies"
171172 RMDir /r " $INSTDIR\${PKG_BIN_DIR}"
172173 RMDir " $INSTDIR"
173174SectionEnd
175+
176+
177+ ; ==============================;
178+ ; File type association ;
179+ ; ==============================;
180+
181+ !macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION APPNAME ICON COMMANDTEXT COMMAND
182+ WriteRegStr HKCU " Software\Classes\.${EXT}" " " " ${FILECLASS}"
183+ WriteRegNone HKCU " Software\Classes\.${EXT}\OpenWithProgids" " ${FILECLASS}"
184+
185+ WriteRegStr HKCU " Software\Classes\${FILECLASS}" " " ` ${DESCRIPTION}`
186+ WriteRegStr HKCU " Software\Classes\${FILECLASS}\Application\" " ApplicationName" ` ${APPNAME}`
187+ WriteRegStr HKCU " Software\Classes\${FILECLASS}\DefaultIcon" " " ` ${ICON}`
188+ WriteRegStr HKCU " Software\Classes\${FILECLASS}\shell" " " " open"
189+ WriteRegStr HKCU " Software\Classes\${FILECLASS}\shell\open" " " ` ${COMMANDTEXT}`
190+ WriteRegStr HKCU " Software\Classes\${FILECLASS}\shell\open\command" " " ` ${COMMAND}`
191+ !macroend
192+
193+ !macro APP_UNASSOCIATE EXT FILECLASS
194+ DeleteRegValue HKCU " Software\Classes\.${EXT}\OpenWithProgids" " ${FILECLASS}"
195+ DeleteRegKey HKCU ` Software\Classes\${FILECLASS}`
196+ !macroend
197+
198+ ; !defines for use with SHChangeNotify
199+ !ifdef SHCNE_ASSOCCHANGED
200+ !undef SHCNE_ASSOCCHANGED
201+ !endif
202+ !define SHCNE_ASSOCCHANGED 0x08000000
203+ !ifdef SHCNF_FLUSH
204+ !undef SHCNF_FLUSH
205+ !endif
206+ !define SHCNF_FLUSH 0x1000
207+
208+ !macro UPDATEFILEASSOC
209+ ; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we can update the shell.
210+ System::Call " shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)"
211+ !macroend
212+
213+
214+ Section " -File type association"
215+ !insertmacro APP_ASSOCIATE " chm" " uchmviewer.chm" " CHM File" " uChmViewer" \
216+ " $INSTDIR\${PKG_BIN_DIR}\uChmViewer.exe,0" " Open with uchmviewer" " $INSTDIR\${PKG_BIN_DIR}\uChmViewer.exe $\" %1$\" "
217+ !insertmacro APP_ASSOCIATE " epub" " uchmviewer.epub" " EPUB File" " uChmViewer" \
218+ " $INSTDIR\${PKG_BIN_DIR}\uChmViewer.exe,0" " Open with uchmviewer" " $INSTDIR\${PKG_BIN_DIR}\uChmViewer.exe $\" %1$\" "
219+ !insertmacro UPDATEFILEASSOC
220+ SectionEnd
221+
222+ Section " un.File type association"
223+ !insertmacro APP_UNASSOCIATE " chm" " uchmviewer.chm"
224+ !insertmacro APP_UNASSOCIATE " epub" " uchmviewer.epub"
225+ !insertmacro UPDATEFILEASSOC
226+ SectionEnd
227+
0 commit comments