简体   繁体   English

NSIS-如果未选择任何组件,请禁用“卸载”按钮

[英]NSIS - Disable “Uninstall” button if no component is selected

I have a NSIS script with two components to uninstall. 我有一个具有两个要卸载组件的NSIS脚本。 If the user unchecks both components in the "Choose components" page, the Uninstall button is still active, and the uninstall process can continue without actually uninstalling anything. 如果用户在“选择组件”页面中取消选中两个组件,则“卸载”按钮仍处于活动状态,并且卸载过程可以继续进行,而无需实际卸载任何内容。 Is there any easy way to disable the "Uninstall" button if no component is selected? 如果没有选择任何组件,是否有任何简便的方法可以禁用“卸载”按钮? The code for selecting the uninstaller section is the following: 选择卸载程序部分的代码如下:

# 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

Thanks in advance! 提前致谢!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM