如果选择某个组件,我想提示用户提供额外信息,但我不确定如何检查是否选择了给定组件。似乎http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.13.2可能在某种程度上相关,但我的印象是一个部分是一组组件......
在安德斯的帮助下,我有这个有效:
!include MUI.nsh
!include nsDialogs.nsh
!include LogicLib.nsh
!include sections.nsh
Name A
InstProgressFlags smooth colored
LicenseBkColor /windows
OutFile A.exe
InstallDir $PROGRAMFILES\A
Var Dialog
Section "A" SEC_A
SectionEnd
Section "B" SEC_B
SectionEnd
!insertmacro MUI_PAGE_COMPONENTS
Page custom getA setA # {{{
!insertmacro MUI_PAGE_DIRECTORY # {{{ install
Function getA
${Unless} ${SectionIsSelected} ${SEC_A}
Abort
${EndUnless}
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Test"
nsDialogs::Show
FunctionEnd
Function setA
MessageBox MB_OK "clicked?"
FunctionEnd
# }}}
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
答案 0 :(得分:8)
每个部分(带名称)都显示为组件页面上的复选框。 (节组可用于形成树布局,但只有实际节包含可执行代码)
sections.nsh
包含操作setions的方便助手宏,如果您使用logiclib.nsh
,则可以执行${If} ${SectionIsSelected} ${MYSECTION}
...