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.

241 lines
6.0 KiB

  1. #ifndef __DOMMIGRATOR_H_
  2. #define __DOMMIGRATOR_H_
  3. #include "resource.h"
  4. #include <atlsnap.h>
  5. #include "MyNodes.h"
  6. #include <ntverp.h>
  7. class CDomMigrator;
  8. class CDomMigratorComponent : public CComObjectRootEx<CComSingleThreadModel>,
  9. public CSnapInObjectRoot<2, CDomMigrator >,
  10. public IExtendContextMenuImpl<CDomMigratorComponent>,
  11. public IExtendControlbarImpl<CDomMigratorComponent>,
  12. public IComponentImpl<CDomMigratorComponent>
  13. {
  14. public:
  15. BEGIN_COM_MAP(CDomMigratorComponent)
  16. COM_INTERFACE_ENTRY(IComponent)
  17. COM_INTERFACE_ENTRY(IExtendContextMenu)
  18. COM_INTERFACE_ENTRY(IExtendControlbar)
  19. END_COM_MAP()
  20. public:
  21. CDomMigratorComponent()
  22. {
  23. }
  24. STDMETHOD(Notify)(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, long arg, long param)
  25. {
  26. if (lpDataObject != NULL)
  27. return IComponentImpl<CDomMigratorComponent>::Notify(lpDataObject, event, arg, param);
  28. // TODO : Add code to handle notifications that set lpDataObject == NULL.
  29. return E_NOTIMPL;
  30. }
  31. // IExtendContextMenu methods
  32. STDMETHOD(AddMenuItems)(LPDATAOBJECT pDataObject,
  33. LPCONTEXTMENUCALLBACK piCallback,
  34. long *pInsertionAllowed);
  35. STDMETHOD(Command)(long lCommandID,
  36. LPDATAOBJECT pDataObject);
  37. };
  38. class CDomMigrator : public CComObjectRootEx<CComSingleThreadModel>,
  39. public CSnapInObjectRoot<1, CDomMigrator>,
  40. public IComponentDataImpl<CDomMigrator, CDomMigratorComponent>,
  41. public IExtendContextMenuImpl<CDomMigrator>,
  42. public IPersistStreamInit,
  43. public ISnapinHelp2,
  44. public CComCoClass<CDomMigrator, &CLSID_DomMigrator>
  45. {
  46. CString m_lpszSnapinHelpFile;
  47. public:
  48. CDomMigrator();
  49. ~CDomMigrator();
  50. BEGIN_COM_MAP(CDomMigrator)
  51. COM_INTERFACE_ENTRY(IComponentData)
  52. COM_INTERFACE_ENTRY(IExtendContextMenu)
  53. COM_INTERFACE_ENTRY(IPersistStreamInit)
  54. COM_INTERFACE_ENTRY(ISnapinHelp)
  55. COM_INTERFACE_ENTRY(ISnapinHelp2)
  56. END_COM_MAP()
  57. //DECLARE_REGISTRY_RESOURCEID(IDR_DOMMIGRATOR)
  58. static HRESULT WINAPI UpdateRegistry( BOOL bUpdateRegistry )
  59. {
  60. WCHAR szBuf[MAX_PATH] = L"";
  61. ::LoadString(_Module.GetResourceInstance(), IDS_Title, szBuf, MAX_PATH);
  62. _ATL_REGMAP_ENTRY regMap[] =
  63. {
  64. { OLESTR("TOOLNAME"), SysAllocString(szBuf) },
  65. { 0, 0 }
  66. };
  67. return _Module.UpdateRegistryFromResourceD( IDR_DOMMIGRATOR, bUpdateRegistry, regMap );
  68. }
  69. DECLARE_NOT_AGGREGATABLE(CDomMigrator)
  70. STDMETHOD(GetClassID)(CLSID *pClassID)
  71. {
  72. return S_OK;
  73. ATLTRACENOTIMPL(_T("CDomMigrator::GetClassID"));
  74. }
  75. STDMETHOD(IsDirty)()
  76. {
  77. return S_FALSE;
  78. ATLTRACENOTIMPL(_T("CDomMigrator::IsDirty"));
  79. }
  80. STDMETHOD(Load)(IStream *pStm)
  81. {
  82. return S_OK;
  83. ATLTRACENOTIMPL(_T("CDomMigrator::Load"));
  84. }
  85. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty)
  86. {
  87. return S_OK;
  88. ATLTRACENOTIMPL(_T("CDomMigrator::Save"));
  89. }
  90. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize)
  91. {
  92. return S_OK;
  93. ATLTRACENOTIMPL(_T("CDomMigrator::GetSizeMax"));
  94. }
  95. STDMETHOD(InitNew)()
  96. {
  97. ATLTRACE(_T("CDomMigrator::InitNew\n"));
  98. return S_OK;
  99. }
  100. STDMETHOD(Initialize)(LPUNKNOWN pUnknown);
  101. static void WINAPI ObjectMain(bool bStarting)
  102. {
  103. if (bStarting)
  104. CSnapInItem::Init();
  105. }
  106. // ISnapinHelp2 methods
  107. STDMETHOD(GetHelpTopic)(LPOLESTR *lpCompiledHelpFile);
  108. STDMETHOD(GetLinkedTopics)(LPOLESTR *lpCompiledHelpFiles);
  109. };
  110. class ATL_NO_VTABLE CDomMigratorAbout : public ISnapinAbout,
  111. public CComObjectRoot,
  112. public CComCoClass< CDomMigratorAbout, &CLSID_DomMigratorAbout>
  113. {
  114. public:
  115. DECLARE_REGISTRY(CDomMigratorAbout, _T("DomMigratorAbout.1"), _T("DomMigratorAbout.1"), IDS_DOMMIGRATOR_DESC, THREADFLAGS_BOTH);
  116. BEGIN_COM_MAP(CDomMigratorAbout)
  117. COM_INTERFACE_ENTRY(ISnapinAbout)
  118. END_COM_MAP()
  119. STDMETHOD(GetSnapinDescription)(LPOLESTR *lpDescription)
  120. {
  121. USES_CONVERSION;
  122. TCHAR szBuf[MAX_PATH];
  123. if ( lpDescription == NULL )
  124. return E_POINTER;
  125. if (::LoadString(_Module.GetResourceInstance(), IDS_DOMMIGRATOR_DESC, szBuf, MAX_PATH) == 0)
  126. return E_FAIL;
  127. *lpDescription = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  128. if (*lpDescription == NULL)
  129. return E_OUTOFMEMORY;
  130. ocscpy(*lpDescription, T2OLE(szBuf));
  131. return S_OK;
  132. }
  133. STDMETHOD(GetProvider)(LPOLESTR *lpName)
  134. {
  135. USES_CONVERSION;
  136. TCHAR szBuf[MAX_PATH];
  137. if ( lpName == NULL )
  138. return E_POINTER;
  139. if (::LoadString(_Module.GetResourceInstance(), IDS_DOMMIGRATOR_PROVIDER, szBuf, MAX_PATH) == 0)
  140. return E_FAIL;
  141. *lpName = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  142. if (*lpName == NULL)
  143. return E_OUTOFMEMORY;
  144. ocscpy(*lpName, T2OLE(szBuf));
  145. return S_OK;
  146. }
  147. STDMETHOD(GetSnapinVersion)(LPOLESTR *lpVersion)
  148. {
  149. USES_CONVERSION;
  150. TCHAR szFormat[MAX_PATH];
  151. TCHAR szVersion[MAX_PATH];
  152. if ( lpVersion == NULL )
  153. return E_POINTER;
  154. if (::LoadString(_Module.GetResourceInstance(), IDS_DOMMIGRATOR_VERSION, szFormat, MAX_PATH) == 0)
  155. return E_FAIL;
  156. szVersion[MAX_PATH - 1] = _T('\0');
  157. int cch = _sntprintf(szVersion, MAX_PATH, szFormat, LVER_PRODUCTVERSION_STR);
  158. if ((cch < 0) || (szVersion[MAX_PATH - 1] != _T('\0')))
  159. {
  160. return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
  161. }
  162. szVersion[MAX_PATH - 1] = _T('\0');
  163. *lpVersion = (LPOLESTR)CoTaskMemAlloc((lstrlen(szVersion) + 1) * sizeof(OLECHAR));
  164. if (*lpVersion == NULL)
  165. return E_OUTOFMEMORY;
  166. ocscpy(*lpVersion, T2OLE(szVersion));
  167. return S_OK;
  168. }
  169. STDMETHOD(GetSnapinImage)(HICON *hAppIcon)
  170. {
  171. if ( hAppIcon == NULL )
  172. return E_POINTER;
  173. *hAppIcon = NULL;
  174. return S_OK;
  175. }
  176. STDMETHOD(GetStaticFolderImage)(HBITMAP *hSmallImage,
  177. HBITMAP *hSmallImageOpen,
  178. HBITMAP *hLargeImage,
  179. COLORREF *cMask)
  180. {
  181. if (( hSmallImage == NULL ) || ( hSmallImageOpen == NULL ) || ( hLargeImage == NULL ))
  182. return E_POINTER;
  183. *hSmallImageOpen = *hSmallImage = *hLargeImage = 0;
  184. return S_OK;
  185. }
  186. };
  187. #endif