Use WritePrivateProfileSection.
To clear the entire section pass NULL for the lpString parameter.
edit:
Tested code:
Imports System.Runtime.InteropServices
Module Module1
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Function WritePrivateProfileSection(ByVal lpAppName As String, ByVal lpString As IntPtr, ByVal lpFileName As String) As Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Function WritePrivateProfileString(ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Boolean
End Function
Sub Main()
Dim res As Boolean
res = WritePrivateProfileString("Test", "val1", "1", "D: est.ini")
res = WritePrivateProfileString("Test", "val2", "1", "D: est.ini")
res = WritePrivateProfileString("Test", "val3", "1", "D: est.ini")
res = WritePrivateProfileString("Test1", "val1", "1", "D: est.ini")
res = WritePrivateProfileString("Test1", "val2", "1", "D: est.ini")
res = WritePrivateProfileString("Test1", "val3", "1", "D: est.ini")
res = WritePrivateProfileSection("Test", IntPtr.Zero, "D: est.ini")
End Sub
End Module
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…