Solved

Detect IP number change

Posted on 2003-12-05
5
452 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
[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
  • 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

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!

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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
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…

705 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