Attribute VB_Name = "modINIFile"
Option Explicit
Public Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String,_
ByVal lpKeyName As Any,_
ByVal lpDefault As String,_
ByVal lpReturnedString As String,_
ByVal nSize As Long,ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String,_
ByVal lpString As Any,_
ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileSection Lib "kernel32" _
Alias "GetPrivateProfileSectionA" _
(ByVal lpAppName As String,_
ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileSection Lib "kernel32" _
Alias "WritePrivateProfileSectionA" _
(ByVal lpAppName As String,_
ByVal lpString As String,_
ByVal lpFileName As String) As Long
' 从INI 文件中取得相关项
' 02 Mar 2006 James Space(128)=> Space(500)
Public Function GetItemFromINI(Section As String,_
Key As String,FileName As String) As String
Dim Valid As String
Dim Size As Integer
Dim Path As String
Dim s As String
s = Space(500)
Size = Len(s)
Valid = GetPrivateProfileString(Section,Key,"",s,Size,FileName)
s = Left(s,Valid)
GetItemFromINI = Trim(s)
End Function
' 将新的INI Item 的值,写入INI文件项中Public Sub writeItemToINI(Section As String,_ Key As String,Value As String,FileName As String) WritePrivateProfileString Section,Value,FileName End Sub
原文链接:https://www.f2er.com/vb/261940.html