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

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