如何监控给定以太网连接的 .NET 以太网电缆是否已插入?
我想枚举所有以太网连接并订阅任何连接状态更改。我对检测互联网访问不感兴趣,只有当以太网连接已连接或未连接时。
更新:我发现这篇博文介绍了如何使用 WMI 查询来获取断开连接通知。
How can I monitor if Ethernet cables are plugged in or not from .NET for a given Ethernet connection?
I would like to enumerate all Ethernet connections and subscribe to any connection status changes. I am not interested in detecting Internet access, only if an Ethernet connection is Connected or Not Connected.
Update: I found this blog post on how to use a WMI query to be notified of disconnections.
发布评论
评论(1)
查看 Win32_NetworkAdapter 类。
Look at the
NetConnectionStatus
property of the Win32_NetworkAdapter class.