procedure TForm1.Button1Click(Sender: TObject);
var
LValueA : Integer;
LValueB : Integer;
LExceptRec : PExceptionRecord;
LErrCode : Integer;
begin
Memo1.Lines.Clear;
LValueA := 0;
try
LValueB := 123 div LValueA;
except
on E: Exception do begin
//PExceptionRecordを取得してエラー番号を取得
LExceptRec := EExternal(E).ExceptionRecord;
LErrCode := LExceptRec.ExceptionCode;
//エラーメッセージとエラー番号を表示 Memo1.Lines.Add(E.Message); Memo1.Lines.Add(E.ClassName); Memo1.Lines.Add('$' + IntToHex(LErrCode, 8)); end;
end;
end;
参考URL:http://mrxray.on.coocan.jp/Delphi/Others/RunError.htm