|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
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 _CrtDbgReport. When _DEBUG is not defined, calls to _CrtSetReportHook are removed during preprocessing.
See _CrtSetReportHook2 for a more robust version of _CrtSetReportHook.
The _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 (_CRT_WARN, _CRT_ERROR, _CRT_ASSERT),
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. See the _CrtSetReportMode function for a complete description of the available report types.
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 FALSE, _CrtDbgReport will be 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. See _CrtSetReportMode, _CrtSetReportFile, and _CrtDbgReport for a complete description of how the debug report is configured and generated.
For more information about using other hook-capable run-time functions and writing your own client-defined hook functions, see Writing Your Own Debug Hook Functions.
|_CrtSetReportHook||<crtdbg.h>||Win 98, Win Me, Win NT, Win 2000, Win XP|
For additional compatibility information, see Compatibility in the Introduction.
Debug versions of C run-time libraries only.
For a sample of how to use _CrtSetReportHook, see report.