unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinSock;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure GetIP(IPList : 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);
IPList.Clear;
Try
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
If phe =
Nil then
Exit;
pPtr := PaPInAddr(phe^.h_addr_list);
I := 0;
while pPtr^[I] <>
nil do
begin
IPList.Add(inet_ntoa(pptr^[I]^));
Inc(I);
end;
Finally
WSACleanup;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetIP(ListBox1.Items);
end;
end.