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