///////////////////////////////////////////////////////////////////////////////
//6.获取计算机名称
///////////////////////////////////////////////////////////////////////////////
function ComputerName:String;
var
ComputerName: PChar;
size: DWord;
begin
GetMem(ComputerName,255) ;
size:=255;
if GetComputerName(ComputerName,size)=true then
begin
result:=ComputerName;
FreeMem(ComputerName) ;
end;
end;
////////////////////////////////////////////////////////////////////////////////
//7.获取计算机IP
////////////////////////////////////////////////////////////////////////////////
function ComputerIP:String;
var phe
HostEnt;
w:TWSAData;
ip_address:longint;
p:^longint;
ipstr:string;
begin
if WSAStartup(2,w)<>0 then exit;
phe:=gethostbyname(pchar(ComputerName));
if phe<>nil then
begin
p:=pointer(phe^.h_addr_list^);
ip_address:=p^;
ip_address:=ntohl(ip_address);
ipstr:=IntToStr(ip_address shr 24)+'.'+IntToStr((ip_address shr 16) and $ff)
+'.'+IntToStr((ip_address shr 8) and $ff)+'.'+IntToStr(ip_address and $ff);
Result :=ipstr;
end;
end;