Kod: Tümünü seç
procedure TForm1.Button1Click(Sender: TObject);
begin
if IdIPWatch1.IsOnline then
showmessage('ip: '+IdIPWatch1.CurrentIP);
end;
Kod: Tümünü seç
procedure TForm1.Button1Click(Sender: TObject);
begin
if IdIPWatch1.IsOnline then
showmessage('ip: '+IdIPWatch1.CurrentIP);
end;
Bu sonuç bi dosyayaya atılıp oradan parse edilebilir.C:\WINDOWS>tracert http://www.delphiturkiye.com
Tracing route to delphiturkiye.com [70.103.189.68]
over a maximum of 30 hops:
1 1 ms 1 ms 1 ms 192.168.0.1(DEfault Gateway)
2 16 ms 1 ms 1 ms 192.168.1.1(DEfault Gatewayin öbür ucu)
3 37 ms 29 ms 9 ms dsl.dynamicxxxxxxxx.ttnet.net.tr [xx.xxx.xx.xxxx](Ip adresiniz)
4 74 ms 43 ms 26 ms 10.20.14.154
5 30 ms 28 ms 13 ms ankM160-kysM20.ttnet.net.tr [195.175.10.9]
6 20 ms 21 ms 28 ms getepeM160-ankM160.ttnet.net.tr [195.175.7.2]
7 105 ms 92 ms 95 ms so-6-0-0.ar3.LON3.gblx.net [208.48.239.5]
8 229 ms 203 ms 205 ms so2-1-0-2488M.ar1.DCA3.gblx.net [67.17.67.57]
9 228 ms 205 ms 203 ms fe-1-2-0--0.er01.asbn.eli.net [207.173.144.25]
10 221 ms 203 ms 205 ms so-2-0-0--0.cr01.mcln.eli.net [207.173.114.129]
11 227 ms 204 ms 203 ms so-0-0-0--0.cr02.chcg.eli.net [207.173.114.250]
12 321 ms 381 ms 333 ms so-1-0-0--0.cr01.slkc.eli.net [207.173.115.237]
13 259 ms 306 ms 307 ms ge-0-0-0--0.gw02.slkc.eli.net [207.173.115.246]
14 258 ms 239 ms 233 ms gw0-cust-BLUEHOST-COM.slkc.eli.net [70.97.59.22]
15 241 ms 225 ms 225 ms box68.bluehost.com [70.103.189.68]
Trace complete.
Kod: Tümünü seç
function TForm1.GetMyIPAdress(Site:string='http://www.showmyip.com/'):string;
Var
MyUrlFile:TDownloadURL;
MyIPInfFile:TextFile;
myLine:String;
index:integer;
begin
result:='';
MyUrlFile:=TDownloadURL.Create(Self);
MyUrlFile.Filename:=ExtractFilePath(Application.Exename)+'MyIpFile.htm';
MyUrlFile.URL:=Site;
MyUrlFile.Execute;
MyUrlFile.Free;
AssignFile(MyIPInfFile,ExtractFilePath(Application.Exename)+'MyIpFile.htm');
Reset(MyIPInfFile);
While not EOF(MyIPInfFile) do
begin
ReadLn(MyIPInfFile,myLine);
index:=Pos('85.',myLine);
if index>0 then begin
While (index<=Length(myLine)) AND (myLine[index]<>' ') do
begin
result:=Result+myLine[index];
inc(index);
end;
break;
end;
end;
CloseFile(MyIPInfFile);
DeleteFile(ExtractFilePath(Application.Exename)+'MyIpFile.htm')
// http://www.whatismyip.com/ : displaycopy('85.105.89.11')
// http://www.showmyip.com/ : displaycopy('85.105.89.11')
// Üstteki iki sitede displaycopy('85.105.89.11') ifadesi var IP alınırken bu yapıdan da alınabilir.
// Ben bunu tercih etmedim Site değişiklik yaparsa çalışmaz. Ayrıca iki sitede <TITLE> içinde IP adresini gösteriyor
// <TITLE> Bu dosyada üstte yer aldığından arama daha hızlı Ayrıca değişme olasılığı daha az.
// Program bireaz yavaş çalışıyor sebebi dosyayı indirmeyle alakalı hattınız ne kadar hızlıysa o kadar hızlı çalışır
end;
Kod: Tümünü seç
Uses ...,
IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
........
.......
procedure TForm2.BtnGetExternalIPClick(Sender: TObject);
Var StIP : String;
tmpLines : TStringList;
begin
stIp := IdHTTP1.Get('http://ipinfo.io/json'); // http den çağırıyoruz.
// Şöyle bir metin (Text) üretir
{"ip": "75.9.150.219",
"hostname": "75.9.150.219.static.ttnet.com.tr",
"city": "Urfa",
"region": "Urfa",
"country": "TR",
"loc": "30.1917,29.0611",
"org": "AS9121 Turk Telekomunikasyon Anonim Sirketi" }
Memo1.Lines.Add('Ip Info : '+stIp);
tmpLines :=TStringList.Create;
tmpLines.Delimiter:=',';
tmpLines.Text:=stIp;
stIp:=tmpLines[1]; // İlk Satır IP nin yazdığı alan
tmpLines.Free;
Delete(stIp,1,Pos(':',stIp)+2); // "ip": string siliniyor
Delete(stIp,Length(stIp)-1,255); // " çift tırnak siliniyor
Memo1.Lines.Add('EXT IP:'+stIP);
end;