检查是否自动获取DNS IP或将其设置为静态 [英] Check if DNS IP is obtained automatically or set static

查看:212
本文介绍了检查是否自动获取DNS IP或将其设置为静态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定是否自动获取(网络接口的)DNS服务器的IP? -我不希望使用netsh调用或涉及解析文件和控制台输出的任何其他方式. -另外,我也不想阅读注册表(除非这是唯一的方法). 是否有Win API函数? 它应该在以下操作系统上运行:Win XP,Win 7 预先感谢.

How can I find out if the IP of a DNS Server (of a Network Interface) is obtained automatically? - I'd prefer NOT to use netsh calls or any other way which involves parsing files and console output. - Also I'd like not to read the Registry (unless it's the only way). Are there any Win API function? Operating Systems it should work on: Win XP, Win 7 Thanks in advance.

推荐答案

我会做的更好.我不仅会避免netsh调用和注册表信息-我将为您保存Win API调用,并将您保存在.Net Fx中:(O.o)b

I'll do ya one better.  Not only will I avoid netsh calls and registry info - I'll save you the Win API call and keep you in the .Net Fx:  (O.o)b

            IEnumerable<string> isDNSDynamic = from holdNI in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
                                               select string.Format("Interface {0} - IsDynamic? {1}",
                                               holdNI.Name,
                                               holdNI.GetIPProperties().IsDynamicDnsEnabled ? "Yes" : "No");

            foreach (string hold in isDNSDynamic)
                Console.WriteLine(hold);


这篇关于检查是否自动获取DNS IP或将其设置为静态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆