我是主动关闭FTP链接的,然后链接时就提示 ‘socket error #10061’,这类错误信息如果才可以修改为自定义信息 ? 网上说捕获 Errorcode再通过 if 语句修改,但是不知道怎样才能够捕获 Errorcode。另外 IdFTP1.Connect(); 也不能够通过 try except end 做相应的判断机制。
解决方案 »
- delphi7.0做一个小程序,数据以*CSV形式导入,绘制曲线......
- 时间范围条件怎么查询范围时间?
- 安装 delphi7 时出现“不能访问 Windows Installer 服务。可能是你在.....”
- (初学者请各位大侠帮忙)笨鸟
- 有关VC调用DELPHI开发的动态连接库的问题,请帮忙.
- 我是一个初学者,何处有好的delphi编程技巧的网站啊,介绍几个.
- 关于TDBLookupComboBox
- 内存拷贝函数?
- 如何使用pb的系统表PBCatTbl和PBCatCol
- VCL中ADO数据集组件的问题
- FMX项目EXE可执行程序资源图片如何部署?
- java中获取tif文件格式的像素矩阵
try
idftp1.Connect;
except
on e: EIdSocketError do
begin
ShowMessage(IntToStr(e.LastError));
end;
end;
Application.OnException := ApplicationException;procedure TFormMain.ApplicationException(Sender: TObject; E:Exception);
begin
......
end;
报如下这个错误 哦!
[dcc32 Error] Main.pas(74): E2003 Undeclared identifier: 'ApplicationException'
idftp1.Connect;
er:=getlasterror()
except
if er=10061 then
begin
showmessage('朋友好久见,联系不上')
end
else
begin
showmessage('尊敬的顾客,还有什么事可帮您')
end
end;
unit Unit1;interfaceuses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
procedure ApplicationException(Sender: TObject; E:Exception);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException := ApplicationException;
end;procedure TForm1.ApplicationException(Sender: TObject; E:Exception);
begin
if (Pos('Socket Error # 10061', E.Message ) >= 1) then
begin
Application.MessageBox(
PChar('连接已中断(' + E.Message + ')'),
PChar('报错信息'), MB_OK + MB_ICONSTOP + MB_TOPMOST);
end
else
Application.ShowException(E);
end;end.