Option Explicit
Private Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private 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 Function ReadIni(ByVal strSection As String, ByVal strKey As String, ByVal strDefault As String, ByVal strFileName As String) As String
Dim intRes As Integer, strRet As String
strRet = Space$(32400)
intRes = GetPrivateProfileString(strSection, strKey, strDefault, strRet, Len(strRet), strFileName)
ReadIni = Left$(strRet, intRes)
End Function
Public Sub WriteIni(ByVal strSection As String, ByVal strKey As String, ByVal strSetting As Variant, ByVal strFileName As String)
WritePrivateProfileString strSection, strKey, CStr(strSetting), strFileName
End Sub
Public Function ReadWinIni(strSection As String, strKey As String) As String
Dim Result As String * 128
Dim Temp As Integer
Temp = GetProfileString(strSection, strKey, "", Result, Len(Result))
ReadWinIni = Left$(Result, Temp)
End Function
Public Sub WriteWinIni(strSection As String, strKey As String, strSetting As String)
WriteProfileString strSection, strKey, strSetting
End Sub
Sunday, April 4, 2010
VB6 Code - Baca Tulis INI File
Labels:
INI-File