SectionsFlags: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{PageAuthor| | {{PageAuthor|Tu Tong}} | ||
== Description == | == Description == | ||
Line 7: | Line 7: | ||
== Usage == | == Usage == | ||
<highlight-nsis> | <highlight-nsis> | ||
!insertmacro | !insertmacro SectionWriteReg HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ||
Function .onInit | Function .onInit | ||
Line 13: | Line 13: | ||
!insertmacro SectionReSetFlags HKLM "${PRODUCT_UNINST_KEY}" "Sections" | !insertmacro SectionReSetFlags HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ||
FunctionEnd | |||
Function Uninstall | |||
!insertmacro SectionReadReg HKLM "${PRODUCT_UNINST_KEY}" "Sections" | |||
FunctionEnd | FunctionEnd | ||
</highlight-nsis> | </highlight-nsis> | ||
== | == Example == | ||
<highlight-nsis> | <highlight-nsis> | ||
; | ; SectionsFlags.nsi | ||
; Sections. | ; | ||
; This example demonstrates how to control section flags. | |||
;-------------------------------- | |||
; Section define/macro header file | |||
; See this header file for more info | |||
!include "SectionFlags.nsh" | |||
!include "SectionFlagsFuncs.nsh" | |||
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SectionsFlags_exam" | |||
;-------------------------------- | |||
Name "SectionsFlags Example" | |||
OutFile "SectionsFlags_exam.exe" | |||
ShowInstDetails show | |||
;-------------------------------- | |||
; Pages | |||
Page components | |||
Page instfiles | |||
;-------------------------------- | |||
; Sections | |||
Section !Required | |||
SectionIn RO | |||
Call Uninstall | |||
DetailPrint "Installed Section 0" | |||
SectionEnd | |||
Section "Group 1 - Option 1" g1o1 | |||
DetailPrint "Installed Section 1" | |||
SectionEnd | |||
Section /o "Group 1 - Option 2" g1o2 | |||
DetailPrint "Installed Section 2" | |||
SectionEnd | |||
Section /o "Group 1 - Option 3" g1o3 | |||
DetailPrint "Installed Section 3" | |||
SectionEnd | |||
Section "Group 2 - Option 1" g2o1 | |||
DetailPrint "Installed Section 4" | |||
SectionEnd | |||
Section /o "Group 2 - Option 2" g2o2 | |||
DetailPrint "Installed Section 5" | |||
SectionEnd | |||
Section /o "Group 2 - Option 3" g2o3 | |||
DetailPrint "Installed Section 6" | |||
SectionEnd | |||
Section "-" | |||
DetailPrint "Installed Section 7" | |||
!insertmacro SectionWriteReg HKLM "${PRODUCT_UNINST_KEY}" "Sections" | |||
SectionEnd | |||
Function .onInit | |||
! | !insertmacro SectionReSetFlags HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ||
FunctionEnd | |||
Function Uninstall | |||
!insertmacro SectionReadReg $R0 $R1 HKLM "${PRODUCT_UNINST_KEY}" "Sections" | |||
; $R0 stores the sections old flags | |||
; $R1 stores the sections new flags | |||
${Section} 6 $R0 $R1 | |||
${Repair} | |||
DetailPrint "Repair Section 6" | |||
${Remove} | |||
DetailPrint "Remove Section 6" | |||
${SectionEnd} | |||
${Section} 5 $R0 $R1 | |||
${Repair} | |||
DetailPrint "Repair Section 5" | |||
${Remove} | |||
DetailPrint "Remove Section 5" | |||
${SectionEnd} | |||
${Section} 4 $R0 $R1 | |||
Section " | ${Repair} | ||
DetailPrint "Repair Section 4" | |||
${Remove} | |||
DetailPrint "Remove Section 4" | |||
${SectionEnd} | |||
${Section} 3 $R0 $R1 | |||
${Repair} | |||
DetailPrint "Repair Section 3" | |||
${Remove} | |||
DetailPrint "Remove Section 3" | |||
${SectionEnd} | |||
${Section} 2 $R0 $R1 | |||
${Repair} | |||
DetailPrint "Repair Section 2" | |||
${Remove} | |||
DetailPrint "Remove Section 2" | |||
${SectionEnd} | |||
${Section} 1 $R0 $R1 | |||
${Repair} | |||
DetailPrint "Repair Section 1" | |||
${Remove} | |||
DetailPrint "Remove Section 1" | |||
${SectionEnd} | |||
${Section} 0 $R0 $R1 | |||
${Repair} | |||
DetailPrint "Repair Section 0" | |||
${Remove} | |||
DetailPrint "Remove Section 0" | |||
${SectionEnd} | |||
DetailPrint "*******************************" | |||
FunctionEnd | |||
</highlight-nsis> | |||
[[Category:Section Management Functions]] | [[Category:Section Management Functions]] |
Revision as of 17:03, 18 October 2005
Author: Tu Tong (talk, contrib) |
Description
These macros use to remember and restate Section Flags Macro works only on NSIS 2.10
Usage
!insertmacro SectionWriteReg HKLM "${PRODUCT_UNINST_KEY}" "Sections" Function .onInit !insertmacro SectionReSetFlags HKLM "${PRODUCT_UNINST_KEY}" "Sections" FunctionEnd Function Uninstall !insertmacro SectionReadReg HKLM "${PRODUCT_UNINST_KEY}" "Sections" FunctionEnd
Example
; SectionsFlags.nsi ; ; This example demonstrates how to control section flags. ;-------------------------------- ; Section define/macro header file ; See this header file for more info !include "SectionFlags.nsh" !include "SectionFlagsFuncs.nsh" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SectionsFlags_exam" ;-------------------------------- Name "SectionsFlags Example" OutFile "SectionsFlags_exam.exe" ShowInstDetails show ;-------------------------------- ; Pages Page components Page instfiles ;-------------------------------- ; Sections Section !Required SectionIn RO Call Uninstall DetailPrint "Installed Section 0" SectionEnd Section "Group 1 - Option 1" g1o1 DetailPrint "Installed Section 1" SectionEnd Section /o "Group 1 - Option 2" g1o2 DetailPrint "Installed Section 2" SectionEnd Section /o "Group 1 - Option 3" g1o3 DetailPrint "Installed Section 3" SectionEnd Section "Group 2 - Option 1" g2o1 DetailPrint "Installed Section 4" SectionEnd Section /o "Group 2 - Option 2" g2o2 DetailPrint "Installed Section 5" SectionEnd Section /o "Group 2 - Option 3" g2o3 DetailPrint "Installed Section 6" SectionEnd Section "-" DetailPrint "Installed Section 7" !insertmacro SectionWriteReg HKLM "${PRODUCT_UNINST_KEY}" "Sections" SectionEnd Function .onInit !insertmacro SectionReSetFlags HKLM "${PRODUCT_UNINST_KEY}" "Sections" FunctionEnd Function Uninstall !insertmacro SectionReadReg $R0 $R1 HKLM "${PRODUCT_UNINST_KEY}" "Sections" ; $R0 stores the sections old flags ; $R1 stores the sections new flags ${Section} 6 $R0 $R1 ${Repair} DetailPrint "Repair Section 6" ${Remove} DetailPrint "Remove Section 6" ${SectionEnd} ${Section} 5 $R0 $R1 ${Repair} DetailPrint "Repair Section 5" ${Remove} DetailPrint "Remove Section 5" ${SectionEnd} ${Section} 4 $R0 $R1 ${Repair} DetailPrint "Repair Section 4" ${Remove} DetailPrint "Remove Section 4" ${SectionEnd} ${Section} 3 $R0 $R1 ${Repair} DetailPrint "Repair Section 3" ${Remove} DetailPrint "Remove Section 3" ${SectionEnd} ${Section} 2 $R0 $R1 ${Repair} DetailPrint "Repair Section 2" ${Remove} DetailPrint "Remove Section 2" ${SectionEnd} ${Section} 1 $R0 $R1 ${Repair} DetailPrint "Repair Section 1" ${Remove} DetailPrint "Remove Section 1" ${SectionEnd} ${Section} 0 $R0 $R1 ${Repair} DetailPrint "Repair Section 0" ${Remove} DetailPrint "Remove Section 0" ${SectionEnd} DetailPrint "*******************************" FunctionEnd