I'm not sure that either of the schemes suggested is going to get you where
you want to go. It *is* possible to detect, at least in some cases, that a
network card has an established connection. However, I'm unsure as to
whether a dialed PPP-type connection will generate this event or not, or
whether a wired Ethernet connection will reliably indicate when it is
disconnected from the wall (this is up to the driver for the adapter).
The scheme involves code that cannot be written in the managed framework, at
the moment, without P/Invoking to a significant number of things. You have
to use CreateMsgQueue() to create a special message queue, then tell NDISUIO
that it should post a message to this queue when a device connects to or
disconnects from the 'network' (again, whatever that means). When a message
is dropped into this queue, a WaitForXXX() call waiting on the queue handle
will wake up and you can read the message from the queue and check for a
network connection that you can use.
Of course, you'll have to do this in a thread to allow your user interface
to run, so you'll also have to build in some way of stopping that thread
when the application exits, figure out whether there is a real connection to
the network or not when a queue event happens, clean up the queue and the
notification, etc. on close, and a number of other things.
So, having said all that, you might want to think about just having the user
tell you, by clicking a button or selecting a menu item, that the network is
available...
Paul T.