Detecting LAN connection using InternetGetConnectedState API doesn't work
Posted on 2003-11-28
In VB6, I'm trying to test different connection scenarios using the InternetGetConnectedStatus API, e.g. testing if connected via modem, via LAN, etc.
My development environment is: Win 2K, VB6, T1 connection.
For some reason, after I created a DUN entry, the return code for 'connected via modem' (INTERNET_CONNECTION_MODEM) returned true, even though I didn't dial-out to the Internet and therefore, wasn't connected to the Internet.
Then when I deleted the one and only DUN entry, the return code for 'connected via LAN' always returned false and so did the 'connected via modem'.
I need to implement code (on all Windows OS platforms) that will determine if the user has an Internet connection or not and if not, my app needs to provide a drop-down list of DUN entries.
Before I experienced the problems after creating the DUN entry, I previously tried disconnecting the Ethernet cable from my PC and then ran my test app. The 'connected via LAN' always returned true. Why is this?
Please advise to why the InternetGetConnectedState API is not returning a value saying that I'm connected to the LAN when I am and visa versa.