コード例 #1
0
        private void refreshNICList(Boolean showHidden)
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in nics)
            {
                IPInterfaceProperties adapterProperties = adapter.GetIPProperties();

                NetworkListItem item = new NetworkListItem(adapter.Name, adapter.Description, adapter.Id, adapter.Supports(NetworkInterfaceComponent.IPv4), adapter.Supports(NetworkInterfaceComponent.IPv6));
                if (!item.getHidden() || showHidden)
                {
                    List <string> dnsList = new List <string>();

                    object dnsResult = Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\" + item.getID(), "NameServer", "");
                    if (dnsResult != null && dnsResult.ToString().Length > 0)
                    {
                        dnsList = new List <string>(((string)dnsResult).Split(new string[] { "," }, System.StringSplitOptions.None));
                    }

                    if (dnsList.Count != 0 && dnsList[0] == "127.0.0.1")
                    {
                        DNSlistbox.Items.Add(item, true);
                    }
                    else
                    {
                        DNSlistbox.Items.Add(item);
                    }
                }
            }
        }
コード例 #2
0
        private void refreshNICList(Boolean showHidden)
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in nics)
            {
                IPInterfaceProperties adapterProperties = adapter.GetIPProperties();

                NetworkListItem item = new NetworkListItem(adapter.Name, adapter.Description, adapter.Id, adapter.Supports(NetworkInterfaceComponent.IPv4), adapter.Supports(NetworkInterfaceComponent.IPv6));
                if (!item.getHidden() || showHidden)
                {
                    List<string> dnsList = new List<string>();

                    object dnsResult = Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\" + item.getID(), "NameServer", "");
                    if (dnsResult != null && dnsResult.ToString().Length > 0)
                    {
                        dnsList = new List<string>(((string)dnsResult).Split(new string[] { "," }, System.StringSplitOptions.None));
                    }

                    if (dnsList.Count != 0 && dnsList[0] == "127.0.0.1")
                    {
                        DNSlistbox.Items.Add(item, true);
                    }
                    else
                    {
                        DNSlistbox.Items.Add(item);
                    }
                }
            }
        }