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.

108 lines
2.6 KiB

  1. // regc.h : Declaration of the Cregc
  2. #ifndef __REGC_H_
  3. #define __REGC_H_
  4. #include "resource.h" // main symbols
  5. /////////////////////////////////////////////////////////////////////////////
  6. // Cregc
  7. class ATL_NO_VTABLE Cregc :
  8. public CComObjectRootEx<CComSingleThreadModel>,
  9. public CComCoClass<Cregc, &CLSID_regc>,
  10. public IDispatchImpl<IComponentRegistrar, &IID_IComponentRegistrar, &LIBID_MDSYNCLib>
  11. {
  12. public:
  13. Cregc()
  14. {
  15. }
  16. DECLARE_NO_REGISTRY()
  17. BEGIN_COM_MAP(Cregc)
  18. COM_INTERFACE_ENTRY(IComponentRegistrar)
  19. COM_INTERFACE_ENTRY(IDispatch)
  20. END_COM_MAP()
  21. // IComponentRegistrar
  22. public:
  23. STDMETHOD(Attach)(BSTR bstrPath)
  24. {
  25. return E_NOTIMPL;
  26. }
  27. STDMETHOD(RegisterAll)()
  28. {
  29. _ATL_OBJMAP_ENTRY* pEntry = _Module.m_pObjMap;
  30. HRESULT hr = S_OK;
  31. while (pEntry->pclsid != NULL)
  32. {
  33. if (pEntry->pfnGetObjectDescription() != NULL)
  34. {
  35. hr = _Module.RegisterServer(TRUE, pEntry->pclsid);
  36. if (FAILED(hr))
  37. break;
  38. }
  39. pEntry++;
  40. }
  41. return hr;
  42. }
  43. STDMETHOD(UnregisterAll)()
  44. {
  45. _ATL_OBJMAP_ENTRY* pEntry = _Module.m_pObjMap;
  46. while (pEntry->pclsid != NULL)
  47. {
  48. if (pEntry->pfnGetObjectDescription() != NULL)
  49. _Module.UnregisterServer(pEntry->pclsid);
  50. pEntry++;
  51. }
  52. return S_OK;
  53. }
  54. STDMETHOD(GetComponents)(SAFEARRAY **ppCLSIDs, SAFEARRAY **ppDescriptions)
  55. {
  56. _ATL_OBJMAP_ENTRY* pEntry = _Module.m_pObjMap;
  57. int nComponents = 0;
  58. while (pEntry->pclsid != NULL)
  59. {
  60. LPCTSTR pszDescription = pEntry->pfnGetObjectDescription();
  61. if (pszDescription)
  62. nComponents++;
  63. pEntry++;
  64. }
  65. SAFEARRAYBOUND rgBound[1];
  66. rgBound[0].lLbound = 0;
  67. rgBound[0].cElements = nComponents;
  68. *ppCLSIDs = SafeArrayCreate(VT_BSTR, 1, rgBound);
  69. *ppDescriptions = SafeArrayCreate(VT_BSTR, 1, rgBound);
  70. pEntry = _Module.m_pObjMap;
  71. for (long i=0; pEntry->pclsid != NULL; pEntry++)
  72. {
  73. LPCTSTR pszDescription = pEntry->pfnGetObjectDescription();
  74. if (pszDescription)
  75. {
  76. LPOLESTR pszCLSID;
  77. StringFromCLSID(*pEntry->pclsid, &pszCLSID);
  78. SafeArrayPutElement(*ppCLSIDs, &i, OLE2BSTR(pszCLSID));
  79. CoTaskMemFree(pszCLSID);
  80. SafeArrayPutElement(*ppCLSIDs, &i, T2BSTR(pszDescription));
  81. i++;
  82. }
  83. }
  84. return S_OK;
  85. }
  86. STDMETHOD(RegisterComponent)(BSTR bstrCLSID)
  87. {
  88. CLSID clsid;
  89. CLSIDFromString(bstrCLSID, &clsid);
  90. _Module.RegisterServer(TRUE, &clsid);
  91. return S_OK;
  92. }
  93. STDMETHOD(UnregisterComponent)(BSTR bstrCLSID)
  94. {
  95. CLSID clsid;
  96. CLSIDFromString(bstrCLSID, &clsid);
  97. _Module.UnregisterServer(&clsid);
  98. return S_OK;
  99. }
  100. };
  101. #endif //__REGC_H_