!include "MUI.nsh"
Name "Test App"
OutFile "test.exe"
!insertmacro MUI_PAGE_COMPONENTS
Page custom SetCustom LeaveCustom
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "SimpChinese"
;--------------------------------
Section "SectionA" SecA
ReadINIStr $0 "$PLUGINSDIRtest.ini" "Field 4" State
MessageBox MB_OK "SectionA 的安装路径为:$0"
SectionEnd
Section "SectionB" SecB
ReadINIStr $0 "$PLUGINSDIRtest.ini" "Field 5" State
MessageBox MB_OK "SectionB 的安装路径为:$0"
SectionEnd
Section "SectionC" SecC
ReadINIStr $0 "$PLUGINSDIRtest.ini" "Field 6" State
MessageBox MB_OK "SectionC 的安装路径为:$0"
SectionEnd
Function .Oninit
InitPluginsDir
File /oname=$PLUGINSDIRtest.ini ".test.ini"
FunctionEnd
Function SetCustom
; 判断勾选的组件,并把未勾选组件的安装路径控件设为不可用
SectionGetFlags ${SecA} $0
StrCmp $0 0 0 +2
WriteINIStr "$PLUGINSDIRtest.ini" "Field 4" "Flags" "Disabled"
StrCmp $0 1 0 +2 ; 如果组件勾选了,还需要去掉 Disabled,这两行代码不能省略
WriteINIStr "$PLUGINSDIRtest.ini" "Field 4" "Flags" ""
SectionGetFlags ${SecB} $0
StrCmp $0 0 0 +2
WriteINIStr "$PLUGINSDIRtest.ini" "Field 5" "Flags" "Disabled"
StrCmp $0 1 0 +2
WriteINIStr "$PLUGINSDIRtest.ini" "Field 5" "Flags" ""
SectionGetFlags ${SecC} $0
StrCmp $0 0 0 +2
WriteINIStr "$PLUGINSDIRtest.ini" "Field 6" "Flags" "Disabled"
StrCmp $0 1 0 +2
WriteINIStr "$PLUGINSDIRtest.ini" "Field 6" "Flags" ""
; 预定义组件安装路径
WriteINIStr "$PLUGINSDIRtest.ini" "Field 4" "State" "$ProgramFiles"
WriteINIStr "$PLUGINSDIRtest.ini" "Field 5" "State" "$DeskTop"
WriteINIStr "$PLUGINSDIRtest.ini" "Field 6" "State" "$WinDir"
InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIRtest.ini"
!insertmacro MUI_HEADER_TEXT "选择各组件的安装路径" "必须输入有效路径"
InstallOptions::show
Pop $R0
FunctionEnd
Function LeaveCustom
; 判断用户输入的路径是否合法。
ReadINIStr $0 "$PLUGINSDIRtest.ini" "Field 4" "State"
StrCmp $0 "" 0 +3
MessageBox MB_OK|MB_ICONSTOP "组件 A 的安装路径不能为空!"
Abort
IfFileExists "$0*" +4
MessageBox MB_YESNO|MB_ICONQUESTION "组件 A 的安装路径的安装目录不存在,是否创建该文件夹?" IDYES +2
Abort
CreateDirectory $0
ReadINIStr $0 "$PLUGINSDIRtest.ini" "Field 5" "State"
StrCmp $0 "" 0 +3
MessageBox MB_OK|MB_ICONSTOP "组件 B 的安装路径不能为空!"
Abort
IfFileExists "$0*" +4
MessageBox MB_YESNO|MB_ICONQUESTION "组件 B 的安装路径的安装目录不存在,是否创建该文件夹?" IDYES +2
Abort
CreateDirectory $0
ReadINIStr $0 "$PLUGINSDIRtest.ini" "Field 6" "State"
StrCmp $0 "" 0 +3
MessageBox MB_OK|MB_ICONSTOP "组件 C 的安装路径不能为空!"
Abort
IfFileExists "$0*" +4
MessageBox MB_YESNO|MB_ICONQUESTION "组件 C 的安装路径的安装目录不存在,是否创建该文件夹?" IDYES +2
Abort
CreateDirectory $0
FunctionEnd
THE END
暂无评论内容