#Include once "windows.bi"
'读取INI
Function IniRead(ByVal IniFile As String, ByVal sSection As String, ByVal sKey As String, ByVal sDefault As String = "") As String
Dim sKeyLen As Dword
Dim sBuffer As ZString * MAX_PATH
sKeyLen = GetPrivateProfileString(@sSection, @sKey, @sDefault, @sBuffer, SizeOf(sBuffer), @IniFile)
If sKeyLen Then Function = Left$(sBuffer,sKeyLen)
End Function
'设置INI
Sub IniWrite(ByVal IniFile As String,ByVal sSection As String, ByVal sKey As String, ByVal sData As String)
WritePrivateProfileString(@sSection, @sKey, @sData, @IniFile)
End Sub
''使用方法
IniWrite(".\test.ini", "T", "test", "写入TEST内容")
?IniRead(".\test.ini", "T", "test", "Default")
|