Solved

IP: Detecting the Default Gateway

Posted on 2000-03-02
7
175 Views
Last Modified: 2010-04-02
How can I (programmatically) detect what my default gateway is?
0
Comment
Question by:jhattingh
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now