Skip to content
⌘ NSIS Forum Archive

WriteIniStr without section

8 posts

fabiochelly#

WriteIniStr without section

Hi,

I need to write in an ini file which contains no sections, only key=value pairs.

I tried to specify "" aas section_name but it doesn't work.

How can I do that?
Afrow UK#
Push $R0
FileOpen $R0 "file.txt" w
FileWrite $R0 "key1=value1$\r$\nkey2=value2$\r$\nkey3=value3$\r$\n"
FileClose $R0
Pop $R0
Please note that without the section headings you will not be able to easily read the values again if you wish to do so.

-Stu
fabiochelly#
The problem is that I didn't create this ini file.
I need to change an existing value but I don't know the other keys.
Afrow UK#
I have realised that I have already written a function to do this!


You want to do something like this:
Push "$INSTDIR\file.ini" ; file to modify 
Push "key=" ; string that a line must begin with
Push "key=newvalue" ; string to replace whole line with
Call ReplaceLineStr
Be warned that it will replace all instances in the file of "key=" with the "key=newvalue".

-Stu
Afrow UK#
Also if you need to read a value, you can use this function:


-Stu