Archive: Problem with UnselectSection.


Problem with UnselectSection.
In the NSIS file I'm currently working on, I want it to check the registry to see if a certain file is installed on the computer or not, and if it is, I want the Section pertaining to that installed file to be visible in the Install Options window. But if it is not installed on the computer(registry key not found), I want that Section to not turn up in the Install Options window.


The problem I'm currently having(after trying several things), is that all the Sections are invisible in the Install Options window, either if the registry key is present or not.

So what am I doing wrong? Please fix the example script:


Function .onInit
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\File 1" "UninstallString"
StrCmp $0 "" +3
!insertmacro UnselectSection ${Sec00}
SectionSetText ${Sec00} ""


ReadRegStr $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\File 2" "UninstallString"
StrCmp $1 "" +3
!insertmacro UnselectSection ${Sec01}
SectionSetText ${Sec01} ""
FunctionEnd

!macro's contain more than one line of code, and so doing a relative jump over a !insertmacro will not work. Use a label instead.

-Stu


OK, I had already tried using labels before with no luck, but I must have done something wrong, because this time it worked.

This example works for what I want(for future readers):


Function .onInit
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\File 1" "UninstallString"
StrCmp $0 "" 0 next
!insertmacro UnselectSection ${Sec00}
SectionSetText ${Sec00} ""

next:
ReadRegStr $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\File 2" "UninstallString"
StrCmp $1 "" 0 next1
!insertmacro UnselectSection ${Sec01}
SectionSetText ${Sec01} ""

next1:
FunctionEnd