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.

195 lines
5.1 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. #ifndef __SDSNAPIN_H_
  3. #define __SDSNAPIN_H_
  4. #include "resource.h"
  5. #ifndef ATLASSERT
  6. #define ATLASSERT(expr) _ASSERTE(expr)
  7. #endif
  8. #include <atlsnap.h>
  9. class CSDSnapinExtData : public CSnapInItemImpl<CSDSnapinExtData, TRUE>
  10. {
  11. public:
  12. static const GUID* m_NODETYPE;
  13. static const OLECHAR* m_SZNODETYPE;
  14. static const OLECHAR* m_SZDISPLAY_NAME;
  15. static const CLSID* m_SNAPIN_CLASSID;
  16. CSDSnapinExtData()
  17. {
  18. memset(&m_scopeDataItem, 0, sizeof(SCOPEDATAITEM));
  19. memset(&m_resultDataItem, 0, sizeof(RESULTDATAITEM));
  20. }
  21. ~CSDSnapinExtData()
  22. {
  23. }
  24. STDMETHOD(CreatePropertyPages)(LPPROPERTYSHEETCALLBACK lpProvider,
  25. LONG_PTR handle,
  26. IUnknown* pUnk,
  27. DATA_OBJECT_TYPES type);
  28. STDMETHOD(QueryPagesFor)(DATA_OBJECT_TYPES type)
  29. {
  30. if (type == CCT_SCOPE || type == CCT_RESULT)
  31. return S_OK;
  32. return S_FALSE;
  33. }
  34. IDataObject* m_pDataObject;
  35. virtual void InitDataClass(IDataObject* pDataObject, CSnapInItem* pDefault)
  36. {
  37. m_pDataObject = pDataObject;
  38. // The default code stores off the pointer to the Dataobject the class is wrapping
  39. // at the time.
  40. // Alternatively you could convert the dataobject to the internal format
  41. // it represents and store that information
  42. }
  43. CSnapInItem* GetExtNodeObject(IDataObject* pDataObject, CSnapInItem* pDefault)
  44. {
  45. // Modify to return a different CSnapInItem* pointer.
  46. return pDefault;
  47. }
  48. };
  49. class CSDSnapin : public CComObjectRootEx<CComSingleThreadModel>,
  50. public CSnapInObjectRoot<0, CSDSnapin>,
  51. public IExtendPropertySheetImpl<CSDSnapin>,
  52. public CComCoClass<CSDSnapin, &CLSID_SDSnapin>
  53. {
  54. public:
  55. CSDSnapin()
  56. {
  57. m_pComponentData = this;
  58. }
  59. EXTENSION_SNAPIN_DATACLASS(CSDSnapinExtData)
  60. BEGIN_EXTENSION_SNAPIN_NODEINFO_MAP(CSDSnapin)
  61. EXTENSION_SNAPIN_NODEINFO_ENTRY(CSDSnapinExtData)
  62. END_EXTENSION_SNAPIN_NODEINFO_MAP()
  63. BEGIN_COM_MAP(CSDSnapin)
  64. COM_INTERFACE_ENTRY(IExtendPropertySheet)
  65. END_COM_MAP()
  66. //DECLARE_REGISTRY_RESOURCEID(IDR_SDSNAPIN)
  67. DECLARE_NOT_AGGREGATABLE(CSDSnapin)
  68. static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
  69. {
  70. HRESULT hr;
  71. TCHAR pName[100] = {0};
  72. if(::LoadString(_Module.GetModuleInstance(), IDS_DISPLAY_NAME,
  73. pName, 100) <= 0)
  74. {
  75. wcscpy(pName, _T("Service Dependencies"));
  76. }
  77. TCHAR dispName[_MAX_PATH+102] = {0};
  78. TCHAR szModule[_MAX_PATH+1];
  79. szModule[_MAX_PATH] = 0;
  80. ::GetModuleFileName(_Module.GetModuleInstance(), szModule, _MAX_PATH);
  81. _sntprintf( dispName,_MAX_PATH+102,_T("@%s,-%d"), szModule, IDS_DISPLAY_NAME);
  82. _ATL_REGMAP_ENTRY regMap[] = {{ OLESTR("PRETTYNAME"), pName },
  83. { OLESTR("NAMESTRINGINDIRECT"),dispName},
  84. { 0, 0 }};
  85. hr = _Module.UpdateRegistryFromResourceD(IDR_SDSNAPIN, TRUE, regMap);
  86. return hr;
  87. }
  88. static void WINAPI ObjectMain(bool bStarting)
  89. {
  90. if(bStarting)
  91. CSnapInItem::Init();
  92. }
  93. };
  94. class ATL_NO_VTABLE CSDSnapinAbout : public ISnapinAbout,
  95. public CComObjectRoot,
  96. public CComCoClass< CSDSnapinAbout, &CLSID_SDSnapinAbout>
  97. {
  98. public:
  99. DECLARE_REGISTRY(CSDSnapinAbout, _T("SDSnapinAbout.1"), _T("SDSnapinAbout.1"), IDS_SDSNAPIN_DESC, THREADFLAGS_BOTH);
  100. BEGIN_COM_MAP(CSDSnapinAbout)
  101. COM_INTERFACE_ENTRY(ISnapinAbout)
  102. END_COM_MAP()
  103. STDMETHOD(GetSnapinDescription)(LPOLESTR *lpDescription)
  104. {
  105. USES_CONVERSION;
  106. TCHAR szBuf[256] = {0};
  107. if (::LoadString(_Module.GetResourceInstance(), IDS_DESCRIPTION, szBuf, 256) == 0)
  108. return E_FAIL;
  109. *lpDescription = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  110. if (*lpDescription == NULL)
  111. return E_OUTOFMEMORY;
  112. ocscpy(*lpDescription, T2OLE(szBuf));
  113. return S_OK;
  114. }
  115. STDMETHOD(GetProvider)(LPOLESTR *lpName)
  116. {
  117. USES_CONVERSION;
  118. TCHAR szBuf[256] = {0};
  119. if (::LoadString(_Module.GetResourceInstance(), IDS_SDSNAPIN_PROVIDER, szBuf, 256) == 0)
  120. return E_FAIL;
  121. *lpName = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  122. if (*lpName == NULL)
  123. return E_OUTOFMEMORY;
  124. ocscpy(*lpName, T2OLE(szBuf));
  125. return S_OK;
  126. }
  127. STDMETHOD(GetSnapinVersion)(LPOLESTR *lpVersion)
  128. {
  129. USES_CONVERSION;
  130. TCHAR szBuf[256] = {0};
  131. if (::LoadString(_Module.GetResourceInstance(), IDS_SDSNAPIN_VERSION, szBuf, 256) == 0)
  132. return E_FAIL;
  133. *lpVersion = (LPOLESTR)CoTaskMemAlloc((lstrlen(szBuf) + 1) * sizeof(OLECHAR));
  134. if (*lpVersion == NULL)
  135. return E_OUTOFMEMORY;
  136. ocscpy(*lpVersion, T2OLE(szBuf));
  137. return S_OK;
  138. }
  139. STDMETHOD(GetSnapinImage)(HICON *hAppIcon)
  140. {
  141. *hAppIcon = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_SERVDEPS));
  142. return S_OK;
  143. }
  144. STDMETHOD(GetStaticFolderImage)(HBITMAP *hSmallImage,
  145. HBITMAP *hSmallImageOpen,
  146. HBITMAP *hLargeImage,
  147. COLORREF *cMask)
  148. {
  149. *hSmallImage = *hSmallImageOpen = LoadBitmap(_Module.GetResourceInstance(),
  150. MAKEINTRESOURCE(IDB_SDSNAPIN_16));
  151. *hLargeImage = LoadBitmap(_Module.GetResourceInstance(),
  152. MAKEINTRESOURCE(IDB_SDSNAPIN_32));
  153. *cMask = RGB(255,255,255);
  154. return S_OK;
  155. }
  156. };
  157. #endif