SectionsFlags: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
No edit summary
Line 5: Line 5:


== Description ==
== Description ==
These macros can remember or set section flags. Macros work only on NSIS 2.10 or higher.
These macros can remember or set section flags.


== Usage ==
== Usage ==

Revision as of 14:21, 27 October 2005

Author: Tu Tong (talk, contrib)


Download Link

Zip.gif sectionflags.zip (4 KB)

Description

These macros can remember or set section flags.

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
  ; $0 - $3 used by macro
 
  ${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