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

  1. /*
  2.  *  WABCODE.H
  3.  *
  4.  *  Status Codes returned by WAB routines
  5.  *
  6.  *  History:
  7.  *      03/04/96    brucek  Copied from MAPI's mapicode.h
  8.  *
  9.  *  Copyright 1993-1998 Microsoft Corporation. All Rights Reserved.
  10.  */
  11.  
  12. #if !defined(MAPICODE_H) && !defined(WABCODE_H)
  13. #define WABCODE_H
  14.  
  15. /* Define S_OK and ITF_* */
  16.  
  17. #ifdef WIN32
  18. #include <objerror.h>
  19. #endif
  20.  
  21. /*
  22.  *  WAB Status codes follow the style of OLE 2.0 sCodes as defined in the
  23.  *  OLE 2.0 Programmer's Reference and header file scode.h (Windows 3.x)
  24.  *  or objerror.h (Windows NT 3.5 and Windows 95).
  25.  *
  26.  */
  27.  
  28. /*  On Windows 3.x, status codes have 32-bit values as follows:
  29.  *
  30.  *   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  31.  *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  32.  *  +-+---------------------+-------+-------------------------------+
  33.  *  |S|       Context       | Facil |               Code            |
  34.  *  +-+---------------------+-------+-------------------------------+
  35.  *
  36.  *  where
  37.  *
  38.  *      S - is the severity code
  39.  *
  40.  *          0 - SEVERITY_SUCCESS
  41.  *          1 - SEVERITY_ERROR
  42.  *
  43.  *      Context - context info
  44.  *
  45.  *      Facility - is the facility code
  46.  *
  47.  *          0x0 - FACILITY_NULL     generally useful errors ([SE]_*)
  48.  *          0x1 - FACILITY_RPC      remote procedure call errors (RPC_E_*)
  49.  *          0x2 - FACILITY_DISPATCH late binding dispatch errors
  50.  *          0x3 - FACILITY_STORAGE  storage errors (STG_E_*)
  51.  *          0x4 - FACILITY_ITF      interface-specific errors
  52.  *
  53.  *      Code - is the facility's status code
  54.  *
  55.  *
  56.  */
  57.  
  58. /*
  59.  *  On Windows NT 3.5 and Windows 95, scodes are 32-bit values
  60.  *  laid out as follows:
  61.  *
  62.  *    3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  63.  *    1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  64.  *   +-+-+-+-+-+---------------------+-------------------------------+
  65.  *   |S|R|C|N|r|    Facility         |               Code            |
  66.  *   +-+-+-+-+-+---------------------+-------------------------------+
  67.  *
  68.  *   where
  69.  *
  70.  *      S - Severity - indicates success/fail
  71.  *
  72.  *          0 - Success
  73.  *          1 - Fail (COERROR)
  74.  *
  75.  *      R - reserved portion of the facility code, corresponds to NT's
  76.  *          second severity bit.
  77.  *
  78.  *      C - reserved portion of the facility code, corresponds to NT's
  79.  *          C field.
  80.  *
  81.  *      N - reserved portion of the facility code. Used to indicate a
  82.  *          mapped NT status value.
  83.  *
  84.  *      r - reserved portion of the facility code. Reserved for internal
  85.  *          use. Used to indicate HRESULT values that are not status
  86.  *          values, but are instead message ids for display strings.
  87.  *
  88.  *      Facility - is the facility code
  89.  *          FACILITY_NULL                    0x0
  90.  *          FACILITY_RPC                     0x1
  91.  *          FACILITY_DISPATCH                0x2
  92.  *          FACILITY_STORAGE                 0x3
  93.  *          FACILITY_ITF                     0x4
  94.  *          FACILITY_WIN32                   0x7
  95.  *          FACILITY_WINDOWS                 0x8
  96.  *
  97.  *      Code - is the facility's status code
  98.  *
  99.  */
  100.  
  101.  
  102.  
  103.  
  104. /*
  105.  *  We can't use OLE 2.0 macros to build sCodes because the definition has
  106.  *  changed and we wish to conform to the new definition.
  107.  */
  108. #define MAKE_MAPI_SCODE(sev,fac,code) \
  109.     ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
  110.  
  111. /* The following two macros are used to build OLE 2.0 style sCodes */
  112.  
  113. #define MAKE_MAPI_E( err )  (MAKE_MAPI_SCODE( 1, FACILITY_ITF, err ))
  114. #define MAKE_MAPI_S( warn ) (MAKE_MAPI_SCODE( 0, FACILITY_ITF, warn ))
  115.  
  116. #ifdef  SUCCESS_SUCCESS
  117. #undef  SUCCESS_SUCCESS
  118. #endif
  119. #define SUCCESS_SUCCESS     0L
  120.  
  121. /* General errors (used by more than one WAB object) */
  122.  
  123. #define MAPI_E_CALL_FAILED                              E_FAIL
  124. #define MAPI_E_NOT_ENOUGH_MEMORY                        E_OUTOFMEMORY
  125. #define MAPI_E_INVALID_PARAMETER                        E_INVALIDARG
  126. #define MAPI_E_INTERFACE_NOT_SUPPORTED                  E_NOINTERFACE
  127. #define MAPI_E_NO_ACCESS                                E_ACCESSDENIED
  128.  
  129. #define MAPI_E_NO_SUPPORT                               MAKE_MAPI_E( 0x102 )
  130. #define MAPI_E_BAD_CHARWIDTH                            MAKE_MAPI_E( 0x103 )
  131. #define MAPI_E_STRING_TOO_LONG                          MAKE_MAPI_E( 0x105 )
  132. #define MAPI_E_UNKNOWN_FLAGS                            MAKE_MAPI_E( 0x106 )
  133. #define MAPI_E_INVALID_ENTRYID                          MAKE_MAPI_E( 0x107 )
  134. #define MAPI_E_INVALID_OBJECT                           MAKE_MAPI_E( 0x108 )
  135. #define MAPI_E_OBJECT_CHANGED                           MAKE_MAPI_E( 0x109 )
  136. #define MAPI_E_OBJECT_DELETED                           MAKE_MAPI_E( 0x10A )
  137. #define MAPI_E_BUSY                                     MAKE_MAPI_E( 0x10B )
  138. #define MAPI_E_NOT_ENOUGH_DISK                          MAKE_MAPI_E( 0x10D )
  139. #define MAPI_E_NOT_ENOUGH_RESOURCES                     MAKE_MAPI_E( 0x10E )
  140. #define MAPI_E_NOT_FOUND                                MAKE_MAPI_E( 0x10F )
  141. #define MAPI_E_VERSION                                  MAKE_MAPI_E( 0x110 )
  142. #define MAPI_E_LOGON_FAILED                             MAKE_MAPI_E( 0x111 )
  143. #define MAPI_E_SESSION_LIMIT                            MAKE_MAPI_E( 0x112 )
  144. #define MAPI_E_USER_CANCEL                              MAKE_MAPI_E( 0x113 )
  145. #define MAPI_E_UNABLE_TO_ABORT                          MAKE_MAPI_E( 0x114 )
  146. #define MAPI_E_NETWORK_ERROR                            MAKE_MAPI_E( 0x115 )
  147. #define MAPI_E_DISK_ERROR                               MAKE_MAPI_E( 0x116 )
  148. #define MAPI_E_TOO_COMPLEX                              MAKE_MAPI_E( 0x117 )
  149. #define MAPI_E_BAD_COLUMN                               MAKE_MAPI_E( 0x118 )
  150. #define MAPI_E_EXTENDED_ERROR                           MAKE_MAPI_E( 0x119 )
  151. #define MAPI_E_COMPUTED                                 MAKE_MAPI_E( 0x11A )
  152. #define MAPI_E_CORRUPT_DATA                             MAKE_MAPI_E( 0x11B )
  153. #define MAPI_E_UNCONFIGURED                             MAKE_MAPI_E( 0x11C )
  154. #define MAPI_E_FAILONEPROVIDER                          MAKE_MAPI_E( 0x11D )
  155.  
  156. /* WAB base function and status object specific errors and warnings */
  157.  
  158. #define MAPI_E_END_OF_SESSION                           MAKE_MAPI_E( 0x200 )
  159. #define MAPI_E_UNKNOWN_ENTRYID                          MAKE_MAPI_E( 0x201 )
  160. #define MAPI_E_MISSING_REQUIRED_COLUMN                  MAKE_MAPI_E( 0x202 )
  161. #define MAPI_W_NO_SERVICE                               MAKE_MAPI_S( 0x203 )
  162.  
  163. /* Property specific errors and warnings */
  164.  
  165. #define MAPI_E_BAD_VALUE                                MAKE_MAPI_E( 0x301 )
  166. #define MAPI_E_INVALID_TYPE                             MAKE_MAPI_E( 0x302 )
  167. #define MAPI_E_TYPE_NO_SUPPORT                          MAKE_MAPI_E( 0x303 )
  168. #define MAPI_E_UNEXPECTED_TYPE                          MAKE_MAPI_E( 0x304 )
  169. #define MAPI_E_TOO_BIG                                  MAKE_MAPI_E( 0x305 )
  170. #define MAPI_E_DECLINE_COPY                             MAKE_MAPI_E( 0x306 )
  171. #define MAPI_E_UNEXPECTED_ID                            MAKE_MAPI_E( 0x307 )
  172.  
  173. #define MAPI_W_ERRORS_RETURNED                          MAKE_MAPI_S( 0x380 )
  174.  
  175. /* Table specific errors and warnings */
  176.  
  177. #define MAPI_E_UNABLE_TO_COMPLETE                       MAKE_MAPI_E( 0x400 )
  178. #define MAPI_E_TIMEOUT                                  MAKE_MAPI_E( 0x401 )
  179. #define MAPI_E_TABLE_EMPTY                              MAKE_MAPI_E( 0x402 )
  180. #define MAPI_E_TABLE_TOO_BIG                            MAKE_MAPI_E( 0x403 )
  181.  
  182. #define MAPI_E_INVALID_BOOKMARK                         MAKE_MAPI_E( 0x405 )
  183.  
  184. #define MAPI_W_POSITION_CHANGED                         MAKE_MAPI_S( 0x481 )
  185. #define MAPI_W_APPROX_COUNT                             MAKE_MAPI_S( 0x482 )
  186.  
  187. #define MAPI_W_PARTIAL_COMPLETION                         MAKE_MAPI_S( 0x680 )
  188.  
  189. /* Address Book specific errors and warnings */
  190.  
  191. #define MAPI_E_AMBIGUOUS_RECIP                          MAKE_MAPI_E( 0x700 )
  192.  
  193.  
  194. /* Miscellaneous errors */
  195. #define MAPI_E_COLLISION                                MAKE_MAPI_E( 0x604 )
  196. #define MAPI_E_NOT_INITIALIZED                          MAKE_MAPI_E( 0x605 )
  197. #define MAPI_E_FOLDER_CYCLE                             MAKE_MAPI_E( 0x60B )
  198.  
  199. /* The range 0x0800 to 0x08FF is reserved */
  200.  
  201. /* Obsolete typing shortcut that will go away eventually. */
  202. #ifndef MakeResult
  203. #define MakeResult(_s)  ResultFromScode(_s)
  204. #endif
  205.  
  206. /* We expect these to eventually be defined by OLE, but for now,
  207.  * here they are.  When OLE defines them they can be much more
  208.  * efficient than these, but these are "proper" and don't make
  209.  * use of any hidden tricks.
  210.  */
  211. #ifndef HR_SUCCEEDED
  212. #define HR_SUCCEEDED(_hr) SUCCEEDED((SCODE)(_hr))
  213. #define HR_FAILED(_hr) FAILED((SCODE)(_hr))
  214. #endif
  215.  
  216. #endif  /* WABCODE_H */
  217.