public void Handle(NetworkAdapterDomain domain)
 {
     foreach (var adapter in domain.GetNetworkAdapters())
     {
         adapter.MediaSubType = RegistryUtil.GetValueListByCondition(@"SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" + adapter.Guid + @"\Connection", "MediaSubType");
     }
 }
Exemple #2
0
 public void Handle(NetworkAdapterDomain domain)
 {
     foreach (var adapter in domain.GetNetworkAdapters())
     {
         adapter.LowerRange = RegistryUtil.GetValueListByCondition(@"SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\" + adapter.Index.ToString("D4") + @"\Ndi\Interfaces", "LowerRange");
     }
 }
Exemple #3
0
        public void Handle(NetworkAdapterDomain domain)
        {
            var fileName        = AppDomain.CurrentDomain.BaseDirectory + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            var physicalAdapter = "";

            foreach (var adapter in domain.GetNetworkAdapters())
            {
                var content = string.Format("{0}  {1} {2} {3} {4} {5} {6} {7} {8}",
                                            adapter.Characteristics,
                                            adapter.Index,
                                            adapter.Guid,
                                            adapter.LowerRange,
                                            adapter.MacAddress,
                                            adapter.MediaSubType,
                                            adapter.NetEnabled,
                                            adapter.PhysicalAdapter,
                                            adapter.AdapterType);
                Console.WriteLine(content);
                File.AppendAllText(fileName, content + Environment.NewLine);
                if (adapter.AdapterType == EnumAdapterType.无线物理网卡 ||
                    adapter.AdapterType == EnumAdapterType.线物理网卡)
                {
                    physicalAdapter += content + Environment.NewLine;
                }
            }
            Console.WriteLine("==============================");
            Console.WriteLine("启用中的物理网卡:");
            Console.WriteLine(physicalAdapter);
        }
 public void Handle(NetworkAdapterDomain domain)
 {
     if (Environment.OSVersion.Version.Major == 5)
     {
         HandleForXp(domain);
     }
     else
     {
         HandleForWin7(domain);
     }
 }
 public void Handle(NetworkAdapterDomain domain)
 {
     foreach (var adapter in domain.GetNetworkAdapters())
     {
         adapter.Characteristics = RegistryUtil.GetValueListByCondition(@"SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\" + adapter.Index.ToString("D4"), "Characteristics");
         //转换成16进制
         //int value;
         //Int32.TryParse(adapter.Characteristics, out value);
         //adapter.Characteristics = value.ToString("x");
     }
 }
 public void Handle(NetworkAdapterDomain domain)
 {
     foreach (var adapter in domain.GetNetworkAdapters())
     {
         if (adapter.NetEnabled &&
             adapter.PhysicalAdapter &&
             CheckoutPhysicalAdapter(adapter.Characteristics))
         {
             if (adapter.MediaSubType == "2" &&
                 adapter.LowerRange != null &&
                 (adapter.LowerRange.ToLower().Contains("wifi") ||
                  adapter.LowerRange.Contains("wlan")))
             {
                 adapter.AdapterType = EnumAdapterType.无线物理网卡;
             }
             else
             {
                 adapter.AdapterType = EnumAdapterType.线物理网卡;
             }
         }
     }
 }
 private void HandleForXp(NetworkAdapterDomain domain)
 {
     using (ManagementObjectSearcher searcher =
             new ManagementObjectSearcher("root\\CIMV2",
             "SELECT * FROM Win32_NetworkAdapterConfiguration"))
     {
         foreach (var o in searcher.Get())
         {
             var queryObj = (ManagementObject)o;
             var adapter = new NetworkAdapter();
             if (queryObj["Index"] != null)
                 adapter.Index = Convert.ToInt32(queryObj["Index"].ToString());
             if (queryObj["SettingID"] != null)
                 adapter.Guid = queryObj["SettingID"].ToString();
             if (queryObj["MacAddress"] != null)
                 adapter.MacAddress = queryObj["MacAddress"].ToString();
             if (queryObj["IPEnabled"] != null)
                 adapter.NetEnabled = Convert.ToBoolean(queryObj["IPEnabled"].ToString());
             adapter.PhysicalAdapter = true;
             domain.AddNetworkAdapter(adapter);
         }
     }
 }