Champak Posted August 22, 2008 Share Posted August 22, 2008 Is it possible to check if the computer has internet connection so pinging is unnecessary? Maybe by reading indicators like "Local Area Connection...is unplugged". It should be faster that way instead of waiting for replies from pinging. Link to comment Share on other sites More sharing options...
weaponx Posted August 22, 2008 Share Posted August 22, 2008 Thats pretty difficult, especially if the machine sits behind a router. Having a live connection to the router does not mean the router has an active connection to the interweb. Link to comment Share on other sites More sharing options...
Champak Posted August 22, 2008 Author Share Posted August 22, 2008 (edited) Three things: 1/ Is there a way to detect if you are behind a router to do a conditional search based on what the situation is? 2/ Not considering the first question, if the router is a problem, can you instead detect the connections speed from internal indicators to determine connection? Like if your connection is below 12mbps, most likely you are not connected, and even if you are, that speed is way too slow to do anything so exit the function. 3/ My particular situation, routers are not a concern, so it would still be helpfull if it is possible. My interest in order with the three considerations would be 2, 3, 1. I'm just trying to find someway of getting away from pinging or actually connecting for this particular purpose. Edited August 22, 2008 by Champak Link to comment Share on other sites More sharing options...
Uten Posted August 22, 2008 Share Posted August 22, 2008 (edited) If your don't have a network interface available the result of ipconfig should let you know. Or this: HI, Func isOnline() If Ping("www.google.de") > 0 Then MsgBox(64, "Internet connection active!", "You internet connection is enabled...") Else MsgBox(16, "Internet connection failure!", "You internet connection is disabled...") EndIf EndFunc ;==>isOnline Func _checkINet() $IsCon = DllCall("WinInet.dll", "int", "InternetGetConnectedState", "int_ptr", 0, "int", 0) If $IsCon[0] = 0 Then MsgBox(0, "NO CONNECTION", "Please Connect To The Internet Before Continuing") Else MsgBox(0, "CONNECTION", "Online") EndIf EndFunc ;==>_checkINetEDIT: missing quote tag. Edited August 22, 2008 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Champak Posted August 27, 2008 Author Share Posted August 27, 2008 Thanks Link to comment Share on other sites More sharing options...
neo291 Posted August 30, 2008 Share Posted August 30, 2008 If ping is disabled for any reason (like my ISP has disabled ping to all sites), u can try this :- $dataFound = _INetGetSource("www.google.com") If StringLen($dataFound) < 100 Then ;........."internet not working".......... Else ;..........."internet is working".......... EndIf I'm not a programmer. Just a Power User. Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 30, 2008 Share Posted August 30, 2008 $INTERNET_CONNECTION_MODEM = 0x1 $INTERNET_CONNECTION_LAN = 0x2 $INTERNET_CONNECTION_PROXY = 0x4 $INTERNET_CONNECTION_MODEM_BUSY = 0x8 $INTERNET_RAS_INSTALLED = 0x10 $INTERNET_CONNECTION_OFFLINE = 0x20 $INTERNET_CONNECTION_CONFIGURED = 0x40 $ret = DllCall("WinInet.dll", "int", "InternetGetConnectedState", "int_ptr", 0, "int", 0) If $ret[0] Then ;check type of connection $sX = "Connected !" & @LF & "------------------" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_MODEM) Then $sX &= "MODEM" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_LAN) Then $sX &= "LAN" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_PROXY) Then $sX &= "PROXY" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_MODEM_BUSY) Then $sX &= "MODEM_BUSY" & @LF If BitAND($ret[1], $INTERNET_RAS_INSTALLED) Then $sX &= "RAS_INSTALLED" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_OFFLINE) Then $sX &= "OFFLINE" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_CONFIGURED) Then $sX &= "CONFIGURED" & @LF Else $sX = "Not Connected" EndIf MsgBox(4096, $ret[0] & ":" & $ret[1], $sX) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now