Leaked source code of windows server 2003
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.

81 lines
2.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-1998
  5. //
  6. // File: ciodmerr.cxx
  7. //
  8. // Contents: ciodm error class
  9. //
  10. // Classes: CiodmError
  11. //
  12. // History: 12-20-97 mohamedn created
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.cxx"
  16. #pragma hdrstop
  17. #include "stdafx.h"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CiodmError::GetErrorMessage, public
  21. //
  22. // Synopsis: returns error message corresponing to sc value
  23. //
  24. // Arguments: none
  25. //
  26. // Returns: valid error message upon success, 0 upon failure
  27. //
  28. // History: 12-20-97 mohamedn created
  29. //
  30. //----------------------------------------------------------------------------
  31. WCHAR const * CiodmError::GetErrorMessage(void)
  32. {
  33. //
  34. // Generate the Win32 error code by removing the facility code (7) and
  35. // the error bit.
  36. //
  37. Win4Assert( _scError );
  38. ULONG Win32status = _scError;
  39. if ( (Win32status & (FACILITY_WIN32 << 16)) == (FACILITY_WIN32 << 16) )
  40. {
  41. Win32status &= ~( 0x80000000 | (FACILITY_WIN32 << 16) );
  42. }
  43. //
  44. // Try looking up the error in the Win32 list of error codes
  45. //
  46. if ( ! FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM,
  47. GetModuleHandle(L"kernel32.dll"),
  48. Win32status,
  49. 0,
  50. _awcsErrorMessage,
  51. sizeof _awcsErrorMessage/ sizeof WCHAR,
  52. 0 ) )
  53. {
  54. if ( ! FormatMessage( FORMAT_MESSAGE_FROM_HMODULE,
  55. GetModuleHandle(L"query.dll"),
  56. Win32status,
  57. 0,
  58. _awcsErrorMessage,
  59. sizeof _awcsErrorMessage/ sizeof WCHAR,
  60. 0 ) )
  61. {
  62. odmDebugOut(( DEB_ERROR, "FormatMessage() Failed: %x\n",GetLastError() ));
  63. return 0;
  64. }
  65. }
  66. return _awcsErrorMessage;
  67. }