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.

171 lines
5.0 KiB

  1. // adext.h - Active Directory Extension header file
  2. #ifndef _ADEXT_H_
  3. #define _ADEXT_H_
  4. #include <atlgdi.h>
  5. // Have to define a dummy _PSP struct because HPROPSHEETPAGE is defined to
  6. // be a ptr to struct _PSP and STL won't allow a vector of pointers
  7. // without having a defineion of the type pointed to.
  8. struct _PSP
  9. {
  10. int dummy;
  11. };
  12. typedef std::vector<HPROPSHEETPAGE> hpage_vector;
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // CActDirExt
  15. //
  16. // This class provides a wrapper around active directory extensions. It provides
  17. // the menu commands and property pages for a particular directory object or
  18. // an object class, depending on which Initialize method is called. The class
  19. // will also execute a menu command if it is passed back the name of the command.
  20. class CActDirExt
  21. {
  22. public:
  23. CActDirExt() : m_spExtInit(NULL) {}
  24. HRESULT Initialize(LPCWSTR pszClass, LPCWSTR pszObjPath);
  25. HRESULT Initialize(LPCWSTR pszClass);
  26. HRESULT GetMenuItems(menu_vector& vMenuNames);
  27. HRESULT GetPropertyPages(hpage_vector& vhPages);
  28. HRESULT Execute(BOMMENU* pbmMenu);
  29. private:
  30. enum {
  31. MENU_CMD_MIN = 100,
  32. MENU_CMD_MAX = 200
  33. };
  34. CMenu m_menu;
  35. CComPtr<IShellExtInit> m_spExtInit;
  36. };
  37. ////////////////////////////////////////////////////////////////////////////////
  38. // CActDirProxy
  39. //
  40. // This class allows a client on a secondary thread to use a directory extension.
  41. // It uses window mesages to create and operate a contained CActDirExt object
  42. // on the main thread. It exposes the same methods as a CActDirExt object.
  43. class CActDirExtProxy
  44. {
  45. public:
  46. CActDirExtProxy();
  47. ~CActDirExtProxy();
  48. static void InitProxy();
  49. // Forwarded methods
  50. HRESULT Initialize(LPCWSTR pszClass)
  51. { return ForwardCall(MSG_INIT1, reinterpret_cast<LPARAM>(pszClass)); }
  52. HRESULT Initialize(LPCWSTR pszClass, LPCWSTR pszObjPath)
  53. { return ForwardCall(MSG_INIT2, reinterpret_cast<LPARAM>(pszClass),
  54. reinterpret_cast<LPARAM>(pszObjPath)); }
  55. HRESULT GetMenuItems(menu_vector& vMenuNames)
  56. { return ForwardCall(MSG_GETMENUITEMS, reinterpret_cast<LPARAM>(&vMenuNames)); }
  57. HRESULT GetPropertyPages(hpage_vector& vhPages)
  58. { return ForwardCall(MSG_GETPROPPAGES, reinterpret_cast<LPARAM>(&vhPages)); }
  59. HRESULT Execute(BOMMENU* pbmMenu)
  60. { return ForwardCall(MSG_EXECUTE, reinterpret_cast<LPARAM>(pbmMenu)); }
  61. static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  62. protected:
  63. enum eProxyMsg
  64. {
  65. MSG_BEGIN = WM_USER + 100,
  66. MSG_INIT1 = WM_USER + 100,
  67. MSG_INIT2,
  68. MSG_GETMENUITEMS,
  69. MSG_GETPROPPAGES,
  70. MSG_EXECUTE,
  71. MSG_DELETE,
  72. MSG_END
  73. };
  74. HRESULT ForwardCall(eProxyMsg eMsg, LPARAM lParam1 = NULL, LPARAM lParam2 = NULL);
  75. private:
  76. CActDirExt* m_pExt; // pointer to actual extension object that this is proxying
  77. LPARAM m_lParam1; // calling parameters for the current call
  78. LPARAM m_lParam2;
  79. static HWND m_hWndProxy; // window on main thread that receives method requests
  80. };
  81. ///////////////////////////////////////////////////////////////////////////////////////////
  82. // CADDataObject
  83. class ATL_NO_VTABLE CADDataObject :
  84. public CComObjectRootEx<CComSingleThreadModel>,
  85. public IDataObject
  86. {
  87. public:
  88. DECLARE_NOT_AGGREGATABLE(CADDataObject)
  89. BEGIN_COM_MAP(CADDataObject)
  90. COM_INTERFACE_ENTRY(IDataObject)
  91. END_COM_MAP()
  92. HRESULT Initialize(LPCWSTR pszObjPath, LPCWSTR pszClass, LPCWSTR pszDcName)
  93. {
  94. if( !pszObjPath || !pszClass || !pszDcName ) return E_POINTER;
  95. m_strObjPath = pszObjPath;
  96. m_strClass = pszClass;
  97. m_strDcName = pszDcName;
  98. return S_OK;
  99. }
  100. // IDataObject
  101. STDMETHOD(GetData)(LPFORMATETC lpFormatetcIn, LPSTGMEDIUM lpMedium);
  102. STDMETHOD(GetDataHere)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium)
  103. { return E_NOTIMPL; }
  104. STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC* ppEnumFormatEtc)
  105. { return E_NOTIMPL; };
  106. STDMETHOD(QueryGetData)(LPFORMATETC lpFormatetc)
  107. { return E_NOTIMPL; };
  108. STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC lpFormatetcIn, LPFORMATETC lpFormatetcOut)
  109. { return E_NOTIMPL; };
  110. STDMETHOD(SetData)(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium, BOOL bRelease)
  111. { return E_NOTIMPL; };
  112. STDMETHOD(DAdvise)(LPFORMATETC lpFormatetc, DWORD advf,
  113. LPADVISESINK pAdvSink, LPDWORD pdwConnection)
  114. { return E_NOTIMPL; };
  115. STDMETHOD(DUnadvise)(DWORD dwConnection)
  116. { return E_NOTIMPL; };
  117. STDMETHOD(EnumDAdvise)(LPENUMSTATDATA* ppEnumAdvise)
  118. { return E_NOTIMPL; };
  119. private:
  120. tstring m_strObjPath;
  121. tstring m_strClass;
  122. tstring m_strDcName;
  123. static UINT m_cfDsObjects;
  124. static UINT m_cfDsDispSpecOptions;
  125. };
  126. #endif // _ADEXT_H_