Imports System.Runtime.InteropServices
Public Class classINI
Private m_Ini As String
Private Declare Function GetPrivateProfileStringKey Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString _
As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
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 Integer
Property Archivo() As String
Get
Archivo = m_Ini
End Get
Set(ByVal value As String)
m_Ini = value
End Set
End Property
'Leer una llave de un archivo .ini
Public Function LeeIni(ByVal Seccion As String, ByVal Llave As String) As String
Dim lret As Long
Dim ret As String
ret = New String(CChar(" "), 255)
lret = GetPrivateProfileStringKey(Seccion, Llave, "", ret, Len(ret), m_Ini)
If InStr(ret, Chr(0)) Then
ret = Left$(ret, Len(ret) - 1)
End If
LeeIni = ret
End Function
'grabar una llave a un archivo ini
Public Sub GrabaIni(ByVal Seccion As String, ByVal Llave As String, ByVal Valor As String)
Dim lret As Long
lret = WritePrivateProfileString(Seccion, Llave, Valor, m_Ini)
End Sub
'comprueva si existe la llave
Public Function Existe(ByVal Seccion As String, ByVal Llave As String) As Boolean
Dim lret As Long
Dim ret As String
Dim valor As String
ret = New String(CChar(" "), 255)
lret = GetPrivateProfileStringKey(Seccion, Llave, "", ret, Len(ret), m_Ini)
If InStr(ret, Chr(0)) Then
ret = Left$(ret, Len(ret) - 1)
End If
valor = Trim(ret)
If valor.Length = 1 Then Existe = False Else Existe = True
End Function
End Class
Luego de esto como seguis?
ResponderEliminar