home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / source / chap13 / lst13_7.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-11  |  793 b   |  44 lines

  1. void StartDebugging()
  2. {
  3.  
  4. #ifdef _DEBUG
  5.  
  6.     hFile= CreateFile("error.log",GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
  7.  
  8.     if (hFile)
  9.     {
  10.     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
  11.     _CrtSetReportFile(_CRT_WARN, hFile);
  12.     _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
  13.     _CrtSetReportFile(_CRT_ERROR, hFile);
  14.     _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
  15.     _CrtSetReportFile(_CRT_ASSERT, hFile);
  16.     }
  17.  
  18.     _RPT0(_CRT_WARN, "Start Debug Reporting\r\n" );
  19.  
  20. #endif
  21. };
  22.  
  23. void StopDebugging()
  24. {
  25. #ifdef _DEBUG
  26.  
  27.     _RPT0(_CRT_WARN, "Stop Debug Reporting\r\n" );
  28.  
  29.     if (hFile)
  30.     CloseHandle(hFile);
  31.  
  32. #endif
  33. };
  34.  
  35. int main( int argc, char *argv[ ], char *envp[ ] )
  36. {
  37.     StartDebugging();
  38.  
  39.     // The Code
  40.  
  41.     StopDebugging();
  42.     return(0);
  43. }
  44.