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