Solved

IP: Detecting the Default Gateway

Posted on 2000-03-02
7
181 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

821 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