A fonte do projeto principal ficará algo como:
implementation
uses Winsock;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
wVersionRequested : WORD;
wsaData : TWSAData;
begin
wVersionRequested := MAKEWORD(1, 1);
WSAStartup(wVersionRequested, wsaData);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
WSACleanup;
end;
procedure TForm1.BtnIPClick(Sender: TObject);
var
p : PHostEnt;
s : array[0..128] of char;
p2 : pchar;
begin
GetHostName(@s, 128);
p := GetHostByName(@s);
Memo1.Lines.Add(p^.h_Name);
p2 := iNet_ntoa(PInAddr(p^.h_addr_list^)^);
Memo1.Lines.Add(p2);
end;
end.
Nenhum comentário:
Postar um comentário