Does anyone know if it's possible to hook into Windows' detection of the
network being connected or not, via some sort of C API?
--
David N. Welton
- http://www.dedasys.com/davidw/
Linux, Open Source Consulting
- http://www.dedasys.com/
TWAPI has various Network related things in it but I am not sure if
they are what you are after.
Robert
# twapi requires full path for program files
set nsfile [file join $::env(windir) system32 netstat.exe]
set opts [list -cmdline "-a -o 5"]
set e [catch {eval twapi::create_process $nsfile $opts} result]
This will capture network status every 5 seconds... : )
Cool, that's close - thanks! The ideal thing would be to hook into
whatever API is related to that little message that pops up when you
unplug the ethernet cable, so that I don't have to poll...
There's an WSAIoctl call for detecting route changes that isn't polling,
but you need a thread for it and there's possibly some stuff in the IP
helper api, too.
WSAIoctl called for SIO_ROUTING_INTERFACE_CHANGE or
SIO_ADDRESS_LIST_CHANGE might work.
There's a more "packaged" version of the same in the IP helper API with
a quick sample.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/notifyaddrchange.asp?frame=true
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/notifyroutechange.asp?frame=true
There's a "network location awareness" API, too, but I don't think it
works in XP yet.