Solved

IP: Detecting the Default Gateway

Posted on 2000-03-02
7
180 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

809 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