Hello,
I'm using ManagementEventWatcher to watch the disconnection of network cable using System.Management.
ManagementEventWatcher with the WQL: SELECT * FROM MSNdis_StatusMediaDisconnect
,
and the following method is fired, 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:
I have 2 network interfaces, from the same manufacturer , and both case, the InstanceName has the same value and I can´t identify what network unplugged!
I have tried all properties from EventArrivedEventArgs, but they don´t have a constraint id for device... like an Device Id.
How can I find out witch network interface was unplugged?