要怎樣判斷網路是否有連線 |
缺席
|
delphi
初階會員 發表:52 回覆:64 積分:38 註冊:2002-05-21 發送簡訊給我 |
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
Hello Here's an sample for that, juat add TextBox, Button, Memo and IdIcmpClient
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
IdIcmpClient1.ReceiveTimeout := 1000;
IdIcmpClient1.Host := Edit1.Text;
for i := 1 to 4 do
IdIcmpClient1.Ping;
end; procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime: string;
begin
sTime := '=';
Memo1.Lines.add(Format('%d bytes from %s: icmp_seq=%d ttl=%d time%s%d ms',[AReplyStatus.BytesReceived,
AReplyStatus.FromIpAddress, AReplyStatus.SequenceId, AReplyStatus.TimeToLive, sTime, AReplyStatus.MsRoundTripTime]));
end;
you can also find a better example in delphi demos folder with error handling
\Delphi6\Demos\Indy\PingGUI but I made this example simple and short
----------------
局局棋盤步步新,
變化無常平常待。
人生相處平常心,
無憂無慮心事成。
----------------
發表人 - flyup 於 2003/01/13 19:28:01
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
I use a freeware suite of internet components. It works great and have demo code. Just take a look: http://www.overbyte.be
http://www.rtfm.be/fpiette/indexuk.htm or
http://users.swing.be/francois.piette/indexuk.htm
----------------
局局棋盤步步新,
變化無常平常待。
人生相處平常心,
無憂無慮心事成。
----------------
|
flyup
資深會員 發表:280 回覆:508 積分:385 註冊:2002-04-15 發送簡訊給我 |
|
yoo
一般會員 發表:1 回覆:4 積分:1 註冊:2002-10-26 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |