home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / AutoPC / apcsdk10.exe / data1.cab / Emulation_Include_Files / objbase.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-13  |  29.4 KB  |  873 lines

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. //  File:       objbase.h
  7. //
  8. //  Contents:   Component object model defintions.
  9. //
  10. //----------------------------------------------------------------------------
  11.  
  12. #include <rpc.h>
  13. #include <rpcndr.h>
  14.  
  15. #if !defined( _OBJBASE_H_ )
  16. #define _OBJBASE_H_
  17.  
  18. #include <pshpack8.h>
  19.  
  20.  
  21. #ifdef UNDER_CE
  22.  
  23. #define COM_NO_WINDOWS_H
  24.  
  25. // Some definitions so we can include the real wtypes.h from nt
  26.  
  27. typedef void __RPC_FAR * RPC_IF_HANDLE;
  28. #define __RPC_FAR
  29. //#define __RPC_USER
  30. typedef void __RPC_FAR * RPC_IF_HANDLE;
  31. #define PRPC_MESSAGE int
  32. #define hyper _int64
  33. #define MIDL_uhyper unsigned _int64
  34. #ifndef _FILETIME_
  35. #define _FILETIME_
  36. #endif
  37. #ifndef _SYSTEMTIME_
  38. #define _SYSTEMTIME_
  39. #endif
  40. #define UUID GUID
  41. #define _SECURITY_ATTRIBUTES_
  42. typedef void  * RPC_AUTH_IDENTITY_HANDLE;
  43. typedef void  * RPC_AUTHZ_HANDLE;
  44.  
  45. #endif // UNDER_CE
  46.  
  47.  
  48. #ifdef _MAC
  49. #ifndef _WLM_NOFORCE_LIBS
  50.  
  51. #ifdef _WLMDLL
  52.         #ifdef _DEBUG
  53.                 #pragma comment(lib, "oledlgd.lib")
  54.                 #pragma comment(lib, "msvcoled.lib")
  55.         #else
  56.                 #pragma comment(lib, "oledlg.lib")
  57.                 #pragma comment(lib, "msvcole.lib")
  58.         #endif
  59. #else
  60.         #ifdef _DEBUG
  61.                 #pragma comment(lib, "wlmoled.lib")
  62.                 #pragma comment(lib, "ole2uid.lib")
  63.         #else
  64.                 #pragma comment(lib, "wlmole.lib")
  65.                 #pragma comment(lib, "ole2ui.lib")
  66.         #endif
  67.         #pragma data_seg(".drectve")
  68.         static char _gszWlmOLEUIResourceDirective[] = "/macres:ole2ui.rsc";
  69.         #pragma data_seg()
  70. #endif
  71.  
  72. #pragma comment(lib, "uuid.lib")
  73.  
  74. #ifdef _DEBUG
  75.     #pragma comment(lib, "ole2d.lib")
  76.     #pragma comment(lib, "ole2autd.lib")
  77. #else
  78.     #pragma comment(lib, "ole2.lib")
  79.     #pragma comment(lib, "ole2auto.lib")
  80. #endif
  81.  
  82. #endif // !_WLM_NOFORCE_LIBS
  83. #endif // _MAC
  84.  
  85. // Component Object Model defines, and macros
  86.  
  87. #ifdef __cplusplus
  88.     #define EXTERN_C    extern "C"
  89. #else
  90.     #define EXTERN_C    extern
  91. #endif
  92.  
  93. #if defined(_WIN32) || defined(_MPPC_)
  94.  
  95. // Win32 doesn't support __export
  96.  
  97. #ifdef _68K_
  98. #define STDMETHODCALLTYPE       __cdecl
  99. #else
  100. #define STDMETHODCALLTYPE       __stdcall
  101. #endif
  102. #define STDMETHODVCALLTYPE      __cdecl
  103.  
  104. #define STDAPICALLTYPE          __stdcall
  105. #define STDAPIVCALLTYPE         __cdecl
  106.  
  107. #else
  108.  
  109. #define STDMETHODCALLTYPE       __export __stdcall
  110. #define STDMETHODVCALLTYPE      __export __cdecl
  111.  
  112. #define STDAPICALLTYPE          __export __stdcall
  113. #define STDAPIVCALLTYPE         __export __cdecl
  114.  
  115. #endif
  116.  
  117.  
  118. #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
  119. #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
  120.  
  121. #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
  122. #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
  123.  
  124. // The 'V' versions allow Variable Argument lists.
  125.  
  126. #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
  127. #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
  128.  
  129. #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
  130. #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
  131.  
  132. #ifdef _OLE32_
  133. #define WINOLEAPI        STDAPI
  134. #define WINOLEAPI_(type) STDAPI_(type)
  135. #else
  136.  
  137. #ifdef _68K_
  138. #ifndef REQUIRESAPPLEPASCAL
  139. #define WINOLEAPI        EXTERN_C DECLSPEC_IMPORT HRESULT PASCAL
  140. #define WINOLEAPI_(type) EXTERN_C DECLSPEC_IMPORT type PASCAL
  141. #else
  142. #define WINOLEAPI        EXTERN_C DECLSPEC_IMPORT PASCAL HRESULT
  143. #define WINOLEAPI_(type) EXTERN_C DECLSPEC_IMPORT PASCAL type
  144. #endif
  145. #else
  146. #define WINOLEAPI        EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE
  147. #define WINOLEAPI_(type) EXTERN_C DECLSPEC_IMPORT type STDAPICALLTYPE
  148. #endif
  149.  
  150. #endif
  151.  
  152. /****** Interface Declaration ***********************************************/
  153.  
  154. /*
  155.  *      These are macros for declaring interfaces.  They exist so that
  156.  *      a single definition of the interface is simulataneously a proper
  157.  *      declaration of the interface structures (C++ abstract classes)
  158.  *      for both C and C++.
  159.  *
  160.  *      DECLARE_INTERFACE(iface) is used to declare an interface that does
  161.  *      not derive from a base interface.
  162.  *      DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
  163.  *      that does derive from a base interface.
  164.  *
  165.  *      By default if the source file has a .c extension the C version of
  166.  *      the interface declaratations will be expanded; if it has a .cpp
  167.  *      extension the C++ version will be expanded. if you want to force
  168.  *      the C version expansion even though the source file has a .cpp
  169.  *      extension, then define the macro "CINTERFACE".
  170.  *      eg.     cl -DCINTERFACE file.cpp
  171.  *
  172.  *      Example Interface declaration:
  173.  *
  174.  *          #undef  INTERFACE
  175.  *          #define INTERFACE   IClassFactory
  176.  *
  177.  *          DECLARE_INTERFACE_(IClassFactory, IUnknown)
  178.  *          {
  179.  *              // *** IUnknown methods ***
  180.  *              STDMETHOD(QueryInterface) (THIS_
  181.  *                                        REFIID riid,
  182.  *                                        LPVOID FAR* ppvObj) PURE;
  183.  *              STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  184.  *              STDMETHOD_(ULONG,Release) (THIS) PURE;
  185.  *
  186.  *              // *** IClassFactory methods ***
  187.  *              STDMETHOD(CreateInstance) (THIS_
  188.  *                                        LPUNKNOWN pUnkOuter,
  189.  *                                        REFIID riid,
  190.  *                                        LPVOID FAR* ppvObject) PURE;
  191.  *          };
  192.  *
  193.  *      Example C++ expansion:
  194.  *
  195.  *          struct FAR IClassFactory : public IUnknown
  196.  *          {
  197.  *              virtual HRESULT STDMETHODCALLTYPE QueryInterface(
  198.  *                                                  IID FAR& riid,
  199.  *                                                  LPVOID FAR* ppvObj) = 0;
  200.  *              virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0;
  201.  *              virtual HRESULT STDMETHODCALLTYPE Release(void) = 0;
  202.  *              virtual HRESULT STDMETHODCALLTYPE CreateInstance(
  203.  *                                              LPUNKNOWN pUnkOuter,
  204.  *                                              IID FAR& riid,
  205.  *                                              LPVOID FAR* ppvObject) = 0;
  206.  *          };
  207.  *
  208.  *          NOTE: Our documentation says '#define interface class' but we use
  209.  *          'struct' instead of 'class' to keep a lot of 'public:' lines
  210.  *          out of the interfaces.  The 'FAR' forces the 'this' pointers to
  211.  *          be far, which is what we need.
  212.  *
  213.  *      Example C expansion:
  214.  *
  215.  *          typedef struct IClassFactory
  216.  *          {
  217.  *              const struct IClassFactoryVtbl FAR* lpVtbl;
  218.  *          } IClassFactory;
  219.  *
  220.  *          typedef struct IClassFactoryVtbl IClassFactoryVtbl;
  221.  *
  222.  *          struct IClassFactoryVtbl
  223.  *          {
  224.  *              HRESULT (STDMETHODCALLTYPE * QueryInterface) (
  225.  *                                                  IClassFactory FAR* This,
  226.  *                                                  IID FAR* riid,
  227.  *                                                  LPVOID FAR* ppvObj) ;
  228.  *              HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
  229.  *              HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
  230.  *              HRESULT (STDMETHODCALLTYPE * CreateInstance) (
  231.  *                                                  IClassFactory FAR* This,
  232.  *                                                  LPUNKNOWN pUnkOuter,
  233.  *                                                  IID FAR* riid,
  234.  *                                                  LPVOID FAR* ppvObject);
  235.  *              HRESULT (STDMETHODCALLTYPE * LockServer) (
  236.  *                                                  IClassFactory FAR* This,
  237.  *                                                  BOOL fLock);
  238.  *          };
  239.  */
  240.  
  241. #if defined(__cplusplus) && !defined(CINTERFACE)
  242. //#define interface               struct FAR
  243. #define interface struct
  244. #define STDMETHOD(method)       virtual HRESULT STDMETHODCALLTYPE method
  245. #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
  246. #define PURE                    = 0
  247. #define THIS_
  248. #define THIS                    void
  249. #define DECLARE_INTERFACE(iface)    interface iface
  250. #define DECLARE_INTERFACE_(iface, baseiface)    interface iface : public baseiface
  251.  
  252.  
  253. #if !defined(BEGIN_INTERFACE)
  254. #if defined(_MPPC_)  && \
  255.     ( (defined(_MSC_VER) || defined(__SC__) || defined(__MWERKS__)) && \
  256.     !defined(NO_NULL_VTABLE_ENTRY) )
  257.    #define BEGIN_INTERFACE virtual void a() {}
  258.    #define END_INTERFACE
  259. #else
  260.    #define BEGIN_INTERFACE
  261.    #define END_INTERFACE
  262. #endif
  263. #endif
  264.  
  265. #else
  266.  
  267. #define interface               struct
  268.  
  269. #define STDMETHOD(method)       HRESULT (STDMETHODCALLTYPE * method)
  270. #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
  271.  
  272. #if !defined(BEGIN_INTERFACE)
  273. #if defined(_MPPC_)
  274.     #define BEGIN_INTERFACE       void    *b;
  275.     #define END_INTERFACE
  276. #else
  277.     #define BEGIN_INTERFACE
  278.     #define END_INTERFACE
  279. #endif
  280. #endif
  281.  
  282.  
  283. #define PURE
  284. #define THIS_                   INTERFACE FAR* This,
  285. #define THIS                    INTERFACE FAR* This
  286. #ifdef CONST_VTABLE
  287. #undef CONST_VTBL
  288. #define CONST_VTBL const
  289. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  290.                                     const struct iface##Vtbl FAR* lpVtbl; \
  291.                                 } iface; \
  292.                                 typedef const struct iface##Vtbl iface##Vtbl; \
  293.                                 const struct iface##Vtbl
  294. #else
  295. #undef CONST_VTBL
  296. #define CONST_VTBL
  297. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  298.                                     struct iface##Vtbl FAR* lpVtbl; \
  299.                                 } iface; \
  300.                                 typedef struct iface##Vtbl iface##Vtbl; \
  301.                                 struct iface##Vtbl
  302. #endif
  303. #define DECLARE_INTERFACE_(iface, baseiface)    DECLARE_INTERFACE(iface)
  304.  
  305. #endif
  306.  
  307.  
  308.  
  309.  
  310. /****** Additional basic types **********************************************/
  311.  
  312.  
  313. #ifndef FARSTRUCT
  314. #ifdef __cplusplus
  315. #define FARSTRUCT   FAR
  316. #else
  317. #define FARSTRUCT
  318. #endif  // __cplusplus
  319. #endif  // FARSTRUCT
  320.  
  321.  
  322.  
  323. #ifndef HUGEP
  324. #if defined(_WIN32) || defined(_MPPC_)
  325. #define HUGEP
  326. #else
  327. #define HUGEP __huge
  328. #endif // WIN32
  329. #endif // HUGEP
  330.  
  331.  
  332. #ifdef _MAC
  333. #if !defined(OLE2ANSI)
  334. #define OLE2ANSI
  335. #endif
  336. #endif
  337.  
  338. #include <stdlib.h>
  339.  
  340. #define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v))
  341.  
  342. #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. #define CLSCTX_INPROC           (CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER)
  350.  
  351. // With DCOM, CLSCTX_REMOTE_SERVER should be included
  352. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  353. #define CLSCTX_ALL              (CLSCTX_INPROC_SERVER| \
  354.                                  CLSCTX_INPROC_HANDLER| \
  355.                                  CLSCTX_LOCAL_SERVER| \
  356.                                  CLSCTX_REMOTE_SERVER)
  357.  
  358. #define CLSCTX_SERVER           (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER)
  359. #else
  360. #define CLSCTX_ALL              (CLSCTX_INPROC_SERVER| \
  361.                                  CLSCTX_INPROC_HANDLER| \
  362.                                  CLSCTX_LOCAL_SERVER )
  363.  
  364. #define CLSCTX_SERVER           (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER)
  365. #endif
  366.  
  367.  
  368. // class registration flags; passed to CoRegisterClassObject
  369. typedef enum tagREGCLS
  370. {
  371.     REGCLS_SINGLEUSE = 0,       // class object only generates one instance
  372.     REGCLS_MULTIPLEUSE = 1,     // same class object genereates multiple inst.
  373.                                 // and local automatically goes into inproc tbl.
  374.     REGCLS_MULTI_SEPARATE = 2,  // multiple use, but separate control over each
  375.                                 // context.
  376.     REGCLS_SUSPENDED      = 4   // register is as suspended, will be activated
  377.                                 // when app calls CoResumeClassObjects
  378. } REGCLS;
  379.  
  380. // interface marshaling definitions
  381. #define MARSHALINTERFACE_MIN 500 // minimum number of bytes for interface marshl
  382.  
  383.  
  384. //
  385. // Common typedefs for paramaters used in Storage API's, gleamed from storage.h
  386. // Also contains Storage error codes, which should be moved into the storage
  387. // idl files.
  388. //
  389.  
  390.  
  391. #define CWCSTORAGENAME 32
  392.  
  393. /* Storage instantiation modes */
  394. #define STGM_DIRECT             0x00000000L
  395. #define STGM_TRANSACTED         0x00010000L
  396. #define STGM_SIMPLE             0x08000000L
  397.  
  398. #define STGM_READ               0x00000000L
  399. #define STGM_WRITE              0x00000001L
  400. #define STGM_READWRITE          0x00000002L
  401.  
  402. #define STGM_SHARE_DENY_NONE    0x00000040L
  403. #define STGM_SHARE_DENY_READ    0x00000030L
  404. #define STGM_SHARE_DENY_WRITE   0x00000020L
  405. #define STGM_SHARE_EXCLUSIVE    0x00000010L
  406.  
  407. #define STGM_PRIORITY           0x00040000L
  408. #define STGM_DELETEONRELEASE    0x04000000L
  409. #if (WINVER >= 400)
  410. #define STGM_NOSCRATCH          0x00100000L
  411. #endif /* WINVER */
  412.  
  413. #define STGM_CREATE             0x00001000L
  414. #define STGM_CONVERT            0x00020000L
  415. #define STGM_FAILIFTHERE        0x00000000L
  416.  
  417. #define STGM_NOSNAPSHOT         0x00200000L
  418.  
  419. /*  flags for internet asyncronous and layout docfile */
  420. #define ASYNC_MODE_COMPATIBILITY    0x00000001L
  421. #define ASYNC_MODE_DEFAULT          0x00000000L
  422.  
  423. #define STGTY_REPEAT                0x00000100L
  424. #define STG_TOEND                   0xFFFFFFFFL
  425.  
  426. #define STG_LAYOUT_SEQUENTIAL       0x00000000L
  427. #define STG_LAYOUT_INTERLEAVED      0x00000001L
  428.  
  429.  
  430.  
  431.  
  432. /* here is where we pull in the MIDL generated headers for the interfaces */
  433. typedef interface    IRpcStubBuffer     IRpcStubBuffer;
  434. typedef interface    IRpcChannelBuffer  IRpcChannelBuffer;
  435.  
  436. #include <wtypes.h>
  437. #include <unknwn.h>
  438. #include <objidl.h>
  439.  
  440.  
  441. // macros to define byte pattern for a GUID.
  442. //      Example: DEFINE_GUID(GUID_XXX, a, b, c, ...);
  443. //
  444. // Each dll/exe must initialize the GUIDs once.  This is done in one of
  445. // two ways.  If you are not using precompiled headers for the file(s) which
  446. // initializes the GUIDs, define INITGUID before including objbase.h.  This
  447. // is how OLE builds the initialized versions of the GUIDs which are included
  448. // in ole2.lib.  The GUIDs in ole2.lib are all defined in the same text
  449. // segment GUID_TEXT.
  450. //
  451. // The alternative (which some versions of the compiler don't handle properly;
  452. // they wind up with the initialized GUIDs in a data, not a text segment),
  453. // is to use a precompiled version of objbase.h and then include initguid.h
  454. // after objbase.h followed by one or more of the guid defintion files.
  455.  
  456. #ifndef INITGUID
  457. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  458.     EXTERN_C const GUID FAR name
  459. #else
  460.  
  461. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  462.         EXTERN_C const GUID name \
  463.                 = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
  464. #endif // INITGUID
  465.  
  466. #define DEFINE_OLEGUID(name, l, w1, w2) \
  467.     DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  468.  
  469. #ifdef _OLE32_
  470.  
  471.  
  472. // Faster (but makes code fatter) inline version...use sparingly
  473. #ifdef __cplusplus
  474. inline BOOL  InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  475. {
  476.    return (
  477.       ((PLONG) &rguid1)[0] == ((PLONG) &rguid2)[0] &&
  478.       ((PLONG) &rguid1)[1] == ((PLONG) &rguid2)[1] &&
  479.       ((PLONG) &rguid1)[2] == ((PLONG) &rguid2)[2] &&
  480.       ((PLONG) &rguid1)[3] == ((PLONG) &rguid2)[3]);
  481. }
  482. #else   // ! __cplusplus
  483. #define InlineIsEqualGUID(rguid1, rguid2)  \
  484.         (((PLONG) rguid1)[0] == ((PLONG) rguid2)[0] &&   \
  485.         ((PLONG) rguid1)[1] == ((PLONG) rguid2)[1] &&    \
  486.         ((PLONG) rguid1)[2] == ((PLONG) rguid2)[2] &&    \
  487.         ((PLONG) rguid1)[3] == ((PLONG) rguid2)[3])
  488. #endif  // __cplusplus
  489.  
  490. #ifdef _OLE32PRIV_
  491. BOOL _fastcall wIsEqualGUID(REFGUID rguid1, REFGUID rguid2);
  492. #define IsEqualGUID(rguid1, rguid2) wIsEqualGUID(rguid1, rguid2)
  493. #else
  494. #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
  495. #endif  // _OLE32PRIV_
  496.  
  497. #else   // ! _OLE32_
  498. #ifdef __cplusplus
  499. inline BOOL IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  500. {
  501.     return !memcmp(&rguid1, &rguid2, sizeof(GUID));
  502. }
  503. #else   //  ! __cplusplus
  504. #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
  505. #endif  //  __cplusplus
  506. #endif  //  _OLE32_
  507.  
  508. #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
  509. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
  510.  
  511. #ifdef __cplusplus
  512.  
  513. // because GUID is defined elsewhere in WIN32 land, the operator == and !=
  514. // are moved outside the class to global scope.
  515.  
  516. #ifdef _OLE32_
  517. inline BOOL operator==(const GUID& guidOne, const GUID& guidOther)
  518. {
  519.     return IsEqualGUID(guidOne,guidOther);
  520. }
  521. #else   // !_OLE32_
  522. inline BOOL operator==(const GUID& guidOne, const GUID& guidOther)
  523. {
  524. #ifdef _WIN32
  525.     return !memcmp(&guidOne,&guidOther,sizeof(GUID));
  526. #else
  527.     return !_fmemcmp(&guidOne,&guidOther,sizeof(GUID)); }
  528. #endif
  529. }
  530. #endif // _OLE32_
  531.  
  532. inline BOOL operator!=(const GUID& guidOne, const GUID& guidOther)
  533. {
  534.     return !(guidOne == guidOther);
  535. }
  536.  
  537. #endif // __cpluscplus
  538.  
  539.  
  540. #ifndef INITGUID
  541. #include <cguid.h>
  542. #endif
  543.  
  544. // COM initialization flags; passed to CoInitialize.
  545. typedef enum tagCOINIT
  546. {
  547.   COINIT_APARTMENTTHREADED  = 0x2,      // Apartment model
  548.   COINIT_MULTITHREADED      = 0x0,      // OLE calls objects on any thread.
  549.  
  550. #if  (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  551.   // These constants are only valid on Windows NT 4.0
  552.   COINIT_DISABLE_OLE1DDE    = 0x4,      // Don't use DDE for Ole1 support.
  553.   COINIT_SPEED_OVER_MEMORY  = 0x8,      // Trade memory for speed.
  554. #endif // DCOM
  555. } COINIT;
  556.  
  557.  
  558.  
  559.  
  560.  
  561. /****** STD Object API Prototypes *****************************************/
  562.  
  563. WINOLEAPI_(DWORD) CoBuildVersion( VOID );
  564.  
  565. /* init/uninit */
  566.  
  567. WINOLEAPI  CoInitialize(LPVOID pvReserved);
  568. WINOLEAPI_(void)  CoUninitialize(void);
  569. WINOLEAPI  CoGetMalloc(DWORD dwMemContext, LPMALLOC FAR* ppMalloc);
  570. WINOLEAPI_(DWORD) CoGetCurrentProcess(void);
  571. WINOLEAPI  CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy);
  572. WINOLEAPI  CoRevokeMallocSpy(void);
  573. WINOLEAPI  CoCreateStandardMalloc(DWORD memctx, IMalloc FAR* FAR* ppMalloc);
  574.  
  575. WINOLEAPI  CoInitializeEx(LPVOID pvReserved, DWORD dwCoInit);
  576.  
  577. #if DBG == 1
  578. WINOLEAPI_(ULONG) DebugCoGetRpcFault( void );
  579. WINOLEAPI_(void) DebugCoSetRpcFault( ULONG );
  580. #endif
  581.  
  582. /* register/revoke/get class objects */
  583.  
  584. WINOLEAPI  CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved,
  585.                     REFIID riid, LPVOID FAR* ppv);
  586. WINOLEAPI  CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk,
  587.                     DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister);
  588. WINOLEAPI  CoRevokeClassObject(DWORD dwRegister);
  589. WINOLEAPI  CoResumeClassObjects(void);
  590. WINOLEAPI  CoSuspendClassObjects(void);
  591. WINOLEAPI_(ULONG) CoAddRefServerProcess(void);
  592. WINOLEAPI_(ULONG) CoReleaseServerProcess(void);
  593. WINOLEAPI  CoGetPSClsid(REFIID riid, CLSID *pClsid);
  594. WINOLEAPI  CoRegisterPSClsid(REFIID riid, REFCLSID rclsid);
  595.  
  596. /* marshaling interface pointers */
  597.  
  598. WINOLEAPI CoGetMarshalSizeMax(ULONG *pulSize, REFIID riid, LPUNKNOWN pUnk,
  599.                     DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags);
  600. WINOLEAPI CoMarshalInterface(LPSTREAM pStm, REFIID riid, LPUNKNOWN pUnk,
  601.                     DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags);
  602. WINOLEAPI CoUnmarshalInterface(LPSTREAM pStm, REFIID riid, LPVOID FAR* ppv);
  603. WINOLEAPI CoMarshalHresult(LPSTREAM pstm, HRESULT hresult);
  604. WINOLEAPI CoUnmarshalHresult(LPSTREAM pstm, HRESULT FAR * phresult);
  605. WINOLEAPI CoReleaseMarshalData(LPSTREAM pStm);
  606. WINOLEAPI CoDisconnectObject(LPUNKNOWN pUnk, DWORD dwReserved);
  607. WINOLEAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases);
  608. WINOLEAPI CoGetStandardMarshal(REFIID riid, LPUNKNOWN pUnk,
  609.                     DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags,
  610.                     LPMARSHAL FAR* ppMarshal);
  611.  
  612. WINOLEAPI_(BOOL) CoIsHandlerConnected(LPUNKNOWN pUnk);
  613. WINOLEAPI_(BOOL) CoHasStrongExternalConnections(LPUNKNOWN pUnk);
  614.  
  615. // Apartment model inter-thread interface passing helpers
  616. WINOLEAPI CoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk,
  617.                     LPSTREAM *ppStm);
  618.  
  619. WINOLEAPI CoGetInterfaceAndReleaseStream(LPSTREAM pStm, REFIID iid,
  620.                     LPVOID FAR* ppv);
  621.  
  622. WINOLEAPI CoCreateFreeThreadedMarshaler(LPUNKNOWN  punkOuter,
  623.                     LPUNKNOWN *ppunkMarshal);
  624.  
  625. /* dll loading helpers; keeps track of ref counts and unloads all on exit */
  626.  
  627. WINOLEAPI_(HINSTANCE) CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree);
  628. WINOLEAPI_(void) CoFreeLibrary(HINSTANCE hInst);
  629. WINOLEAPI_(void) CoFreeAllLibraries(void);
  630. WINOLEAPI_(void) CoFreeUnusedLibraries(void);
  631.  
  632.  
  633. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  634.  
  635. /* Call Security. */
  636.  
  637. WINOLEAPI CoInitializeSecurity(
  638.                     PSECURITY_DESCRIPTOR         pSecDesc,
  639.                     LONG                         cAuthSvc,
  640.                     SOLE_AUTHENTICATION_SERVICE *asAuthSvc,
  641.                     void                        *pReserved1,
  642.                     DWORD                        dwAuthnLevel,
  643.                     DWORD                        dwImpLevel,
  644.                     void                        *pReserved2,
  645.                     DWORD                        dwCapabilities,
  646.                     void                        *pReserved3 );
  647. WINOLEAPI CoGetCallContext( REFIID riid, void **ppInterface );
  648. WINOLEAPI CoQueryProxyBlanket(
  649.     IUnknown                  *pProxy,
  650.     DWORD                     *pwAuthnSvc,
  651.     DWORD                     *pAuthzSvc,
  652.     OLECHAR                  **pServerPrincName,
  653.     DWORD                     *pAuthnLevel,
  654.     DWORD                     *pImpLevel,
  655.     RPC_AUTH_IDENTITY_HANDLE  *pAuthInfo,
  656.     DWORD                     *pCapabilites );
  657. WINOLEAPI CoSetProxyBlanket(
  658.     IUnknown                 *pProxy,
  659.     DWORD                     dwAuthnSvc,
  660.     DWORD                     dwAuthzSvc,
  661.     OLECHAR                  *pServerPrincName,
  662.     DWORD                     dwAuthnLevel,
  663.     DWORD                     dwImpLevel,
  664.     RPC_AUTH_IDENTITY_HANDLE  pAuthInfo,
  665.     DWORD                     dwCapabilities );
  666. WINOLEAPI CoCopyProxy(
  667.     IUnknown    *pProxy,
  668.     IUnknown   **ppCopy );
  669. WINOLEAPI CoQueryClientBlanket(
  670.     DWORD             *pAuthnSvc,
  671.     DWORD             *pAuthzSvc,
  672.     OLECHAR          **pServerPrincName,
  673.     DWORD             *pAuthnLevel,
  674.     DWORD             *pImpLevel,
  675.     RPC_AUTHZ_HANDLE  *pPrivs,
  676.     DWORD             *pCapabilities );
  677. WINOLEAPI CoImpersonateClient();
  678. WINOLEAPI CoRevertToSelf();
  679. WINOLEAPI CoQueryAuthenticationServices(
  680.     DWORD *pcAuthSvc,
  681.     SOLE_AUTHENTICATION_SERVICE **asAuthSvc );
  682. WINOLEAPI CoSwitchCallContext( IUnknown *pNewObject, IUnknown **ppOldObject );
  683.  
  684. #define COM_RIGHTS_EXECUTE 1
  685.  
  686. #endif // DCOM
  687.  
  688. /* helper for creating instances */
  689.  
  690. WINOLEAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
  691.                     DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv);
  692.  
  693.  
  694. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  695.  
  696. WINOLEAPI CoGetInstanceFromFile(
  697.     COSERVERINFO *              pServerInfo,
  698.     CLSID       *               pClsid,
  699.     IUnknown    *               punkOuter, // only relevant locally
  700.     DWORD                       dwClsCtx,
  701.     DWORD                       grfMode,
  702.     OLECHAR *                   pwszName,
  703.     DWORD                       dwCount,
  704.     MULTI_QI        *           pResults );
  705.  
  706. WINOLEAPI CoGetInstanceFromIStorage(
  707.     COSERVERINFO *              pServerInfo,
  708.     CLSID       *               pClsid,
  709.     IUnknown    *               punkOuter, // only relevant locally
  710.     DWORD                       dwClsCtx,
  711.     struct IStorage *           pstg,
  712.     DWORD                       dwCount,
  713.     MULTI_QI        *           pResults );
  714.  
  715. WINOLEAPI CoCreateInstanceEx(
  716.     REFCLSID                    Clsid,
  717.     IUnknown    *               punkOuter, // only relevant locally
  718.     DWORD                       dwClsCtx,
  719.     COSERVERINFO *              pServerInfo,
  720.     DWORD                       dwCount,
  721.     MULTI_QI        *           pResults );
  722.  
  723. #endif // DCOM
  724.  
  725.  
  726. /* other helpers */
  727.  
  728. WINOLEAPI StringFromCLSID(REFCLSID rclsid, LPOLESTR FAR* lplpsz);
  729. WINOLEAPI CLSIDFromString(LPOLESTR lpsz, LPCLSID pclsid);
  730. WINOLEAPI StringFromIID(REFIID rclsid, LPOLESTR FAR* lplpsz);
  731. WINOLEAPI IIDFromString(LPOLESTR lpsz, LPIID lpiid);
  732. WINOLEAPI_(BOOL) CoIsOle1Class(REFCLSID rclsid);
  733. WINOLEAPI ProgIDFromCLSID (REFCLSID clsid, LPOLESTR FAR* lplpszProgID);
  734. WINOLEAPI CLSIDFromProgID (LPCOLESTR lpszProgID, LPCLSID lpclsid);
  735. WINOLEAPI_(int) StringFromGUID2(REFGUID rguid, LPOLESTR lpsz, int cbMax);
  736.  
  737. WINOLEAPI CoCreateGuid(GUID FAR *pguid);
  738.  
  739. WINOLEAPI_(BOOL) CoFileTimeToDosDateTime(
  740.                  FILETIME FAR* lpFileTime, LPWORD lpDosDate, LPWORD lpDosTime);
  741. WINOLEAPI_(BOOL) CoDosDateTimeToFileTime(
  742.                        WORD nDosDate, WORD nDosTime, FILETIME FAR* lpFileTime);
  743. WINOLEAPI  CoFileTimeNow( FILETIME FAR* lpFileTime );
  744.  
  745.  
  746. WINOLEAPI CoRegisterMessageFilter( LPMESSAGEFILTER lpMessageFilter,
  747.                                 LPMESSAGEFILTER FAR* lplpMessageFilter );
  748.  
  749. #if (_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM) // DCOM
  750. WINOLEAPI CoRegisterChannelHook( REFGUID ExtensionUuid, IChannelHook *pChannelHook );
  751. #endif // DCOM
  752.  
  753.  
  754. /* TreatAs APIS */
  755.  
  756. WINOLEAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID pClsidNew);
  757. WINOLEAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew);
  758.  
  759.  
  760. /* the server dlls must define their DllGetClassObject and DllCanUnloadNow
  761.  * to match these; the typedefs are located here to ensure all are changed at
  762.  * the same time.
  763.  */
  764.  
  765. //#ifdef _MAC
  766. //typedef STDAPICALLTYPE HRESULT (* LPFNGETCLASSOBJECT) (REFCLSID, REFIID, LPVOID *);
  767. //#else
  768. typedef HRESULT (STDAPICALLTYPE * LPFNGETCLASSOBJECT) (REFCLSID, REFIID, LPVOID *);
  769. //#endif
  770.  
  771. //#ifdef _MAC
  772. //typedef STDAPICALLTYPE HRESULT (* LPFNCANUNLOADNOW)(void);
  773. //#else
  774. typedef HRESULT (STDAPICALLTYPE * LPFNCANUNLOADNOW)(void);
  775. //#endif
  776.  
  777. STDAPI  DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppv);
  778.  
  779. STDAPI  DllCanUnloadNow(void);
  780.  
  781.  
  782. /****** Default Memory Allocation ******************************************/
  783. WINOLEAPI_(LPVOID) CoTaskMemAlloc(ULONG cb);
  784. WINOLEAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, ULONG cb);
  785. WINOLEAPI_(void)   CoTaskMemFree(LPVOID pv);
  786.  
  787. /****** DV APIs ***********************************************************/
  788.  
  789.  
  790. WINOLEAPI CreateDataAdviseHolder(LPDATAADVISEHOLDER FAR* ppDAHolder);
  791.  
  792. WINOLEAPI CreateDataCache(LPUNKNOWN pUnkOuter, REFCLSID rclsid,
  793.                                         REFIID iid, LPVOID FAR* ppv);
  794.  
  795.  
  796.  
  797.  
  798. /****** Storage API Prototypes ********************************************/
  799.  
  800.  
  801. WINOLEAPI StgCreateDocfile(const OLECHAR FAR* pwcsName,
  802.             DWORD grfMode,
  803.             DWORD reserved,
  804.             IStorage FAR * FAR *ppstgOpen);
  805.  
  806. WINOLEAPI StgOpenStorage(const OLECHAR FAR* pwcsName,
  807.               IStorage FAR *pstgPriority,
  808.               DWORD grfMode,
  809.               SNB snbExclude,
  810.               DWORD reserved,
  811.               IStorage FAR * FAR *ppstgOpen);
  812.  
  813. WINOLEAPI StgIsStorageFile(const OLECHAR FAR* pwcsName);
  814. WINOLEAPI StgIsStorageILockBytes(ILockBytes FAR* plkbyt);
  815.  
  816. WINOLEAPI StgSetTimes(OLECHAR const FAR* lpszName,
  817.                    FILETIME const FAR* pctime,
  818.                    FILETIME const FAR* patime,
  819.                    FILETIME const FAR* pmtime);
  820.  
  821. WINOLEAPI StgOpenAsyncDocfileOnIFillLockBytes( IFillLockBytes *pflb,
  822.              DWORD grfMode,
  823.              DWORD asyncFlags,
  824.              IStorage **ppstgOpen);
  825.  
  826. WINOLEAPI StgGetIFillLockBytesOnILockBytes( ILockBytes *pilb,
  827.              IFillLockBytes **ppflb);
  828.  
  829. WINOLEAPI StgGetIFillLockBytesOnFile(OLECHAR const *pwcsName,
  830.              IFillLockBytes **ppflb);
  831.  
  832.  
  833. WINOLEAPI StgOpenLayoutDocfile(OLECHAR const *pwcsDfName,
  834.              DWORD grfMode,
  835.              DWORD reserved,
  836.              IStorage **ppstgOpen);
  837.  
  838.  
  839.  
  840. //
  841. //  Moniker APIs
  842. //
  843.  
  844. WINOLEAPI  BindMoniker(LPMONIKER pmk, DWORD grfOpt, REFIID iidResult, LPVOID FAR* ppvResult);
  845. WINOLEAPI  CoGetObject(LPCWSTR pszName, BIND_OPTS *pBindOptions, REFIID riid, void **ppv);
  846. WINOLEAPI  MkParseDisplayName(LPBC pbc, LPCOLESTR szUserName,
  847.                 ULONG FAR * pchEaten, LPMONIKER FAR * ppmk);
  848. WINOLEAPI  MonikerRelativePathTo(LPMONIKER pmkSrc, LPMONIKER pmkDest, LPMONIKER
  849.                 FAR* ppmkRelPath, BOOL dwReserved);
  850. WINOLEAPI  MonikerCommonPrefixWith(LPMONIKER pmkThis, LPMONIKER pmkOther,
  851.                 LPMONIKER FAR* ppmkCommon);
  852. WINOLEAPI  CreateBindCtx(DWORD reserved, LPBC FAR* ppbc);
  853. WINOLEAPI  CreateGenericComposite(LPMONIKER pmkFirst, LPMONIKER pmkRest,
  854.     LPMONIKER FAR* ppmkComposite);
  855. WINOLEAPI  GetClassFile (LPCOLESTR szFilename, CLSID FAR* pclsid);
  856.  
  857. WINOLEAPI  CreateClassMoniker(REFCLSID rclsid, LPMONIKER FAR* ppmk);
  858.  
  859. WINOLEAPI  CreateFileMoniker(LPCOLESTR lpszPathName, LPMONIKER FAR* ppmk);
  860.  
  861. WINOLEAPI  CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem,
  862.     LPMONIKER FAR* ppmk);
  863. WINOLEAPI  CreateAntiMoniker(LPMONIKER FAR* ppmk);
  864. WINOLEAPI  CreatePointerMoniker(LPUNKNOWN punk, LPMONIKER FAR* ppmk);
  865.  
  866. WINOLEAPI  GetRunningObjectTable( DWORD reserved, LPRUNNINGOBJECTTABLE FAR* pprot);
  867.  
  868. #ifndef RC_INVOKED
  869. #include <poppack.h>
  870. #endif // RC_INVOKED
  871.  
  872. #endif     // __OBJBASE_H__
  873.