Installs a client-defined reporting function by hooking it into the C run-time debug reporting process (debug version only).
_CRT_REPORT_HOOK _CrtSetReportHook( _CRT_REPORT_HOOK reportHook );
New client-defined reporting function to hook into the C run-time debug reporting process.
Returns the previous client-defined reporting function.
_CrtSetReportHook allows an application to use its own reporting function into the C run-time debug library reporting process. As a result, whenever
_CrtDbgReport is called to generate a debug report, the application's reporting function is called first. This functionality enables an application to perform operations such as filtering debug reports so it can focus on specific allocation types or send a report to destinations not available by using
_DEBUG isn't defined, calls to
_CrtSetReportHook are removed during preprocessing.
For a more robust version of
_CrtSetReportHook function installs the new client-defined reporting function specified in
reportHook and returns the previous client-defined hook. The following example demonstrates how a client-defined report hook should be prototyped:
int YourReportHook( int reportType, char *message, int *returnValue );
reportType is the debug report type (
message is the fully assembled debug user message to be contained in the report, and
returnValue is the value specified by the client-defined reporting function that should be returned by
_CrtDbgReport. For a complete description of the available report types, see the
If the client-defined reporting function completely handles the debug message such that no further reporting is required, then the function should return
TRUE. When the function returns
_CrtDbgReport is called to generate the debug report using the current settings for the report type, mode, and file. In addition, by specifying the
_CrtDbgReport return value in
returnValue, the application can also control whether a debug break occurs. For a complete description of how the debug report is configured and generated, see
For more information about using other hook-capable run-time functions and writing your own client-defined hook functions, see Debug hook function writing.
If your application is compiled with /clr and the reporting function is called after the application has exited main, the CLR will throw an exception if the reporting function calls any CRT functions.
For more compatibility information, see Compatibility.
Debug versions of C run-time libraries only.