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.

70 lines
1.7 KiB

  1. // factory.cpp -- Class factory for this COM DLL
  2. #include "stdafx.h"
  3. STDMETHODIMP CFactory::Create(REFCLSID rclsid, REFIID riid, PVOID *ppv)
  4. {
  5. CFactory *pFactory = New CFactory(NULL);
  6. if (!pFactory)
  7. return STG_E_INSUFFICIENTMEMORY;
  8. HRESULT hr = pFactory->m_ImpIClassFactory.Init(rclsid);
  9. if (hr == S_OK)
  10. hr = pFactory->m_ImpIClassFactory.QueryInterface(riid, ppv);
  11. if (hr != S_OK)
  12. delete pFactory;
  13. return hr;
  14. }
  15. STDMETHODIMP CFactory::CImpIClassFactory::Init(REFCLSID rclsid)
  16. {
  17. if (rclsid == CLSID_ITStorage || rclsid == CLSID_IFSStorage
  18. || rclsid == CLSID_PARSE_URL
  19. || rclsid == CLSID_IE4_PROTOCOLS
  20. )
  21. {
  22. m_clsid = rclsid;
  23. return NO_ERROR;
  24. }
  25. return CLASS_E_CLASSNOTAVAILABLE;
  26. }
  27. STDMETHODIMP CFactory::CImpIClassFactory::CreateInstance
  28. (IUnknown* pUnkOuter,REFIID riid, PPVOID ppv)
  29. {
  30. *ppv = NULL;
  31. if (NULL != pUnkOuter && riid != IID_IUnknown)
  32. return CLASS_E_NOAGGREGATION;
  33. if (m_clsid == CLSID_IFSStorage)
  34. return CFileSystemStorage::Create(pUnkOuter, riid, ppv);
  35. if (m_clsid == CLSID_ITStorage)
  36. return CWarehouse::Create(pUnkOuter, riid, ppv);
  37. if (m_clsid == CLSID_PARSE_URL)
  38. return CParser::Create(pUnkOuter, riid, ppv);
  39. if (m_clsid == CLSID_IE4_PROTOCOLS)
  40. return CIOITnetProtocol::Create(pUnkOuter, riid, ppv);
  41. RonM_ASSERT(FALSE);
  42. return E_NOINTERFACE;
  43. }
  44. STDMETHODIMP CFactory::CImpIClassFactory::LockServer(BOOL fLock)
  45. {
  46. if (fLock)
  47. pDLLServerState->LockServer();
  48. else
  49. pDLLServerState->UnlockServer();
  50. return NOERROR;
  51. }