两步
1:在 uses 后添加 winsock,
2:自己定义以下函数function GetIPAddress: string;
var
  phoste:PHostEnt;
  Buffer:array[0..100] of char;
  WSAData:TWSADATA;
begin
  result:='';
  if WSASTartup($0101, WSAData) <> 0 then exit;
  GetHostName(Buffer,Sizeof(Buffer));
  phoste:=GetHostByName(buffer);
  if phoste = nil then
  begin
    result:='127.0.0.1';
  end
  else
  result:=StrPas(inet_ntoa(PInAddr(phoste^.h_addr_list^)^));
  WSACleanup;
end;
其他的自己添吧!
例:   label1.Caption:=GetIPAddress;则 label1将显示自己的ip地址

解决方案 »

  1.   

    Function  GetCurrentcupaddr:string;
    Const
        cupnamesize=255;
    var
        cupname:pointer;
        remcup :PHostEnt;
    begin
        cupname:=Nil;
        Try
            Getmem(cupname,cupnamesize);
            Gethostname(cupname,cupnamesize);
            if (char(cupname^)<>#0) then
            begin
                remcup:=Gethostbyname(cupname);
                result:=inttostr(ord(remcup^.h_addr_list^[0]))+'.'+
                    inttostr(ord(remcup^.h_addr_list^[1]))+'.'+
                    inttostr(ord(remcup^.h_addr_list^[2]))+'.'+
                    inttostr(ord(remcup^.h_addr_list^[3]));
            end
            else
                result:='&Icirc;&acute;&Ouml;&ordf;';
        finally
            if (cupname<>Nil) then
                freemem(cupname,cupnamesize);
        end;
    end;