this applies to windows only. Fred probably did his function to support linix and windows, which would explain the problem. The exact problem was that once i created my pref file, i could not make changes unless i deleted the file. The api does not require that. Here is how to use the api:
Code: Select all
#BufferSize=1000
Global *FileBuffer ;so it can be used inside any function
*FileBuffer = AllocateMemory(#BufferSize)
;other vars used by API
;these can be declared inside functions as required
IniFileName.s="MyIni.INI"
Section.s="First User"
KeyName.s="First Key"
;write a string to the ini file
WritePrivateProfileString_(Section, KeyName, "Data!", IniFileName)
;Read a string
GetPrivateProfileString_(Section, KeyName, "Default", *FileBuffer, MemorySize(*FileBuffer), IniFileName)
KeyData.s=PeekS(*FileBuffer)
Debug KeyData
;Read a long or int
KeyName="Key Int"
KeyVal.l=GetPrivateProfileInt_(Section,KeyName, 0, IniFileName)
;Write a long or int(this gets slightly odd)
WritePrivateProfileString_(Section,KeyName,Str(KeyVal),IniFileName)