unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure GlobalExceptionHandler(Sender: TObject; E: Exception);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//***********************************************************************
procedure TForm1.Button1Click(Sender: TObject);
var
i,j: integer;
begin
j:=0;
i:=10 div j;
end;
//***********************************************************************
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException := GlobalExceptionHandler;
end;
//***********************************************************************
procedure TForm1.GlobalExceptionHandler(Sender: TObject; E: Exception);
var
fic: textfile;
begin
AssignFile (fic,'logerrores.txt');
if FileExists('logerrores.txt')=false then
begin
ReWrite(fic);
end
else
begin
Append(fic);
end;
writeln(fic,datetostr(now()) + ' ' + timetostr(now()));
writeln(fic,'-------------------------------------------------------------------');
writeln(fic,'Exception class name = '+E.ClassName);
writeln(fic,'Exception message = '+E.Message);
writeln(fic,''); CloseFile (fic);
end;
end.
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario