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

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