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.

100 lines
3.4 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 "Err.hpp"
  18. #include "Common.hpp"
  19. #include "UString.hpp"
  20. #include "McsDmMsg.h"
  21. // These codes are passed as the messageNumber argument to MsgWrite and SysMsgWrite.
  22. // Recursively walk through a path, trying to create the directories at each level
  23. DWORD // ret - 0 if successful (directories created\already existed), OS return code otherwise
  24. DirectoryCreateR(
  25. WCHAR const * dirToCreate // in-directory to create (full path or UNC)
  26. );
  27. class TErrorDct : public TError
  28. {
  29. public:
  30. TErrorDct(
  31. int displevel = 0,// in -mimimum severity level to display
  32. int loglevel = 0 ,// in -mimimum severity level to log
  33. int logmode = 0 ,// in -0=replace, 1=append
  34. int beeplevel = 100 // in -min error level for beeping
  35. ) : TError(displevel,loglevel,NULL,logmode,beeplevel)
  36. {}
  37. virtual WCHAR * ErrorCodeToText(
  38. DWORD code ,// in -message code
  39. DWORD lenMsg ,// in -length of message text area
  40. WCHAR * msg // out-returned message text
  41. );
  42. WCHAR const * LookupMessage(UINT msgNumber);
  43. virtual void __cdecl
  44. SysMsgWrite(
  45. int num ,// in -error number/level code
  46. DWORD lastRc ,// in -error return code
  47. UINT msgNumber ,// in -constant for message
  48. ... // in -printf args to msg pattern
  49. );
  50. virtual void __cdecl
  51. MsgWrite(
  52. int num ,// in -error number/level code
  53. UINT msgNumber ,// in -constant for message
  54. ... // in -printf args to msg pattern
  55. );
  56. void __cdecl
  57. DbgMsgWrite(
  58. int num ,// in -error number/level code
  59. WCHAR const msg[] ,// in -error message to display
  60. ... // in -printf args to msg pattern
  61. );
  62. virtual BOOL LogOpen(
  63. WCHAR const * fileName ,// in -name of file including any path
  64. int mode = 0 ,// in -0=overwrite, 1=append
  65. int level = 0 // in -minimum level to log
  66. )
  67. {
  68. WCHAR directory[MAX_PATH];
  69. safecopy(directory,fileName);
  70. WCHAR * x = wcsrchr(directory,'\\');
  71. if ( x )
  72. {
  73. (*x) = 0;
  74. DirectoryCreateR(directory);
  75. }
  76. return TError::LogOpen(fileName,mode,level);
  77. }
  78. };
  79. #endif //__ERRDCT_HPP__