
03/01/2007, 08:48
|
 | | | Fecha de Ingreso: agosto-2006
Mensajes: 381
Antigüedad: 18 años, 9 meses Puntos: 2 | |
Re: Reconocer servidor haber genera un archivo ini (config.ini) en la ruta donde esta el ejecutable de la siguiente manera:
[Servidores]
Imagenes = \\servidor1300\
declara las siguientes apis en un modulo
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal SName$, ByVal KName$, ByVal def$, ByVal _
ret$, ByVal size%, ByVal fn$) As Long
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
y estas funciones
Public Function ReadINI(ByVal fn As String, ByVal sect As String, _
ByVal key As String, ByVal def As String) As String
ret = String$(255, 0)
retval = GetPrivateProfileString(sect, key, def, ret, Len(ret), fn)
If retval = 0 Then
ret = def
Else
ret = Mid(ret, 1, retval)
If ret = "" Then
ret = def
End If
End If
ReadINI = Trim$(ret)
End Function
Public Sub WriteINI(ByVal fn As String, ByVal sect As String, ByVal _
key As String, ByVal s As String)
Dim retval As Integer
If key = "" Then
retval = WritePrivateProfileString(sect, 0&, 0&, fn)
ElseIf s = "" Then
retval = WritePrivateProfileString(sect, key, 0&, fn)
Else
retval = WritePrivateProfileString(sect, key, s, fn)
End If
End Sub
y listo, ahora para recuperar el valor es asi
ServidorIMG = ReadINI(app.path & "\config.ini", "Servidores", "Imagenes", "") |