MSNdis_StatusMediaDisconnect 和设备唯一名称
我正在使用 ManagementEventWatcher 来观察使用 System.Management 的网络电缆的断开情况。
使用 WQL 的 ManagementEventWatcher:SELECT * FROM MSNdis_StatusMediaDisconnect
,
当 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);
}
问题是:
我有 2 个网络接口,来自同一制造商,并且两种情况下,InstanceName 具有相同的值,但我无法识别拔出哪个网络!
我已经尝试了 EventArrivedEventArgs 中的所有属性,但它们没有设备的约束 ID...例如设备 ID。
如何查明网络接口是否被拔掉?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看“Win32_NetworkAdapter.NetConnectionID”。这是 - 在我的机器上 [!!] - 您将在网络连接 [控制面板] 中看到的字符串完全相同,并且它应该是相同的值,出现在“MSNdis_EnumerateAdapter.InstanceName=”中。
也许,这有帮助!?
br--马布拉
Have a look to the "Win32_NetworkAdapter.NetConnectionID". This is - at my machine [!!] - the excact same string you'll see in the network connections [control panel] and it should be the same value, apearing in "MSNdis_EnumerateAdapter.InstanceName=".
May be, this helps!?
br--mabra