home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / mdcommsg.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  1KB  |  57 lines

  1. /*++
  2.  
  3. Copyright (c) 1997 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     commsg.h
  8.  
  9. Abstract:
  10.  
  11.     HRESULT <-> Win32 error mapping macros.
  12.  
  13. Author:
  14.  
  15.     Michael W. Thomas (michth)   24-Sep-1996
  16.  
  17. Revision History:
  18.  
  19.     Keith Moore (keithmo)        07-Feb-1997
  20.         Cleanup, comment, made Metadata errors "real" HRESULTs.
  21.  
  22. --*/
  23.  
  24.  
  25. #ifndef _COMMSG_H_
  26. #define _COMMSG_H_
  27.  
  28.  
  29. //
  30. // RETURNCODETOHRESULT() maps a return code to an HRESULT. If the return
  31. // code is a Win32 error (identified by a zero high word) then it is mapped
  32. // using the standard HRESULT_FROM_WIN32() macro. Otherwise, the return
  33. // code is assumed to already be an HRESULT and is returned unchanged.
  34. //
  35.  
  36. #define RETURNCODETOHRESULT(rc)                             \
  37.             (((rc) < 0x10000)                               \
  38.                 ? HRESULT_FROM_WIN32(rc)                    \
  39.                 : (rc))
  40.  
  41.  
  42. //
  43. // HRESULTTOWIN32() maps an HRESULT to a Win32 error. If the facility code
  44. // of the HRESULT is FACILITY_WIN32, then the code portion (i.e. the
  45. // original Win32 error) is returned. Otherwise, the original HRESULT is
  46. // returned unchagned.
  47. //
  48.  
  49. #define HRESULTTOWIN32(hres)                                \
  50.             ((HRESULT_FACILITY(hres) == FACILITY_WIN32)     \
  51.                 ? HRESULT_CODE(hres)                        \
  52.                 : (hres))
  53.  
  54.  
  55. #endif  // _COMMSG_H_
  56.  
  57.