I use ManagementEventWatcher to watch for network cable disconnection using System.Management.
ManagementEventWatcher with WQL : SELECT * FROM MSNdis_StatusMediaDisconnect,
and the following method is launched when EventArrived:
private void ServiceNetWorkStatusWmiDisconnected(object sender, EventArrivedEventArgs args)
{
string instanceName = args.NewEvent.Properties["InstanceName"].Value as string;
ServiceNetWorkStatusWmi = string.Format("Network disconnected ({0})", instanceName);
Console.WriteLine(ServiceNetWorkStatusWmi);
}
The problem is this:
I have 2 network interfaces from the same manufacturer, and in both cases, the InstanceName value has the same value, and I can not determine which network is disconnected!
I tried all the properties of EventArrivedEventArgs, but they do not have a device restriction identifier ... like a device identifier.
How do I know if the witch network interface has been disabled?
user236340
source
share