function GetLocalHostIP: String;//取得本机的IP地址
var IP: String
ia: in_addr;
begin
SetLength(IP, 255);
gethostname(PChar(IP), Length(IP));
phs := gethostbyname(PChar(IP));
if phs <> nil then
begin
CopyMemory(@ia.S_addr, phs^.h_addr^, SizeOf(ia.S_addr));
StrCopy(PChar(IP), inet_ntoa(ia));
end;
Result := IP;
end;