Solved

Detect IP number change

Posted on 2003-12-05
5
441 Views
Last Modified: 2010-04-05
Hi Experts,

Is there a way to detect if windows change its IP addrerss ??

eg.
ipconfig /relaese
ipconfig /renew

If the IP address is obtained from a DHCP server the server may deliver a different address. How do i detect if this happen ??

Something like this : procedure WmSettingChange(var Msg : TWmSettingChange); message WM_SETTINGCHANGE; ??

Regards
Peter
0
Comment
Question by:PeterLarsen
  • 2
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
gmayo earned 50 total points
ID: 9883354
Just check every minute or so. If the number is different from last time, then it's changed.

Here's some code to get the list of IP addresses for your machine (you may have more than one):

procedure GetIPs(s : TStrings);
type
      TaPInAddr = Array[0..10] of PInAddr;
      PaPInAddr = ^TaPInAddr;
var
      phe : PHostEnt;
      pptr : PaPInAddr;
      Buffer : Array[0..63] of Char;
      i : Integer;
      GInitData : TWSAData;
begin
      WSAStartup($101, GInitData);
      s.Clear;
      GetHostName(Buffer, SizeOf(Buffer));
      phe := GetHostByName(buffer);
      if phe <> nil then begin
            pPtr := PaPInAddr(phe^.h_addr_list);
            I := 0;
            while pPtr^[I] <> nil do
            begin
                  s.Add(inet_ntoa(pptr^[I]^));
                  Inc(I);
            end;
            WSACleanup;
      end;
end;


Geoff M.
0
 
LVL 2

Author Comment

by:PeterLarsen
ID: 9884221
Thanks for your comment.
There must be a better way to do this.

btw. Do you know how to get the DNS entrys ?

Kind Regards
Peter
0
 
LVL 6

Expert Comment

by:MannSoft
ID: 9884237
That's the method I use in some of my utilities.  Granted I didn't search every inch of the internet, but all the sources I found indicated that it was the only way to do it.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9884242
Don't know how to get the DNS servers. Try asking that question in a new thread.

Geoff M.
0
 
LVL 2

Author Comment

by:PeterLarsen
ID: 9884556
I dont have time to search the entire net, so i will simply poll for changes - as suggested by Geoff. :-)

About DNS lookup - i have tried that but with no success (there are no simple answer to that) :-(

Kind Regards
Peter
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Working this component WebCopy with proxy, help 3 85
code issue 8 135
Delphi Mdi application Child forms get behind control 7 219
Delphi: Connect to running MS Outlook 4 95
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

825 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