开发者

How do I set the Alternate DNS server?

开发者 https://www.devze.com 2022-12-15 00:15 出处:网络
I\'m trying to set the Alternate DNS Server using .NET. I have managed to set the main DNS server by using this bit of code.

I'm trying to set the Alternate DNS Server using .NET. I have managed to set the main DNS server by using this bit of code.

ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
                ManagementObjectCollection moc = mc.GetInstances();
                foreach (ManagementObject mo in moc)
                {
                    if ((bool)mo["IPEnabled"])
                    {
                        ManagementBaseObject objdns = mo.GetMethodParameters("SetDNSServerSearchOrder");
                        if (objdns != null)
                        {
                          开发者_如何学Go  string[] s = { "127.0.0.1" };
                            objdns["DNSServerSearchOrder"] = s;
                            mo.InvokeMethod("SetDNSServerSearchOrder", objdns, null);
                        }
                    }
                }

Now I need to figure out how to set the Alternate DNS Server. Please help. Thanks in advance!


most probably

string[] s = { "127.0.0.1", "127.0.0.2" };
0

精彩评论

暂无评论...
验证码 换一张
取 消