IP address for Gateway, DNS

I am using Delphi 5.0, I will like to know how to retrive the IP address for gateway, subnet mask, DNS (some time more than one) and the domain name.

Thanks
jlisloAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

redhornCommented:
If what you want is the configured gateway, etc., then consult the Registry.

For domain name & DNS:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP

look at these keys:
Domain
Hostname
NameServer

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\NetTrans\0002

Look at these keys:
DefaultGateway
IPAddress
IPMask

You might find the information under \0001 or \0003 or perhaps some other number. Remember that these are the configured properties of a given protocol attached to a given interface (e.g., network card). If you know which interface your connection is using, this should be accurate, but to find out your 'actual' IP address and hostname (the ones you are using), consult Winsock. I don't think Winsock can tell you your gateway.

<http://www.gnomehome.demon.nl/uddf/pages/network.htm#network4>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LischkeCommented:
These values all don't work with Windows NT. Here the answers from jhance and Ray (taken from UDDF):

{ Q_10218385 by jhance

1) Win95: the IP and MASK are in the registry at:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\NetTrans

you'll note that there are multiple entries there.  The one you needs depends on which network adapter you are using.

2) WinNT 4.0: also in the registry

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\<adapter service instance>\Parameters\Tcpip

where <adapter service instance> is the service instance of the particular adapter you are interested in.

3) Win98: the Win95 information applies but it also supports the iphlpapi.dll functions AddIpAddress()/DeleteIpAddress() functions.  These also work on NT4.0 SP4 and later under some circumstances.

4) Win2000 - As with NT4.0 and also the iphlpapi.dll functions.

}

// programmatically: Q.10232316 (rwilson) from UDDF
function my_ip_address:longint;
const
  bufsize=255;
var
  buf: pointer;
  RemoteHost : PHostEnt; (* No, don't free it! *)
begin
  buf:=NIL;
  try
    getmem(buf,bufsize);
    winsock.gethostname(buf,bufsize);   (* this one maybe without domain *)
    RemoteHost:=Winsock.GetHostByName(buf);
    if RemoteHost=NIL then
      my_ip_address:=winsock.htonl($07000001)  (* 127.0.0.1 *)
    else
      my_ip_address:=longint(pointer(RemoteHost^.h_addr_list^)^);
  finally
    if buf<>NIL then  freemem(buf,bufsize);
    end;
  result:=winsock.ntohl(result);
  end;


Ciao, Mike
0
jlisloAuthor Commented:
Thanks
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

LischkeCommented:
Thanks for ignoring me
0
jlisloAuthor Commented:
Lischke,

Sorry about that! I don't know how to spit the points or direct assign points to you. Is their any way to make it up to you please let me know.

Jammy
0
LischkeCommented:
Unfortunately, you cannot split the points to several answers. Usually, you'd open a dummy questions like "for Lischke..." and can so assign additional points to other experts being usful in the process...

Ciao, Mike
0
jlisloAuthor Commented:
No problem!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.