如下:
uses winsock;
function localIp:string;
type tapinaddr=array[0..10] of pinaddr;
var .....
begin
wsastartup($101,ginitdata);
result:='';
gethostname(buffer,sizeof(buffer));
phe:=gethostbyame(buffer);
if phe<>nil then
begin
pptr:=papinaddr(phe^.h_addr_list);
i:=0;
while pptr^<>nil do
begin
result:=strpas(inet_ntoa(pptr^^));
inc(i);
end;
end;
wsacleanup;
end;