Ini文件的操作

作者在 2007-04-24 02:05:00 发布以下内容

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

 

默认分类 | 阅读 1663 次
文章评论,共0条
游客请输入验证码
浏览585112次