; ===================================================== ; VoiletCStudio Windows 安装脚本 (NSIS) ; 用法: makensis installer/voiletcstudio.nsi ; ===================================================== !define PRODUCT_NAME "VoiletCStudio" !define PRODUCT_VERSION "1.2" !define PRODUCT_PUBLISHER "LinuxAcme" !define PRODUCT_EXE "VoiletCStudio.exe" Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "VoiletCStudio-Setup-${PRODUCT_VERSION}.exe" InstallDir "$PROGRAMFILES\${PRODUCT_NAME}" RequestExecutionLevel admin ; ----- 安装页面 ----- Page directory Page instfiles ; ----- 默认安装路径 ----- Section "Install" SetOutPath "$INSTDIR" ; 复制主程序 File "VoiletCStudio.exe" ; 复制 Qt 运行时 DLL(需要提前准备好) ; File /r "Qt5Core.dll" ; File /r "Qt5Gui.dll" ; File /r "Qt5Widgets.dll" ; 复制 MinGW 运行时 ; File /r "libgcc_s_seh-1.dll" ; File /r "libstdc++-6.dll" ; File /r "libwinpthread-1.dll" ; 创建卸载程序 WriteUninstaller "$INSTDIR\uninstall.exe" ; 注册 .VSC 文件关联 WriteRegStr HKCR ".VSC" "" "VoiletCStudio.VSC" WriteRegStr HKCR "VoiletCStudio.VSC" "" "VoiletCStudio 工程文件" WriteRegStr HKCR "VoiletCStudio.VSC\DefaultIcon" "" "$INSTDIR\${PRODUCT_EXE},0" WriteRegStr HKCR "VoiletCStudio.VSC\shell\open\command" "" '"$INSTDIR\${PRODUCT_EXE}" "%1"' ; 注册表卸载信息 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$INSTDIR\uninstall.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "${PRODUCT_PUBLISHER}" ; 开始菜单快捷方式 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\VoiletCStudio.lnk" "$INSTDIR\${PRODUCT_EXE}" CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\卸载.lnk" "$INSTDIR\uninstall.exe" ; 桌面快捷方式 CreateShortCut "$DESKTOP\VoiletCStudio.lnk" "$INSTDIR\${PRODUCT_EXE}" ; 通知系统刷新文件关联 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' SectionEnd ; ----- 卸载 ----- Section "Uninstall" ; 删除程序 Delete "$INSTDIR\${PRODUCT_EXE}" Delete "$INSTDIR\uninstall.exe" RMDir "$INSTDIR" ; 删除文件关联 DeleteRegKey HKCR ".VSC" DeleteRegKey HKCR "VoiletCStudio.VSC" ; 删除注册表 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" ; 删除快捷方式 Delete "$SMPROGRAMS\${PRODUCT_NAME}\VoiletCStudio.lnk" Delete "$SMPROGRAMS\${PRODUCT_NAME}\卸载.lnk" RMDir "$SMPROGRAMS\${PRODUCT_NAME}" Delete "$DESKTOP\VoiletCStudio.lnk" System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' SectionEnd