Me gustaria crear un programa que al poner la direccion web me salga la ip me ayudannn y a partir de hay meterle extras...
Te serviría esto:
struct hostent *h;
if((h=gethostbyname("foro.elhacker.net"))) {
printf("Host: %s\n", h->h_name);
printf(" IP: %s\n", inet_ntoa(*((struct in_addr*)h->h_addr)));
}
MODIFICO: Perdón, no me di cuenta que estaba en el foro de VB
ping?
Si como cuando vas a Cmd > Ping foroelhacker.net pues algo asi y que muestre la ip :$
Aquí lo tienes en batch, ahora pasalo a Visual basic.
]http://foro.elhacker.net/scripting/reto_batch_get_ip_from_dns-t360917.0.html] (http://foro.elhacker.net/scripting/reto_batch_get_ip_from_dns-t360917.0.html)
Cita de: -- KiLiaN -- en 30 Agosto 2012, 14:59 PM
Aquí lo tienes en batch, ahora pasalo a Visual basic.
]http://foro.elhacker.net/scripting/reto_batch_get_ip_from_dns-t360917.0.html] (http://foro.elhacker.net/scripting/reto_batch_get_ip_from_dns-t360917.0.html)
Muchas gracias tio como siempre hay ^^
Saludos.
(Ya lo se deberia de haber buscado mas) :-*
si lo vas a hacer desde visual basic queda mas elegante hacerlo con apis, sino hacelo en batch.
WMI:
Function ResolveIP(strComputer)
Dim wmiQuery : wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputer & "'"
Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Dim objPing : Set objPing = objWMIService.ExecQuery(wmiQuery)
Dim objStatus
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then
ResolveIP = "Computer is Unreachable!"
Else
ResolveIP = objStatus.ProtocolAddress
End If
Next
End Function
http://www.visualbasicscript.com/Ping-WMI-amp-NonWMI-Versions-Functions-amp-Simple-Connectivity-Monitor-m42535.aspx
Con las apis del winsock
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Function GetHostByName Lib "ws2_32" Alias "gethostbyname" (ByVal hostname As String) As Long
Private Declare Function WSAStartup Lib "ws2_32" (ByVal wVersionRequired As Long, lpWSAData As WSADATA) As Long
Private Type WSADATA
wversion As Integer
wHighVersion As Integer
szDescription(0 To 256) As Byte
szSystemStatus(0 To 128) As Byte
iMaxSockets As Integer
iMaxUdpDg As Integer
lpszVendorInfo As Long
End Type
Private Type Hostent
h_name As Long
h_aliases As Long
h_addrtype As Integer
h_length As Integer
h_addr_list As Long
End Type
Public Function IPHost(Host As String) As String
Dim sHostName As String * 256
Dim lpHost As Long
Dim Hostent As Hostent
Dim dwIPAddr As Long
Dim tmpIPAddr() As Byte
Dim i As Integer
Dim sIPAddr As String
Dim WSA As WSADATA
WSAStartup 257, WSA
lpHost = GetHostByName(Host)
If lpHost <> 0 Then
CopyMemory Hostent, lpHost, Len(Hostent)
CopyMemory dwIPAddr, Hostent.h_addr_list, 4
ReDim tmpIPAddr(1 To Hostent.h_length)
CopyMemory tmpIPAddr(1), dwIPAddr, Hostent.h_length
For i = 1 To Hostent.h_length
sIPAddr = sIPAddr & tmpIPAddr(i) & "."
Next
IPHost = Mid$(sIPAddr, 1, Len(sIPAddr) - 1)
End If
End Function
EJEMPLOS DE USO
Sub form_load()
'ASI SE USA
MsgBox IPHost("www.google.es")
MsgBox IPHost("foro.elhacker.net")
'ASI NO SE USA
MsgBox IPHost("http://www.google.es/")
MsgBox IPHost("http://foro.elhacker.net")
End Sub