1
0

WinampFactory.cpp 967 B

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