zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
comdecl.h
Go to the documentation of this file.
1 // comdecl.h: Macros to facilitate COM interface and GUID declarations.
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 
4 #ifndef _COMDECL_H_
5 #define _COMDECL_H_
6 
7 #ifndef _XBOX
8  #include <basetyps.h> // For standard COM interface macros
9 #else
10  #pragma warning(push)
11  #pragma warning(disable:4061)
12  #include <xtl.h> // Required by xobjbase.h
13  #include <xobjbase.h> // Special definitions for Xbox build
14  #pragma warning(pop)
15 #endif
16 
17 // The DEFINE_CLSID() and DEFINE_IID() macros defined below allow COM GUIDs to
18 // be declared and defined in such a way that clients can obtain the GUIDs using
19 // either the __uuidof() extension or the old-style CLSID_Foo / IID_IFoo names.
20 // If using the latter approach, the client can also choose whether to get the
21 // GUID definitions by defining the INITGUID preprocessor constant or by linking
22 // to a GUID library. This works in either C or C++.
23 
24 #ifdef __cplusplus
25 
26  #define DECLSPEC_UUID_WRAPPER(x) __declspec(uuid(#x))
27  #ifdef INITGUID
28 
29  #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
30  class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \
31  EXTERN_C const GUID DECLSPEC_SELECTANY CLSID_##className = __uuidof(className)
32 
33  #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
34  interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \
35  EXTERN_C const GUID DECLSPEC_SELECTANY IID_##interfaceName = __uuidof(interfaceName)
36 
37  #else // INITGUID
38 
39  #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
40  class DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) className; \
41  EXTERN_C const GUID CLSID_##className
42 
43  #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
44  interface DECLSPEC_UUID_WRAPPER(l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8) interfaceName; \
45  EXTERN_C const GUID IID_##interfaceName
46 
47  #endif // INITGUID
48 
49 #else // __cplusplus
50 
51  #define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
52  DEFINE_GUID(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
53 
54  #define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
55  DEFINE_GUID(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
56 
57 #endif // __cplusplus
58 
59 #endif // #ifndef _COMDECL_H_