Title: NSIS学习笔记三-中文测试
Author: Kagula
Date: 2016-08-30
Environment: NSIS 3.0(Released July 24, 2016)
Introduction
Simple install program code demonstrate. Using default MUI2 Style GUI.
I think NSIS 3.0 is the first version that support unicode(chinese).
Feature List
[1]支持检查安装程序是否在运行。
[2]支持检查主程序是否在运行。
[3]支持版本检测。
[4]支持升级安装。
[5]支持用户修改安装路径。
[6]支持中文。
[7]支持从控制面板卸载程序。
Prepare:
suppose source directory name is issue and exist in the same directory as nis script.
Manifest:
!include "MUI2.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
!include "nsProcess.nsh"
Unicode true
!define APPNAME "XXX软件客户端"
!define COMPANYNAME "XXX有限公司"
!define DESCRIPTION ""
!define APPEXENAME "XXX.exe"
!define VERSIONMAJOR 1
!define VERSIONMINOR 0
!define VERSIONBUILD 0
!define VERSIONREVISION 0
!define MYINSTALLDIR "organizationName"
!define MYINSTALLSUBDIR "productName"
# This is the size (in kB) of all the files copied into "Program Files"
!define INSTALLSIZE 20000
!define HELPURL "http://www.kagula.com/" # "Support Information" link
!define UPDATEURL "http://www.kagula.com/" # "Product Updates" link
!define ABOUTURL "http://www.kagula.com/" # "Publisher" link
;--------------------------------------------------------------------
!define VERSIONLONG "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}.${VERSIONREVISION}"
!define SETUPFILENAME "Setup${VERSIONLONG}.exe"
OutFile "${SETUPFILENAME}"
Name "${APPNAME}"
InstallDir "$PROGRAMFILES\${MYINSTALLDIR}\${MYINSTALLSUBDIR}"
ShowInstDetails show
RequestExecutionLevel admin
XPStyle on
CompletedText "完成安装"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFuncDir
Function MyFuncDir
#不知道为什么这里不能引用全局变量
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "MainProgramLocation"
${If} $0 != ""
;disable browser button.
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1001
EnableWindow $0 0
;disable edit install p