1 Attribute VB_Name
= "ConfIO"
3 ' Este archivo es parte del programa "reseter", el cĂșal es pertenece a SVCommunity.org y a Todosv.com
4 ' Mantenedores principales:
6 Public Declare Function GetPrivateProfileString _
8 Alias "GetPrivateProfileStringA" (ByVal lpSectionName
As String, _
9 ByVal lpKeyName
As Any
, _
10 ByVal lpDefault
As String, _
11 ByVal lpbuffurnedString
As String, _
12 ByVal nBuffSize
As Long, _
13 ByVal lpFileName
As String) As Long
14 Public Declare Function WritePrivateProfileString _
16 Alias "WritePrivateProfileStringA" (ByVal lpSectionName
As String, _
17 ByVal lpKeyName
As Any
, _
18 ByVal lpString
As Any
, _
19 ByVal lpFileName
As String) As Long
20 Private Declare Function GetPrivateProfileSectionNames _
22 Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer
As String, _
23 ByVal nSize
As Long, _
24 ByVal lpFileName
As String) As Long
25 Private Declare Function GetPrivateProfileSection _
27 Alias "GetPrivateProfileSectionA" (ByVal lpAppName
As String, _
28 ByVal lpReturnedString
As String, _
29 ByVal nSize
As Long, _
30 ByVal lpFileName
As String) As Long
31 'Las siguientes constantes determinan el nombre de la clave a ocupar para el parametro
32 Private Const IO_codigo
As String = "Codigo"
34 Public Sub Obtener_Lista_Externa()
37 On Error GoTo Obtener_Lista_Externa_Err
39 Dim Modelos() As String
40 Dim szBuf
As String, lLen
As Integer
41 126 Registrar
"Cargando perfiles de dispositivos soportados..."
42 'Obtenemos los nombres de todas las secciones, vienen separadas por NullChar Chr(0)
43 100 szBuf
= String$(32767, vbNullChar
) 'Creamos el buffer
44 101 lLen
= GetPrivateProfileSectionNames(szBuf
, Len(szBuf
), rINI_ROUTERS
) 'Obtenemos el largo del la lectura
45 102 szBuf
= Left
$(szBuf, lLen
) 'Cortamos lo innecesario
47 103 If szBuf
= vbNullString
Then
51 104 Modelos
= Split(szBuf
, vbNullChar
)
52 105 ReDim Preserve Modelos(UBound(Modelos
) - 1) As String
53 Dim i
As Long 'Para el contador
54 Dim a
As Long 'Total de modelos
55 106 a
= UBound(Modelos
)
58 108 frmPrincipal
.ComReset
.AddItem
Modelos(i
)
61 Registrar
">" & a
& " perfiles cargados"
65 Obtener_Lista_Externa_Err:
66 Controlar_Error Erl
, Err
.Description
, "Reseter.ConfIO.Obtener_Lista_Externa.Ref 12/2/2008 : 09:38:34"
71 Public Sub Memoria_IO(nRouter
As String)
72 'De la memoria al archivo
74 On Error GoTo Memoria_IO_Err
78 101 Escribir nRouter
, IO_codigo
, m_Datos
.codigo
84 Controlar_Error Erl
, Err
.Description
, "Reseter.ConfIO.Memoria_IO.Ref 12/2/2008 : 09:38:34"
89 Public Sub IO_Memoria(nRouter
As String)
90 'Del archivo a la memoria
92 On Error GoTo IO_Memoria_Err
96 101 m_Datos
.codigo
= Leer(nRouter
, IO_codigo
)
103 Controlar_Error Erl
, Err
.Description
, "Reseter.ConfIO.IO_Memoria.Ref 12/2/2008 : 09:38:34"
108 Private Function Leer(nRouter
As String, _
109 nEspecificacion
As String, _
110 Optional nValor
As String = vbNullString
) As String
112 On Error GoTo Leer_Err
114 Dim Buffer
As String * 32767
116 100 Buffer
= String$(32767, vbNullChar
)
117 101 Lgt
= GetPrivateProfileString(nRouter
, nEspecificacion
, nValor
, Buffer
, Len(Buffer
), rINI_ROUTERS
)
119 102 If Lgt
Then Leer
= Left
$(Buffer, Lgt
) Else Leer
= vbNullString
123 Controlar_Error Erl
, Err
.Description
, "Reseter.ConfIO.Leer.Ref 12/2/2008 : 09:38:34"
128 Private Sub Escribir(nRouter
As String, _
129 nEspecificacion
As String, _
130 ByVal nValor
As String)
132 On Error GoTo Escribir_Err
134 100 WritePrivateProfileString nRouter
, nEspecificacion
, nValor
, rINI_ROUTERS
138 Controlar_Error Erl
, Err
.Description
, "Reseter.ConfIO.Escribir.Ref 12/2/2008 : 09:38:34"
143 Public Function Existe_Seccion(nRouter
As String) As Boolean
144 '28/04/07 -> nRouter definido como String en lugar de Variant
146 On Error GoTo Existe_Seccion_Err
149 100 Buffer
= String$(32767, Chr
$(0))
150 101 Existe_Seccion
= GetPrivateProfileSection(nRouter
, Buffer
, Len(Buffer
), rINI_ROUTERS
)
154 Controlar_Error Erl
, Err
.Description
, "Reseter.ConfIO.Existe_Seccion.Ref 12/2/2008 : 09:38:34"