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.

81 lines
2.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: misc.hxx
  7. //
  8. // Contents: Definitions of utility stuff for use
  9. //
  10. // Functions:
  11. //
  12. // Macros:
  13. //
  14. // History:
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef _MISC_HXX_
  18. #define _MISC_HXX_
  19. #if DBG == 1
  20. STDAPI CheckAndReturnResult(
  21. HRESULT hr,
  22. LPSTR lpstrFile,
  23. UINT line,
  24. int cSuccess,
  25. ...);
  26. STDAPI_(void) CheckResult(HRESULT hr, LPSTR lpstrFile, UINT line);
  27. STDAPI PrintHRESULT(DWORD dwFlags, HRESULT hr);
  28. #define SRETURN(hr) \
  29. return CheckAndReturnResult((hr), __FILE__, __LINE__, -1)
  30. #define RRETURN(hr) \
  31. return CheckAndReturnResult((hr), __FILE__, __LINE__, 0)
  32. #define RRETURN1(hr, s1) \
  33. return CheckAndReturnResult((hr), __FILE__, __LINE__, 1, (s1))
  34. #define RRETURN2(hr, s1, s2) \
  35. return CheckAndReturnResult((hr), __FILE__, __LINE__, 2, (s1), (s2))
  36. #define RRETURN3(hr, s1, s2, s3) \
  37. return CheckAndReturnResult((hr), __FILE__, __LINE__, 3, (s1), (s2), (s3))
  38. #define RRETURN_EXP_IF_ERR(hr) \
  39. {if (FAILED(hr)) { \
  40. RaiseException(hr); \
  41. } \
  42. RRETURN(hr);}
  43. #define WARN_ERROR(hr) CheckResult((hr), __FILE__, __LINE__)
  44. #define TRETURN(hr) return PrintHRESULT(DEB_TRACE, (hr))
  45. #define TRACEHRESULT(hr) PrintHRESULT(DEB_TRACE, (hr))
  46. #else // DBG == 0
  47. #define SRETURN(hr) return (hr)
  48. #define RRETURN(hr) return (hr)
  49. #define RRETURN1(hr, s1) return (hr)
  50. #define RRETURN2(hr, s1, s2) return (hr)
  51. #define RRETURN3(hr, s1, s2, s3) return (hr)
  52. #define RRETURN_EXP_IF_ERR(hr) \
  53. {if (FAILED(hr)) { \
  54. RaiseException(hr); \
  55. } \
  56. RRETURN(hr);}
  57. #define WARN_ERROR(hr)
  58. #define TRETURN(hr) return (hr)
  59. #define TRACEHRESULT(hr)
  60. #endif // DBG
  61. #endif //_MISC_HXX_