Leaked source code of windows server 2003
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.

245 lines
8.0 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. // MAC vestiges
  7. #define M_PROLOG(where)
  8. #define SET_A5
  9. #define GET_A5()
  10. #define A5_PROLOG(where)
  11. #define RESTORE_A5()
  12. #define NAME_SEG(x)
  13. #define IGetProcAddress(a,b) GetProcAddress((a),(b))
  14. #define ReportResult(a,b,c,d) ResultFromScode(b)
  15. #define MAP16(v16) v16
  16. #define MAP32(v32)
  17. #define MAP1632(v16,v32) v16
  18. /****** Misc defintions ***************************************************/
  19. #define implement struct
  20. #define ctor_dtor private
  21. #define implementations private
  22. #define shared_state private
  23. // helpers for internal methods and functions which follow the same convention
  24. // as the external ones
  25. #ifdef __cplusplus
  26. #define INTERNALAPI_(type) extern "C" type
  27. #else
  28. #define INTERNALAPI_(type) type
  29. #endif
  30. #define INTERNAL HRESULT
  31. #define INTERNAL_(type) type
  32. #define FARINTERNAL HRESULT FAR
  33. #define FARINTERNAL_(type) type FAR
  34. #define NEARINTERNAL HRESULT NEAR
  35. #define NEARINTERNAL_(type) type NEAR
  36. //BEGIN REVIEW: We may not need all the following ones
  37. #define OT_LINK 1L
  38. #define OT_EMBEDDED 2L
  39. #define OT_STATIC 3L
  40. //END REVIEW .....
  41. /****** Old Error Codes ************************************************/
  42. #define S_OOM E_OUTOFMEMORY
  43. #define S_BADARG E_INVALIDARG
  44. #define S_BLANK E_BLANK
  45. #define S_FORMAT E_FORMAT
  46. #define S_NOT_RUNNING E_NOTRUNNING
  47. #define E_UNSPEC E_FAIL
  48. /****** Macros for nested clases ******************************************/
  49. /* MAC vestiges */
  50. #define NC(a,b) a##::##b
  51. #define DECLARE_NC(a,b) friend b;
  52. /****** More Misc defintions **********************************************/
  53. // LPLPVOID should not be made a typedef. typedef won't compile; worse
  54. // within complicated macros the compiler generates unclear error messages
  55. //
  56. #define LPLPVOID void FAR * FAR *
  57. #define UNREFERENCED(a) ((void)(a))
  58. #ifndef BASED_CODE
  59. #define BASED_CODE __based(__segname("_CODE"))
  60. #endif
  61. /****** Standard IUnknown Implementation **********************************/
  62. /*
  63. * The following macro declares a nested class CUnknownImpl,
  64. * creates an object of that class in the outer class, and
  65. * declares CUnknownImpl to be a friend of the outer class. After
  66. * writing about 20 class headers, it became evident that the
  67. * implementation of CUnknownImpl was very similar in all cases,
  68. * and this macro captures the similarity. The classname
  69. * parameter is the name of the outer class WITHOUT the leading
  70. * "C"; i.e., for CFileMoniker, classname is FileMoniker.
  71. */
  72. #define noError return NOERROR
  73. #define STDUNKDECL( ignore, classname ) implement CUnknownImpl:IUnknown { public: \
  74. CUnknownImpl( C##classname FAR * p##classname ) { m_p##classname = p##classname;} \
  75. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPLPVOID ppvObj); \
  76. STDMETHOD_(ULONG,AddRef)(THIS); \
  77. STDMETHOD_(ULONG,Release)(THIS); \
  78. private: C##classname FAR* m_p##classname; }; \
  79. DECLARE_NC(C##classname, CUnknownImpl) \
  80. CUnknownImpl m_Unknown;
  81. /*
  82. * The following macro implements all the methods of a nested
  83. * CUnknownImpl class EXCEPT FOR QUERYINTERFACE. This macro was
  84. * written after about 20 classes were written in which the
  85. * implementations of CUnknownImpl were all the same.
  86. */
  87. #define STDUNKIMPL(classname) \
  88. STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::AddRef( void ){ \
  89. return ++m_p##classname->m_refs; } \
  90. STDMETHODIMP_(ULONG) NC(C##classname,CUnknownImpl)::Release( void ){ \
  91. if (--m_p##classname->m_refs == 0) { delete m_p##classname; return 0; } \
  92. return m_p##classname->m_refs;}
  93. /*
  94. * The following macro implements class::CUnknownImpl::QueryInterface IN
  95. * THE SPECIAL CASE IN WHICH THE OUTER CLASS PRESENTS ONLY ONE INTERFACE
  96. * OTHER THAN IUNKNOWN AND IDEBUG. This is not universally the case,
  97. * but it is common enough that this macro will save time and space.
  98. */
  99. #ifdef _DEBUG
  100. #define STDDEB_QI(classname) \
  101. if (iidInterface == IID_IDebug) {*ppv = (void FAR *)&(m_p##classname->m_Debug); return 0;} else
  102. #else
  103. #define STDDEB_QI(classname)
  104. #endif
  105. #define STDUNK_QI_IMPL(classname, interfacename) \
  106. STDMETHODIMP NC(C##classname,CUnknownImpl)::QueryInterface \
  107. (REFIID iidInterface, void FAR * FAR * ppv) { \
  108. if (iidInterface == IID_IUnknown) {\
  109. *ppv = (void FAR *)&m_p##classname->m_Unknown;\
  110. AddRef(); noError;\
  111. } else if (iidInterface == IID_I##interfacename) { \
  112. *ppv = (void FAR *) &(m_p##classname->m_##classname); \
  113. m_p##classname->m_pUnkOuter->AddRef(); return NOERROR; \
  114. } else \
  115. STDDEB_QI(classname) \
  116. {*ppv = NULL; return ResultFromScode(E_NOINTERFACE);} \
  117. }
  118. /*
  119. * The following macro implements the IUnknown methods inherited
  120. * by the implementation of another interface. The implementation
  121. * is simply to delegate all calls to m_pUnkOuter. Parameters:
  122. * ocname is the outer class name, icname is the implementation
  123. * class name.
  124. *
  125. */
  126. #define STDUNKIMPL_FORDERIVED(ocname, icname) \
  127. STDMETHODIMP NC(C##ocname,C##icname)::QueryInterface \
  128. (REFIID iidInterface, LPLPVOID ppvObj) { \
  129. return m_p##ocname->m_pUnkOuter->QueryInterface(iidInterface, ppvObj);} \
  130. STDMETHODIMP_(ULONG) NC(C##ocname,C##icname)::AddRef(void) { \
  131. return m_p##ocname->m_pUnkOuter->AddRef(); } \
  132. STDMETHODIMP_(ULONG) NC(C##ocname,C##icname)::Release(void) { \
  133. return m_p##ocname->m_pUnkOuter->Release(); }
  134. /****** Debug defintions **************************************************/
  135. #include <debug.h>
  136. /****** Other API defintions **********************************************/
  137. // Utility function not in the spec; in ole2.dll.
  138. // Read and write length-prefixed strings. Open/Create stream.
  139. // ReadStringStream does allocation, returns length of
  140. // required buffer (strlen + 1 for terminating null)
  141. STDAPI ReadStringStream( LPSTREAM pstm, LPSTR FAR * ppsz );
  142. STDAPI WriteStringStream( LPSTREAM pstm, LPCSTR psz );
  143. STDAPI OpenOrCreateStream( IStorage FAR * pstg, const char FAR * pwcsName,
  144. IStream FAR* FAR* ppstm);
  145. // read and write ole control stream (in ole2.dll)
  146. STDAPI WriteOleStg (LPSTORAGE pstg, IOleObject FAR* pOleObj,
  147. DWORD dwReserved, LPSTREAM FAR* ppstmOut);
  148. STDAPI ReadOleStg (LPSTORAGE pstg, DWORD FAR* pdwFlags,
  149. DWORD FAR* pdwOptUpdate, DWORD FAR* pdwReserved,
  150. LPMONIKER FAR* ppmk, LPSTREAM FAR* pstmOut);
  151. STDAPI ReadM1ClassStm(LPSTREAM pStm, CLSID FAR* pclsid);
  152. STDAPI WriteM1ClassStm(LPSTREAM pStm, REFCLSID rclsid);
  153. // low level reg.dat access (in compobj.dll)
  154. STDAPI CoGetInProcDll(REFCLSID rclsid, BOOL fServer, LPSTR lpszDll, int cbMax);
  155. STDAPI CoGetLocalExe(REFCLSID rclsid, LPSTR lpszExe, int cbMax);
  156. STDAPI CoGetPSClsid(REFIID iid, LPCLSID lpclsid);
  157. // simpler alternatives to public apis
  158. #define StringFromCLSID2(rclsid, lpsz, cbMax) \
  159. StringFromGUID2(rclsid, lpsz, cbMax)
  160. #define StringFromIID2(riid, lpsz, cbMax) \
  161. StringFromGUID2(riid, lpsz, cbMax)
  162. STDAPI_(int) Ole1ClassFromCLSID2(REFCLSID rclsid, LPSTR lpsz, int cbMax);
  163. STDAPI_(BOOL) GUIDFromString(LPCSTR lpsz, LPGUID pguid);
  164. STDAPI CLSIDFromOle1Class(LPCSTR lpsz, LPCLSID lpclsid, BOOL fForceAssign=FALSE);
  165. STDAPI_(BOOL) CoIsHashedOle1Class(REFCLSID rclsid);
  166. STDAPI CoOpenClassKey(REFCLSID clsid, HKEY FAR* lphkeyClsid);
  167. // were public; now not
  168. STDAPI SetDocumentBitStg(LPSTORAGE pStg, BOOL fDocument);
  169. STDAPI GetDocumentBitStg(LPSTORAGE pStg);
  170. /*
  171. * Some docfiles stuff
  172. */
  173. #define STGM_DFRALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_DENY_WRITE)
  174. #define STGM_DFALL (STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE)
  175. #define STGM_SALL (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)
  176. #endif // _OLE2SP_H_