添加 system32.Management 引用
private bool ListenNET()
{
ManagementObjectSearcher s = new ManagementObjectSearcher(@"SELECT DeviceID FROM Win32_NetworkAdapter WHERE NetConnectionStatus=2 AND PNPDeviceID LIKE 'PCI%'");
return s.Get().Count > 0; //True表示存在已连接的真实网卡,False反之。
}