windows 如何找到当前的 DNS 服务器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/62127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:11:30  来源:igfitidea点击:

How can I find the current DNS server?

windowsdelphinetworkingdns

提问by mj2008

I'm using Delphi and need to get the current Windows DNS server IP address so I can do a lookup. What function should I call to find it? The only solution I have right now does an ipconfig/all to get it, which is horrible.

我正在使用 Delphi 并且需要获取当前的 Windows DNS 服务器 IP 地址,以便我可以进行查找。我应该调用什么函数来找到它?我现在唯一的解决方案是使用 ipconfig/all 来获取它,这太可怕了。

采纳答案by DeeCee

Found a nice one using the function GetNetworkParams().Seems to work quite good. You can find it here: http://www.swissdelphicenter.ch/torry/showcode.php?id=2452

使用函数 GetNetworkParams() 找到了一个不错的方法。似乎工作得很好。你可以在这里找到它:http: //www.swissdelphicenter.ch/torry/showcode.php?id=2452

回答by kender

Do you really need to know what is DNS server to do a lookup?

您真的需要知道什么是 DNS 服务器才能进行查找吗?

Hereis a solution how to get a IP address using 2 functions: GetHostName and GetHostByName. I assume the GetHostByName function does the lookup you need for you, or am I wrong?

是如何使用 2 个函数获取 IP 地址的解决方案:GetHostName 和 GetHostByName。我假设 GetHostByName 函数会为您进行查找,还是我错了?

回答by Mladen Jankovi?

See GetNetowrkParamsmethod (Platform SDK: IP Helper)

参见GetNetowrkParams方法(Platform SDK:IP Helper)