SectionsFlags: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
(use attach, not a manual link) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
== Download Link == | == Download Link == | ||
<attach>SectionFlags.zip</attach> | |||
== Description == | == Description == | ||
These macros can remember or set section flags. | These macros can remember or set section flags. This example show you how to get section flags and remember in windows registry after first install, installer will reset all the flags on next time to run installer. Funtion Uninstall is called before install files sections... | ||
== Usage == | == Usage == | ||
<highlight-nsis> | <highlight-nsis> | ||
Section "Required" | |||
SectionIn RO | |||
Call Uninstall | |||
SectionEnd | |||
Insert code (Sections) here... | |||
Section "-" | Section "-" | ||
${SectionWriteReg} HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ${SectionWriteReg} HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ||
Line 19: | Line 26: | ||
Function Uninstall | Function Uninstall | ||
${SectionGetValues} HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ${SectionGetValues} HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ||
${Section} ${Section Index} | |||
${Repair} | |||
insert code here... | |||
${Remove} | |||
insert code here... | |||
${SectionEnd} | |||
FunctionEnd | FunctionEnd | ||
Line 34: | Line 48: | ||
; Section define/macro header file | ; Section define/macro header file | ||
; See this header file for more info | ; See this header file for more info | ||
! | !include ".\SectionFunc.nsh" | ||
;${SectionReadReg} | ;${SectionReadReg} | ||
${SectionResetFlags} | ${SectionResetFlags} | ||
${SectionWriteReg} | ${SectionWriteReg} | ||
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SectionsFlags_exam" | |||
;-------------------------------- | ;-------------------------------- | ||
Line 52: | Line 64: | ||
; Pages | ; Pages | ||
Page components | Page components | ||
Page instfiles | Page instfiles | ||
Line 65: | Line 76: | ||
SectionEnd | SectionEnd | ||
Section " | Section "Section 1" sec1 | ||
SectionGetText ${sec1} $0 | |||
DetailPrint "Installed $0" | |||
SectionGetText ${ | |||
DetailPrint "Installed | |||
SectionEnd | SectionEnd | ||
Section /o " | Section /o "Section 2" sec2 | ||
SectionGetText ${ | SectionGetText ${sec2} $0 | ||
DetailPrint "Installed | DetailPrint "Installed $0" | ||
SectionEnd | SectionEnd | ||
Section /o " | Section /o "Section 3" sec3 | ||
SectionGetText ${ | SectionGetText ${sec3} $0 | ||
DetailPrint "Installed | DetailPrint "Installed $0" | ||
SectionEnd | SectionEnd | ||
Line 100: | Line 96: | ||
Function .onInit | Function .onInit | ||
${SectionResetFlags} HKLM "${PRODUCT_UNINST_KEY}" "Sections" | |||
FunctionEnd | FunctionEnd | ||
Line 106: | Line 102: | ||
${SectionGetValues} HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ${SectionGetValues} HKLM "${PRODUCT_UNINST_KEY}" "Sections" | ||
${Section} ${ | ${Section} ${sec1} | ||
${Repair} | ${Repair} | ||
DetailPrint "Repaired | DetailPrint "Repaired Section 1" | ||
${Remove} | ${Remove} | ||
DetailPrint " | DetailPrint "REMOVED Section 1" | ||
${SectionEnd} | ${SectionEnd} | ||
${Section} ${ | ${Section} ${sec2} | ||
${Repair} | ${Repair} | ||
DetailPrint "Repaired | DetailPrint "Repaired Section 2" | ||
${Remove} | ${Remove} | ||
DetailPrint " | DetailPrint "REMOVED Section 2" | ||
${SectionEnd} | ${SectionEnd} | ||
${Section} ${ | ${Section} ${sec3} | ||
${Repair} | ${Repair} | ||
DetailPrint "Repaired | DetailPrint "Repaired Section 3" | ||
${Remove} | ${Remove} | ||
DetailPrint " | DetailPrint "REMOVED Section 3" | ||
${SectionEnd} | ${SectionEnd} | ||
Latest revision as of 18:17, 19 January 2006
Author: Tu Tong (talk, contrib) |
Download Link
SectionFlags.zip (3 KB)
Description
These macros can remember or set section flags. This example show you how to get section flags and remember in windows registry after first install, installer will reset all the flags on next time to run installer. Funtion Uninstall is called before install files sections...
Usage
Section "Required" SectionIn RO Call Uninstall SectionEnd Insert code (Sections) here... Section "-" ${SectionWriteReg} HKLM "${PRODUCT_UNINST_KEY}" "Sections" SectionEnd Function .onInit ${SectionResetFlags} HKLM "${PRODUCT_UNINST_KEY}" "Sections" FunctionEnd Function Uninstall ${SectionGetValues} HKLM "${PRODUCT_UNINST_KEY}" "Sections" ${Section} ${Section Index} ${Repair} insert code here... ${Remove} insert code here... ${SectionEnd} 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 ".\SectionFunc.nsh" ;${SectionReadReg} ${SectionResetFlags} ${SectionWriteReg} !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 SectionEnd Section "Section 1" sec1 SectionGetText ${sec1} $0 DetailPrint "Installed $0" SectionEnd Section /o "Section 2" sec2 SectionGetText ${sec2} $0 DetailPrint "Installed $0" SectionEnd Section /o "Section 3" sec3 SectionGetText ${sec3} $0 DetailPrint "Installed $0" SectionEnd Section "-" ${SectionWriteReg} HKLM "${PRODUCT_UNINST_KEY}" "Sections" SectionEnd Function .onInit ${SectionResetFlags} HKLM "${PRODUCT_UNINST_KEY}" "Sections" FunctionEnd Function Uninstall ${SectionGetValues} HKLM "${PRODUCT_UNINST_KEY}" "Sections" ${Section} ${sec1} ${Repair} DetailPrint "Repaired Section 1" ${Remove} DetailPrint "REMOVED Section 1" ${SectionEnd} ${Section} ${sec2} ${Repair} DetailPrint "Repaired Section 2" ${Remove} DetailPrint "REMOVED Section 2" ${SectionEnd} ${Section} ${sec3} ${Repair} DetailPrint "Repaired Section 3" ${Remove} DetailPrint "REMOVED Section 3" ${SectionEnd} DetailPrint "*******************************" FunctionEnd