?
Solved

How to get the local DNS IP address?

Posted on 2003-02-24
10
Medium Priority
?
544 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
  • 3
  • 2
  • 2
  • +2
9 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
Technology Partners: 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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses

621 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