需要引入 System.Management . public string NetStatus() { ManagementObjectCollection objects; string status = ""; ManagementObjectSearcher searcher = new ManagementObjectSearcher(); searcher.Query.QueryString = "Select * From Win32_NetworkAdapter "; objects = searcher.Get(); foreach (ManagementObject obj in objects) { foreach (PropertyData p in obj.Properties) { if (p.Name.Equals("NetConnectionStatus")) { if (p.Value != null) { status = p.Value.ToString(); } } } } switch (status) { case "0&#