Archive: check internet connection


check internet connection
Hello.
I have a question regarding checking internet connection.
I am trying to detect if there is an internet connection with the folowing code:
------------------------------------
Function ConnectInternet

Push $R0

ClearErrors
Dialer::AttemptConnect
IfErrors noie3

Pop $R0
StrCmp $R0 "online" connected
MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet."
Quit

noie3:

; IE3 not installed
MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now."

connected:
MessageBox MB_OK " connection to internet was verified."
Pop $R0

FunctionEnd
-----------------------
The problem is : I want to detect if
the function works corectly and I unplug the network
cable. Then I run the installer, but the function still detects that the internet connection is on, and I get the message box with "connection to internet was verified"

How do I solve this?

Thanks.


Are you sure that you have the correct sintax of the plugin?


Maybe it will always report online when there is a permanent network connection. Try it on a system with dial-up access.


i can confirm what joost said


Most likely, the cause for this behavior is that the macro relies on the InternetGetconnectionState(Ex)() API in WININET.DLL which ships with IE. As you've seen, this API is _not_ reliable (just unplug the cable on a host that connects through a router...)

After searching more, I think the least bad solution is to connect out to some IP address that you hard-coded... but that won't do you any good if the client host is running a firewall which prevents any unauthorized outgoing connections. Rats :-)

Fred.