var
localhost:array[0..255] of char;
host:pchar;
gethostname(localhost,255)
host:= gethostbyname(localHost); /* Get local host */
localhost:array[0..255] of char;
host:pchar;
gethostname(localhost,255)
host:= gethostbyname(localHost); /* Get local host */
...procedure GetHostInfo(var asName, asAddress: string);
var
WSAData: TWSAData;
HostEnt: PHostEnt;
begin
WSAStartup(2, WSAData);
SetLength(asName, 255);
Gethostname(PChar(asName), 255);
SetLength(asName, StrLen(PChar(asName)));
HostEnt := gethostbyname(PChar(asName));
with HostEnt^ do
asAddress := Format('%d.%d.%d.%d',[Byte(h_addr^[0]), Byte(h_addr^[1]),
Byte(h_addr^[2]), Byte(h_addr^[3])]); WSACleanup;
end;