NSIS:需要在生成的代码中添加组件选择页面和文件夹浏览窗口,以及菜单快捷方式和桌面快捷方式

时间:2019-05-17 15:07:09

标签: components nsis

我使用NSIS快速设置脚本生成器创建了一个安装程序。输出很好,但是我需要添加一些东西: 1)组件选择,并有描述  a)Mech Designer核心文件  b)闪点机甲包 2)如果用户还选择了组件b,则必须打开文件夹浏览器以选择其他路径来将这些组件放入其中。 3)创建开始菜单和桌面快捷方式的选项

!define APP_NAME "Mech Designer"
!define COMP_NAME "MasterBLB's Soft"
!define VERSION "00.00.00.05"
!define COPYRIGHT "Bartłomiej Laskowski  © 2006"
!define DESCRIPTION "Application"
!define LICENSE_TXT "C:\Qt\Projects\MechDesigner\Documentation\license.txt"
!define INSTALLER_NAME "C:\Qt\Projects\MechDesigner\Installer\Nsisqssg\Output\Mech Designer\setup.exe"
!define MAIN_APP_EXE "MechDesigner.exe"
!define INSTALL_TYPE "SetShellVarContext current"
!define REG_ROOT "HKCU"
!define REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${MAIN_APP_EXE}"
!define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"

!define REG_START_MENU "Start Menu Folder"

var SM_Folder

######################################################################

VIProductVersion  "${VERSION}"
VIAddVersionKey "ProductName"  "${APP_NAME}"
VIAddVersionKey "CompanyName"  "${COMP_NAME}"
VIAddVersionKey "LegalCopyright"  "${COPYRIGHT}"
VIAddVersionKey "FileDescription"  "${DESCRIPTION}"
VIAddVersionKey "FileVersion"  "${VERSION}"

######################################################################

SetCompressor ZLIB
Name "${APP_NAME}"
Caption "${APP_NAME}"
OutFile "${INSTALLER_NAME}"
BrandingText "${APP_NAME}"
XPStyle on
InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" ""
InstallDir "$PROGRAMFILES\Mech Designer by MasterBLB"

######################################################################

!include "MUI.nsh"

!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING

!insertmacro MUI_PAGE_WELCOME

!ifdef LICENSE_TXT
!insertmacro MUI_PAGE_LICENSE "${LICENSE_TXT}"
!endif

!insertmacro MUI_PAGE_DIRECTORY

!ifdef REG_START_MENU
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Mech Designer by MasterBLB"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
!insertmacro MUI_PAGE_STARTMENU Application $SM_Folder
!endif

!insertmacro MUI_PAGE_INSTFILES

!define MUI_FINISHPAGE_RUN "$INSTDIR\${MAIN_APP_EXE}"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM

!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_UNPAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

######################################################################

Section "Mech Designer core"
${INSTALL_TYPE}
SetOverwrite ifnewer
SetOutPath "$INSTDIR"
File "C:\Qt\Projects\MechDesigner\Installer\Data\libgcc_s_dw2-1.dll"
File "C:\Qt\Projects\MechDesigner\Installer\Data\libstdc++-6.dll"
File "C:\Qt\Projects\MechDesigner\Installer\Data\libwinpthread-1.dll"
File "C:\Qt\Projects\MechDesigner\Installer\Data\Mech Designer user's manual.pdf"
File "C:\Qt\Projects\MechDesigner\Installer\Data\MechDesigner.exe"
File "C:\Qt\Projects\MechDesigner\Installer\Data\Qt5Core.dll"
File "C:\Qt\Projects\MechDesigner\Installer\Data\Qt5Gui.dll"
File "C:\Qt\Projects\MechDesigner\Installer\Data\Qt5Widgets.dll"
File "C:\Qt\Projects\MechDesigner\Installer\Data\setup.ini"
SetOutPath "$INSTDIR\styles"
File "C:\Qt\Projects\MechDesigner\Installer\Data\styles\qwindowsvistastyle.dll"
SetOutPath "$INSTDIR\platforms"
File "C:\Qt\Projects\MechDesigner\Installer\Data\platforms\qwindows.dll"
SetOutPath "$INSTDIR\GUI"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Actuators.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Ammo.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\BallisticHardpoint.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\CloseButton.PNG"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\CockpitMods.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Computers.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\DockedMode.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\EnergyHardpoint.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\FloatingMode.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Gyro.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\HeatDissipated.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\HeatGenerated.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Heatsinks.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\JumpJets.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\MissileHardpoint.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Slots.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\SupportHardpoint.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Tonnage.png"
File "C:\Qt\Projects\MechDesigner\Installer\Data\GUI\Warning.png"
SectionEnd

######################################################################

Section -Icons_Reg
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\uninstall.exe"

!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$SM_Folder"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"

!ifdef WEB_SITE
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk" "$INSTDIR\${APP_NAME} website.url"
!endif
!insertmacro MUI_STARTMENU_WRITE_END
!endif

!ifndef REG_START_MENU
CreateDirectory "$SMPROGRAMS\Mech Designer by MasterBLB"
CreateShortCut "$SMPROGRAMS\Mech Designer by MasterBLB\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE}"
CreateShortCut "$SMPROGRAMS\Mech Designer by MasterBLB\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"

!ifdef WEB_SITE
WriteIniStr "$INSTDIR\${APP_NAME} website.url" "InternetShortcut" "URL" "${WEB_SITE}"
CreateShortCut "$SMPROGRAMS\Mech Designer by MasterBLB\${APP_NAME} Website.lnk" "$INSTDIR\${APP_NAME} website.url"
!endif
!endif

WriteRegStr ${REG_ROOT} "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "DisplayName" "${APP_NAME}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "DisplayIcon" "$INSTDIR\${MAIN_APP_EXE}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "DisplayVersion" "${VERSION}"
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "Publisher" "${COMP_NAME}"

!ifdef WEB_SITE
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}"  "URLInfoAbout" "${WEB_SITE}"
!endif
SectionEnd

######################################################################

Section Uninstall
${INSTALL_TYPE}
Delete "$INSTDIR\libgcc_s_dw2-1.dll"
Delete "$INSTDIR\libstdc++-6.dll"
Delete "$INSTDIR\libwinpthread-1.dll"
Delete "$INSTDIR\Mech Designer user's manual.pdf"
Delete "$INSTDIR\MechDesigner.exe"
Delete "$INSTDIR\Qt5Core.dll"
Delete "$INSTDIR\Qt5Gui.dll"
Delete "$INSTDIR\Qt5Widgets.dll"
Delete "$INSTDIR\setup.ini"
Delete "$INSTDIR\styles\qwindowsvistastyle.dll"
Delete "$INSTDIR\platforms\qwindows.dll"
Delete "$INSTDIR\GUI\Actuators.png"
Delete "$INSTDIR\GUI\Ammo.png"
Delete "$INSTDIR\GUI\BallisticHardpoint.png"
Delete "$INSTDIR\GUI\CloseButton.PNG"
Delete "$INSTDIR\GUI\CockpitMods.png"
Delete "$INSTDIR\GUI\Computers.png"
Delete "$INSTDIR\GUI\DockedMode.png"
Delete "$INSTDIR\GUI\EnergyHardpoint.png"
Delete "$INSTDIR\GUI\FloatingMode.png"
Delete "$INSTDIR\GUI\Gyro.png"
Delete "$INSTDIR\GUI\HeatDissipated.png"
Delete "$INSTDIR\GUI\HeatGenerated.png"
Delete "$INSTDIR\GUI\Heatsinks.png"
Delete "$INSTDIR\GUI\JumpJets.png"
Delete "$INSTDIR\GUI\MissileHardpoint.png"
Delete "$INSTDIR\GUI\Slots.png"
Delete "$INSTDIR\GUI\SupportHardpoint.png"
Delete "$INSTDIR\GUI\Tonnage.png"
Delete "$INSTDIR\GUI\Warning.png"

RmDir "$INSTDIR\GUI"
RmDir "$INSTDIR\platforms"
RmDir "$INSTDIR\styles"

Delete "$INSTDIR\uninstall.exe"
!ifdef WEB_SITE
Delete "$INSTDIR\${APP_NAME} website.url"
!endif

RmDir "$INSTDIR"

!ifdef REG_START_MENU
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $SM_Folder
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME} Website.lnk"
!endif
Delete "$DESKTOP\${APP_NAME}.lnk"

RmDir "$SMPROGRAMS\$SM_Folder"
!endif

!ifndef REG_START_MENU
Delete "$SMPROGRAMS\Mech Designer by MasterBLB\${APP_NAME}.lnk"
Delete "$SMPROGRAMS\Mech Designer by MasterBLB\Uninstall ${APP_NAME}.lnk"
!ifdef WEB_SITE
Delete "$SMPROGRAMS\Mech Designer by MasterBLB\${APP_NAME} Website.lnk"
!endif
Delete "$DESKTOP\${APP_NAME}.lnk"

RmDir "$SMPROGRAMS\Mech Designer by MasterBLB"
!endif

DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
SectionEnd

可悲的是,我没有NSIS的经验,这个任务简直是我力所不及的:/您能帮助队友吗?

0 个答案:

没有答案