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.

71 lines
1.7 KiB

  1. #include "priv.h"
  2. #include "comcatex.h"
  3. #include "enumband.h"
  4. // Private forward decalarations
  5. typedef HRESULT (CALLBACK* PFNENUMCLSIDPROC)(REFGUID rguid, LPARAM lParam);
  6. typedef struct tagADDCATIDENUM
  7. {
  8. PFNENUMCATIDCLASSES pfnEnum;
  9. const CATID* pcatid;
  10. LPARAM lParam;
  11. } ADDCATIDENUM, *PADDCATIDENUM;
  12. STDMETHODIMP _SHEnumGUIDsWithCallback(IEnumCLSID* peclsid, PFNENUMCLSIDPROC pfnEnum, LPARAM lParam);
  13. STDMETHODIMP _AddCATIDEnum(REFCLSID rclsid, LPARAM lParam);
  14. STDMETHODIMP SHEnumClassesImplementingCATID(REFCATID rcatid, PFNENUMCATIDCLASSES pfnEnum, LPARAM lParam)
  15. {
  16. ADDCATIDENUM params;
  17. params.pcatid = &rcatid;
  18. params.pfnEnum = pfnEnum;
  19. params.lParam = lParam;
  20. IEnumCLSID *peclsid;
  21. HRESULT hr = SHEnumClassesOfCategories(1, (CATID*)&rcatid, 0, NULL, &peclsid);
  22. if (SUCCEEDED(hr))
  23. {
  24. hr = _SHEnumGUIDsWithCallback(peclsid, _AddCATIDEnum, (LPARAM)&params);
  25. peclsid->Release();
  26. }
  27. return hr;
  28. }
  29. STDMETHODIMP _SHEnumGUIDsWithCallback(IEnumCLSID* peclsid, PFNENUMCLSIDPROC pfnEnum, LPARAM lParam)
  30. {
  31. CLSID clsid;
  32. HRESULT hr;
  33. ULONG i;
  34. if (NULL == peclsid || NULL == pfnEnum)
  35. {
  36. return E_INVALIDARG;
  37. }
  38. hr = S_OK;
  39. peclsid->Reset();
  40. while (S_OK == peclsid->Next(1, &clsid, &i))
  41. {
  42. hr = pfnEnum(clsid, lParam);
  43. if (S_OK != hr)
  44. {
  45. break;
  46. }
  47. }
  48. return hr;
  49. }
  50. STDMETHODIMP _AddCATIDEnum(REFCLSID rclsid, LPARAM lParam)
  51. {
  52. PADDCATIDENUM p = (PADDCATIDENUM)lParam;
  53. ASSERT(NULL != p);
  54. ASSERT(NULL != p->pfnEnum);
  55. return (*p->pfnEnum)(*p->pcatid, rclsid, p->lParam);
  56. }