Catch network adapter up/down and address changed event (Windows, C#)
I am searching for a method to be notified when any windows network interfaces go up or down or the addresses of any network interfaces are changed.
I would prefer solutions in C#, C is also possible. Winpcap could be used.
I am aware that there is an 开发者_运维技巧event for network adapter address changes in C#, but this also possible without enumerationg all adapters and looking the changed settings?
May some advanced programmer help a fellow newbie.
with best regards
Have a look at the System.Net.NetworkInformation namespace. The NetworkChange class allows you to register for NetworkAddressChanged, and there are NetworkAvailability events and others that should cover most of what you're looking for. You will need to enumerate just like the sample shows- many machines have complex network setups that don't just boil down to "hey, something changed", so you'll need to set up the baseline before you start.
精彩评论