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.

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