線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1633
推到 Plurk!
推到 Facebook!

撥接上網時,如何用Delphi取得真實IP?

答題得分者是:pcboy
bear28
一般會員


發表:44
回覆:53
積分:19
註冊:2002-09-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-07 10:39:23 IP:211.22.xxx.xxx 未訂閱
撥接上網時,如何用Delphi取得真實IP? 謝謝...
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-03-07 15:33:33 IP:218.163.xxx.xxx 未訂閱
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=24410    網海無涯,學無止境!
bear28
一般會員


發表:44
回覆:53
積分:19
註冊:2002-09-10

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-03-08 19:18:12 IP:211.22.xxx.xxx 未訂閱
thank...
pcboy
版主


發表:177
回覆:1838
積分:1463
註冊:2004-01-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2006-11-24 10:02:09 IP:219.87.xxx.xxx 未訂閱
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
Memo1: TMemo;
Edit1: TEdit;
IdHTTP1: TIdHTTP;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
j, k , m: Integer;
addr: array[1..4] of String;
begin
{
查真實 Internet IP 網址
http://myipaddress.com/show-my-ip-address/
http://www.danasoft.com/
http://ipid.shat.net/
http://www.whatismyip.com/
}
// Memo1.WordWrap:=False; // 不換行
IdHTTP1.HandleRedirects:=true;
Memo1.Text:=IdHTTP1.Get('http://ipid.shat.net/');
k :=1;
for i:= 0 to Memo1.Lines.Count -1 do
begin
if k<5 then
for j:= 1 to Length(Memo1.Lines[i]) do
begin
// 找 .<!--
if (Memo1.Lines[i][j]='.') and (Memo1.Lines[i][j 1]='<') and
(Memo1.Lines[i][j 2]='!') and (Memo1.Lines[i][j 3]='-') and (Memo1.Lines[i][j 4]='-') then
begin
if Memo1.Lines[i][j-2]='>' then Addr[k]:= Memo1.Lines[i][j-1];
if Memo1.Lines[i][j-3]='>' then Addr[k]:= Memo1.Lines[i][j-2] Memo1.Lines[i][j-1];
if Memo1.Lines[i][j-4]='>' then Addr[k]:= Memo1.Lines[i][j-3] Memo1.Lines[i][j-2] Memo1.Lines[i][j-1];
k:=k 1;
end;
if k=4 then
begin
if (Memo1.Lines[i][j]='>') and (Memo1.Lines[i][j 2]='<') then
begin
Addr[4]:= Memo1.Lines[i][j 1];
k:=k 1;
end;
if (Memo1.Lines[i][j]='>') and (Memo1.Lines[i][j 3]='<') then
begin
Addr[4]:= Memo1.Lines[i][j 1] Memo1.Lines[i][j 2];
k:=k 1;
end;
if (Memo1.Lines[i][j]='>') and (Memo1.Lines[i][j 4]='<') then
begin
Addr[4]:= Memo1.Lines[i][j 1] Memo1.Lines[i][j 2] Memo1.Lines[i][j 3];
k:=k 1;
end;
end;
end;
end;
Edit1.text:= Addr[1] '.' Addr[2] '.' Addr[3] '.' Addr[4] ;
Form1.Caption:='GetRealIP';
Memo1.Visible:=False;
Form1.Height:=80;
Form1.Width:=150;
end;
end.

------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案!

子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問!
系統時間:2024-04-23 14:10:18
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!