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.

975 lines
32 KiB

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