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.

108 lines
3.7 KiB

  1. #ifndef __ERRDCT_HPP__
  2. #define __ERRDCT_HPP__
  3. /*---------------------------------------------------------------------------
  4. File: ErrDct.hpp
  5. Comments: TError derived class that specifies a numeric code for each message
  6. format. The goal is to make it easy to convert this to a real message file
  7. later.
  8. This class also improves on the behavior of the TError class by returning text
  9. for HRESULT error codes.
  10. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  11. Proprietary and confidential to Mission Critical Software, Inc.
  12. REVISION LOG ENTRY
  13. Revision By: Christy Boles
  14. Revised on 03/26/99 13:04:51
  15. ---------------------------------------------------------------------------
  16. */
  17. #include <comdef.h>
  18. #include "Err.hpp"
  19. #include "Common.hpp"
  20. #include "UString.hpp"
  21. #include "McsDmMsg.h"
  22. // These codes are passed as the messageNumber argument to MsgWrite and SysMsgWrite.
  23. // Recursively walk through a path, trying to create the directories at each level
  24. DWORD // ret - 0 if successful (directories created\already existed), OS return code otherwise
  25. DirectoryCreateR(
  26. WCHAR const * dirToCreate // in-directory to create (full path or UNC)
  27. );
  28. class TErrorDct : public TError
  29. {
  30. public:
  31. TErrorDct(
  32. int displevel = 0,// in -mimimum severity level to display
  33. int loglevel = 0 ,// in -mimimum severity level to log
  34. int logmode = 0 ,// in -0=replace, 1=append
  35. int beeplevel = 100 // in -min error level for beeping
  36. ) : TError(displevel,loglevel,NULL,logmode,beeplevel)
  37. {}
  38. virtual WCHAR * ErrorCodeToText(
  39. DWORD code ,// in -message code
  40. DWORD lenMsg ,// in -length of message text area
  41. WCHAR * msg // out-returned message text
  42. );
  43. WCHAR const * LookupMessage(UINT msgNumber);
  44. virtual void __cdecl
  45. SysMsgWrite(
  46. int num ,// in -error number/level code
  47. DWORD lastRc ,// in -error return code
  48. UINT msgNumber ,// in -constant for message
  49. ... // in -printf args to msg pattern
  50. );
  51. virtual void __cdecl
  52. MsgWrite(
  53. int num ,// in -error number/level code
  54. UINT msgNumber ,// in -constant for message
  55. ... // in -printf args to msg pattern
  56. );
  57. void __cdecl
  58. DbgMsgWrite(
  59. int num ,// in -error number/level code
  60. WCHAR const msg[] ,// in -error message to display
  61. ... // in -printf args to msg pattern
  62. );
  63. virtual BOOL LogOpen(
  64. WCHAR const * fileName ,// in -name of file including any path
  65. int mode = 0 ,// in -0=overwrite, 1=append
  66. int level = 0 ,// in -minimum level to log
  67. bool bBeginNew = false // in -begin a new log file
  68. )
  69. {
  70. WCHAR directory[MAX_PATH];
  71. safecopy(directory,fileName);
  72. WCHAR * x = wcsrchr(directory,'\\');
  73. if ( x )
  74. {
  75. (*x) = 0;
  76. DirectoryCreateR(directory);
  77. }
  78. return TError::LogOpen(fileName,mode,level,bBeginNew);
  79. }
  80. _bstr_t __cdecl
  81. GetMsgText(
  82. UINT msgNumber ,// in -constant for message
  83. ... // in -printf args to msg pattern
  84. );
  85. };
  86. #endif //__ERRDCT_HPP__