How to get DNS entry for local host (VC++6)?
-
Hi together, I need some help to get the name of the local host from DNS (VC++6). My problem is that the WINS entry is different from the DNS entry. So, gethostname() and gethostbyname/addr() always return the WINS entry and not the DNS entry. Moreover, I can't change the entries or configure the system :sigh: Can anybody help me on how to get the DNS entry (host name) anyway? For example, if I type "nslookup <IP of local host>" to the console, I get the wanted host name. I just need this functionality in C++. Thank you very much for your help! Marcus.
-
Hi together, I need some help to get the name of the local host from DNS (VC++6). My problem is that the WINS entry is different from the DNS entry. So, gethostname() and gethostbyname/addr() always return the WINS entry and not the DNS entry. Moreover, I can't change the entries or configure the system :sigh: Can anybody help me on how to get the DNS entry (host name) anyway? For example, if I type "nslookup <IP of local host>" to the console, I get the wanted host name. I just need this functionality in C++. Thank you very much for your help! Marcus.
Have you looked at
DnsQueryConfig()
?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
-
Have you looked at
DnsQueryConfig()
?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
Hi David, thank you very much for the tip. I tried out the function in the last three hours. However, it doesn't work as expected. I tried
DnsQueryConfig(DnsConfigHostName_A, FALSE, NULL, NULL, szHostName, &ulSize);
and this gives me the local(!) host name :omg: So, the result is equal to
gethostname()
. Then I triedDnsQueryConfig(DnsConfigFullHostName_A, FALSE, NULL, NULL, szHostName, &ulSize);
and it works only on those machines where the local host name (WINS entry) is equal to the DNS entry. So, I suppose that
DnsQueryConfig()
queries information by giving the local host name to DNS :wtf: Of course this won't work. Moreover, the function doesn't work for Win2000 although it is specified for it (I always get a "wrong parameter" error). Maybe you can tell me what I'm doing wrong? Or do you have another idea? Thank you again for your help, Marcus.