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.

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