- NSIS Discussion
- How to read regvalue ant to set sections parametrs, based on it
Archive: How to read regvalue ant to set sections parametrs, based on it
Dkom
25th December 2004 13:39 UTC
How to read regvalue ant to set sections parametrs, based on it
If I install over previous version - I want to make one section readonly (or invisible).
If it's clean install - user can check/unckeck this section.
So I think, that it is possible to read some registry value: if it presents - the section becomes readonly (or invisible). If not - this section looks like others.
But I don't now, how to do this. For example:
Section "some_name" Sec01
...some_commands
ReadRegDWORD $R3 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "somevalue"
StrCmp $R3 "1" yes no
yes:
StrCpy $R4 "-blablabla"
goto q
no:
StrCpy $R4 "blablabla"
q:
SectionEnd
Section /o $R4 SEC02
...
some_commands
SectionEnd
But it doesn't work. Checkbox always visible, and section name invisible.
Afrow UK
25th December 2004 15:33 UTC
Use SectionSetText.
Or you can use the Section macro's in Sections.nsh if you need them.
-Stu
Dkom
25th December 2004 18:28 UTC
Maybe it's not difficult but I can't understand how to apply SectionSetText to section.
When I use
Section /o "Name" SEC02
SectionSetText "SEC02" "" ("" - to make section invisible)
some_commands
SectionEnd
nothing hapens. Maybe it's because of Modern UI?
Anders
26th December 2004 02:12 UTC
SectionSetText ${SEC02} ...
Dkom
26th December 2004 08:02 UTC
Nothing again. When I put SectionSetText ${SEC02} "" in .onInit it shows "unknown variable/constant "{SEC02}" detected, ignoring" and section SEC01 is invisible (but not SEC02).
Another interesting thing: when I write
Section "" SEC02 - it's invisible
but when I write
Function .onInit
StrCpy $0 ""
...
FunctionEnd
Section "$0" SEC02 - checkbox always visible
Here is my script http://www.046*****~komarov/script.zip How to make section SEC02 invisible (to read regkey, if it is =1 then invisible, if it's not present - then visible).
glory_man
26th December 2004 10:43 UTC
Ìîæåò ïî-ðóññêè íàïèñàòü? :) My English is terrible. :D
Try to insert .onInit-function after sections declaration.
Maybe this example helps you.
ClearErrors
ReadRegStr $0 HKLM "Your Software" "your key"
IfErrors hide 0
strcmp $0 1 hide good
hide:
SectionSetText ${SEC02} ""
; ... another action when hide section
good:
But I can mistake (ìåñòàìè). ;)
Dkom
26th December 2004 18:11 UTC
To glory_man (in Russian)
Äà,äîáàâëåíèå onInit ïîñëå ñàìèõ ñåêöèé ïîìîãëî. À êàê ðàñïîëîæåíèå onInit ìîæåò ïîâëèÿòü íà ðàáîòó èíñòàëëÿòîðà (äî èëè ïîñëå îïèñàíèÿ ñåêöèé)?. À îáÿçÿòåëüíî ñòàâèòü
ClearErrors è IfErrors.  òâîåì æå ïðèìåðå îí âñåãäà çàïðåùàåò ñåêöèþ (åñëè êëþ÷à íåò, çíà÷èò áóäåò error->hide åñëè åñòü - òî 1 è îïÿòü hide. Ó ìåíÿ êëþ÷ åñëè åñòü, òî îí âñåãäà 1 èëè åãî âîîáùå íåò, òàê ÷òî âðîäå ðàáîòàåò è áåç ClearErrors è IfErrors.
To others: I moved Function .onInit after all sections, and this one works:
Section "name" SEC01
...some commands
SectionEnd
Section "Name2" SEC02
...some commands
SectionEnd
Function on.Init
...some commands
ReadRegDword $9 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "NoModify"
StrCmp $9 "1" not_visible visible
not_visible:
SectionSetText ${SEC02} ""
visible:
FunctionEnd
Thanks to all. :)
glory_man
27th December 2004 19:11 UTC
To Dkom (in Russian).
Âîîáùå òî, íàâåðíîå, áîëåå ïðàâèëüíî èñïîëüçîâàòü ôëàã îøèáêè äëÿ ïåðåõîäà. Ò.å. åñëè êëþ÷ îòñóòñâóåò, òî ïðè åãî ÷òåíèè óñòàíîâèñòÿ ýòîò ôëàã. À åñëè êëþ÷ åñòü, è íå íóæíî çíàòü åãî çíà÷åíèå, òî äåëàé ïåðåõîä. Õîòÿ âîçìîæíî ýòî è âñå ðàâíî. Âåäü åñëè êëþ÷à íåò, òî ïåðåìåííîé ïðèñâîèòñÿ çíà÷åíèå "".
È äåëî â ðàñïîëîæåíèè ñåêöèé, à íå ôóíêöèè. Ïî-ìîåìó.
È, íàâåðíîå, ëó÷øå ïèñàòü ïî àíãëèéñêè - àòî íå ïîéìóò.
Dkom asked - How onInit placement influences istallation-programm work. I think the problem is in section placement but not in .onInit function placement. As at sections description the announcement and giving of a section_index_ouput is made. Therefore at compilation of the project all over again it is necessary to define these variables (section_index_ouputis) and then use them.
Am I right? (old Users).
Sorry my English.
Instructor
28th December 2004 07:22 UTC
Î, áëÿ, ðóññêèå êîðåøà. ß óæ äóìàë ìû òóò ñ Takhir'îì îäíè.
glory_man
29th December 2004 13:35 UTC
Íàñ ìàëî, íî ìû â òåëüíÿøêàõ :D.
È âñå-òàêè ïðàâ ÿ èëè íåò â ñâîåì ïðåäûäóùåì ïîñòå.
Old users - where are you?
Look my previous post. Am I right?