你是不是要解释*.*.*.*?var AList:TstringList; begin AList := TstringList.create; try AList.Delimiter := '.'; AList.DelimitedText := '111.111.111.111'; for k:= 0 to AList.count - 1 do showmessage(AList[k]); finally AList.free; end; end;
function getipsection(ip:string;section:integer):string; var i:integer; begin for i:=1 to section-1 do begin delete(ip,1,pos('.',ip)); end; if section=4 then result:=ip else result:=copy(ip,1,pos('.',ip)-1); end;
function LIP: string; type TaPInAddr = array[0..10] of PInAddr; PaPInAddr = ^TaPInAddr; var phe: PHostEnt; pptr: PaPInAddr; Buffer: array[0..63] of char; I: Integer; GInitData: TWSADATA; begin WSAStartup($101, GInitData); Result := ''; GetHostName(Buffer, SizeOf(Buffer)); phe := GetHostByName(buffer); if phe = nil then Exit; pptr := PaPInAddr(Phe^.h_addr_list); I := 0; while pptr^[I] <> nil do begin result := StrPas(inet_ntoa(pptr^[I]^)); Inc(I); end; WSACleanup; end;
AList:TstringList;
begin
AList := TstringList.create;
try
AList.Delimiter := '.';
AList.DelimitedText := '111.111.111.111';
for k:= 0 to AList.count - 1 do
showmessage(AList[k]);
finally
AList.free;
end;
end;
var
i:integer;
begin
for i:=1 to section-1 do
begin
delete(ip,1,pos('.',ip));
end;
if section=4 then
result:=ip
else
result:=copy(ip,1,pos('.',ip)-1);
end;
type
TaPInAddr = array[0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe: PHostEnt;
pptr: PaPInAddr;
Buffer: array[0..63] of char;
I: Integer;
GInitData: TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^[I] <> nil do begin
result := StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;