Wenn ich eine INI-Datei erstellte, dann sieht sie so aus:
Code: Alles auswählen
[Test]
key = val
wal = 4
Kann man das abstellen? Oder muss ich doch die ganze INI Datei einlesen und neu schreiben - manuell?
Code: Alles auswählen
[Test]
key = val
wal = 4
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
Code: Alles auswählen
CreatePreferences("D:\temp\settings.ini")
PreferenceGroup("Test")
WritePreferenceString("key", "val")
WritePreferenceLong("wal", 4)
ClosePreferences()
Code: Alles auswählen
[Test]
key#=#val
wal#=#4
Code: Alles auswählen
[URL]
Protocol=unreal
ProtocolDescription=Unreal Protocol
Name=userAgent
Map=Entry.unr
LocalMap=Intro.unr
Host=
Portal=
MapExt=unr
SaveExt=usa
Port=7777
Class=s_SWAT.s_Player_T
[FirstRun]
FirstRun=436
< Geht noch weiter... >
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
Code: Alles auswählen
;-TOP
; Kommentar : Include INI-Dateien
; Author : mk-soft
; Second Author :
; Datei : INI-File.pb
; Version : 1.01
; Erstellt :
; Geändert : 02.10.2006
;
; Compilermode :
;
; ***************************************************************************************
Procedure GetSectionsNames(path.s, *list.s())
Protected *buffer, *adr, temp.s
*buffer = AllocateMemory($4000)
GetPrivateProfileSectionNames_(*buffer, $4000, path)
*adr = *buffer
Repeat
temp = PeekS(*adr)
If temp <> ""
AddElement(*list())
*list() = temp
EndIf
*adr + Len(temp) + 1
Until temp = ""
FreeMemory(*buffer)
EndProcedure
; ***************************************************************************************
Procedure GetSection(section.s, path.s, *list.s())
Protected *buffer, *adr, temp.s
*buffer = AllocateMemory($4000)
GetPrivateProfileSection_(section, *buffer, $4000, path)
*adr = *buffer
Repeat
temp.s = PeekS(*adr)
If temp <> ""
AddElement(*list())
*list() = temp
EndIf
*adr + Len(temp) + 1
Until temp = ""
FreeMemory(*buffer)
EndProcedure
; ***************************************************************************************
Procedure.s ReadINI(lpAppName.s, lpKeyName.s, lpFileName.s, lpDefault.s = "")
Protected *lpReturnedString
Protected Result.s
*lpReturnedString = AllocateMemory(1024)
lpDefault = ""
GetPrivateProfileString_(lpAppName, lpKeyName, lpDefault, *lpReturnedString, 1024, lpFileName)
Result.s = PeekS(*lpReturnedString)
FreeMemory(*lpReturnedString)
ProcedureReturn Result
EndProcedure
; ***************************************************************************************
Procedure WriteINI(lpszSection.s, lpszKey.s, lpszString.s, lpszFile.s)
Protected result
result = WritePrivateProfileString_(lpszSection, lpszKey, lpszString, lpszFile)
ProcedureReturn result
EndProcedure
; ***************************************************************************************
;- Test
NewList SectionsNames.s()
NewList Section.s()
path.s = GetCurrentDirectory() + "test.ini"
GetSectionsNames(path, SectionsNames())
ForEach SectionsNames()
Debug SectionsNames()
ClearList(Section())
GetSection(SectionsNames(), path, Section())
ForEach Section()
Debug Section()
Next
Next
; ***************************************************************************************