Name

SafeCallErrorProc Variable

Syntax

var SafeCallErrorProc: Pointer;

procedure SafeCallError(ErrorCode: Integer; ErrorAddr: Pointer);
begin ... end;
SafeCallErrorProc := @SafeCallError;

Description

Delphi calls the procedure that SafeCallErrorProc points to when a safecall routine returns an HResult that indicates an error. If SafeCallErrorProc is nil, or if the procedure does not raise an exception (so it returns normally), Delphi reports runtime error 24 (ESafeCallException).

Tips and Tricks

  • The ComObj unit sets this variable to a procedure that tries to get IErrorInfo information, and raise an EOleException exception using the ErrorCode and IErrorInfo data.

  • When you implement a COM server in Delphi, any Delphi exceptions raised in a safecall method are handled by the object’s SafeCallException method and mapped to an HResult. The SafeCallErrorProc procedure is called only for runtime errors and non-Delphi exceptions.

See Also

Function Keyword, Interface Keyword, Procedure Keyword, Safecall Directive, TObject Type

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.