Ver Mensaje Individual
  #3  
Antiguo 13-04-2013
Avatar de AzidRain
[AzidRain] AzidRain is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Córdoba, Veracruz, México
Posts: 2.914
Reputación: 21
AzidRain Va camino a la fama
Esta función devuelve el dato que requieres:
Código Delphi [-]
function IP_Publica: string;

  function EsNumerico( S: string ): Boolean;
  begin
    Result := false;
    if ( Length( S ) > 0 ) then
      case S[1] of
        '0'..'9': Result := True;
      end;
  end;
var
  HTMLBody: string;
  i: Integer;
  IdHTTP: TIdHTTP;
begin
  Result := '';

  // ¿Estamos conectados a Internet?
  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 EsNumerico( HTMLBody[i] ) or ( HTMLBody[i] = '.' ) then
          Result := Result + HTMLBody[i];
      end;

     finally
       IdHTTP.Free;
     end;
  end;
end;

Hay otras formas de obtenerla pero son mas complejas, para algo rápido esta funciona (hasta que dyndns cancele el servicio jejeje).
__________________
AKA "El animalito" ||Cordobés a mucha honra||
Responder Con Cita