- NSIS Discussion
- SectionSetFlags Question
Archive: SectionSetFlags Question
WebMatze
2nd March 2006 08:41 UTC
SectionSetFlags Question
I'd like to know how to use SectionSetFlags with a section index that i get from the registry, here is an example:
ReadRegStr $0 blah blah
SectionSetFlags ${$0} 9
It doesn't work and i didn't find in the forum a way to make it work.
Can someone tell me if there is a way to make that work?
Thanks in advance
MAtze
glory_man
2nd March 2006 09:40 UTC
You need to read documentation first.
4.9.13.1 SectionSetFlags
section_index section_flags
Sets the section's flags. The flag is a 32 bit integer.
So if registry key hold section flags you need to use:
SectionSetFlags ${sec_id} $0
Where sec_id section_index_output
4.6.1.2 Section
[/o] [([!]|[-])section_name] [section_index_output]
WebMatze
2nd March 2006 09:48 UTC
Thanks for your comments but I read the docs, the problem is here:
SectionSetFlags ${$0} 9
I want to pass the result of ReadRegStr in the SectionSetFlags command, the result is the section_index...
Example:
ReadRegStr $0 HKLM "Soft\" "1"
;$0 is blah
SetSectionFlags ${$0} 1
-> $0 should be blah, but it dosn't work
any idea?
glory_man
2nd March 2006 09:56 UTC
Waht code you use to define sections?
WebMatze
2nd March 2006 10:04 UTC
Here is a sample...
Section "SectionName" uniqueidsection
;blah
WriteRegStr HKLM "Soft" id1 "uniqueidsection"
SctionEnd
glory_man
2nd March 2006 10:07 UTC
Attache your code to the post.
glory_man
2nd March 2006 10:12 UTC
Maybe code with SectionSetFlags is before sections definention. So try to remove it after of all sections.
WebMatze
2nd March 2006 10:13 UTC
Thanks for your help but i cant post the code, i deleted it by mistake and i'm quiet tired of trying to make it work...
So i think i will search a new way to disable sections...
Thanks again.
Matze
Anders
2nd March 2006 11:21 UTC
${$0} doesnt make any sense, unless you had a DEFINE named $0
Afrow UK
2nd March 2006 12:08 UTC
${} is a define. $0 is a variable. You are trying to put a variable inside a define?
SetSectionFlags $0 9
-Stu
WebMatze
2nd March 2006 12:20 UTC
The problem is that if i want that sectionsetflag works correctly, it must be in the form:
SectionSetFlags ${sec_id} 1
SectionSetFlags sec_id 1
-> doesn't work...
Afrow UK
2nd March 2006 12:22 UTC
${sec_id} is just a define that contains the section index (zero based) therefore you can use a variable in its place which may contain the section index. "sec_id" does not work because it's a string not an integer.
-Stu
Afrow UK
2nd March 2006 12:24 UTC
In fact you don't even need to give it a variable or define for the first operand. You could pass it a constant "0" (to specify the first Section) if you happen to be using SectionSetFlags/SectionGetFlags etc further up in your script before the actual Section define is created (with Section "Sec Name" SecID).
-Stu
WebMatze
2nd March 2006 12:33 UTC
THanks for the explanations,
i'll try your method, but, perhaps can you help me...
here is my code sample:
Section "Sec1" Sec1
;blah
SectionEnd
Function .oninit
ReadRegStr $0 HKLM "Software\Blah" "String1"
; String1= Sec1
SectionSetFlags $0 8
FunctionEnd
Will that work?
Afrow UK
2nd March 2006 15:58 UTC
No it will not because like I've already said, Sec1 is a compile-time definition for a constant "0". Once compiled, the constant name "Sec1" is no longer a part of the installer - it has been replaced with the constant value "0" - so it's the same as putting "0" there instead of "${Sec1}". If this weren't the case then we'd end up adding extra overhead which is completely pointless.
Instead of storing "Sec1" in the registry you should store the Section index instead ( ${Sec1} ).
-Stu
WebMatze
2nd March 2006 18:53 UTC
Thanks for the reply, this time i understood how section_index works...
thanks