?
Solved

How to get the local DNS IP address?

Posted on 2003-02-24
10
Medium Priority
?
492 Views
Last Modified: 2010-04-04
Does anybody have an idea how to get the dns ip addresses for a local network card / modem in Delphi 6? ANy help would be appreciated.
0
Comment
Question by:kloiv
[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
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 100 total points
ID: 8014800
use TIPWatch from Indy9
0
 
LVL 21

Assisted Solution

by:ziolko
ziolko earned 100 total points
ID: 8014889
uses WinSock;

_Address: DWord;
_HostName: String;
_Phe: PHostEnt;


_Address := inet_addr(PChar(_HostName));
if (_Address = INADDR_NONE) then
  begin
    _Phe := GetHostByName(PChar(_HostName));
    if _Phe <> Nil then
      begin
        _Address := longint(plongint(_Phe^.h_addr_list^)^);
        _HostName := _Phe^.h_name;
        _HostIP := StrPas(inet_ntoa(TInAddr(_Address)));
      end;
  end
else
  begin
    _Phe := GetHostByAddr(@_Address, 4, AF_INET);
    if _Phe = Nil then
      _HostName := 'Name unavailable'
    else
      _HostName := _Phe^.h_name;
    _HostIP := StrPas(inet_ntoa(TInAddr(_Address)));
  end;

ziolko.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8014909
... of course You need WSAStartUp() and WSACleanUp();
ziolko.
0
Independent Software Vendors: 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!

 

Author Comment

by:kloiv
ID: 8016489
I like Lee Nover's idea of using Indy 9 to do this, but I can't find the method to get the DNS server addresses - could you explain how this is acheived please? Thanks in advance.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 8017496
check the properties (Indy 9 IdIPWatch):
CurrentIP
IsOnline
IPHistoryList
LocalIP
LocalName
PreviousIP
... ;-)
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 8017545
oh .. also the events OnStatus and OnStatusChanged
0
 

Author Comment

by:kloiv
ID: 8057264
Thanks everyone, but in the end I decided to get the available DNS server addresses using "fixed info" from iphlpapi.dll.
0
 

Expert Comment

by:CleanupPing
ID: 9317081
kloiv:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 10

Expert Comment

by:kacor
ID: 9956728
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
        to split points between Lee_Nover and ziolko
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

765 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