Advertisement
Dyc9

Untitled

Jun 15th, 2016
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1.  
  2. #ifndef GUID_DEFINED
  3. #define GUID_DEFINED
  4. #if defined(__midl)
  5. typedef struct {
  6. unsigned long Data1;
  7. unsigned short Data2;
  8. unsigned short Data3;
  9. byte Data4[ 8 ];
  10. } GUID;
  11. #else
  12. typedef struct _GUID {
  13. unsigned long Data1;
  14. unsigned short Data2;
  15. unsigned short Data3;
  16. unsigned char Data4[ 8 ];
  17. } GUID;
  18. #endif
  19. #endif
  20.  
  21. #ifndef FAR
  22. #ifdef _WIN32
  23. #define FAR
  24. #else
  25. #define FAR _far
  26. #endif
  27. #endif
  28.  
  29. #ifndef DECLSPEC_SELECTANY
  30. #if (_MSC_VER >= 1100)
  31. #define DECLSPEC_SELECTANY __declspec(selectany)
  32. #else
  33. #define DECLSPEC_SELECTANY
  34. #endif
  35. #endif
  36.  
  37. #ifndef EXTERN_C
  38. #ifdef __cplusplus
  39. #define EXTERN_C extern "C"
  40. #else
  41. #define EXTERN_C extern
  42. #endif
  43. #endif
  44.  
  45. #ifdef DEFINE_GUID
  46. #undef DEFINE_GUID
  47. #endif
  48.  
  49. #ifdef INITGUID
  50. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  51. EXTERN_C const GUID DECLSPEC_SELECTANY name \
  52. = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
  53. #else
  54. #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  55. EXTERN_C const GUID FAR name
  56. #endif // INITGUID
  57.  
  58. #define DEFINE_OLEGUID(name, l, w1, w2) DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
  59.  
  60. #ifndef _GUIDDEF_H_
  61. #define _GUIDDEF_H_
  62.  
  63. #ifndef __LPGUID_DEFINED__
  64. #define __LPGUID_DEFINED__
  65. typedef GUID *LPGUID;
  66. #endif
  67.  
  68. #ifndef __LPCGUID_DEFINED__
  69. #define __LPCGUID_DEFINED__
  70. typedef const GUID *LPCGUID;
  71. #endif
  72.  
  73. #ifndef __IID_DEFINED__
  74. #define __IID_DEFINED__
  75.  
  76. typedef GUID IID;
  77. typedef IID *LPIID;
  78. #define IID_NULL GUID_NULL
  79. #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
  80. typedef GUID CLSID;
  81. typedef CLSID *LPCLSID;
  82. #define CLSID_NULL GUID_NULL
  83. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
  84. typedef GUID FMTID;
  85. typedef FMTID *LPFMTID;
  86. #define FMTID_NULL GUID_NULL
  87. #define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID(rfmtid1, rfmtid2)
  88.  
  89. #ifdef __midl_proxy
  90. #define __MIDL_CONST
  91. #else
  92. #define __MIDL_CONST const
  93. #endif
  94.  
  95. #ifndef _REFGUID_DEFINED
  96. #define _REFGUID_DEFINED
  97. #ifdef __cplusplus
  98. #define REFGUID const GUID &
  99. #else
  100. #define REFGUID const GUID * __MIDL_CONST
  101. #endif
  102. #endif
  103.  
  104. #ifndef _REFIID_DEFINED
  105. #define _REFIID_DEFINED
  106. #ifdef __cplusplus
  107. #define REFIID const IID &
  108. #else
  109. #define REFIID const IID * __MIDL_CONST
  110. #endif
  111. #endif
  112.  
  113. #ifndef _REFCLSID_DEFINED
  114. #define _REFCLSID_DEFINED
  115. #ifdef __cplusplus
  116. #define REFCLSID const IID &
  117. #else
  118. #define REFCLSID const IID * __MIDL_CONST
  119. #endif
  120. #endif
  121.  
  122. #ifndef _REFFMTID_DEFINED
  123. #define _REFFMTID_DEFINED
  124. #ifdef __cplusplus
  125. #define REFFMTID const IID &
  126. #else
  127. #define REFFMTID const IID * __MIDL_CONST
  128. #endif
  129. #endif
  130.  
  131. #endif // !__IID_DEFINED__
  132.  
  133. #if !defined (__midl)
  134. #if !defined (_SYS_GUID_OPERATORS_)
  135. #define _SYS_GUID_OPERATORS_
  136. #include <string.h>
  137.  
  138. // Faster (but makes code fatter) inline version...use sparingly
  139. #ifdef __cplusplus
  140. __inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  141. {
  142. return (
  143. ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
  144. ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
  145. ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
  146. ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
  147. }
  148.  
  149. __inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
  150. {
  151. return !memcmp(&rguid1, &rguid2, sizeof(GUID));
  152. }
  153.  
  154. #else // ! __cplusplus
  155.  
  156. #define InlineIsEqualGUID(rguid1, rguid2) \
  157. (((unsigned long *) rguid1)[0] == ((unsigned long *) rguid2)[0] && \
  158. ((unsigned long *) rguid1)[1] == ((unsigned long *) rguid2)[1] && \
  159. ((unsigned long *) rguid1)[2] == ((unsigned long *) rguid2)[2] && \
  160. ((unsigned long *) rguid1)[3] == ((unsigned long *) rguid2)[3])
  161.  
  162. #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
  163.  
  164. #endif // __cplusplus
  165.  
  166. #ifdef __INLINE_ISEQUAL_GUID
  167. #undef IsEqualGUID
  168. #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
  169. #endif
  170.  
  171. // Same type, different name
  172.  
  173. #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
  174. #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
  175.  
  176.  
  177. #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_
  178. #define _SYS_GUID_OPERATOR_EQ_
  179. // A couple of C++ helpers
  180.  
  181. #ifdef __cplusplus
  182. __inline bool operator==(REFGUID guidOne, REFGUID guidOther)
  183. {
  184. return !!IsEqualGUID(guidOne,guidOther);
  185. }
  186.  
  187. __inline bool operator!=(REFGUID guidOne, REFGUID guidOther)
  188. {
  189. return !(guidOne == guidOther);
  190. }
  191. #endif
  192. #endif // _SYS_GUID_OPERATOR_EQ_
  193. #endif // _SYS_GUID_OPERATORS_
  194. #endif // __midl
  195. #endif // _GUIDDEF_H_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement