FF_INI_DeleteSection seems to be calling the wrong API to delete a section.
Thanks Roger, I will put it in the bug tracker.
Hi Roger,
It is the correct API, but there is some redundancy in that function. There is no need to open and read the file.... Here is a better, more correct, version:
Function FF_INI_DeleteSection(ByVal IniFile As String, ByVal lSection As String) As Long
Local zFile As Asciiz * %MAX_PATH
Local zSection As Asciiz * %MAX_PATH
zFile = IniFile
zSection = lSection
Function = WritePrivateProfileString( zSection, ByVal %Null, ByVal %Null, zFile )
End Function
Note: You must use a FULLY qualified path to the ini file otherwise Windows assumes that the INI is in the Windows directory and it will NOT look for it in your application's path. You can use the App.Path variable for the applications' path (e.g. App.Path & "theapp.ini" )
The new function code will be in the next update.
Yes, reading isn't needed, but the function should be WritePrivateProfileSection if we want to delete a section...
Quote from: Roger GarstangYes, reading isn't needed, but the function should be WritePrivateProfileSection if we want to delete a section...
Not from the documentation that I've read. I have looked at my Win95 programming book and several code examples on CodeProject and they all use WritePrivateProfileString.
It wasn't deleting the section for me...even with the redundant file reading it should have deleted the section shouldn't it? It does look like what you say is correct according to the docs the Section api is only there for 16bit compat. I'll test it some more.
Make sure that you are using a full path filename. I wasted a lot of time until I realized that just using a filename alone (e.g. "myini.ini") would assume that the ini was in the Windows directory and not the application directory.
Must have just been the file stuff as this code works just fine:
'---------------------------------------------------------------------------
' Delete an entire section and all it's keys from a given INI file
'---------------------------------------------------------------------------
Function FF_INI_DeleteSection(ByVal IniFile As String, ByVal lSection As String) As Long
Function = WritePrivateProfileString(ByCopy lSection, ByVal %Null, ByVal %Null, ByCopy IniFile)
End Function