f1:= (ip and $0ff);
f2:= (ip and $0ff00)/$100;
f3:= (ip and $0ff0000)/$10000;
f4:= (ip and $off000000)/$1000000;
str:= format('%d.%d.%d.%d',[f1,f2,f3,f4]);
f1:= (ip and $0ff);
f2:= (ip and $0ff00) div $100;
f3:= (ip and $0ff0000) div $10000;
f4:= (ip and $off000000) div $1000000;
str:= format('%d.%d.%d.%d',[f4,f3,f2,f1]);
只是不知道有没有现成的函数.
给你一个函数,改一下
function getcomputerIP:string;
var
HostName:array[0..255] of char;
WSAData:TWSAData;
MyHostHostEnt;
begin
result:='0.0.0.0';
WSAStartUp(2,WSAData);
GetHostName(@HostName[1],sizeof(HostName));
MyHost:=GetHostbyname(@hostname[1]);
if myhost<>nil then
result:=format('%d.%d.%d.%d',[ord(myhost.h_addr^[0]),ord(myhost.h_addr^[1]),ord(myhost.h_addr^[2]),ord(myhost.h_addr^[3]));
end;