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.

210 lines
5.0 KiB

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