有關網址轉IP的程式問題 |
尚未結案
|
snoopyet0909
一般會員 發表:2 回覆:6 積分:1 註冊:2005-06-09 發送簡訊給我 |
以下為程式部分: unit Unit1; interface uses
SysUtils, Types, Classes, Variants, QTypes, QGraphics, QControls, QForms,
QDialogs, QStdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient; type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Button1: TButton;
IdTCPClient1: TIdTCPClient;
Button2: TButton;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.xfm} procedure TForm1.FormCreate(Sender: TObject);
begin
label1.Caption:='Input the WWW Website:';
label2.Caption:='the IP is:';
button1.Caption:='Sure';
button2.Caption:='Close';
edit1.Text:='';
edit2.Text:='';
end; procedure TForm1.Button1Click(Sender: TObject);
begin
try
idtcpclient1.Host:=edit1.Text;
idtcpclient1.Connected();
edit2.Text:=idtcpclient1.Socket.Binding.PeerIP ;
idtcpclient1.Disconnect;
except
showmessage('disconnect');
end;
end; procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end; end. 我的問題是:
我的程式執行時網址不能轉成IP,
所以要麻煩大家幫我看看,
是不是哪個地方有問題?
順便告訴我怎麼改! 我是Delphi的初學者
麻煩大家
先在這邊說聲謝謝
|
pcboy
版主 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
|
snoopyet0909
一般會員 發表:2 回覆:6 積分:1 註冊:2005-06-09 發送簡訊給我 |
|
rexchiu
中階會員 發表:14 回覆:88 積分:70 註冊:2002-03-17 發送簡訊給我 |
引言: 以下為程式部分: unit Unit1; interface uses SysUtils, Types, Classes, Variants, QTypes, QGraphics, QControls, QForms, QDialogs, QStdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Label1: TLabel; Button1: TButton; IdTCPClient1: TIdTCPClient; Button2: TButton; Label2: TLabel; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.xfm} procedure TForm1.FormCreate(Sender: TObject); begin label1.Caption:='Input the WWW Website:'; label2.Caption:='the IP is:'; button1.Caption:='Sure'; button2.Caption:='Close'; edit1.Text:=''; edit2.Text:=''; end; procedure TForm1.Button1Click(Sender: TObject); begin try idtcpclient1.Host:=edit1.Text; idtcpclient1.Port:=80;//指定一個連接port.WWW通常都是80 idtcpclient1.Connect(5000);//開始連接,5000指的是time out的時間. //idtcpclient1.Connected(); if idtcpclient1.connected() then //判斷有沒有連接成功? begin edit2.Text:=idtcpclient1.Socket.Binding.PeerIP ; end; idtcpclient1.Disconnect; except showmessage('disconnect'); end; end; procedure TForm1.Button2Click(Sender: TObject); begin close; end; end.改成紅色的部份就可以了... 說明都寫在註解上了~~ Best Regards, Rex Chiu
------
Best Regards, Rex Chiu |
snoopyet0909
一般會員 發表:2 回覆:6 積分:1 註冊:2005-06-09 發送簡訊給我 |
|
Theodore
一般會員 發表:11 回覆:10 積分:4 註冊:2003-05-15 發送簡訊給我 |
TIdStack.ResolveHost
TIdStack
Convert a host name into an IP address.
function ResolveHost(const AHost: string): string;
Parameters
const AHost: string
Host name to convert.
Return Value
String - IP address for the host name.
Description
ResolveHost is a String function that returns the IP address for a given host name specified by the AHost parameter. For example, if AHost is set to "wvnvm.wvnet.edu", the function will return "129.71.2.4". If AHost was set to 129.71.2.4", this function returns "129.71.2.4".
|
Ktop_Robot
站務副站長 發表:0 回覆:3511 積分:0 註冊:2007-04-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |