sads
asked on
finding address of NICs DNS servers
How do I programically find the address's of the configured DNS servers in winsock 1.1. I can find all other relavent info using GetAdaptersInfo. I'm using VC++ 6.
Thanks in advance..
Chris
Thanks in advance..
Chris
The problem with the IPHLPAPI.DLL is that it's not available on your platform. Since you're using WINSOCK 1.1 I'm assuming it's Win95 and you don't have access to it.
The best approach in this instance is to use the WINIPCFG with its output directed to a file. Then you can parse the file for the DNS server information.
Use something like:
system("WINIPCFG /ALL /BATCH");
will dump the output to WINIPCFG.OUT. There you can easily find the DNS server(s) for the system. In WINSOCK 1.1 there is only global DNS setting that is shared by all network adapters on the system.
The best approach in this instance is to use the WINIPCFG with its output directed to a file. Then you can parse the file for the DNS server information.
Use something like:
system("WINIPCFG /ALL /BATCH");
will dump the output to WINIPCFG.OUT. There you can easily find the DNS server(s) for the system. In WINSOCK 1.1 there is only global DNS setting that is shared by all network adapters on the system.
Alternatively, on WINSOCK 1.1 systems you can locate the DNS server(s) from the registry at:
HLM\System\CurrentControlS et\Service s\VxD\MSTC P and the NameServer value you'll find there.
HLM\System\CurrentControlS
ASKER
I have asked this question twice (by accident). Refer to the other question. Sorry, its been a bad day.
Hum, why are you trying to delete this one as it contains a solution that works on XP (as you mentioned that in the other Q)? See my above comment...
ASKER
I am already using that call (see the question). It gets me everthing I need, but it does not return the DNS entries (unless its well hidden). Thats what I'm looking for, the DNS entries.
I somehow asked this question 2 times (and got **** for it). So I just picked one to delete and this was it.
Thanks
Chris
I somehow asked this question 2 times (and got **** for it). So I just picked one to delete and this was it.
Thanks
Chris
>>unless its well hidden
Not really :o)
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tcpip/tcpip_6ptf.asp ("IP_ADAPTER_DNS_SERVER_AD DRESS")
And it seems that it was my fault, I thought of 'GetAdaptersAddresses()' (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tcpip/tcpip_2joz.asp), but wroute '...AdapterInfo()' :o)
Not really :o)
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tcpip/tcpip_6ptf.asp ("IP_ADAPTER_DNS_SERVER_AD
And it seems that it was my fault, I thought of 'GetAdaptersAddresses()' (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tcpip/tcpip_2joz.asp), but wroute '...AdapterInfo()' :o)
ASKER
Does this not need a define (see the h file) that requires winsock 2?
I don't have the .h file here at the moment, but the MS docs are pretty clear:
Requirements
Windows NT/2000/XP: Included in Windows XP and Windows .NET Server.
Windows 95/98/Me: Unsupported.
Header: Declared in Iphlpapi.h.
Library: Use Iphlpapi.lib.
Requirements
Windows NT/2000/XP: Included in Windows XP and Windows .NET Server.
Windows 95/98/Me: Unsupported.
Header: Declared in Iphlpapi.h.
Library: Use Iphlpapi.lib.
ASKER
I have tried the below, but again winsock2....
#ifdef _WINSOCK2API_
//
// The following functions require Winsock2.
//
DWORD
WINAPI
GetAdaptersAddresses(
ULONG Family,
DWORD Flags,
PVOID Reserved,
PIP_ADAPTER_ADDRESSES pAdapterAddresses,
PULONG pOutBufLen
);
#endif
DWORD
WINAPI
GetPerAdapterInfo(
ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen
);
DWORD
#ifdef _WINSOCK2API_
//
// The following functions require Winsock2.
//
DWORD
WINAPI
GetAdaptersAddresses(
ULONG Family,
DWORD Flags,
PVOID Reserved,
PIP_ADAPTER_ADDRESSES pAdapterAddresses,
PULONG pOutBufLen
);
#endif
DWORD
WINAPI
GetPerAdapterInfo(
ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen
);
DWORD
Hmmm.. so, why don't you just
#define _WINSOCK2API_
before including the header file?
#define _WINSOCK2API_
before including the header file?
ASKER
Yup I tried that, then went full out on winsock2 and got shot down by the implementation team as to not wanting to update to winsock2 on the older 98 machines. So I went back to the drawing board thinking there must be source for a nslookup etc etc, but so far that two has come up empty...
Thanks for you input so far, It did make me go back to see if I missed anything...
Thanks for you input so far, It did make me go back to see if I missed anything...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much.
Chris
Chris
As promised, for boxes set to get DNS via DHCP:
2K:
Value DhcpNameServerList
HKLM\System\CurrentControl Set\Servic es\TcpIp\P arameters\ Interfaces \<Class>
value DhcpNameServer
This ClassID is the <Class> from <Service>_<Class> mentioned above.
NT:
Values DhcpNameServer and DhcpNameServerBackup
95:
No option for DNS via DHCP
2K:
Value DhcpNameServerList
HKLM\System\CurrentControl
value DhcpNameServer
This ClassID is the <Class> from <Service>_<Class> mentioned above.
NT:
Values DhcpNameServer and DhcpNameServerBackup
95:
No option for DNS via DHCP
ASKER
Very cool
Thanks a lot. I appreciate the effort.
Chris
Thanks a lot. I appreciate the effort.
Chris
An overview can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tcpip/ipover_394j.asp ("Managing Network Adapters")