//*******************************************************
void myInvalidParameterHandler(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved)
{
wchar_t buff1[512] = {0};
wchar_t buff2[512] = {0};
swprintf_s( buff1,_countof(buff1),L"Invalid parameter detected in function %s."
L" File: %s Line: %d\n", function, file, line );
swprintf_s( buff2,_countof(buff2),L"Expression: %s\n", expression );
WriteToLog( buff1 );
WriteToLog( buff2 );
wprintf(buff1);
wprintf(buff2);
}
void myInvalidParameterHandler(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved)
{
wchar_t buff1[512] = {0};
wchar_t buff2[512] = {0};
swprintf_s( buff1,_countof(buff1),L"Invalid parameter detected in function %s."
L" File: %s Line: %d\n", function, file, line );
swprintf_s( buff2,_countof(buff2),L"Expression: %s\n", expression );
WriteToLog( buff1 );
WriteToLog( buff2 );
wprintf(buff1);
wprintf(buff2);
}
//********************************************************
main() 中
{
_invalid_parameter_handler oldHandler, newHandler;
newHandler = myInvalidParameterHandler;
oldHandler = _set_invalid_parameter_handler(newHandler);
// Disable the message box for assertions.
_CrtSetReportMode(_CRT_ASSERT, 0);
}