INI formatting

Tech-Archive recommends: Fix windows errors by optimizing your registry



I'm switching from Registry to INI file to store program settings (Vista
made me to do that).
I'm trying to use this approach to write to INI file:

Public Sub WriteKeyValue(sSection As String, sKey As String, sKeyValue As
String)
Dim lngResult As Long
lngResult = WritePrivateProfileString(sSection, sKey, sKeyValue,
m_FileName)
End Sub

I'm getting not separated entries in the INI file like this:
[Section1]
MyKeyValue1=Value1
MyKeyValue2=Value2
MyKeyValue3=Value3
[Section2]
MyKeyValue21=Value21
MyKeyValue22=Value22
MyKeyValue23=Value23
[Section2]
MyKeyValue31=Value31
MyKeyValue32=Value32
MyKeyValue33=Value33

I checked the format of several existing on my PC INI files and noticed that
they have separation between sections, like this:
[Section1]
MyKeyValue1=Value1
MyKeyValue2=Value2
MyKeyValue3=Value3

[Section2]
MyKeyValue21=Value21
MyKeyValue22=Value22
MyKeyValue23=Value23

[Section2]
MyKeyValue31=Value31
MyKeyValue32=Value32
MyKeyValue33=Value33

A can add vbNewLine when I'm adding the last Key to the Section.
But because I have a lot of Registry entries I need to move to INI file I'm
afraid that I will lose control which line is the last one.
I would prefer to add a blank line BEFORE any section. I think it would
simplify the writing to the file when a new Key is added or the value of the
existing one is changed.
I used Google but found nothing.

Thank you
vovan


.



Relevant Pages

  • Re: INI formatting
    ... I know that Vista doesn't allow to do many things in Program Files, ... Vista Home the problem with Registry appeared. ... Note that Vista blocks writing to INI file if the INI is located in ...
    (microsoft.public.vb.general.discussion)
  • Re: Relink question
    ... to a known shared location (including Windows folders and the Registry) ... neither your frontend nor your INI file should be in any of ... ByVal lpReturnedString As String, _ ... sKey As String, _ ...
    (microsoft.public.access.formscoding)
  • Re: Too many controls
    ... I just finished typing something to this effect in another ... The INI file is 1 level ... It's limited to string values (although I never use ... > anything but string values in the Registry myself); ...
    (alt.comp.lang.borland-delphi)
  • Re: INI formatting
    ... Note that Vista blocks writing to INI file if the INI is located in Program ... Public Sub WriteKeyValue(sSection As String, sKey As String, sKeyValue As ...
    (microsoft.public.vb.general.discussion)
  • Serialize/Deserialize Font to/from string
    ... How do I serialize Font object into a string that I can store in either ... INI file or the registry (I know it’s a bad thing, ...
    (microsoft.public.dotnet.languages.vb)