I would like to detect when a device is connected to an ethernet port of the machine that my application is running on. I know how to do this with a USB port but the problem is, the Port isn’t USB!
If it was a USB device I would simply override WndProc and catch the message, if it is WM_DEVICECHANGE, then i’m on to a winner, I was wondering if it was as simple as this with any device that may be plugged into the port?
I don’t want to know if there is anything happening, or if the device is working, just simply to find if there has been an insertion or removal.
I never used it myself, but I think that the
NetworkChange.NetworkAvailabilityChangedevent might fit your needs.Update
A brief investigation indicates that NetworkChange.NetworkAddressChanged might work better: