[Lazarus] How to find out the public IP in code?
silvioprog
silvioprog at gmail.com
Sat Nov 7 17:30:48 CET 2015
On Sat, Nov 7, 2015 at 12:13 PM, fecske fecske <fecske95 at gmail.com> wrote:
> or see this
>
> http://forum.lazarus.freepascal.org/index.php/topic,17506.msg110917.html#msg110917
If you just want to get your external IP using some service like dyndns,
you should use pure FCL:
=== begin code ===
uses fphttpclient, RegExpr;
procedure TForm1.Button1Click(Sender: TObject);
begin
with TRegExpr.Create('[0-9.]+') do try
if Exec(TFPHTTPClient.SimpleGet('http://checkip.dyndns.org')) then
ShowMessage(Match[0])
finally Free; end;
end;
=== end code ==
However, if you can use other service like echoip.com, just:
=== begin code ===
uses fphttpclient;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(TFPHTTPClient.SimpleGet('http://echoip.com/'));
end;
=== end code ===
HTH
--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20151107/87fdcea3/attachment-0003.html>
More information about the Lazarus
mailing list