Leaked source code of windows server 2003
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.

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