引入现代UI头文件
!include "MUI2.nsh"
页面设置
#安装时取消 弹出确认框
!define MUI_ABORTWARNING
#安装时欢迎界面的图片
!define MUI_WELCOMEFINISHPAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp
#卸载时欢迎界面的图片
!define MUI_UNWELCOMEFINISHPAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall.bmp
安装页面
#欢迎界面
!insertmacro MUI_PAGE_WELCOME
#设置安装目录界面
!insertmacro MUI_PAGE_DIRECTORY
#安装
!insertmacro MUI_PAGE_INSTFILES
#安装完成
!insertmacro MUI_PAGE_FINISH
卸载页面
#欢迎界面
!insertmacro MUI_UNPAGE_WELCOME
#确认界面
!insertmacro MUI_UNPAGE_CONFIRM
#卸载
!insertmacro MUI_UNPAGE_INSTFILES
#卸载完成
!insertmacro MUI_UNPAGE_FINISH
设置页面语言
!insertmacro MUI_LANGUAGE "SimpChinese"
控制面板显示程序信息
#显示名称
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UGUI" "DisplayName" "UGUI"
#设置卸载路径
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UGUI" "UninstallString" "$INSTDIR\Uninstall.exe"
#删除信息
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UGUI"
资料
Modern UI 2.1
示例
!include "MUI2.nsh"
Unicode true
Name "Guide"
OutFile "Basic.exe"
InstallDir $Desktop\ModernUITest
!define MUI_ABORTWARNING
!define MUI_WELCOMEFINISHPAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp
!define MUI_UNWELCOMEFINISHPAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Wizard\orange-uninstall.bmp
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "SimpChinese"
Section
SetOutPath $INSTDIR
File *.exe
File *.dll
File /r MonoBleedingEdge
File /r UGUI_Data
WriteUninstaller $INSTDIR\Uninstall.exe
CreateDirectory "$SMPROGRAMS\A Test"
CreateShortcut "$DESKTOP\UGUI.lnk" "$INSTDIR\UGUI.exe"
CreateShortcut "$SMPROGRAMS\A Test\UGUI.lnk" "$INSTDIR\UGUI.exe"
CreateShortcut "$SMPROGRAMS\A Test\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UGUI" "DisplayName" "UGUI"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UGUI" "UninstallString" "$INSTDIR\Uninstall.exe"
SectionEnd
Section "Uninstall"
RMDIR /r $INSTDIR
RMDIR /r "$SMPROGRAMS\A Test"
Delete "$DESKTOP\UGUI.lnk"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\UGUI"
SectionEnd