I know this is a really old post, but i had a small point to make here for this subject that came to mind while searching for something else.
Someone mentioned hard coding an address, and someone mentioned seeing an address via a hex dump and calling it spyware.
The API function InternetCheckConnection will always be true if the www url address will resolve to an IP address somewhere on the internet. For example, open a command prompt and ping
http://www.mymachinesdasaxzy.com - it resolves to 207.223.0.140 - even though there is no such domain of
http://www.mymachinesdasaxzy.com the API InternetCheckConnection returns true because the url resolves to an IP address somewhere on the internet (in this case to an IP address in a range of IP addresses held by Comcast). On the other hand, if you ping http://www.mymach_$inesdasaxzy.com you will find that it will not resolve to an IP address so the API function InternetCheckConnection will return false even though you may have a valid internet usage connection.
You can ping
http://www.mymachinesdasaxzy.com and it will time out because there is no real domain to return a response to the ping (as there is no server for a
http://www.mymachinesdasaxzy.com domain), even though the IP address resolved, but the timeout does not affect the API return as long as the url resolves to an IP address.
So, you can select nonsense or non-existant domains for use with the API InternetCheckConnection and if it will resolve to an IP address on the internet somewhere the API will return true which means that even with a nonsense or non-existant domain as long at it will resolve to an IP address on the internet the API InternetCheckConnection will indicate a valid connection to the internet as it is a valid connection to the internet because the resolved IP address does exist some place on the internet even if you get ping timeouts when trying to ping it. (that is of course if the non-existant or nonsense www address you used resolves to an IP address)
So in effect, the API InternetCheckConnection is not checking for a valid internet usage connection like its name imply's, its actually checking for a resolved IP address and assumes two things:
1. Failure of the url used to resolve to an IP address indicates that you do not have a valid usage connection to the internet (which can not always be true for the API InternetCheckConnection because you can have a vaild connection and a url not resolve to an IP address on the internet somewhere).
2. A url resolving to an IP address indicates that you do have a valid usage connection to the internet. (which will always be true for the API InternetCheckConnection because it will always return true if the url will resolve to an IP address somewhere on the internet)
Since you can have a vaild internet usage connection and the API InternetCheckConnection will return false if there is no resolved IP address from the url used with the API, it means that you can not trust the API to indicate the lack of a valid internet usage connection. However, because the API InternetCheckConnection will always return true if the url will resolve to an IP address on the internet somewhere you can trust the API to indicate the presence of a valid internet usage connection if the url will resolve to an IP address.
Maybe thinking about it as InternetCheckForResolvedAddress instead of InternetCheckConnection...

would help define this a little more, as in:
Code: Select all
If InternetCheckForResolvedAddress(@url_x$,#FLAG_ICC_FORCE_CONNECTION,0) = #True
......
;instead of
If InternetCheckConnection(@url_x$,#FLAG_ICC_FORCE_CONNECTION,0) = #True
.....
Information and code sample to illustrate this somewhat:
Code: Select all
Procedure CheckInetConnect()
;note: InternetCheckConnection will always be true if the www address will resolve to an IP address
; for example, open a command prompt and ping www.mymachinesdasaxzy.com - it resolves to 207.223.0.140
; so InternetCheckConnection will return true even though there is no such domain of www.mymachinesdasaxzy.com
; this happens because that resolved IP address falls into the domain holdings of someone else. In the example
; using www.mymachinesdasaxzy.com - it resolves to 207.223.0.140 - it resolves to an IP address that is registered to Comcast
statusa.i
statusb.i
statusc.i
statusd.i
statusx.i
status.i
url_x$ = "http://www.mymachinesdasaxzy.com" ; resolves to an IP address in the comcast domain
url_a$="http://www.google.com"
url_b$="http://www.yahoo.com"
url_c$="http://www.google.de"
url_d$="http://www.dw-world.de"
If InternetCheckConnection_(@url_x$,#FLAG_ICC_FORCE_CONNECTION,0) = #False ; we pick our best guess for reliable connection check for the first check, if can't reach we try some others in case there is some weird internet thing going on - if this first one doesn't work out, if it does then we just skip the rest and go with our pick for the fastest and most reliable for indication.
If InternetCheckConnection_(@url_a$,#FLAG_ICC_FORCE_CONNECTION,0) = #True ; we got here because our best guess didn't return true
statusa = #True
Else
statusa = #False
EndIf
If statusa = #False ; whoops...can't get a connection to url_a$ so lets try this one
If InternetCheckConnection_(@url_b$,#FLAG_ICC_FORCE_CONNECTION,0) = #True
statusb = #True
Else
statusb = #False
EndIf
EndIf
If statusb = #False ; whoops...can't get a connection to url_b$ but maybe we are in the other half of the world so lets try this one too
If InternetCheckConnection_(@url_c$,#FLAG_ICC_FORCE_CONNECTION,0) = #True
statusc = #True
Else
statusc = #False
EndIf
EndIf
If statusc = #False ; whoops...can't get a connection to url_c$ so lets try it one more time to make sure
If InternetCheckConnection_(@url_d$,#FLAG_ICC_FORCE_CONNECTION,0) = #True
statusd = #True
Else
statusd = #False
EndIf
EndIf
Else
statusx = #True
EndIf
; ok, we tried all the best ones from around the world, the four known to be good and reliable plus our best guess (which might be one from our ISP for example - one from the ISP would be the fastest), and...
; if any of them return true then we have a valid internet usage connection
If statusx = #True Or statusa = #True Or statusb = #True Or statusc = #True Or statusd = #True ; if any are true then we have a vaild usage connection for the internet.
ProcedureReturn #True
Else
ProcedureReturn #False ; and if none of them are true then its a pretty sure bet that we do not have a vaild internet usage connection at the time
EndIf
EndProcedure
Debug CheckInetConnect() ; if 1 then we have a valid internet usage connection, if 0 then we don't