Nombre de equipo

Holas necesito saber como obtener el nombre de un equipo atravez de su IP
Respuesta
1
Public Function JLNombreDesdeIP(ByVal IP As String) As String
Dim ptrHosent As Long
Dim hAddress As Long
Dim nbytes As Long
If JLPing_IniciaSockets() Then
'convert string address to long
hAddress = inet_addr(IP)
If hAddress <> SOCKET_ERROR Then
'obtain a pointer to the HOSTENT structure
'that contains the name and address
'corresponding to the given network address.
ptrHosent = gethostbyaddr(hAddress, 4, AF_INET)
If ptrHosent <> 0 Then
'convert address and
'get resolved hostname
CopyMemory ptrHosent, ByVal ptrHosent, 4
nbytes = lstrlen(ByVal ptrHosent)
If nbytes > 0 Then
IP = Space$(nbytes)
CopyMemory ByVal IP, ByVal ptrHosent, nbytes
JLNombreDesdeIP = IP
End If
Else
'MsgBox "Call to gethostbyaddr failed."
JLNombreDesdeIP = "**JLError()**"
End If 'If ptrHosent
JLPing_LimpiaSockets
Else
JLNombreDesdeIP = "**JLError()**"
'MsgBox "String passed is an invalid IP."
End If 'If hAddress
Else
MsgBox "Sockets failed to initialize."
End If 'If SocketsInitialize
End Function
Public Function JLPing_IniciaSockets() As Boolean
Dim WSAD As WSADATA
JLPing_IniciaSockets = WSAStartup(WS_VERSION_REQD, WSAD) = IP_SUCCESS
End Function
No va a funcionar, pero mándame los nombres de las constantes y variables que necesites y te las envío de volada, la tengo en un .bas junto con otras funciones, asi que no me fué posible aislarla.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas