在NSIS中的两个部分之间插入自定义页
(很抱歉,我想不出更好的标题) 我有以下部分代码:在NSIS中的两个部分之间插入自定义页,nsis,Nsis,(很抱歉,我想不出更好的标题) 我有以下部分代码: !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES Page Custom nsDialogsPage nsDialogsPageLeave section Section1 #do something sectionEnd section Section2 #do something else sectionEnd Function nsDialogsPage
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
Page Custom nsDialogsPage nsDialogsPageLeave
section Section1
#do something
sectionEnd
section Section2
#do something else
sectionEnd
Function nsDialogsPage
#do something
FunctionEnd
Function nsDialogsPageLeave
#do something else
FunctionEnd
但是,现在我希望自定义页面显示在Section1之后和Section2之前(我在Section2中使用的自定义页面中输入一些信息)。我该怎么做?(我总是可以将自定义页面放在MUI_Page_INSTFILES之前,但这对用户来说很奇怪。)所有部分都在INSTFILES页面上执行,但是也可以有多个INSTFILES页面。要防止所有节执行两次,您需要使用
sections.nsh
中的helper宏打开/关闭正确的节,或者将某些状态存储在全局变量中,并将所有节代码放入if块中,例如:${if}$installstep=0
。您可能还需要使用SetAutoClose
..我使用了PRE函数来选择/取消选择节:
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_PRE checkSkipSection
!insertmacro MUI_PAGE_INSTFILES
Page Custom nsDialogsPage nsDialogsPageLeave
!define MUI_PAGE_CUSTOMFUNCTION_PRE checkSkipSection
!insertmacro MUI_PAGE_INSTFILES
Var SkipSection
section Section1
#do something
StrCpy $SkipSection 1
sectionEnd
section Section2
#do something else
sectionEnd
Function nsDialogsPage
#do something
FunctionEnd
Function nsDialogsPageLeave
#do something else
FunctionEnd
Function checkSkipSection
${If} $SkipSection = ""
SectionSetFlags ${Section1} ${SF_SELECTED}
SectionSetFlags ${Section2} 0
${ElseIf} $SkipSection = 1
SectionSetFlags ${Section2} ${SF_SELECTED}
SectionSetFlags ${Section1} 0
${EndIf}
FunctionEnd
因此,在第一个MUI_页面_INSTFILES中,仅运行第1节,而在第二个MUI_页面_INSTFILES页面中运行第2节。安装程序通常在开始对系统进行更改的实际安装步骤之前收集尽可能多的信息,为什么你认为这样分割安装进度是个好主意?谢谢,我尝试了全局变量的想法,这很有效!但是,代码看起来非常混乱:)或者如果不想使用SkipSection变量,请对自定义页面使用两个单独的函数checkSkipSection1和2,并相应地设置每个页面中的标志。