|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.|
After specifying _CRTDBG_MODE_FILE with _CrtSetReportMode, you can specify the file handle to receive the message text. _CrtSetReportFile is also used by _CrtDbgReport, _CrtDbgReportW to specify the destination of text (debug version only).
On successful completion, _CrtSetReportFile returns the previous report file defined for the report type specified in reportType. If an invalid value is passed in for reportType, this function invokes the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, errno is set to EINVAL and the function returns _CRTDBG_HFILE_ERROR. For more information, see errno, _doserrno, _sys_errlist, and _sys_nerr.
_CrtSetReportFile is used with the _CrtSetReportMode function to define the destination or destinations for a specific report type generated by _CrtDbgReport. When _CrtSetReportMode has been called to assign the _CRTDBG_MODE_FILE reporting mode for a specific report type, _CrtSetReportFile should then be called to define the specific file or stream to use as the destination. When _DEBUG is not defined, calls to _CrtSetReportFile are removed during preprocessing.
The following table shows a list of the available choices for reportFile and the resulting behavior of _CrtDbgReport. These options are defined as bit flags in Crtdbg.h.
The report file used by each report type can be separately controlled. For example, it is possible to specify that a reportType of _CRT_ERROR be reported to stderr, while a reportType of _CRT_ASSERT be reported to a user-defined file handle or stream.
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.