如题?

解决方案 »

  1.   

    function TFORM1.LocalIP: 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   //取得本机所有IP
      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:= result + '#' + StrPas(inet_ntoa(pptr^[I]^));
        Inc(I);
      end;
      WSACleanup;
    end;
      

  2.   

    也可以不象楼上的那么麻烦
    Delphi自己带有控件
    在indy Misc页面里的叫IdIPWatch1
    它的IdIPWatch1.LocalIP就是本机的IP,这个控件还有其他的功能,自己发现吧
      

  3.   

    用TNMFinger控制就可以得到自己的IP啦,也需要那么复杂。