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