对于自己的本地ip,得到计算机名称倒很简单。
uses winsock;
function iptoname(ip: string): string;
var
WSAData: TWSAData;
p: PHostEnt;
InetAddr: dword;
begin
result := '''';
WSAStartup(2, WSAData);
InetAddr := inet_addr(PChar(IP));
try
p := GetHostByAddr(@InetAddr, Length(IP), PF_Inet);
if p <> nil then result := p^.h_name;
except
result := '''';
end;
end;