我有一个NSIS脚本,有两个要卸载的组件。如果用户取消选中"选择组件"页面,卸载按钮仍处于活动状态,卸载过程可以继续,而无需实际卸载任何内容。是否有任何简单的方法可以禁用"卸载"如果没有选择组件,按钮? 选择卸载程序部分的代码如下:
# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
Push $R0
ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
StrCmp $R0 1 0 next${UNSECTION_ID}
!insertmacro SelectSection "${UNSECTION_ID}"
GoTo done${UNSECTION_ID}
next${UNSECTION_ID}:
!insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
Pop $R0
!macroend
提前致谢!
答案 0 :(得分:2)
UninstPage Components un.InitComponents
UninstPage InstFiles
Section "un.Foo" SID_FOO
SectionEnd
Section /o "un.Bar" SID_BAR
SectionEnd
!include LogicLib.nsh
Function un.InitComponents
;!insertmacro SELECT_UNSECTION SECTION_NAME ...
Call un.onSelChange ; Make sure the initial button state is correct
FunctionEnd
Function un.onSelChange
GetDlgItem $1 $hwndParent 1
${If} ${SectionIsSelected} ${SID_FOO}
${OrIf} ${SectionIsSelected} ${SID_BAR}
EnableWindow $1 1
${Else}
EnableWindow $1 0
${EndIf}
FunctionEnd