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.

413 lines
13 KiB

  1. /* ole2sp.h - semi-private info; only for test apps within the development group
  2. */
  3. #if !defined( _OLE2SP_H_ )
  4. #define _OLE2SP_H_
  5. #include <shellapi.h>
  6. // For MAC, M_PROLOG and M_EPILOG are macros which assist us in setting up the A5
  7. // world for a DLL when a method in the DLL is called from outside the DLL.
  8. #ifdef _MAC
  9. #define _MAX_PATH 260
  10. #ifdef __cplusplus
  11. class CSetA5
  12. {
  13. public:
  14. CSetA5 (ULONG savedA5){ A5save = SetA5(savedA5);}
  15. ~CSetA5 (){ SetA5(A5save);}
  16. private:
  17. ULONG A5save;
  18. };
  19. pascal long GetA5(void) = 0x2E8D;
  20. #define M_PROLOG(where) CSetA5 Dummy((where)->savedA5)
  21. #define SET_A5 ULONG savedA5
  22. #define GET_A5() savedA5 = GetA5()
  23. // These macros assist Mac in manually saving/setting/restoring A5 in routines that contain
  24. // goto's.
  25. #define A5_PROLOG(where) ULONG A5save = SetA5(where->savedA5)
  26. #define RESTORE_A5() SetA5(A5save)
  27. // Lets MAC name our segments without ifdef's.
  28. #define NAME_SEG(x)
  29. #endif // ccplus
  30. #else
  31. #define M_PROLOG(where)
  32. #define SET_A5
  33. #define GET_A5()
  34. #define A5_PROLOG(where)
  35. #define RESTORE_A5()
  36. #define NAME_SEG(x)
  37. //
  38. // By defining SEG(x) to code_seg(), we make #pragma SEG(x) a nop and
  39. // eliminate lots of unknown pragma warnings... 02/18/94
  40. //
  41. #define SEG(x) code_seg()
  42. #define IGetProcAddress(a,b) GetProcAddress((a),(b))
  43. #endif
  44. #define ReportResult(a,b,c,d) ResultFromScode(b)
  45. #ifdef WIN32
  46. #define MAP16(v16)
  47. #define MAP32(v32) v32
  48. #define MAP1632(v16,v32) v32
  49. #else
  50. #define MAP16(v16) v16
  51. #define MAP32(v32)
  52. #define MAP1632(v16,v32) v16
  53. #endif
  54. /****** Misc defintions ***************************************************/
  55. #ifdef __TURBOC__
  56. #define implement struct huge
  57. #else
  58. #define implement struct
  59. #endif
  60. #define ctor_dtor private
  61. #define implementations private
  62. #define shared_state private
  63. // helpers for internal methods and functions which follow the same convention
  64. // as the external ones
  65. #ifdef __cplusplus
  66. #define INTERNALAPI_(type) extern "C" type
  67. #else
  68. #define INTERNALAPI_(type) type
  69. #endif
  70. #define INTERNAL HRESULT
  71. #define INTERNAL_(type) type
  72. #define FARINTERNAL HRESULT FAR
  73. #define FARINTERNAL_(type) type FAR
  74. #define NEARINTERNAL HRESULT NEAR
  75. #define NEARINTERNAL_(type) type NEAR
  76. //BEGIN REVIEW: We may not need all the following ones
  77. #define OT_LINK 1L
  78. #define OT_EMBEDDED 2L
  79. #define OT_STATIC 3L
  80. //END REVIEW .....
  81. /****** Old Error Codes ************************************************/
  82. #define S_OOM E_OUTOFMEMORY
  83. #define S_BADARG E_INVALIDARG
  84. #define S_BLANK E_BLANK
  85. #define S_FORMAT E_FORMAT
  86. #define S_NOT_RUNNING E_NOTRUNNING
  87. #define E_UNSPEC E_FAIL
  88. /****** Macros for nested clases ******************************************/
  89. /* To overcome problems with nested classes on MAC
  90. *
  91. * NC(a,b) is used to define a member function of a nested class:
  92. *
  93. * STDMETHODIMP_(type) NC(ClassName,NestedClassName)::MemberFunction(...)
  94. *
  95. * DECLARE_NC(a,b) is used within a class declaration to let a nested class
  96. * access it container class:
  97. *
  98. * class ClassName {
  99. * ..............
  100. *
  101. * class NestedClassName {
  102. * .............
  103. * };
  104. * DECLARE_NC(ClassName,NestedClassName)
  105. * ..............
  106. * };
  107. */
  108. #ifdef _MAC
  109. #define NESTED_CLASS(a,b) struct a##_##b
  110. #define NC(a,b) a##__##b
  111. #define NC1(a,b) a##_##b
  112. #define DECLARE_NC(a,b) typedef a##::##b a##__##b; friend a##__##b;
  113. #define DECLARE_NC2(a,b) typedef a##::a##_##b a##__##b; friend a##__##b;
  114. #else
  115. #define NC(a,b) a##::##b
  116. #define DECLARE_NC(a,b) friend b;
  117. #endif
  118. /****** More Misc defintions **********************************************/
  119. // LPLPVOID should not be made a typedef. typedef won't compile; worse
  120. // within complicated macros the compiler generates unclear error messages
  121. //
  122. #define LPLPVOID void FAR * FAR *
  123. #define UNREFERENCED(a) ((void)(a))
  124. #ifndef BASED_CODE
  125. #ifdef WIN32
  126. #define BASED_CODE
  127. #else
  128. #define BASED_CODE __based(__segname("_CODE"))
  129. #endif
  130. #endif
  131. /****** Standard IUnknown Implementation **********************************/
  132. /*
  133. * The following macro declares a nested class CUnknownImpl,
  134. * creates an object of that class in the outer class, and
  135. * declares CUnknownImpl to be a friend of the outer class. After
  136. * writing about 20 class headers, it became evident that the
  137. * implementation of CUnknownImpl was very similar in all cases,
  138. * and this macro captures the similarity. The classname
  139. * parameter is the name of the outer class WITHOUT the leading
  140. * "C"; i.e., for CFileMoniker, classname is FileMoniker.
  141. */
  142. #define noError return NOERROR
  143. #ifdef _MAC
  144. #define STDUNKDECL(cclassname,classname) NESTED_CLASS(cclassname, CUnknownImpl):IUnknown { public: \
  145. NC1(cclassname,CUnknownImpl)( cclassname FAR * p##classname ) { m_p##classname = p##classname;} \
  146. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPLPVOID ppvObj); \
  147. STDMETHOD_(ULONG,AddRef)(THIS); \
  148. STDMETHOD_(ULONG,Release)(THIS); \
  149. private: cclassname FAR* m_p##classname; }; \
  150. DECLARE_NC2(cclassname, CUnknownImpl) \
  151. NC(cclassname, CUnknownImpl) m_Unknown;
  152. #else // _MAC
  153. #define STDUNKDECL( ignore, classname ) implement CUnknownImpl:IUnknown { public: \
  154. CUnknownImpl( C##classname FAR * p##classname ) { m_p##classname = p##classname;} \
  155. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPLPVOID ppvObj); \
  156. STDMETHOD_(ULONG,AddRef)(THIS); \
  157. STDMETHOD_(ULONG,Release)(THIS); \
  158. private: C##classname FAR* m_p##classname; }; \
  159. DECLARE_NC(C##classname, CUnknownImpl) \
  160. CUnknownImpl m_Unknown;
  161. #endif
  162. /*
  163. * The following macro implements all the methods of a nested
  164. * CUnknownImpl class EXCEPT FOR QUERYINTERFACE. This macro was
  165. * written after about 20 classes were written in which the
  166. * implementations of CUnknownImpl were all the same.
  167. */
  168. #ifdef WIN32
  169. #define STDUNKIMPL(classname) \
  170. STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::AddRef( void ) \
  171. { \
  172. InterlockedIncrement((LONG *)&m_p##classname->m_refs); \
  173. \
  174. return m_p##classname->m_refs; \
  175. } \
  176. \
  177. STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::Release( void ) \
  178. { \
  179. ULONG culRefs = 0; \
  180. \
  181. culRefs = InterlockedDecrement((LONG *)&m_p##classname->m_refs); \
  182. \
  183. if (culRefs == 0) \
  184. { \
  185. delete m_p##classname; \
  186. } \
  187. \
  188. return culRefs; \
  189. }
  190. #else
  191. #define STDUNKIMPL(classname) \
  192. STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::AddRef( void ){ \
  193. return ++m_p##classname->m_refs; } \
  194. STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::Release( void ){ \
  195. if (--m_p##classname->m_refs == 0) { delete m_p##classname; return 0; } \
  196. return m_p##classname->m_refs;}
  197. #endif // WIN32
  198. /*
  199. * The following macro implements class::CUnknownImpl::QueryInterface IN
  200. * THE SPECIAL CASE IN WHICH THE OUTER CLASS PRESENTS ONLY ONE INTERFACE
  201. * OTHER THAN IUNKNOWN AND IDEBUG. This is not universally the case,
  202. * but it is common enough that this macro will save time and space.
  203. */
  204. #ifdef _DEBUG
  205. #define STDDEB_QI(classname) \
  206. if (IsEqualGUID(iidInterface, IID_IDebug)) \
  207. {*ppv = (void FAR *)&(m_p##classname->m_Debug); return 0;} else
  208. #else
  209. #define STDDEB_QI(classname)
  210. #endif
  211. #ifdef WIN32
  212. #define STDUNK_QI_IMPL(classname, interfacename) \
  213. STDMETHODIMP NC(C##classname,CUnknownImpl)::QueryInterface \
  214. (REFIID iidInterface, void FAR * FAR * ppv) \
  215. { \
  216. HRESULT hres = S_OK; \
  217. \
  218. if (IsEqualIID(iidInterface,IID_IUnknown)) \
  219. { \
  220. *ppv = (void FAR *)&m_p##classname->m_Unknown; \
  221. AddRef(); \
  222. } \
  223. else if (IsEqualIID(iidInterface,IID_I##interfacename)) \
  224. { \
  225. *ppv = (void FAR *) &(m_p##classname->m_##classname); \
  226. m_p##classname->m_pUnkOuter->AddRef(); \
  227. } \
  228. else STDDEB_QI(classname) \
  229. { \
  230. *ppv = NULL; \
  231. hres = ResultFromScode(E_NOINTERFACE); \
  232. } \
  233. \
  234. return hres; \
  235. }
  236. #else
  237. STDMETHODIMP NC(C##classname,CUnknownImpl)::QueryInterface \
  238. (REFIID iidInterface, void FAR * FAR * ppv) { \
  239. if (IsEqualGUID(iidInterface,IID_IUnknown)) {\
  240. *ppv = (void FAR *)&m_p##classname->m_Unknown;\
  241. AddRef(); noError;\
  242. } else if (IsEqualGUID(iidInterface, IID_I##interfacename)) { \
  243. *ppv = (void FAR *) &(m_p##classname->m_##classname); \
  244. m_p##classname->m_pUnkOuter->AddRef(); return NOERROR; \
  245. } else \
  246. STDDEB_QI(classname) \
  247. {*ppv = NULL; return ResultFromScode(E_NOINTERFACE);} \
  248. }
  249. #endif
  250. /*
  251. * The following macro implements the IUnknown methods inherited
  252. * by the implementation of another interface. The implementation
  253. * is simply to delegate all calls to m_pUnkOuter. Parameters:
  254. * ocname is the outer class name, icname is the implementation
  255. * class name.
  256. *
  257. */
  258. #define STDUNKIMPL_FORDERIVED(ocname, icname) \
  259. STDMETHODIMP NC(C##ocname,C##icname)::QueryInterface \
  260. (REFIID iidInterface, LPLPVOID ppvObj) { \
  261. return m_p##ocname->m_pUnkOuter->QueryInterface(iidInterface, ppvObj);} \
  262. STDMETHODIMP_(ULONG) NC(C##ocname,C##icname)::AddRef(void) { \
  263. return m_p##ocname->m_pUnkOuter->AddRef(); } \
  264. STDMETHODIMP_(ULONG) NC(C##ocname,C##icname)::Release(void) { \
  265. return m_p##ocname->m_pUnkOuter->Release(); }
  266. /****** Debug defintions **************************************************/
  267. #include <debug.h>
  268. /****** Other API defintions **********************************************/
  269. // low level reg.dat access (in compobj.dll)
  270. STDAPI CoGetInProcDll(REFCLSID rclsid, BOOL fServer, LPOLESTR lpszDll, int cbMax);
  271. STDAPI CoGetLocalExe(REFCLSID rclsid, LPOLESTR lpszExe, int cbMax);
  272. // simpler alternatives to public apis
  273. // WINOLEAPI_(int) StringFromGUID2(REFGUID rguid, LPOLESTR lpsz, int cbMax);
  274. #define StringFromCLSID2(rclsid, lpsz, cbMax) \
  275. StringFromGUID2(rclsid, lpsz, cbMax)
  276. #define StringFromIID2(riid, lpsz, cbMax) \
  277. StringFromGUID2(riid, lpsz, cbMax)
  278. STDAPI_(int) Ole1ClassFromCLSID2(REFCLSID rclsid, LPOLESTR lpsz, int cbMax);
  279. STDAPI_(BOOL) GUIDFromString(LPCOLESTR lpsz, LPGUID pguid);
  280. STDAPI CLSIDFromOle1Class(LPCOLESTR lpsz, LPCLSID lpclsid, BOOL fForceAssign=FALSE);
  281. STDAPI_(BOOL) CoIsHashedOle1Class(REFCLSID rclsid);
  282. STDAPI CoOpenClassKey(REFCLSID clsid, BOOL bOpenForWrite, HKEY FAR* lphkeyClsid);
  283. // were public; now not
  284. STDAPI SetDocumentBitStg(LPSTORAGE pStg, BOOL fDocument);
  285. STDAPI GetDocumentBitStg(LPSTORAGE pStg);
  286. INTERNAL CreateStandardMalloc(DWORD memctx, IMalloc FAR* FAR* ppMalloc);
  287. /*
  288. * Some docfiles stuff
  289. */
  290. #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
  291. #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
  292. #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
  293. /*
  294. * Some moniker stuff
  295. */
  296. //REVIEW32: Should this get exported publicly??
  297. STDAPI Concatenate(LPMONIKER pmkFirst, LPMONIKER pmkRest,
  298. LPMONIKER FAR * ppmkComposite );
  299. /*
  300. * Drag and Drop Interface Property Name
  301. */
  302. #define OLE_DROP_TARGET_PROP L"OleDropTargetInterface"
  303. #define OLE_DROP_TARGET_PROPA "OleDropTargetInterface"
  304. #define OLE_DROP_TARGET_MARSHALHWND L"OleDropTargetMarshalHwnd"
  305. #define OLE_DROP_TARGET_MARSHALHWNDA "OleDropTargetMarshalHwnd"
  306. /*
  307. * Private Clipboard Window IDataObject property name
  308. */
  309. #define CLIPBOARD_DATA_OBJECT_PROP L"ClipboardDataObjectInterface"
  310. #endif // _OLE2SP_H_