Re:How to get IP adres
m...@dpa.com.pl schrieb in Nachricht <7pisq5$q7...@info.cyf-kr.edu.pl>...
:Network adres writeni in network configuraction in tcp/ip protocol in
:windows 95.
:
:I want resolve this problem in delphi.
:
:
:Marian
:e-mail: m...@kki.net.pl
:
Be sure to have WinSock in your uses clause and you can use the following
code:
procedure ShowIPAddress;
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^)^);
ShowMessage(Format('%s', [p^.h_Name])); {This is the hostname}
ShowMessage(Format('%s',[p2])); {This is the IPAddress}
WSACleanup;
end;
Hth,
Matthias.