Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get DNS entry for local host (VC++6)?

How to get DNS entry for local host (VC++6)?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialc++question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    khb
    wrote on last edited by
    #1

    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.

    D 1 Reply Last reply
    0
    • K khb

      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.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • D David Crow

        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

        K Offline
        K Offline
        khb
        wrote on last edited by
        #3

        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 tried

        DnsQueryConfig(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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups