views:

75

answers:

3

I could do an endless timer checking IsInetOffline(), but I would prefer a hook callback that tells me when I plug/unplug the ethernet network cable or connect to wireless internet. Is there such a thing in the Windows API?

+1  A: 

If you're on .NET you can use the System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged event. It's using Winsock APIs under the covers if you need to do it without .NET (Reflector it if you want to know more), but it's some nasty async stuff in there- not a nice handy "call me when the network status changes".

nitzmahone
A: 

There may be a better way, but there is a NotifyAddrChange asynchronous function in the IP Helper Library that will create a notification when an IPv4 address changes.

shf301
A: 

It's done with Win32 Shell Notifications (Explorer does that)
You can see on http://tinyurl.com/yjy3ajr for code in C

marcus