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. C++ How to retrieve IP Address/Default Gateway

C++ How to retrieve IP Address/Default Gateway

Scheduled Pinned Locked Moved C / C++ / MFC
c++sysadmintutorial
5 Posts 4 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.
  • G Offline
    G Offline
    gamefreak2291
    wrote on last edited by
    #1

    I'm trying to figure out how to locate and use the IP Address/Default Gateway in a C++ program. This is so that a simple program can be universal on any network. I have been able to run "ipconfig /all" and output all the information to a text file, but I can't make it usable in the same program.

    N M D 3 Replies Last reply
    0
    • G gamefreak2291

      I'm trying to figure out how to locate and use the IP Address/Default Gateway in a C++ program. This is so that a simple program can be universal on any network. I have been able to run "ipconfig /all" and output all the information to a text file, but I can't make it usable in the same program.

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      If you already have it in a txt, you can open and read it with files management as other stuff. About the use... maybe this[^] can help you.

      Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.

      G 1 Reply Last reply
      0
      • N Nelek

        If you already have it in a txt, you can open and read it with files management as other stuff. About the use... maybe this[^] can help you.

        Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.

        G Offline
        G Offline
        gamefreak2291
        wrote on last edited by
        #3

        I thought about that, and while I can get it down to the correct line, I couldn't get it to retrieve only the gateway. Had some issues using the find command. Its safe to say I'm pretty amateur.

        1 Reply Last reply
        0
        • G gamefreak2291

          I'm trying to figure out how to locate and use the IP Address/Default Gateway in a C++ program. This is so that a simple program can be universal on any network. I have been able to run "ipconfig /all" and output all the information to a text file, but I can't make it usable in the same program.

          M Offline
          M Offline
          Moak
          wrote on last edited by
          #4

          gamefreak2291 wrote:

          I'm trying to figure out how to locate and use the IP Address/Default Gateway in a C++ program. This is so that a simple program can be universal on any network.

          Not sure why you need this information for a simple networking program. Have a look at the API Helper API[^]. There can be multiple network interfaces in your system, you can use GetAdaptersInfo()[^] to get IP address/netmask/etc for all of them. Hope this helps! /M

          Webchat in Europe :java: (only 4K)

          1 Reply Last reply
          0
          • G gamefreak2291

            I'm trying to figure out how to locate and use the IP Address/Default Gateway in a C++ program. This is so that a simple program can be universal on any network. I have been able to run "ipconfig /all" and output all the information to a text file, but I can't make it usable in the same program.

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

            See if this helps.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Man who follows car will be exhausted." - Confucius

            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