views:

1144

answers:

3

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.

A: 

See GetNetowrkParams method (Platform SDK: IP Helper)

Mladen Jankovic
+1  A: 

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

Here is 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?

kender
I'm wanting to get the DNS server so I can do an MX lookup. The code you link to seems to show how to find your own IP?
mj2008
Yes. I assumed you wanted just a name->IP lookup, so gave you the GetHostByName function :)
kender
+3  A: 

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

DeeCee
This code worked nicely. Thank you.
mj2008
you're welcome :)
DeeCee