Last Updated: February 25, 2016
·
572
· gpakosz

Suppress all Microsoft CRT dialog boxes

Useful e.g. when you don't want your automated tests to wait for a click in those dialog boxes upon a failure.

#ifdef _WIN32
int stfuHook(int, char*, int* returnValue)
{
  if (returnValue)
    *returnValue = 0;

  return true;
}
#endif

int main(int argc, char * argv[])
{
#ifdef _WIN32
  _CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, stfuHook);
#endif

...