|
-
Jul 31st, 2006, 05:00 AM
#1
Thread Starter
New Member
Network check
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
-
Jul 31st, 2006, 02:42 PM
#2
Retired VBF Adm1nistrator
Re: Network check
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:
Code:
My.Computer.Network.IsAvailable()
You can use the methods in My.Computer.Network to figure out if you're connected or not
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jul 31st, 2006, 11:44 PM
#3
Thread Starter
New Member
Re: Network check
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
-
Aug 1st, 2006, 12:05 AM
#4
PowerPoster
Re: Network check
you should use Winsock, but here is an API version
VB Code:
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
-
Aug 1st, 2006, 02:24 AM
#5
Thread Starter
New Member
-
Aug 1st, 2006, 02:30 AM
#6
PowerPoster
Re: Network check
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|