PDA

Click to See Complete Forum and Search --> : Network check


ma_umesh
Jul 31st, 2006, 05:00 AM
hey guys i need the program to check whether the computer is connected to internet or not


with the warning message "not connected' if not connected

PLz help me fast

plenderj
Jul 31st, 2006, 02:42 PM
You could try pinging the local computer's default gateway, and then ping the local ISP's dns servers. If you can ping the DNS servers, chances are you're connected.
You can check if you're on the local network by using this code:


My.Computer.Network.IsAvailable()


You can use the methods in My.Computer.Network to figure out if you're connected or not

ma_umesh
Jul 31st, 2006, 11:44 PM
Common guys help me out


i know how to check whther the computer is connected net or not

but i need to know how to make exe to check the computer is connected to internet or not

rory
Aug 1st, 2006, 12:05 AM
you should use Winsock, but here is an API version


Option Explicit

Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" _
(ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long

Private Const sURL As String = "http://www.mytesturl.com"

Private Function CheckInternet() As Boolean
If InternetCheckConnection(sURL, FLAG_ICC_FORCE_CONNECTION, 0&) Then
CheckInternet = True
End If
End Function

Private Sub Command1_Click()
MsgBox CheckInternet
End Sub

ma_umesh
Aug 1st, 2006, 02:24 AM
frens thanks for all of u for sending me the solutions

happy frenship week :wave: :thumb: :eek2:

rory
Aug 1st, 2006, 02:30 AM
no prob, remember to change the URL to a valid one so it works..

Tip, if you were to use Winsock, then use the Winsock Error and Connect Events to set a Boolean, it will not hang like the API does temporarily when it cant connect .. but it will require more code.