Leaked source code of windows server 2003
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.

60 lines
1.2 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. ASSERT( 0 != _cRef );
  31. ULONG cRef = InterlockedDecrement(&_cRef);
  32. if ( 0 == cRef )
  33. {
  34. delete this;
  35. }
  36. return cRef;
  37. }
  38. HRESULT CSafeServiceSite::QueryService(REFGUID guidService, REFIID riid, void **ppvObj)
  39. {
  40. if (_psp)
  41. return _psp->QueryService(guidService, riid, ppvObj);
  42. *ppvObj = NULL;
  43. return E_NOINTERFACE;
  44. }
  45. HRESULT CSafeServiceSite::SetProviderWeakRef(IServiceProvider *psp)
  46. {
  47. _psp = psp;
  48. return S_OK;
  49. }