Detecting a current Internet connection
Morning Gurus !
Well here is a problem. I am developing an application that needs to connect to the internet to perform an FTP transfer. Detecting the presence of a valid connection seems to be **** HARD !
Having read whats seems to be available on code guru, I feel the RasEnumConnections & RasGetConnectStatus have short comings and are too unreliable. (Worth pointing out that I have no experience of socket level programming)
A solution posted by Patrick Philippot seems to be what I need except the <iphlpapi.h> and lib are required and I spent many hours failing to install the SDK from Microsoft :mad:
Does anyone know of a way of detecting a valid Internet connection that wont invoke a 'dial up connection box' .
Many thanks boys and girls
Regards Philip...
# 1 Re: Detecting a current Internet connection
try using WinInet API function InternetGetConnectedState() ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetgetconnectedstate.asp), but that is only available when IE4.0 or later is installed.
regards
# 3 Re: Detecting a current Internet connection
I've attached a small project.
The ConnectionTest class (in _ConnectionTest.h and .cpp) sets the necessary registry key to prevent the dial-up connection box from appearing. Then the program attempts to connect to 2 sites. Then it resets the registry key.
This class itself was offered by another here at CG. I just added a message box, in OnInitDialog, to report the current connection status.
There seems to be a consensus that the best way of determining a Internet connection is to try to connect to a site.
Hope this helps.
RCFox at 2007-11-9 13:54:19 >
