; Lutra's NSIS installer hooks (`bundle.windows.nsis.installerHooks`). ; ; Offers Lutra in Explorer's "Open with" menu for PHP files without making ; it the default app. Tauri's `bundle.fileAssociations` would set the ; extension's default value to its ProgID (the bundler's `APP_ASSOCIATE` ; macro), taking over the double-click, so on Windows Lutra registers only: ; ; - the ProgID `Lutra.PhpFile` (description, icon, open command); ; - the ProgID as a value under `Software\Classes\.\OpenWithProgids`, ; leaving `.`'s default value (the user's default app) alone; ; - `Software\Classes\Applications\lutra-desktop.exe` with `SupportedTypes`, ; so "Open with → Choose another app" lists Lutra under its own name. ; ; All of it goes to SHCTX, which is HKCU for Lutra's per-user setup. The ; uninstaller removes the same entries and nothing else: other apps' values ; under `OpenWithProgids` stay, and so does the user's default app. !define LUTRA_PROGID "Lutra.PhpFile" ; Registers Lutra as an "Open with" choice for `.${EXT}` files. !macro LUTRA_OPEN_WITH EXT WriteRegStr SHCTX "Software\Classes\.${EXT}\OpenWithProgids" "${LUTRA_PROGID}" "" WriteRegStr SHCTX "Software\Classes\Applications\${MAINBINARYNAME}.exe\SupportedTypes" ".${EXT}" "" !macroend ; Removes what `LUTRA_OPEN_WITH` wrote for `.${EXT}`. !macro LUTRA_UN_OPEN_WITH EXT DeleteRegValue SHCTX "Software\Classes\.${EXT}\OpenWithProgids" "${LUTRA_PROGID}" !macroend ; The extensions Lutra offers to open. !macro LUTRA_FOR_EACH_EXT MACRO !insertmacro ${MACRO} "php" !insertmacro ${MACRO} "phtml" !insertmacro ${MACRO} "phpt" !insertmacro ${MACRO} "inc" !macroend !macro NSIS_HOOK_POSTINSTALL WriteRegStr SHCTX "Software\Classes\${LUTRA_PROGID}" "" "PHP file" WriteRegStr SHCTX "Software\Classes\${LUTRA_PROGID}\DefaultIcon" "" "$INSTDIR\${MAINBINARYNAME}.exe,0" WriteRegStr SHCTX "Software\Classes\${LUTRA_PROGID}\shell\open\command" "" '"$INSTDIR\${MAINBINARYNAME}.exe" "%1"' WriteRegStr SHCTX "Software\Classes\Applications\${MAINBINARYNAME}.exe" "FriendlyAppName" "${PRODUCTNAME}" WriteRegStr SHCTX "Software\Classes\Applications\${MAINBINARYNAME}.exe\DefaultIcon" "" "$INSTDIR\${MAINBINARYNAME}.exe,0" WriteRegStr SHCTX "Software\Classes\Applications\${MAINBINARYNAME}.exe\shell\open\command" "" '"$INSTDIR\${MAINBINARYNAME}.exe" "%1"' !insertmacro LUTRA_FOR_EACH_EXT LUTRA_OPEN_WITH !insertmacro UPDATEFILEASSOC !macroend !macro NSIS_HOOK_POSTUNINSTALL !insertmacro LUTRA_FOR_EACH_EXT LUTRA_UN_OPEN_WITH DeleteRegKey SHCTX "Software\Classes\${LUTRA_PROGID}" DeleteRegKey SHCTX "Software\Classes\Applications\${MAINBINARYNAME}.exe" !insertmacro UPDATEFILEASSOC !macroend