利用控件ApplicationEvents可以给程序做Log记录
现在想请问一下
该控件下的 onException事件主要是什么意思
是不是每次操作都会触发该事件呢 ?另外,Delphi中raise关键字是什么用的
谢谢
现在想请问一下
该控件下的 onException事件主要是什么意思
是不是每次操作都会触发该事件呢 ?另外,Delphi中raise关键字是什么用的
谢谢
解决方案 »
- 怎样成为DELPHI高手
- 关于软件更新,如何从服务器上下载新版本的软件?
- 我在使用TRichViewEdit时,输入中文后,选部分文字后,选中的部分就变成乱码了!如附件图片!
- 通过IE发送UDP包要怎么实现?
- image的大问题
- 关于用DLL作为MDI窗体问题
- 投诉:请问斑竹,我的信誉分怎么莫名其妙少了5分?分多分少不是什么问题,但是请给我一个解释,谢谢!
- intraweb的初级问题,散分~~!
- 新手急问,在线等待。为什么我设置TADOTABLE控件的tablename属性的时候,提示“数据提供者或其它服务返回E_FAIL状态”。
- 一个小问题
- Query为什么说没处于modify模式呀
- 如何把网页中所有图片的网址提取出来?
raise呢,就是触发一个Exception,或者说引发一个Exception;一般是引发一个自定义的Exception
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~参考下面的代码:procedure TFormLog.LogException(Sender: TObject; E: Exception);
var
Filename: string;
LogFile: TextFile;
begin
// prepares log file
Filename := ChangeFileExt (Application.Exename, '.log');
// ~~~~~~~~~~~~~~~~~应用程序的名称
AssignFile (LogFile, Filename);
if FileExists (FileName) then
Append (LogFile) // open existing file
else
Rewrite (LogFile); // create a new one // write to the file and show error
Writeln (LogFile, DateTimeToStr (Now) + ':' + E.Message);
if not CheckBoxSilent.Checked then
Application.ShowException (E); // close the file
CloseFile (LogFile);
end;procedure TFormLog.Button1Click(Sender: TObject);
var
a, b, c: Integer;
begin
a := 10;
b := 0;
c := a div b;
ShowMessage (IntToStr (c));
end;procedure TFormLog.Button2Click(Sender: TObject);
begin
raise Exception.Create ('raise button pressed');
end;----------------------------------------------------
每次Button1Click/Button2Click的点击事件执行完后,就会自动执行TFormLog.LogException
这是为什么 ?另外procedure TFormLog.LogException(Sender: TObject; E: Exception);
~~~~~~~~~~~~这是什么类型 ?
导致后面的 Writeln (LogFile, DateTimeToStr (Now) + ':' + E.Message);
~~~~~~~~~
我就弄不明白了
能再仔细的教教我吗 ?
谢谢
Exception是系统自己定义的一个结构,在出错时,系统就将出错信息填写到相应的区域,你在处理时,就可提取你需要的信息!!
不知道你明白了吗??