Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.3 KiB

  1. //=============================================================================*
  2. // COPYRIGHT� 2001 Microsoft Corporation and Executive Software International, Inc.
  3. //=============================================================================*
  4. // File: ErrMsg.cpp
  5. //=============================================================================*
  6. #include "stdafx.h"
  7. #include <windows.h>
  8. #include "ErrMacro.h"
  9. #include "Message.h"
  10. #include "ErrLog.h"
  11. #include "Dfrgres.h"
  12. #include "IntFuncs.h"
  13. #include "vString.hpp"
  14. #include "GetDfrgRes.h" // to use the GetDfrgResHandle()
  15. //This logfile capability is activated only for the engines.
  16. #if defined(DFRGFAT) || defined(DFRGNTFS)
  17. #include "LogFile.h"
  18. extern BOOL bLogFile;
  19. #endif
  20. extern BOOL bPopups;
  21. extern BOOL bIdentifiedErrorPath;
  22. extern HINSTANCE hInst;
  23. //-------------------------------------------------------------------*
  24. // function: ErrorMessageBox
  25. //
  26. // returns: None
  27. // note:
  28. //-------------------------------------------------------------------*
  29. BOOL
  30. ErrorMessageBox(
  31. TCHAR* cMsg,
  32. TCHAR* cTitle
  33. )
  34. {
  35. //Added cNewMsg code to take care of the case where cMsg == NULL, so that we put some message
  36. //out instead of nothing.
  37. TCHAR cNewMsg[256];
  38. if(cMsg == NULL)
  39. {
  40. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, // source and processing options
  41. NULL, // message source
  42. NULL, // message identifier
  43. NULL, // language identifier
  44. cNewMsg, // message buffer
  45. 255, // maximum size of message buffer
  46. NULL // array of message inserts
  47. );
  48. } else
  49. {
  50. wcscpy(cNewMsg, cMsg);
  51. }
  52. #ifndef OFFLINEDK
  53. //Write the error to the error log.
  54. WriteErrorToErrorLog(cNewMsg, -1, NULL);
  55. //This logfile capability is activated only for the engines.
  56. #if defined(DFRGFAT) || defined(DFRGNTFS)
  57. //If the logfile for the test harness is enabled, then log it there too.
  58. if(bLogFile){
  59. WriteStringToLogFile(cNewMsg);
  60. //return TRUE; //Have to bail out here so we don't print the messagebox below.
  61. }
  62. #endif
  63. //If this is set for messageboxes (not IoStress) then pop up a messagebox too.
  64. if(bPopups && !bIdentifiedErrorPath){
  65. MessageBox(NULL, cNewMsg, cTitle, MB_ICONSTOP|MB_OK);
  66. //Once an error message has been printed, don't print another.
  67. bIdentifiedErrorPath = TRUE;
  68. }
  69. #endif
  70. return TRUE;
  71. }
  72. //-------------------------------------------------------------------*
  73. // function: FileBugReportMessage
  74. //
  75. // returns: Always TRUE
  76. // FileBugReportMessage is identical to ErrorMessageBox, except that it puts up
  77. // a generic message telling the user to give us a log file
  78. // rather than pop up a message explaining the error.
  79. // This function is used when there is a code error, not when it isn't a bug, such as
  80. // when the user tells us to run on a volume that doesn't exist.
  81. //-------------------------------------------------------------------*
  82. BOOL
  83. FileBugReportMessage(
  84. TCHAR* cMsg,
  85. TCHAR* cTitle
  86. )
  87. {
  88. #ifndef OFFLINEDK
  89. VString msg(IDS_FILE_BUG_MESSAGE, GetDfrgResHandle());
  90. //Write the error to the error log.
  91. WriteErrorToErrorLog(cMsg, -1, NULL);
  92. //If this is set for messageboxes (not IoStress) then pop up a messagebox too.
  93. if(bPopups && !bIdentifiedErrorPath){
  94. MessageBox(NULL, msg.GetBuffer(), cTitle, MB_OK|MB_ICONSTOP);
  95. //Once an error message has been printed, don't print another.
  96. bIdentifiedErrorPath = TRUE;
  97. }
  98. #endif
  99. return TRUE;
  100. }