Board index » delphi » How is to Get local adresse IP with Delphi 4.0

How is to Get local adresse IP with Delphi 4.0

Hello,

Somebody could tell to me how to obtain
Address ip of the local machine with Delphi 4.0
Thank you.

 

Re:How is to Get local adresse IP with Delphi 4.0


: Pierre HIRTH <pierre.hi...@sbm.mc> schrieb in im Newsbeitrag:
81im1g$m1...@news2.isdnet.net...
: Hello,
:
: Somebody could tell to me how to obtain
: Address ip of the local machine with Delphi 4.0
: Thank you.
:
:

 uses WinSock;
procedure GetIPAddress:string;
var wVersionRequested : WORD;
    wsaData : TWSAData;
    p : PHostEnt;
    s : array[0..128] of char;
    p2 : pchar;

begin
     wVersionRequested := MAKEWORD(1, 1);
     WSAStartup(wVersionRequested, wsaData);
     GetHostName(@s, 128);
     p := GetHostByName(@s);
     p2 := iNet_ntoa(PInAddr(p^.h_addr_list^)^);
     { This is the hostname:=Format('%s', [p^.h_Name]); }
     Result:=Format('%s',[p2]);
     WSACleanup;
end;

Hth,
Matthias.

Other Threads