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.

56 lines
1.4 KiB

  1. // PageFact.cpp: implementation of the CPageFactory class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "pch.h"
  5. #include "PageFact.h"
  6. #include "Page1.h"
  7. #include "Page2.h"
  8. //////////////////////////////////////////////////////////////////////
  9. // ITaskPageFactory
  10. //////////////////////////////////////////////////////////////////////
  11. typedef struct
  12. {
  13. const CLSID *pclsid;
  14. _ATL_CREATORFUNC* pfnCreateInstance;
  15. } _PAGEMAP_ENTRY;
  16. #define PAGE_ENTRY2(clsid,class) {&clsid, class::_CreatorClass::CreateInstance},
  17. #define PAGE_ENTRY(class) PAGE_ENTRY2(__uuidof(class), class)
  18. static const _PAGEMAP_ENTRY s_rgPage[] =
  19. {
  20. PAGE_ENTRY(CPage1)
  21. PAGE_ENTRY(CPage2)
  22. };
  23. STDMETHODIMP CPageFactory::CreatePage(REFCLSID rclsidPage, REFIID riid, void ** ppv)
  24. {
  25. HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
  26. //if (CLSID_CPage1 == rclsidPage)
  27. //{
  28. // hr = CPage1::_CreatorClass::CreateInstance(NULL, riid, ppv);
  29. //}
  30. //else if (CLSID_CPage2 == rclsidPage)
  31. //{
  32. // hr = CPage2::_CreatorClass::CreateInstance(NULL, riid, ppv);
  33. //}
  34. // etc.
  35. for (UINT i = 0; i < ARRAYSIZE(s_rgPage); i++)
  36. {
  37. if (rclsidPage == *s_rgPage[i].pclsid)
  38. {
  39. if (NULL != s_rgPage[i].pfnCreateInstance)
  40. {
  41. hr = s_rgPage[i].pfnCreateInstance(NULL, riid, ppv);
  42. }
  43. break;
  44. }
  45. }
  46. return hr;
  47. }