관리 메뉴

안까먹을라고 쓰는 블로그

[VB6.0] INI 읽고/쓰기 본문

Language/VB 6.0

[VB6.0] INI 읽고/쓰기

YawnsDuzin 2012. 12. 10. 19:09

 

반응형
'사용자정의INI 읽기.쓰기
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 lpKeyName As Any, ByVal lpString As Any, _
    ByVal lpFileName As String) As Long
 
 
'INI 값 읽기
Public Function INIRead(Session As String, Key As String, inifile As String) As String
    Dim lngRet      As Long
    Dim strValue    As String * 1024
    Dim temp       As String
   
    On Error GoTo INIRead_Error
   
    lngRet = GetPrivateProfileString(Session, Key, "", strValue, 1024, inifile)
   
    If Len(IntRet) = 0 Then
    End If   
    INIRead = Left(strValue, InStr(strValue, Chr(0)) - 1)   
Exit Function
INIRead_Error:
End Function
 
 
'INI 값 쓰기
Public Function INIWrite(Session As String, Key As String, Data As String, inifile As String) As String
    Dim lngRet As Long
    lngRet = WritePrivateProfileString(Session, Key, Data, inifile)
End Function


반응형
Comments