資源簡介
C++檢測網絡連接是否正常

代碼片段和文件信息
//---------------------------------------------------------------------------
//Download?by?http://www.codefans.net
#include?
#pragma?hdrstop
#include?“Mainform.h“
//---------------------------------------------------------------------------
#pragma?package(smart_init)
#pragma?resource?“*.dfm“
TForm1?*Form1;
//---------------------------------------------------------------------------
__fastcall?TForm1::TForm1(TComponent*?Owner)
????????:?TForm(Owner)
{
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::BitBtn1Click(Tobject?*Sender)
{
??NMEcho1->ReportLevel?=?Status_Basic;
??NMEcho1->TimeOut?=?StrToInt(Edit5->Text);
??NMEcho1->Host?=?Edit2->Text;
??NMEcho1->Port?=?StrToInt(Edit3->Text);
??NMEcho1->Connect();
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::BitBtn2Click(Tobject?*Sender)
{
??NMEcho1->Disconnect();?????????
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::NMEcho1Connect(Tobject?*Sender)
{
???StatusBar1->SimpleText?=?“連接成功!“;
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::NMEcho1ConnectionFailed(Tobject?*Sender)
{
???StatusBar1->SimpleText?=?“連接失敗!“;
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::Button1Click(Tobject?*Sender)
{
??Edit4->Text?=?NMEcho1->Echo(Edit1->Text);
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::Button4Click(Tobject?*Sender)
{
??NMEcho1->Abort();
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::NMEcho1Disconnect(Tobject?*Sender)
{
??if?(StatusBar1?!=?0)
????StatusBar1->SimpleText?=?“連接已經被斷開!“;
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::NMEcho1HostResolved(TComponent?*Sender)
{
??StatusBar1->SimpleText?=?“成功解析遠程主機域名!“;????????
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::NMEcho1InvalidHost(bool?&Handled)
{
??AnsiString?NewHost;
??if?(InputQuery(“遠程主機域名無效!“?“請重新選擇遠程主機“?NewHost))
??{
????NMEcho1->Host?=?NewHost;
????Handled?=?true;
??}
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::NMEcho1Status(TComponent?*Sender
??????AnsiString?Status)
{
?if?(StatusBar1?!=?0)
????StatusBar1->SimpleText?=?Status;
}
//---------------------------------------------------------------------------
void?__fastcall?TForm1::NMEcho1ConnectionRequired(bool?&Handled)
{
?if?(MessageBox(0?“是否需要連接遠程主機?“?“信息提示“?MB_YESNO?+?MB_ICONEXCLAMATION)?==?IDYES)
??{
????Handled?=?true;
????Button1Click(NULL);
??}
}
//---------------------------------------------------------------
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
-----------?---------??----------?-----??----
????????????????13999????????????????????9
- 上一篇:C# C語言分別與labview調用DLL范例
- 下一篇:車輛行駛死鎖問題
評論
共有 條評論