Function Verificar_conexion_a_internet()
'Nombre: Verificar conexión a internet
'Autor: Bloc
'Fecha Publicada: 13/08/2013
If My.Computer.Network.IsAvailable = True Then
Try
If My.Computer.Network.Ping("www.google.com", 10) Then
MsgBox("Si hay conexión a internet", MsgBoxStyle.Information)
End If
Catch ex As Exception
MsgBox("No hay conexión a internet", MsgBoxStyle.Critical)
End Try
End If
End Function
Saludos!.
El codigo no funciona... inhabilite el DNS de mi red y al ejecutar me dice que no hay conexion de internet. pero hago ping a 8.8.4.4 y veo que si tengo conexion a internet.
No tienes permitido ver enlaces.
Registrate o Entra a tu cuenta
El codigo no funciona... inhabilite el DNS de mi red y al ejecutar me dice que no hay conexion de internet. pero hago ping a 8.8.4.4 y veo que si tengo conexion a internet.
Jojojoo, muy buen detalle el aportado por [L]ord [R]NA, ademas tiene esa sutileza que me encanta!
Querido Bloc, es cierto que si no tienes DNS que resuelva un domino tu programa fallará. Por tanto reemplaza esta linea:
If My.Computer.Network.Ping("www.google.com", 10) Then
Por esta otra:
If My.Computer.Network.Ping("8.8.8.8", 10) Then
Saludos!
private void Test_Connection()
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply reply = ping.Send("1.1.1.1");
MessageBox.Show(reply.Status.ToString()!="Success"?
"No se tiene conexion a Internet":
"Se tiene conexion a Internet");
}