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.

58 lines
1.1 KiB

  1. #include "stock.h"
  2. #pragma hdrstop
  3. #include "cowsite.h"
  4. HRESULT CObjectWithSite::SetSite(IUnknown *punkSite)
  5. {
  6. IUnknown_Set(&_punkSite, punkSite);
  7. return S_OK;
  8. }
  9. HRESULT CObjectWithSite::GetSite(REFIID riid, void **ppvSite)
  10. {
  11. if (_punkSite)
  12. return _punkSite->QueryInterface(riid, ppvSite);
  13. *ppvSite = NULL;
  14. return E_FAIL;
  15. }
  16. HRESULT CSafeServiceSite::QueryInterface(REFIID riid, void **ppv)
  17. {
  18. static const QITAB qit[] = {
  19. QITABENT(CSafeServiceSite, IServiceProvider),
  20. { 0 },
  21. };
  22. return QISearch(this, qit, riid, ppv);
  23. }
  24. ULONG CSafeServiceSite::AddRef()
  25. {
  26. return InterlockedIncrement(&_cRef);
  27. }
  28. ULONG CSafeServiceSite::Release()
  29. {
  30. if (InterlockedDecrement(&_cRef))
  31. return _cRef;
  32. delete this;
  33. return 0;
  34. }
  35. HRESULT CSafeServiceSite::QueryService(REFGUID guidService, REFIID riid, void **ppvObj)
  36. {
  37. if (_psp)
  38. return _psp->QueryService(guidService, riid, ppvObj);
  39. *ppvObj = NULL;
  40. return E_NOINTERFACE;
  41. }
  42. HRESULT CSafeServiceSite::SetProviderWeakRef(IServiceProvider *psp)
  43. {
  44. _psp = psp;
  45. return S_OK;
  46. }