Ver Mensaje Individual
  #1  
Antiguo 21-09-2006
Avatar de vtdeleon
vtdeleon vtdeleon is offline
Miembro
 
Registrado: abr 2004
Ubicación: RD & USA
Posts: 3.236
Reputación: 24
vtdeleon Va por buen camino
Saber Ip Pública

Funcion para saber la ip pública. Necesita las unidades IdHTTP y WinInet.

Codigo recogido en el Foro.
Código Delphi [-]
function IP_Publica:string;
  function IsNumeric( T:string ):boolean;
  begin
    Result:=false;
    if (length(T)>0) then
      case T[1] of
          '0'..'9':Result:=true;
      end;
  end;
var
  HTMLBody:string;
  i:integer;
  IdHTTP:TIdHTTP;
begin
  Result:='';
  if   WinInet.InternetGetConnectedState(nil,0)
  then begin
       IdHTTP:=TIdHTTP.Create(Application);
       try
         HTMLBody:=IdHTTP.Get('http://checkip.dyndns.org/');
         for i:=0 to Length(HTMLBody)-1 do begin
             if   IsNumeric(HTMLBody[i])
             or  (HTMLBody[i]='.')
             then Result:=Result+HTMLBody[i];
         end;
       finally
         IdHTTP.Free;
       end;
  end;
end;
Responder Con Cita