function whatismyip(): String;
var anurl: String;
var r:TregExpr;
var myip: string;
begin
anurl := IdHTTP1.Get('http:\\www.whatismyip.com');
r:= TregExpr.Create;
r.Expression := '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if r.Exec(anurl) then myip := r.Match[0];
r.Destroy;
whatismyip:=myip;
end;
This snippet requires indy and also regular expressions from http://regexpstudio.com/
There is a version using windows sockets here :-
http://www.delphifusion.com/forum/showthread.php?t=247
Subscribe to:
Post Comments (Atom)
5 comments:
Thanks for writing this.
Post a Comment