Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1025 lines
33 KiB

  1. /*****************************************************************************\
  2. * *
  3. * compobj.h - Component object model definitions *
  4. * *
  5. * OLE Version 2.0 *
  6. * *
  7. * Copyright (c) 1992-1993, Microsoft Corp. All rights reserved. *
  8. * *
  9. \*****************************************************************************/
  10. #if !defined( _COMPOBJ_H_ )
  11. #define _COMPOBJ_H_
  12. /****** Linkage Definitions *************************************************/
  13. /*
  14. * These are macros for declaring methods/functions. They exist so that
  15. * control over the use of keywords (CDECL, PASCAL, __export,
  16. * extern "C") resides in one place, and because this is the least
  17. * intrusive way of writing function declarations that do not have
  18. * to be modified in order to port to the Mac.
  19. *
  20. * The macros without the trailing underscore are for functions/methods
  21. * which a return value of type HRESULT; this is by far the most common
  22. * case in OLE. The macros with a trailing underscore take a return
  23. * type as a parameter.
  24. *
  25. * WARNING: STDAPI is hard coded into the LPFNGETCLASSOBJECT typedef below.
  26. */
  27. #ifdef __cplusplus
  28. #define EXTERN_C extern "C"
  29. #else
  30. #define EXTERN_C extern
  31. #endif
  32. #ifdef _MAC
  33. #define STDMETHODCALLTYPE
  34. #define STDAPICALLTYPE pascal
  35. #define STDAPI EXTERN_C STDAPICALLTYPE HRESULT
  36. #define STDAPI_(type) EXTERN_C STDAPICALLTYPE type
  37. #else // !_MAC
  38. #ifdef WIN32
  39. #define STDMETHODCALLTYPE __export __cdecl
  40. #define STDAPICALLTYPE __export __stdcall
  41. #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
  42. #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
  43. #else
  44. #define STDMETHODCALLTYPE __export FAR CDECL
  45. #define STDAPICALLTYPE __export FAR PASCAL
  46. #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
  47. #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
  48. #endif
  49. #endif //!_MAC
  50. #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
  51. #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
  52. /****** Interface Declaration ***********************************************/
  53. /*
  54. * These are macros for declaring interfaces. They exist so that
  55. * a single definition of the interface is simulataneously a proper
  56. * declaration of the interface structures (C++ abstract classes)
  57. * for both C and C++.
  58. *
  59. * DECLARE_INTERFACE(iface) is used to declare an interface that does
  60. * not derive from a base interface.
  61. * DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
  62. * that does derive from a base interface.
  63. *
  64. * By default if the source file has a .c extension the C version of
  65. * the interface declaratations will be expanded; if it has a .cpp
  66. * extension the C++ version will be expanded. if you want to force
  67. * the C version expansion even though the source file has a .cpp
  68. * extension, then define the macro "CINTERFACE".
  69. * eg. cl -DCINTERFACE file.cpp
  70. *
  71. * Example Interface declaration:
  72. *
  73. * #undef INTERFACE
  74. * #define INTERFACE IClassFactory
  75. *
  76. * DECLARE_INTERFACE_(IClassFactory, IUnknown)
  77. * {
  78. * // *** IUnknown methods ***
  79. * STDMETHOD(QueryInterface) (THIS_
  80. * REFIID riid,
  81. * LPVOID FAR* ppvObj) PURE;
  82. * STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  83. * STDMETHOD_(ULONG,Release) (THIS) PURE;
  84. *
  85. * // *** IClassFactory methods ***
  86. * STDMETHOD(CreateInstance) (THIS_
  87. * LPUNKNOWN pUnkOuter,
  88. * REFIID riid,
  89. * LPVOID FAR* ppvObject) PURE;
  90. * };
  91. *
  92. * Example C++ expansion:
  93. *
  94. * struct FAR IClassFactory : public IUnknown
  95. * {
  96. * virtual HRESULT STDMETHODCALLTYPE QueryInterface(
  97. * IID FAR& riid,
  98. * LPVOID FAR* ppvObj) = 0;
  99. * virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0;
  100. * virtual HRESULT STDMETHODCALLTYPE Release(void) = 0;
  101. * virtual HRESULT STDMETHODCALLTYPE CreateInstance(
  102. * LPUNKNOWN pUnkOuter,
  103. * IID FAR& riid,
  104. * LPVOID FAR* ppvObject) = 0;
  105. * };
  106. *
  107. * NOTE: Our documentation says '#define interface class' but we use
  108. * 'struct' instead of 'class' to keep a lot of 'public:' lines
  109. * out of the interfaces. The 'FAR' forces the 'this' pointers to
  110. * be far, which is what we need.
  111. *
  112. * Example C expansion:
  113. *
  114. * typedef struct IClassFactory
  115. * {
  116. * const struct IClassFactoryVtbl FAR* lpVtbl;
  117. * } IClassFactory;
  118. *
  119. * typedef struct IClassFactoryVtbl IClassFactoryVtbl;
  120. *
  121. * struct IClassFactoryVtbl
  122. * {
  123. * HRESULT (STDMETHODCALLTYPE * QueryInterface) (
  124. * IClassFactory FAR* This,
  125. * IID FAR* riid,
  126. * LPVOID FAR* ppvObj) ;
  127. * HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
  128. * HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
  129. * HRESULT (STDMETHODCALLTYPE * CreateInstance) (
  130. * IClassFactory FAR* This,
  131. * LPUNKNOWN pUnkOuter,
  132. * IID FAR* riid,
  133. * LPVOID FAR* ppvObject);
  134. * HRESULT (STDMETHODCALLTYPE * LockServer) (
  135. * IClassFactory FAR* This,
  136. * BOOL fLock);
  137. * };
  138. */
  139. #if defined(__cplusplus) && !defined(CINTERFACE)
  140. #ifdef __TURBOC__
  141. #define interface struct huge
  142. #else
  143. #define interface struct FAR
  144. #endif
  145. #define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method
  146. #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
  147. #define PURE = 0
  148. #define THIS_
  149. #define THIS void
  150. #define DECLARE_INTERFACE(iface) interface iface
  151. #define DECLARE_INTERFACE_(iface, baseiface) interface iface : public baseiface
  152. #else
  153. #define interface struct
  154. #ifdef _MAC
  155. #define STDMETHOD(method) long method##pad;\
  156. HRESULT (STDMETHODCALLTYPE * method)
  157. #define STDMETHOD_(type,method) long method##pad;\
  158. type (STDMETHODCALLTYPE * method)
  159. #else // _MAC
  160. #define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE * method)
  161. #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
  162. #endif // !_MAC
  163. #define PURE
  164. #define THIS_ INTERFACE FAR* This,
  165. #define THIS INTERFACE FAR* This
  166. #ifdef CONST_VTABLE
  167. #define DECLARE_INTERFACE(iface) typedef interface iface { \
  168. const struct iface##Vtbl FAR* lpVtbl; \
  169. } iface; \
  170. typedef const struct iface##Vtbl iface##Vtbl; \
  171. const struct iface##Vtbl
  172. #else
  173. #define DECLARE_INTERFACE(iface) typedef interface iface { \
  174. struct iface##Vtbl FAR* lpVtbl; \
  175. } iface; \
  176. typedef struct iface##Vtbl iface##Vtbl; \
  177. struct iface##Vtbl
  178. #endif
  179. #define DECLARE_INTERFACE_(iface, baseiface) DECLARE_INTERFACE(iface)
  180. #endif
  181. #if defined(TUNING)
  182. #define LOCAL static
  183. #else
  184. #define LOCAL static
  185. #endif
  186. /****** Additional basic types **********************************************/
  187. #ifndef FARSTRUCT
  188. #ifdef __cplusplus
  189. #define FARSTRUCT FAR
  190. #else
  191. #define FARSTRUCT
  192. #endif // __cplusplus
  193. #endif // FARSTRUCT
  194. #ifndef WINAPI /* If not included with 3.1 headers... */
  195. #ifdef WIN32
  196. #define FAR
  197. #define PASCAL __stdcall
  198. #define CDECL
  199. #else
  200. #define FAR _far
  201. #define PASCAL _pascal
  202. #define CDECL _cdecl
  203. #endif
  204. #define VOID void
  205. #define WINAPI FAR PASCAL
  206. #define CALLBACK FAR PASCAL
  207. #ifndef FALSE
  208. #define FALSE 0
  209. #define TRUE 1
  210. #endif
  211. typedef int BOOL;
  212. typedef unsigned char BYTE;
  213. typedef unsigned short WORD;
  214. typedef unsigned int UINT;
  215. typedef long LONG;
  216. typedef unsigned long DWORD;
  217. typedef UINT WPARAM;
  218. typedef LONG LPARAM;
  219. typedef LONG LRESULT;
  220. typedef unsigned int HANDLE;
  221. #define DECLARE_HANDLE(name) typedef UINT name
  222. DECLARE_HANDLE(HMODULE);
  223. DECLARE_HANDLE(HINSTANCE);
  224. DECLARE_HANDLE(HLOCAL);
  225. DECLARE_HANDLE(HGLOBAL);
  226. DECLARE_HANDLE(HDC);
  227. DECLARE_HANDLE(HRGN);
  228. DECLARE_HANDLE(HWND);
  229. DECLARE_HANDLE(HMENU);
  230. DECLARE_HANDLE(HACCEL);
  231. DECLARE_HANDLE(HTASK);
  232. #ifndef NULL
  233. #define NULL 0
  234. #endif
  235. typedef void FAR * LPVOID;
  236. typedef WORD FAR * LPWORD;
  237. typedef DWORD FAR * LPDWORD;
  238. typedef char FAR* LPSTR;
  239. typedef const char FAR* LPCSTR;
  240. typedef void FAR* LPLOGPALETTE;
  241. typedef void FAR* LPMSG;
  242. //typedef struct tagMSG FAR *LPMSG;
  243. typedef HANDLE FAR *LPHANDLE;
  244. typedef struct tagRECT FAR *LPRECT;
  245. typedef struct FARSTRUCT tagSIZE
  246. {
  247. int cx;
  248. int cy;
  249. } SIZE;
  250. typedef SIZE* PSIZE;
  251. #endif /* WINAPI */
  252. typedef short SHORT;
  253. typedef unsigned short USHORT;
  254. typedef DWORD ULONG;
  255. #ifndef HUGEP
  256. #ifdef WIN32
  257. #define HUGEP
  258. #else
  259. #define HUGEP __huge
  260. #endif // WIN32
  261. #endif // HUGEP
  262. typedef WORD WCHAR;
  263. #ifndef WIN32
  264. typedef struct FARSTRUCT _LARGE_INTEGER {
  265. DWORD LowPart;
  266. LONG HighPart;
  267. } LARGE_INTEGER, *PLARGE_INTEGER;
  268. #endif
  269. #define LISet32(li, v) ((li).HighPart = ((LONG)(v)) < 0 ? -1 : 0, (li).LowPart = (v))
  270. #ifndef WIN32
  271. typedef struct FARSTRUCT _ULARGE_INTEGER {
  272. DWORD LowPart;
  273. DWORD HighPart;
  274. } ULARGE_INTEGER, *PULARGE_INTEGER;
  275. #endif
  276. #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
  277. #ifndef _WINDOWS_
  278. #ifndef _FILETIME_
  279. #define _FILETIME_
  280. typedef struct FARSTRUCT tagFILETIME
  281. {
  282. DWORD dwLowDateTime;
  283. DWORD dwHighDateTime;
  284. } FILETIME;
  285. #endif
  286. #endif
  287. #ifdef WIN32
  288. #define HTASK DWORD
  289. #endif
  290. #include "scode.h"
  291. // *********************** Compobj errors **********************************
  292. #define CO_E_NOTINITIALIZED (CO_E_FIRST + 0x0)
  293. // CoInitialize has not been called and must be
  294. #define CO_E_ALREADYINITIALIZED (CO_E_FIRST + 0x1)
  295. // CoInitialize has already been called and cannot be called again (temporary)
  296. #define CO_E_CANTDETERMINECLASS (CO_E_FIRST + 0x2)
  297. // can't determine clsid (e.g., extension not in reg.dat)
  298. #define CO_E_CLASSSTRING (CO_E_FIRST + 0x3)
  299. // the string form of the clsid is invalid (including ole1 classes)
  300. #define CO_E_IIDSTRING (CO_E_FIRST + 0x4)
  301. // the string form of the iid is invalid
  302. #define CO_E_APPNOTFOUND (CO_E_FIRST + 0x5)
  303. // application not found
  304. #define CO_E_APPSINGLEUSE (CO_E_FIRST + 0x6)
  305. // application cannot be run more than once
  306. #define CO_E_ERRORINAPP (CO_E_FIRST + 0x7)
  307. // some error in the app program file
  308. #define CO_E_DLLNOTFOUND (CO_E_FIRST + 0x8)
  309. // dll not found
  310. #define CO_E_ERRORINDLL (CO_E_FIRST + 0x9)
  311. // some error in the dll file
  312. #define CO_E_WRONGOSFORAPP (CO_E_FIRST + 0xa)
  313. // app written for other version of OS or other OS altogether
  314. #define CO_E_OBJNOTREG (CO_E_FIRST + 0xb)
  315. // object is not registered
  316. #define CO_E_OBJISREG (CO_E_FIRST + 0xc)
  317. // object is already registered
  318. #define CO_E_OBJNOTCONNECTED (CO_E_FIRST + 0xd)
  319. // handler is not connected to server
  320. #define CO_E_APPDIDNTREG (CO_E_FIRST + 0xe)
  321. // app was launched, but didn't registered a class factory
  322. // ********************* ClassObject errors ********************************
  323. #define CLASS_E_NOAGGREGATION (CLASSFACTORY_E_FIRST + 0x0)
  324. // class does not support aggregation (or class object is remote)
  325. // *********************** Reg.dat errors **********************************
  326. #define REGDB_E_READREGDB (REGDB_E_FIRST + 0x0)
  327. // some error reading the registration database
  328. #define REGDB_E_WRITEREGDB (REGDB_E_FIRST + 0x1)
  329. // some error reading the registration database
  330. #define REGDB_E_KEYMISSING (REGDB_E_FIRST + 0x2)
  331. // some error reading the registration database
  332. #define REGDB_E_INVALIDVALUE (REGDB_E_FIRST + 0x3)
  333. // some error reading the registration database
  334. #define REGDB_E_CLASSNOTREG (REGDB_E_FIRST + 0x4)
  335. // some error reading the registration database
  336. #define REGDB_E_IIDNOTREG (REGDB_E_FIRST + 0x5)
  337. // some error reading the registration database
  338. // *************************** RPC errors **********************************
  339. #define RPC_E_FIRST MAKE_SCODE(SEVERITY_ERROR, FACILITY_RPC, 0x000)
  340. // call was rejected by callee, either by MF::HandleIncomingCall or
  341. #define RPC_E_CALL_REJECTED (RPC_E_FIRST + 0x1)
  342. // call was canceld by call - returned by MessagePending
  343. // this code only occurs if MessagePending return cancel
  344. #define RPC_E_CALL_CANCELED (RPC_E_FIRST + 0x2)
  345. // the caller is dispatching an intertask SendMessage call and
  346. // can NOT call out via PostMessage
  347. #define RPC_E_CANTPOST_INSENDCALL (RPC_E_FIRST + 0x3)
  348. // the caller is dispatching an asynchronus call can NOT
  349. // make an outgoing call on behalf of this call
  350. #define RPC_E_CANTCALLOUT_INASYNCCALL (RPC_E_FIRST + 0x4)
  351. // the caller is not in a state where an outgoing call can be made
  352. // this is the case if the caller has an outstandig call and
  353. // another incoming call was excepted by HIC; now the caller is
  354. // not allowed to call out again
  355. #define RPC_E_CANTCALLOUT_INEXTERNALCALL (RPC_E_FIRST + 0x5)
  356. // the connection terminated or is in a bogus state
  357. // and can not be used any more. Other connections
  358. // are still valid.
  359. #define RPC_E_CONNECTION_TERMINATED (RPC_E_FIRST + 0x6)
  360. // the callee (server [not server application]) is not available
  361. // and disappeared; all connections are invalid
  362. #define RPC_E_SERVER_DIED (RPC_E_FIRST + 0x7)
  363. // the caller (client ) disappeared while the callee (server) was
  364. // processing a call
  365. #define RPC_E_CLIENT_DIED (RPC_E_FIRST + 0x8)
  366. // the date paket with the marshalled parameter data is
  367. // incorrect
  368. #define RPC_E_INVALID_DATAPACKET (RPC_E_FIRST + 0x9)
  369. // the call was not transmitted properly; the message queue
  370. // was full and was not emptied after yielding
  371. #define RPC_E_CANTTRANSMIT_CALL (RPC_E_FIRST + 0xa)
  372. // the client (caller) can not marshall the parameter data
  373. // or unmarshall the return data - low memory etc.
  374. #define RPC_E_CLIENT_CANTMARSHAL_DATA (RPC_E_FIRST + 0xb)
  375. #define RPC_E_CLIENT_CANTUNMARSHAL_DATA (RPC_E_FIRST + 0xc)
  376. // the server (caller) can not unmarshall the parameter data
  377. // or marshall the return data - low memory
  378. #define RPC_E_SERVER_CANTMARSHAL_DATA (RPC_E_FIRST + 0xd)
  379. #define RPC_E_SERVER_CANTUNMARSHAL_DATA (RPC_E_FIRST + 0xe)
  380. // received data are invalid; can be server or
  381. // client data
  382. #define RPC_E_INVALID_DATA (RPC_E_FIRST + 0xf)
  383. // a particular parameter is invalid and can not be un/marshalled
  384. #define RPC_E_INVALID_PARAMETER (RPC_E_FIRST + 0x10)
  385. // a internal error occured
  386. #define RPC_E_UNEXPECTED (RPC_E_FIRST + 0xFFFF)
  387. /****** Globally Unique Ids *************************************************/
  388. #ifdef __cplusplus
  389. struct FAR GUID
  390. {
  391. DWORD Data1;
  392. WORD Data2;
  393. WORD Data3;
  394. BYTE Data4[8];
  395. BOOL operator==(const GUID& iidOther) const
  396. #ifdef WIN32
  397. { return !memcmp(&Data1,&iidOther.Data1,sizeof(GUID)); }
  398. #else
  399. { return !_fmemcmp(&Data1,&iidOther.Data1,sizeof(GUID)); }
  400. #endif
  401. BOOL operator!=(const GUID& iidOther) const
  402. { return !((*this) == iidOther); }
  403. };
  404. #else
  405. typedef struct GUID
  406. {
  407. DWORD Data1;
  408. WORD Data2;
  409. WORD Data3;
  410. BYTE Data4[8];
  411. } GUID;
  412. #endif
  413. typedef GUID FAR* LPGUID;
  414. // macros to define byte pattern for a GUID.
  415. // Example: DEFINE_GUID(GUID_XXX, a, b, c, ...);
  416. //
  417. // Each dll/exe must initialize the GUIDs once. This is done in one of
  418. // two ways. If you are not using precompiled headers for the file(s) which
  419. // initializes the GUIDs, define INITGUID before including compobj.h. This
  420. // is how OLE builds the initialized versions of the GUIDs which are included
  421. // in ole2.lib. The GUIDs in ole2.lib are all defined in the same text
  422. // segment GUID_TEXT.
  423. //
  424. // The alternative (which some versions of the compiler don't handle properly;
  425. // they wind up with the initialized GUIDs in a data, not a text segment),
  426. // is to use a precompiled version of compobj.h and then include initguid.h
  427. // after compobj.h followed by one or more of the guid defintion files.
  428. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  429. EXTERN_C const GUID CDECL FAR name
  430. #ifdef INITGUID
  431. #include "initguid.h"
  432. #endif
  433. #define DEFINE_OLEGUID(name, l, w1, w2) \
  434. DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  435. // Interface ID are just a kind of GUID
  436. typedef GUID IID;
  437. typedef IID FAR* LPIID;
  438. #define IID_NULL GUID_NULL
  439. #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
  440. // Class ID are just a kind of GUID
  441. typedef GUID CLSID;
  442. typedef CLSID FAR* LPCLSID;
  443. #define CLSID_NULL GUID_NULL
  444. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
  445. #if defined(__cplusplus)
  446. #define REFGUID const GUID FAR&
  447. #define REFIID const IID FAR&
  448. #define REFCLSID const CLSID FAR&
  449. #else
  450. #define REFGUID const GUID FAR* const
  451. #define REFIID const IID FAR* const
  452. #define REFCLSID const CLSID FAR* const
  453. #endif
  454. #ifndef INITGUID
  455. #include "coguid.h"
  456. #endif
  457. /****** Other value types ***************************************************/
  458. // memory context values; passed to CoGetMalloc
  459. typedef enum tagMEMCTX
  460. {
  461. MEMCTX_TASK = 1, // task (private) memory
  462. MEMCTX_SHARED = 2, // shared memory (between processes)
  463. #ifdef _MAC
  464. MEMCTX_MACSYSTEM = 3, // on the mac, the system heap
  465. #endif
  466. // these are mostly for internal use...
  467. MEMCTX_UNKNOWN = -1, // unknown context (when asked about it)
  468. MEMCTX_SAME = -2, // same context (as some other pointer)
  469. } MEMCTX;
  470. // class context: used to determine what scope and kind of class object to use
  471. // NOTE: this is a bitwise enum
  472. typedef enum tagCLSCTX
  473. {
  474. CLSCTX_INPROC_SERVER = 1, // server dll (runs in same process as caller)
  475. CLSCTX_INPROC_HANDLER = 2, // handler dll (runs in same process as caller)
  476. CLSCTX_LOCAL_SERVER = 4 // server exe (runs on same machine; diff proc)
  477. } CLSCTX;
  478. #define CLSCTX_ALL (CLSCTX_INPROC_SERVER| \
  479. CLSCTX_INPROC_HANDLER| \
  480. CLSCTX_LOCAL_SERVER)
  481. #define CLSCTX_INPROC (CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER)
  482. #define CLSCTX_SERVER (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER)
  483. // class registration flags; passed to CoRegisterClassObject
  484. typedef enum tagREGCLS
  485. {
  486. REGCLS_SINGLEUSE = 0, // class object only generates one instance
  487. REGCLS_MULTIPLEUSE = 1, // same class object genereates multiple inst.
  488. // and local automatically goes into inproc tbl.
  489. REGCLS_MULTI_SEPARATE = 2, // multiple use, but separate control over each
  490. // context.
  491. // NOTE: CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE is the same as
  492. // (CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER), REGCLS_MULTI_SEPARATE, but
  493. // not the same as CLSCTX_LOCAL_SERVER, REGCLS_MULTI_SEPARATE.
  494. } REGCLS;
  495. // interface marshaling definitions
  496. #define MARSHALINTERFACE_MIN 40 // minimum number of bytes for interface marshl
  497. // marshaling flags; passed to CoMarshalInterface
  498. typedef enum tagMSHLFLAGS
  499. {
  500. MSHLFLAGS_NORMAL = 0, // normal marshaling via proxy/stub
  501. MSHLFLAGS_TABLESTRONG = 1, // keep object alive; must explicitly release
  502. MSHLFLAGS_TABLEWEAK = 2 // doesn't hold object alive; still must release
  503. } MSHLFLAGS;
  504. // marshal context: determines the destination context of the marshal operation
  505. typedef enum tagMSHCTX
  506. {
  507. MSHCTX_LOCAL = 0, // unmarshal context is local (eg.shared memory)
  508. MSHCTX_NOSHAREDMEM = 1, // unmarshal context has no shared memory access
  509. } MSHCTX;
  510. // call type used by IMessageFilter::HandleIncommingMessage
  511. typedef enum tagCALLTYPE
  512. {
  513. CALLTYPE_TOPLEVEL = 1, // toplevel call - no outgoing call
  514. CALLTYPE_NESTED = 2, // callback on behalf of previous outgoing call - should always handle
  515. CALLTYPE_ASYNC = 3, // aysnchronous call - can NOT be rejected
  516. CALLTYPE_TOPLEVEL_CALLPENDING = 4, // new toplevel call with new LID
  517. CALLTYPE_ASYNC_CALLPENDING = 5 // async call - can NOT be rejected
  518. } CALLTYPE;
  519. typedef struct tagINTERFACEINFO
  520. {
  521. interface IUnknown FAR *pUnk; // the pointer to the object
  522. IID iid; // interface id
  523. WORD wMethod; // interface methode
  524. } INTERFACEINFO, FAR * LPINTERFACEINFO;
  525. // status of server call - returned by IMessageFilter::HandleIncommingCall
  526. // and passed to IMessageFilter::RetryRejectedCall
  527. typedef enum tagSERVERCALL
  528. {
  529. SERVERCALL_ISHANDLED = 0,
  530. SERVERCALL_REJECTED = 1,
  531. SERVERCALL_RETRYLATER = 2
  532. } SERVERCALL;
  533. // Pending type indicates the level of nesting
  534. typedef enum tagPENDINGTYPE
  535. {
  536. PENDINGTYPE_TOPLEVEL = 1, // toplevel call
  537. PENDINGTYPE_NESTED = 2, // nested call
  538. } PENDINGTYPE;
  539. // return values of MessagePending
  540. typedef enum tagPENDINGMSG
  541. {
  542. PENDINGMSG_CANCELCALL = 0, // cancel the outgoing call
  543. PENDINGMSG_WAITNOPROCESS = 1, // wait for the return and don't dispatch the message
  544. PENDINGMSG_WAITDEFPROCESS = 2 // wait and dispatch the message
  545. } PENDINGMSG;
  546. /****** IUnknown Interface **************************************************/
  547. #undef INTERFACE
  548. #define INTERFACE IUnknown
  549. DECLARE_INTERFACE(IUnknown)
  550. {
  551. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  552. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  553. STDMETHOD_(ULONG,Release) (THIS) PURE;
  554. };
  555. typedef IUnknown FAR* LPUNKNOWN;
  556. /****** Class Factory Interface *******************************************/
  557. #undef INTERFACE
  558. #define INTERFACE IClassFactory
  559. DECLARE_INTERFACE_(IClassFactory, IUnknown)
  560. {
  561. // *** IUnknown methods ***
  562. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  563. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  564. STDMETHOD_(ULONG,Release) (THIS) PURE;
  565. // *** IClassFactory methods ***
  566. STDMETHOD(CreateInstance) (THIS_ LPUNKNOWN pUnkOuter,
  567. REFIID riid,
  568. LPVOID FAR* ppvObject) PURE;
  569. STDMETHOD(LockServer) (THIS_ BOOL fLock) PURE;
  570. };
  571. typedef IClassFactory FAR* LPCLASSFACTORY;
  572. /****** Memory Allocation Interface ***************************************/
  573. #undef INTERFACE
  574. #define INTERFACE IMalloc
  575. DECLARE_INTERFACE_(IMalloc, IUnknown)
  576. {
  577. // *** IUnknown methods ***
  578. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  579. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  580. STDMETHOD_(ULONG,Release) (THIS) PURE;
  581. // *** IMalloc methods ***
  582. STDMETHOD_(void FAR*, Alloc) (THIS_ ULONG cb) PURE;
  583. STDMETHOD_(void FAR*, Realloc) (THIS_ void FAR* pv, ULONG cb) PURE;
  584. STDMETHOD_(void, Free) (THIS_ void FAR* pv) PURE;
  585. STDMETHOD_(ULONG, GetSize) (THIS_ void FAR* pv) PURE;
  586. STDMETHOD_(int, DidAlloc) (THIS_ void FAR* pv) PURE;
  587. STDMETHOD_(void, HeapMinimize) (THIS) PURE;
  588. };
  589. typedef IMalloc FAR* LPMALLOC;
  590. /****** IMarshal Interface ************************************************/
  591. // forward declaration for IStream; must include storage.h later to use
  592. #ifdef __cplusplus
  593. interface IStream;
  594. #else
  595. typedef interface IStream IStream;
  596. #endif
  597. typedef IStream FAR* LPSTREAM;
  598. #undef INTERFACE
  599. #define INTERFACE IMarshal
  600. DECLARE_INTERFACE_(IMarshal, IUnknown)
  601. {
  602. // *** IUnknown methods ***
  603. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  604. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  605. STDMETHOD_(ULONG,Release) (THIS) PURE;
  606. // *** IMarshal methods ***
  607. STDMETHOD(GetUnmarshalClass)(THIS_ REFIID riid, LPVOID pv,
  608. DWORD dwDestContext, LPVOID pvDestContext,
  609. DWORD mshlflags, LPCLSID pCid) PURE;
  610. STDMETHOD(GetMarshalSizeMax)(THIS_ REFIID riid, LPVOID pv,
  611. DWORD dwDestContext, LPVOID pvDestContext,
  612. DWORD mshlflags, LPDWORD pSize) PURE;
  613. STDMETHOD(MarshalInterface)(THIS_ LPSTREAM pStm, REFIID riid,
  614. LPVOID pv, DWORD dwDestContext, LPVOID pvDestContext,
  615. DWORD mshlflags) PURE;
  616. STDMETHOD(UnmarshalInterface)(THIS_ LPSTREAM pStm, REFIID riid,
  617. LPVOID FAR* ppv) PURE;
  618. STDMETHOD(ReleaseMarshalData)(THIS_ LPSTREAM pStm) PURE;
  619. STDMETHOD(DisconnectObject)(THIS_ DWORD dwReserved) PURE;
  620. };
  621. typedef IMarshal FAR* LPMARSHAL;
  622. #undef INTERFACE
  623. #define INTERFACE IStdMarshalInfo
  624. DECLARE_INTERFACE_(IStdMarshalInfo, IUnknown)
  625. {
  626. // *** IUnknown methods ***
  627. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  628. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  629. STDMETHOD_(ULONG,Release) (THIS) PURE;
  630. // *** IStdMarshalInfo methods ***
  631. STDMETHOD(GetClassForHandler)(THIS_ DWORD dwDestContext,
  632. LPVOID pvDestContext, LPCLSID pClsid) PURE;
  633. };
  634. typedef IStdMarshalInfo FAR* LPSTDMARSHALINFO;
  635. /****** Message Filter Interface *******************************************/
  636. #undef INTERFACE
  637. #define INTERFACE IMessageFilter
  638. DECLARE_INTERFACE_(IMessageFilter, IUnknown)
  639. {
  640. // *** IUnknown methods ***
  641. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  642. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  643. STDMETHOD_(ULONG,Release) (THIS) PURE;
  644. // *** IMessageFilter methods ***
  645. STDMETHOD_(DWORD, HandleInComingCall) (THIS_ DWORD dwCallType,
  646. HTASK htaskCaller, DWORD dwTickCount,
  647. DWORD dwReserved ) PURE;
  648. STDMETHOD_(DWORD, RetryRejectedCall) (THIS_
  649. HTASK htaskCallee, DWORD dwTickCount,
  650. DWORD dwRejectType ) PURE;
  651. STDMETHOD_(DWORD, MessagePending) (THIS_
  652. HTASK htaskCallee, DWORD dwTickCount,
  653. DWORD dwPendingType ) PURE;
  654. };
  655. typedef IMessageFilter FAR* LPMESSAGEFILTER;
  656. /****** External Connection Information ***********************************/
  657. #undef INTERFACE
  658. #define INTERFACE IExternalConnection
  659. DECLARE_INTERFACE_(IExternalConnection, IUnknown)
  660. {
  661. // *** IUnknown methods ***
  662. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  663. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  664. STDMETHOD_(ULONG,Release) (THIS) PURE;
  665. // *** IExternalConnection methods ***
  666. STDMETHOD_(DWORD, AddConnection) (THIS_ DWORD reserved) PURE;
  667. STDMETHOD_(DWORD, ReleaseConnection) (THIS_ DWORD reserved, BOOL fLastReleaseCloses) PURE;
  668. };
  669. typedef IExternalConnection FAR* LPEXTERNALCONNECTION;
  670. /****** Enumerator Interfaces *********************************************/
  671. /*
  672. * Since we don't use parametrized types, we put in explicit declarations
  673. * of the enumerators we need.
  674. */
  675. #undef INTERFACE
  676. #define INTERFACE IEnumString
  677. DECLARE_INTERFACE_(IEnumString, IUnknown)
  678. {
  679. // *** IUnknown methods ***
  680. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  681. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  682. STDMETHOD_(ULONG,Release) (THIS) PURE;
  683. // *** IEnumString methods ***
  684. STDMETHOD(Next) (THIS_ ULONG celt,
  685. LPSTR FAR* rgelt,
  686. ULONG FAR* pceltFetched) PURE;
  687. STDMETHOD(Skip) (THIS_ ULONG celt) PURE;
  688. STDMETHOD(Reset) (THIS) PURE;
  689. STDMETHOD(Clone) (THIS_ IEnumString FAR* FAR* ppenm) PURE;
  690. };
  691. typedef IEnumString FAR* LPENUMSTRING;
  692. #undef INTERFACE
  693. #define INTERFACE IEnumUnknown
  694. DECLARE_INTERFACE_(IEnumUnknown, IUnknown)
  695. {
  696. // *** IUnknown methods ***
  697. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  698. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  699. STDMETHOD_(ULONG,Release) (THIS) PURE;
  700. // *** IEnumUnknown methods ***
  701. STDMETHOD(Next) (THIS_ ULONG celt, LPUNKNOWN FAR* rgelt, ULONG FAR* pceltFetched) PURE;
  702. STDMETHOD(Skip) (THIS_ ULONG celt) PURE;
  703. STDMETHOD(Reset) (THIS) PURE;
  704. STDMETHOD(Clone) (THIS_ IEnumUnknown FAR* FAR* ppenm) PURE;
  705. };
  706. typedef IEnumUnknown FAR* LPENUMUNKNOWN;
  707. /****** STD Object API Prototypes *****************************************/
  708. STDAPI_(DWORD) CoBuildVersion( VOID );
  709. /* init/uninit */
  710. STDAPI CoInitialize(LPMALLOC pMalloc);
  711. STDAPI_(void) CoUninitialize(void);
  712. STDAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC FAR* ppMalloc);
  713. STDAPI_(DWORD) CoGetCurrentProcess(void);
  714. STDAPI CoCreateStandardMalloc(DWORD memctx, IMalloc FAR* FAR* ppMalloc);
  715. /* register/revoke/get class objects */
  716. STDAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved,
  717. REFIID riid, LPVOID FAR* ppv);
  718. STDAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk,
  719. DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister);
  720. STDAPI CoRevokeClassObject(DWORD dwRegister);
  721. /* marshaling interface pointers */
  722. STDAPI CoMarshalInterface(LPSTREAM pStm, REFIID riid, LPUNKNOWN pUnk,
  723. DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags);
  724. STDAPI CoUnmarshalInterface(LPSTREAM pStm, REFIID riid, LPVOID FAR* ppv);
  725. STDAPI CoMarshalHresult(LPSTREAM pstm, HRESULT hresult);
  726. STDAPI CoUnmarshalHresult(LPSTREAM pstm, HRESULT FAR * phresult);
  727. STDAPI CoReleaseMarshalData(LPSTREAM pStm);
  728. STDAPI CoDisconnectObject(LPUNKNOWN pUnk, DWORD dwReserved);
  729. STDAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases);
  730. STDAPI CoGetStandardMarshal(REFIID riid, LPUNKNOWN pUnk,
  731. DWORD dwDestContext, LPVOID pvDestContext, DWORD mshlflags,
  732. LPMARSHAL FAR* ppMarshal);
  733. /* dll loading helpers; keeps track of ref counts and unloads all on exit */
  734. STDAPI_(HINSTANCE) CoLoadLibrary(LPSTR lpszLibName, BOOL bAutoFree);
  735. STDAPI_(void) CoFreeLibrary(HINSTANCE hInst);
  736. STDAPI_(void) CoFreeAllLibraries(void);
  737. STDAPI_(void) CoFreeUnusedLibraries(void);
  738. /* helper for creating instances */
  739. STDAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
  740. DWORD dwClsContext, REFIID riid, LPVOID FAR* ppv);
  741. /* other helpers */
  742. STDAPI_(BOOL) IsEqualGUID(REFGUID rguid1, REFGUID rguid2);
  743. STDAPI StringFromCLSID(REFCLSID rclsid, LPSTR FAR* lplpsz);
  744. STDAPI CLSIDFromString(LPSTR lpsz, LPCLSID pclsid);
  745. STDAPI StringFromIID(REFIID rclsid, LPSTR FAR* lplpsz);
  746. STDAPI IIDFromString(LPSTR lpsz, LPIID lpiid);
  747. STDAPI_(BOOL) CoIsOle1Class(REFCLSID rclsid);
  748. STDAPI ProgIDFromCLSID (REFCLSID clsid, LPSTR FAR* lplpszProgID);
  749. STDAPI CLSIDFromProgID (LPCSTR lpszProgID, LPCLSID lpclsid);
  750. STDAPI_(int) StringFromGUID2(REFGUID rguid, LPSTR lpsz, int cbMax);
  751. STDAPI CoCreateGuid(GUID FAR *pguid);
  752. STDAPI_(BOOL) CoFileTimeToDosDateTime(
  753. FILETIME FAR* lpFileTime, LPWORD lpDosDate, LPWORD lpDosTime);
  754. STDAPI_(BOOL) CoDosDateTimeToFileTime(
  755. WORD nDosDate, WORD nDosTime, FILETIME FAR* lpFileTime);
  756. STDAPI CoFileTimeNow( FILETIME FAR* lpFileTime );
  757. STDAPI CoRegisterMessageFilter( LPMESSAGEFILTER lpMessageFilter,
  758. LPMESSAGEFILTER FAR* lplpMessageFilter );
  759. /* TreatAs APIS */
  760. STDAPI CoGetTreatAsClass(REFCLSID clsidOld, LPCLSID pClsidNew);
  761. STDAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew);
  762. /* the server dlls must define their DllGetClassObject and DllCanUnloadNow
  763. * to match these; the typedefs are located here to ensure all are changed at
  764. * the same time.
  765. */
  766. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppv);
  767. #ifdef _MAC
  768. typedef STDAPICALLTYPE HRESULT (FAR* LPFNGETCLASSOBJECT) (REFCLSID, REFIID, LPVOID FAR*);
  769. #else
  770. typedef HRESULT (STDAPICALLTYPE FAR* LPFNGETCLASSOBJECT) (REFCLSID, REFIID, LPVOID FAR*);
  771. #endif
  772. STDAPI DllCanUnloadNow(void);
  773. #ifdef _MAC
  774. typedef STDAPICALLTYPE HRESULT (FAR* LPFNCANUNLOADNOW)(void);
  775. #else
  776. typedef HRESULT (STDAPICALLTYPE FAR* LPFNCANUNLOADNOW)(void);
  777. #endif
  778. /****** Debugging Helpers *************************************************/
  779. #ifdef _DEBUG
  780. // writes to the debug port and displays a message box
  781. STDAPI FnAssert(LPSTR lpstrExpr, LPSTR lpstrMsg, LPSTR lpstrFileName, UINT iLine);
  782. #endif // _DEBUG
  783. #endif // _COMPOBJ_H_