SectionsFlags: Difference between revisions

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


== Description ==
== Description ==
These macros use to remember and restate Section Flags
These macros use to remember and restate Section Flags.
Macro works only on NSIS 2.10
Macro works only on NSIS 2.10.


== Usage ==
== Usage ==
Line 16: Line 16:


   Function Uninstall
   Function Uninstall
     !insertmacro SectionReadReg HKLM "${PRODUCT_UNINST_KEY}" "Sections"
     !insertmacro SectionReadReg HKLM "${PRODUCT_UNINST_KEY}" "Sections"
   FunctionEnd
   FunctionEnd



Revision as of 17:06, 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