Private Declare  Writeini Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As String, ByVal lpFileName As String) As Long
Private Declare  Getini Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Sub Command1_Click() '写ini文件
    Dim path As String
    If Right(App.path, 1) <> "\" Then
       path = App.path + "\"
    End If
    Writeini "introduce", "name", "xp", path & "ceshi.ini"
    Writeini "introduce", "age", "21", path & "ceshi.ini"
    Writeini "introduce", "sex", "man", path & "ceshi.ini"
   
End Sub
Private Sub Command2_Click() '读取ini文件
    Dim path As String
    If Right(App.path, 1) <> "\" Then
       path = App.path + "\"
    End If
    Dim buf As String
    buf = String(256, Chr(0))
    Getini "introduce", "name", "", buf, 256, path & "ceshi.ini"
    MsgBox buf
    Getini "introduce", "age", "", buf, 256, path & "ceshi.ini"
    MsgBox buf
    Getini "introduce", "sex", "", buf, 256, path & "ceshi.ini"
    MsgBox buf
End Sub

