MSNdis_StatusMediaDisconnect and unique device name

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?

+3
source share
1

"Win32_NetworkAdapter.NetConnectionID". - [!!] - , [ ], , "MSNdis_EnumerateAdapter.InstanceName =".

, !?

- mabra

0

Source: https://habr.com/ru/post/1726285/


All Articles