Page 1 of 1

Preference files...

Posted: Sun May 14, 2006 11:49 pm
by Joakim Christiansen
The original INI file:
// Some INI files uses comments like this

And even just like this!

[Group1]
Number = 10

[Group2]
Number = 20

; And pure basic use comments like this in INI files
; But it please don't make it mess up the whole file like it does now!
The same file after I changed the value of Number in Group1:
// Some INI files uses comments like this =
And even just like this! =
[Group1]
Number = 99
[Group2]
Number = 20
; And pure basic use comments like this in INI files
; But it please don't make it mess up the whole file like it does now!
Does it really have to trash the whole INI file? :lol:
Please just fix this... <-- that was the feature request

Posted: Mon May 15, 2006 3:04 am
by va!n
The same file after I changed the value of Number in Group1:
o_O
Please just fix this... <-- that was the feature request
:)

Posted: Mon May 15, 2006 3:28 am
by Joakim Christiansen
It's not fun making a INI editor for a game when the INI file looks like it was raped after I changed a value in it! :lol:
I know it's a stupid request, but I think it should be easy to fix.

Posted: Mon May 15, 2006 9:21 am
by maw
If it's a windows program I suggest you use the WinAPI to modify INI-files that is created by other programs to avoid this kind of problems. I use them myself in a couple of programs that needs to modify the INI-file for UT2004, which does NOT like being modified by PB :D

This is a link to all available functions: http://msdn.microsoft.com/library/defau ... ctions.asp

Code: Select all

BOOL WritePrivateProfileString(
  LPCTSTR lpAppName,
  LPCTSTR lpKeyName,
  LPCTSTR lpString,
  LPCTSTR lpFileName
);
It's very easy to use. Just one single line of code:

Code: Select all

WritePrivateProfileString_(@"Section", @"Key", @"Value", @"ini-file.ini")

Posted: Mon May 15, 2006 3:46 pm
by Joakim Christiansen
You saved the day maw, thank you! :D