How can I detect if the computer is connected to internet (also please mention if I need any components)?
Printable View
How can I detect if the computer is connected to internet (also please mention if I need any components)?
you could just send a ping to your dns server
rgds pete
how??? Using "shell"?
Yep...
wouldn't something along the lines of
Shell "ping www.google.com"
work ?
k but how can i check the results of ping?
To tell you the truth i diodn't think of that... damnit, no point if you can't check it... lol
Erm, wait til the other guy gets back in here, he should know :)
yep.. nice sig by the way
lol, tyQuote:
Originally Posted by kill_bill_gates
I wonder if this has been asked B4 u kno, i'm, sure it has, do a search there should be a few examples...
There's massive threads about this. Many ways to do it. The problem is, some of the methods initiate a connection attempt, which maybe unwanted. On the other hand, if you don't want to initiate a connection attempt, then you must use tons of code (that have already been composed by other people) that will check to see if there is an internet connection Cable/DSL/Dial up.
Ping, write the results to text file, then phase through flie for results.
VB Code:
Shell "cmd /k ping google.com >c:\ping_test.txt ", vbHide
Its in the forum somwhere, thats where i got the code above form.
_
Thanks dude
Wellcome
You need to use some api to get the state of your current connection. There are few different approches that could be used so here is the simplest one:Quote:
Originally Posted by kill_bill_gates
VB Code:
Private Const INTERNET_CONNECTION_CONFIGURED = &H40 Private Const INTERNET_CONNECTION_LAN = &H2 Private Const INTERNET_CONNECTION_MODEM = &H1 Private Const INTERNET_CONNECTION_OFFLINE = &H20 Private Const INTERNET_CONNECTION_PROXY = &H4 Private Const INTERNET_RAS_INSTALLED = &H10 Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email][email protected][/email] Dim Ret As Long Me.AutoRedraw = True 'retrieve the connection status InternetGetConnectedState Ret, 0& 'show the result If (Ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then Me.Print "Local system has a valid connection to the Internet, but it may or may not be currently connected." If (Ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then Me.Print "Local system uses a local area network to connect to the Internet." If (Ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then Me.Print "Local system uses a modem to connect to the Internet." If (Ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then Me.Print "Local system is in offline mode." If (Ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then Me.Print "Local system uses a proxy server to connect to the Internet." If (Ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then Me.Print "Local system has RAS installed." End Sub
wow, thanks rhino
No problem. :wave: