Internet connection

  • Thread starter Thread starter Krzysztof Kazmierczak
  • Start date Start date
K

Krzysztof Kazmierczak

Hi All!

How i can check if is there an internet connection
available? When i use API functions
(InternetAttemptConnect, InternetCheckConnection,
InternetGetConnectedStateEx) i sometimes have diferent
results (when there's no cable, functions says that i'm
connected).
Is there any other method instead of trying to catch the
exception while proceding WebRequest and WebResponse when
the network cable is unplugged?

Thank you very much for any help!
Kind regards
Krzysztof Kazmierczak
 
Hi Krzysztof,

You can use the WMI class MSNdis_MediaConnectStatus in the root\wmi
namespace. The NdisMediaConnectStatus property gives the connection status
of the NIC on the network. Please refer to the following thread for some
code snippet:

http://groups.google.com/groups?q=MSNdis_MediaConnectStatus&hl=en&lr=&ie=UTF
-8&oe=UTF-8&selm=OALX7BxACHA.2352%40tkmsftngp02&rnum=8

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 
Back
Top