Skip to content
⌘ NSIS Forum Archive

Problem about "StrCmp" & "SectionIn"

7 posts

Guest#

Problem about "StrCmp" & "SectionIn"

Hi everybody, I'm the newbie of writing NSIS, I've a problem on writing that, could anyone help me?

If I would like to write a script that have below function:

firstly, read a regedit string, if that is "1", set the section to selectable, else set the section to unselectable. could anyone can tell me how can I do that?

my wrong script:
		Section /o "Test"
Call CheckInstall
SectionEnd

Function CheckInstall
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\X-Tiger" "TEST"
StrCmp $0 "1" +1
SectionIn RO
FunctionEnd
finally, I'm sorry for my poor english XD
Afrow UK#
You should use the SelectSection macro in Sections.nsh:
!include Sections.nsh

Section "Blah!" SecBlah
...
SectionEnd

Section /o "Test"
Push $R0
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\X-Tiger" "TEST"
StrCmp $R0 1 0 NoSelect
!insertmacro SelectSection ${SecBlah}
NoSelect:
Pop $R0
SectionEnd
-Stu
Guest#
Afrow UK, thanks for your help, but that does not work too...

Does my script is wrong?
glory_man#
Maybe this example help you.

Section "SEC1" Sec1
SectionEnd

Section "-SEC2" Sec2
SectionEnd

Function .onInit

Push $R0
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\X-Tiger" "TEST"
StrCmp $R0 1 0 NoSelect
SectionSetText ${Sec2} "SEC2"

NoSelect:
Pop $R0
FunctionEnd
I check regestry key inside .onInit function. And than change name of 2-nd section from hidden ("-Sec2") to visible ("Sec2") using SectionSetText.
Joel#
I don't have that, but you can try this too:

Name "X-TigerSP2 - Test"
OutFile "Test.exe"

!include "Sections.nsh"

FileBufSize 6

BrandingText "Copyright (c) 2004 X-Ray"
XPStyle on
ShowInstDetails show


Page Components pre_comp
Page InstFiles

Section "SEC1" Sec1
DetailPrint "Here's SEC1"
SectionEnd

Function pre_comp
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\X-Tiger" "TEST"
StrCmp $R0 1 0 NoSelect
SectionSetFlags ${Sec1} 0xFFFFFFFE

NoSelect:
FunctionEnd

Section "-SEC2"
DetailPrint "Default is SEC2"
SectionEnd
Guest#
Lobo Lunar, your method also work too, but something need to change: Section /o "SEC1" Sec1

^_^ thanks, Lobo Lunar.