1 Attribute VB_Name
= "mINI"
3 'Este modulo fué programado por Vladimir - TodoSV.com & SVCommunity.org
4 Private Declare Function GetPrivateProfileSectionNames _
6 Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer
As String, _
8 ByVal lpFileName
As String) As Long
9 Private Declare Function GetPrivateProfileString _
11 Alias "GetPrivateProfileStringA" (ByVal lpSectionName
As String, _
12 ByVal lpKeyName
As Any
, _
13 ByVal lpDefault
As String, _
14 ByVal lpbuffurnedString
As String, _
15 ByVal nBuffSize
As Long, _
16 ByVal lpFileName
As String) As Long
18 Public Function mINI_Obtener_Nombre_Secciones(Ruta_INI
As String) As Collection
21 On Error GoTo mINI_Obtener_Nombre_Secciones_Err
23 Dim Secciones() As String
24 Dim szBuf
As String, lLen
As Integer
25 'Obtenemos los nombres de todas las secciones, vienen separadas por NullChar Chr(0)
26 100 szBuf
= String$(32767, vbNullChar
) 'Creamos el buffer
27 101 lLen
= GetPrivateProfileSectionNames(szBuf
, Len(szBuf
), Ruta_INI
) 'Obtenemos el largo del la lectura
28 102 szBuf
= Left
$(szBuf, lLen
) 'Cortamos lo innecesario
30 103 If szBuf
= vbNullString
Then
34 104 Secciones
= Split(szBuf
, vbNullChar
)
37 105 a
= UBound(Secciones
) - 1
38 106 Set mINI_Obtener_Nombre_Secciones
= New Collection
41 108 mINI_Obtener_Nombre_Secciones
.Add
Secciones(i
)
46 mINI_Obtener_Nombre_Secciones_Err:
47 Controlar_Error Erl
, Err
.Description
, "P10XB.mINI.mINI_Obtener_Nombre_Secciones.Ref 7/6/2008 : 11:57:58"
52 Public Function mINI_Leer_Clave_de_Seccion(Ruta_INI
As String, _
53 nombre_Seccion
As String, _
54 nombre_Clave
As String, _
55 Optional Valor_si_no_existe
As String = vbNullString
) As String
57 On Error GoTo mINI_Leer_Clave_de_Seccion_Err
59 Dim Buffer
As String * 32767
61 100 Buffer
= String$(32767, vbNullChar
)
62 101 Lgt
= GetPrivateProfileString(nombre_Seccion
, nombre_Clave
, Valor_si_no_existe
, Buffer
, Len(Buffer
), Ruta_INI
)
64 102 If Lgt
Then mINI_Leer_Clave_de_Seccion
= Left
$(Buffer, Lgt
) Else mINI_Leer_Clave_de_Seccion
= vbNullString
67 mINI_Leer_Clave_de_Seccion_Err:
68 Controlar_Error Erl
, Err
.Description
, "P10XB.mINI.mINI_Leer_Clave_de_Seccion.Ref 7/6/2008 : 11:57:58"