如何在NSIS组件页面之前根据注册表预设组件勾选状态

!include "MUI.nsh"
 OutFile "test.exe"

 !define MUI_PAGE_CUSTOMFUNCTION_Pre ComponentsPre
 !insertmacro MUI_PAGE_COMPONENTS
 !insertmacro MUI_PAGE_INSTFILES

 !insertmacro MUI_LANGUAGE "Simpchinese"

Section "组件A" SecA
SectionEnd

Section "组件B" SecB
SectionEnd

Section "组件C" SecC
SectionEnd

Function ComponentsPre
; 如果注册表 HKEY_CURRENT_USER\Software\Test 下存在 SecA 键,且其值为 0 ,那么第一个组件默认就不勾选。
; 以下同。
ReadRegStr $0 HKCU "Software\Test" "SecA"
IfErrors +2
 StrCmp $0 0 0 +2
 SectionSetFlags ${SecA} 0

ReadRegStr $0 HKCU "Software\Test" "SecB"
IfErrors +2
 StrCmp $0 0 0 +2
 SectionSetFlags ${SecB} 0

ReadRegStr $0 HKCU "Software\Test" "SecC"
IfErrors +2
 StrCmp $0 0 0 +2
 SectionSetFlags ${SecC} 0

Functionend
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容