!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