Solved

IP: Detecting the Default Gateway

Posted on 2000-03-02
7
185 Views
Last Modified: 2010-04-02
How can I (programmatically) detect what my default gateway is?
0
Comment
Question by:jhattingh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2576611
Mh, found some IP info behind:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\NetTrans
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2576642
Thanks for responding.

I take it there isn't an API for this. In which case, I found that the DG is shown in

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{5A7F5924-5CC7-473D-B4C1-B683BA607D49}\Parameters\Tcpip

How would I programmatically retrieve or identify this key?
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2576646
.. I don't mean how do I read the registry! I mean findin the GUID that identifies the correct key...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:KangaRoo
ID: 2576845
Aie, that key is not on my system :(

For using the registry, check the manuals (or win32.hlp)
Following are the functions used with the registry:

RegCloseKey
RegConnectRegistry
RegCreateKey
RegCreateKeyEx
RegDeleteKey
RegDeleteValue
RegEnumKey
RegEnumKeyEx
RegEnumValue
RegFlushKey
RegGetKeySecurity
RegLoadKey
RegNotifyChangeKeyValue
RegOpenKey
RegOpenKeyEx
RegQueryInfoKey
RegQueryMultipleValues
RegQueryValue
RegQueryValueEx
RegReplaceKey
RegRestoreKey
RegSaveKey
RegSetKeySecurity
RegSetValue
RegSetValueEx
RegUnLoadKey

The tool WinIpCfg uses RegOpenKey, RegQueryValueEx and RegCloseKey.
0
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 2576868
If you are running Win98 or Win2000, the IPHLPAPI.DLL offers the:

GetAdaptersInfo() function which will return the information you are looking for.

On Win95, you have to search the registry for the right network adapter and then find the gateway setting for that adapter.

On NT, it's the same process just a different registry tree.
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2576893
Fantastic!
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2576896
Thank you
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question