VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "IniFile"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
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
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 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 sFileName As String
Public Property Get INIFileName() As String
    INIFileName = sFileName
End Property
Public Property Let INIFileName(s_filename As String)
    sFileName = s_filename
End Property
Public Sub WritePrivateINIString(sSection, sKEy As String, sValue As String)
    Dim lRes As Long
    lRes = WritePrivateProfileString(sSection, sKEy, sValue, sFileName)
End Sub
Public Function GetPrivateINIString(sSection As String, sKEy As String, Optional sDefault As String) As String
    Dim lRes As Long
    Dim lLen As Long
    Dim sTstr As String
    sTstr = Space$(512)
    lRes = GetPrivateProfileString(sSection, sKEy, sDefault, sTstr, Len(sTstr), sFileName)
    If lRes > 0 Then
        sTstr = Left$(sTstr, lRes)
    End If
    GetPrivateINIString = sTstr
End Function
Public Sub WriteWinINIString(sSection As String, sKEy As String, sValue As String)
    Dim lRes As Long
    lRes = WriteProfileString(sSection, sKEy, sValue)
End Sub
Public Function GetWinINIString(sSection, sKEy, Optional sDefault As String) As String
    Dim lRes As Long
    Dim lTlen As Long
    Dim sTstr As String
    sTstr = Space$(512)
    lRes = GetProfileString(sSection, sKEy, sDefault, sTstr, Len(sTstr))
    If lRes > 0 Then
        sTstr = Left$(sTstr, lRes)
    End If
    GetWinINIString = sTstr
End Function
