请教:自定义异常类如何定义和实现啊?我目前主要是想获取当前窗口的异常信息,还要包括获取当前窗口信息,系统时间,当前登陆人员及当前操作信息等,哪位大侠指教啊!谢谢,一定高分以谢!  :)

解决方案 »

  1.   

    从Exception继承出来不就行了吗?
      

  2.   

    我知道从其他异常类继承出来啊,如exception;但是在具体实现的时候,我要获取其他信息,怎么获取啊,比如说获取某个窗口的title之类的信息,比如当前系统的日期啊,等等,如何实现,多多指教啊!谢谢
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, DB, ADODB, StdCtrls;type
      TForm1 = class(TForm)
        ADOQuery1: TADOQuery;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
      TFormException = class(Exception)
      private
      public
        constructor Create(const Msg: string; aForm: TForm);
      end;var
      Form1: TForm1;implementation{$R *.dfm}{ TFormException }constructor TFormException.Create(const Msg: string; aForm: TForm);
    begin
      Message := Msg + aForm.Caption;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      raise TFormException.Create('aa', self);
    end;