有什么函数能得到IP地址*.*.*.*其中的一个字段

解决方案 »

  1.   

    你是不是要解释*.*.*.*?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;
      

  2.   

    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;
      

  3.   

    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;
      

  4.   

    我的裡面有個IdIPWatch1 再indy misc中,直接顯示出來,不過不知道怎麼來的