interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,winsock;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TaPInAddr = Array[0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
procedure TForm1.Button1Click(Sender: TObject);
var
phe: PHostEnt;
PPTr: PaPInAddr;
Buffer: Array[0..63] of Char;
I: Integer;
GInitData: TWSAData;
st:TstringList;
begin
WSAStartup($101, GInitData);
st:=TStringList.Create;
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if phe = nil then
begin
Exit;
end;
PPTr := PaPInAddr(phe^.h_addr_list);
I := 0;
while PPTr^[I] <> nil do
begin
st.Add(inet_ntoa(PPTr^[I]^));
showmessage(st.strings[i]);
Inc(I);
end;
WSACleanup;
end;