ElevatorFactory.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "ElevatorFactory.h"
  2. #include "FileTypeRegistrar.h"
  3. FileTypeRegistrar registrar;
  4. void Lock();
  5. void UnLock();
  6. ElevatorFactory::ElevatorFactory()
  7. {
  8. }
  9. ElevatorFactory::~ElevatorFactory()
  10. {
  11. }
  12. ULONG ElevatorFactory::AddRef()
  13. {
  14. return 10;
  15. }
  16. ULONG ElevatorFactory::Release()
  17. {
  18. return 10;
  19. }
  20. HRESULT ElevatorFactory::QueryInterface(REFIID riid, void ** ppAny)
  21. {
  22. // IID_IUnknown is the REFIID of standard interface IUnknown
  23. if(riid == IID_IUnknown)
  24. {
  25. *ppAny = (IUnknown *)this;
  26. }
  27. else if(riid == IID_IClassFactory)
  28. {
  29. *ppAny = (IClassFactory *)this;
  30. }
  31. else
  32. {
  33. *ppAny = NULL;
  34. return E_NOINTERFACE;
  35. }
  36. ((IUnknown *)(*ppAny))->AddRef();
  37. return S_OK;
  38. }
  39. HRESULT ElevatorFactory::LockServer(BOOL fLock)
  40. {
  41. if (fLock)
  42. Lock();
  43. else
  44. UnLock();
  45. return S_OK;
  46. }
  47. HRESULT ElevatorFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppAny)
  48. {
  49. if(pUnkOuter != NULL)
  50. {
  51. return CLASS_E_NOAGGREGATION;
  52. }
  53. FileTypeRegistrar *pRegistrar = &registrar;
  54. return pRegistrar->QueryInterface(riid, ppAny);
  55. }