Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Windows 7's network status

In Windows 7 whenever the internet access gets lost, the network indicator turns yellow. I want to get this status in my software and set an alarm whenever the internet connection gets lost (an internet alarm). How can I get this status? All of the other libraries like this one, just show the status of disconnection (red) and otherwise say that the internet is available. I couldn't find any library that does this nor any API function.

like image 298
Alireza Noori Avatar asked Jun 01 '11 07:06

Alireza Noori


People also ask

How do I check my network status on Windows 7?

Select the Start button, then type settings. Select Settings > Network & internet. The status of your network connection will appear at the top. Windows 10 lets you quickly check your network connection status.


2 Answers

In the Windows API Code Pack there is a NetworkManager class that gets you both IsConnected and IsConnectedToInternet. Comes with some useful samples too. If you want to detect a change in status, do not poll - there are .NET events you can add handlers for just like adding a click handler.

Also see Detect Internet V. local lan connection, An elegant / simple way to check whether internet is available or not, I need a event to detect Internet connect/disconnect, etc.

like image 185
Kate Gregory Avatar answered Sep 18 '22 15:09

Kate Gregory


You could modify the network libary you found. Just look at the Network Interface Class. OperationalStatus can be more that up and down :)

like image 28
Dennis Avatar answered Sep 19 '22 15:09

Dennis