![]() ![]() |
|
VB源码推荐:一个操作Ini文件的类 | |
作者:佚名 文章来源:不详 点击数 更新时间:2008/4/18 14:44:40 文章录入:杜斌 责任编辑:杜斌 | |
|
|
【VB源码推荐:一个操作Ini文件的类】
´// Write to strINI WritePrivateProfileString strSection, _ strKey, strValue, strInI End Sub Public Function GetFile(strSection As String, _ strKey As String) As String Dim strTmp As String Dim lngRet As String strTmp = String$(100, Chr(32)) lngRet = GetPrivateProfileString(strSection, _ strKey, "", strTmp, _ Len(strTmp), strInI) GetFile = strTmp End Function Public Property Let INIFile(ByVal New_IniPath As String) ´// Sets the new ini path strInI = New_IniPath End Property Public Property Get INIFile() As String ´// Returns the current ini path INIFile = strInI End Property ´--------cIniFile.cls 使用举例---------------- Dim myIniFile As New cIniFile ´---指定访问的ini文件 If Len(App.Path) > 3 Then ´under disk root dir , eg: "C:\" myIniFile.INIFile = App.Path & "\setting.ini" Else myIniFile.INIFile = App.Path & "setting.ini" End If ´---写入ini文件 myIniFile.WriteFile "setting", "username", strUser ´---读出ini文件的数据 ´ 注意,如果是字符串,则去掉末尾一个字符 ´ ----flybird@chinaasp.com strUser = Trim(myIniFile.GetFile("setting", "username")) strUser = Left(strUser, Len(strUser) - 1) |
|
![]() ![]() |