Ok here is some code which you can convert to build a list of IP addresses.
I have just put a listbox in but you could use a TStringList. You could
also pass an IP in and have it return true or false if the IP is available
on your machine.
function TIPListForm.GetIpAddress : String;
// RM 08/01/2000
// Returns the IP address of the current machine
// If TCP IP is not intsalled or number cannot be found returns ''
// Uses Winsock (not winsock 2 which may cause problems on WIn95A)
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
Counter : Integer;
GInitData : TWSADATA;
begin
Result := '';
WSAStartup($101, GInitData);
try
try
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if (phe <> nil) then begin
pptr := PaPInAddr(Phe^.h_addr_list);
Counter := 0;
while (pptr^[Counter] <> nil) do begin
result := StrPas(inet_ntoa(pptr^[Counter]^));
ListBox.Items.Add(Result);
Inc(Counter);
end;
end;
except
file://Trap exceptions and return an empty string
Result := '';
end;
finally
WSACleanup;
end;
end;
Rob
Software engineer
Wild Software Ltd
[EMAIL PROTECTED]
----- Original Message -----
From: "Dennis Chuah" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Thursday, June 21, 2001 3:49 PM
Subject: RE: [DUG]: A function to test: is this my IP #?
>
> Peter,
>
> Hi. Unfortunately there is no short answer.
>
> You will need to call gethostname, pass the return value to gethostbyname.
> This returns a pointer to the hostent structure. The h_addr_list member
of
> this structure points to list of pointers that point to the list of IP
> addresses that have been assigned to the local machine. You will then
need
> to loop through these addresses and see if your IP address is in the list.
> Be careful about network / i386 byte ordering.
>
> HTH,
> Dennis.
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, 21 June 2001 14:26
> > To: Multiple recipients of list delphi
> > Subject: [DUG]: A function to test: is this my IP #?
> >
> >
> > Hi folks,
> > Does someone perchance know of a function available in the
> > Windows or WinInet APIs which allows me to ask "is this one of
> > the IP numbers configured for THIS computer"?
> >
> > Something like: isLocalIPNumber(const IP: string): Boolean
> >
> >
> > cheers,
> > peter
> >
> > ============================================
> > Peter Hyde, WebCentre Ltd & SPIS Ltd, Christchurch, New Zealand
> > * Web automation for online periodicals: http://TurboPress.com
> > * TurboNote+: http://TurboPress.com/tbnote.htm
> > -- handy onscreen notes and instant messaging
> > ------------------------------------------------------------------
> > ---------
> > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
>
> --------------------------------------------------------------------------
-
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"