Archive: WriteIniStr without section


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?


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

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.


Ah right. I'll write a function to do this then (won't take too long)!

-Stu


Thank you very much


I have realised that I have already written a function to do this!
http://nsis.sourceforge.net/archive/...b.php?page=626

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

Also if you need to read a value, you can use this function:
http://nsis.sourceforge.net/archive/...b.php?page=636

-Stu


Thank you very much