VB Code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As System.Text.StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'/// retrieve a value from an ini file , in this case one i have stored under C:\
Dim strItem As New System.Text.StringBuilder(256)
GetPrivateProfileString("drivers", "wave", "Default", strItem, strItem.Capacity, "C:\dynamic.ini")
MessageBox.Show(strItem.ToString)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'/// add a new item to the ini file ( you can also update the values here )
Dim strNewItem As String = "another item under the drivers section"
WritePrivateProfileString("drivers", "newitem", strNewItem, "C:\dynamic.ini")
End Sub