Skip to content
⌘ NSIS Forum Archive

Howto write INI settings without a value?

8 posts

dbach#

Howto write INI settings without a value?

Hi.

I need to write something like this:

[section]
ENTRYNAME 
As you can see, there is no "=" or a value. How can I handle this?

Thanks,
Denis
Boyito#
Try in this way

ReadINIStr $0 File.ini SECTION ENTRYNAME
IfErrors 0 iniExist
WriteINIStr File.ini SECTION ENTRYNAME ""
iniExist:

Bye
Afrow UK#
You cannot write it without the =. You will have to manipulate the file using FileOpen, FileRead, FileWrite and FileClose.

Stu
dbach#
Originally posted by Afrow UK
You cannot write it without the =. You will have to manipulate the file using FileOpen, FileRead, FileWrite and FileClose.

Stu
Thanks for your reply.

I am not that familiar with FileOpen/Write/Read. Can you provide me an URL which could help me here to solve my problem?

I talked to some of the devs. They said that the windows-api supports writing/reading of 'entries' without a value (thats why they write it that way). So why doesn't the Installer supports it an easy way? :|
Afrow UK#
According to WritePrivateProfileString, if you specify NULL lpString for it will delete the entire key. You can have a look at the API here: http://msdn.microsoft.com/en-us/library/ms725501(VS.85).aspx
I cannot see any reference to creating keys without an =.

The File* are in the documentation. Search the forums as well.

Stu
Anders#
you can do:
writeinistr "$temp\file.ini" section "name$\r$\n;dummy" ""
but that is hacky as hell and only works once for each section and you get alot of dummy entries

I'm pretty sure you can't write without a = with the win api
dbach#
Originally posted by Anders
you can do:
writeinistr "$temp\file.ini" section "name$\r$\n;dummy" ""
but that is hacky as hell and only works once for each section and you get alot of dummy entries

I'm pretty sure you can't write without a = with the win api
Thanks Anders. This would be a workaround for my problem I guess. I will talk to the devs about my problem.


Thanks for all your solutions so far!!

Edit:
I could write:
writeinistr "$temp\file.ini" section "name$\r$\n;dummy=" ""
and after that
deleteinistr section dummy

Then I do not have any dummies in my .INI file.