开发者

How do I set the Alternate DNS server?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜