Name
SafeCallErrorProc Variable
Syntax
var SafeCallErrorProc: Pointer; procedureSafeCallError
(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 getIErrorInfo
information, and raise anEOleException
exception using theErrorCode
andIErrorInfo
data.When you implement a COM server in Delphi, any Delphi exceptions raised in a
safecall
method are handled by the object’sSafeCallException
method and mapped to anHResult
. TheSafeCallErrorProc
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.