我正在尝试使用NSIS创建一个安装程序,该安装程序将3个不同的组件安装到三个不同的路径。我希望用户选择/确认每个用户,但只应询问他们是否已选择相关组件。
由于页面不能出现在各个部分,我不知道如何做到这一点
有什么建议吗?
提前致谢: - )
答案 0 :(得分:1)
您可以使用多个目录页面:
!include LogicLib.nsh
InstallDir $ProgramFiles32\Foo\Bar
Var Comp1Path
Var Comp2Path
Page Components
PageEx Directory
DirText "Blah blah 1"
DirVar $Comp1Path
PageCallbacks Comp1Pre
PageExEnd
PageEx Directory
DirText "Blah blah 2"
DirVar $Comp2Path
PageCallbacks Comp2Pre
PageExEnd
Page InstFiles
Section /o Comp1 SID_C1
DetailPrint "Installing Comp1 to $Comp1Path"
SectionEnd
Section Comp2 SID_C2
DetailPrint "Installing Comp2 to $Comp2Path"
SectionEnd
Function Comp1Pre
StrCpy $Comp1Path $InstDir\Comp1
${IfNot} ${SectionIsSelected} ${SID_C1}
Abort ; Skipping this page
${EndIf}
FunctionEnd
Function Comp2Pre
StrCpy $Comp2Path $InstDir\Comp2
${IfNot} ${SectionIsSelected} ${SID_C2}
Abort
${EndIf}
FunctionEnd
; In this example the next button on the components page might be the last page before InstFiles so we have to update the button text
!include WinMessages.nsh
Function .onSelChange
GetDlgItem $1 $hwndParent 1
${If} ${SectionIsSelected} ${SID_C1}
${OrIf} ${SectionIsSelected} ${SID_C2}
SendMessage $1 ${WM_SETTEXT} 0 "STR:$(^NextBtn)"
${Else}
SendMessage $1 ${WM_SETTEXT} 0 "STR:$(^InstallBtn)"
${EndIf}
FunctionEnd
另一种方法是使用nsDialogs创建自定义页面,只需禁用或隐藏用户无需确认的文本字段...