Detect IP number change

Hi Experts,

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

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; ??

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.

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);
      TaPInAddr = Array[0..10] of PInAddr;
      PaPInAddr = ^TaPInAddr;
      phe : PHostEnt;
      pptr : PaPInAddr;
      Buffer : Array[0..63] of Char;
      i : Integer;
      GInitData : TWSAData;
      WSAStartup($101, GInitData);
      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

Geoff M.

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
PeterLarsenAuthor Commented:
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
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.
Don't know how to get the DNS servers. Try asking that question in a new thread.

Geoff M.
PeterLarsenAuthor Commented:
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
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

From novice to tech pro — start learning today.