Archive: SectionSetFlags Question


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


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]

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?


Waht code you use to define sections?


Here is a sample...

Section "SectionName" uniqueidsection
;blah
WriteRegStr HKLM "Soft" id1 "uniqueidsection"
SctionEnd


Attache your code to the post.


Maybe code with SectionSetFlags is before sections definention. So try to remove it after of all sections.


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


${$0} doesnt make any sense, unless you had a DEFINE named $0


${} is a define. $0 is a variable. You are trying to put a variable inside a define?

SetSectionFlags $0 9

-Stu


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...


${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


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


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?


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


Thanks for the reply, this time i understood how section_index works...

thanks