Lo he adaptado a mi manera:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" ( _
ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
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 String, _
ByVal lpString As String, _
ByVal lpFileName As String) As Long
Private iSection As String
Private iPath As String
Public Sub Set_Path(sPath As String)
iPath = sPath
End Sub
Public Sub Set_Section(sSection As String)
iSection = sSection
End Sub
Public Function Leer_Ini(key As String) As String
Dim sBuffer As String * 256, lenValue As Long
lenValue = GetPrivateProfileString(iSection, key, "", sBuffer, Len(sBuffer), iPath)
Leer_Ini = Left(sBuffer, lenValue)
End Function
Public Function Grabar_Ini(key As String, valor As Variant) As String
WritePrivateProfileString iSection, key, valor, iPath
End Function