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.0 KiB

  1. #include "datausr.h"
  2. HRESULT
  3. GetStgMedpUnkForRelease(IUnknown **pp_unk)
  4. {
  5. CStgMedIf *p_smi = new CStgMedIf();
  6. HRESULT hr = p_smi->QueryInterface(IID_IUnknown, (PPVOID)pp_unk);
  7. return hr;
  8. }
  9. CStgMedIf::CStgMedIf()
  10. {
  11. m_cRef = 0;
  12. }
  13. STDMETHODIMP
  14. CStgMedIf::QueryInterface(
  15. REFIID riid,
  16. LPLPVOID ppv
  17. )
  18. {
  19. *ppv = NULL;
  20. if (IsEqualIID(riid, IID_IUnknown))
  21. {
  22. *ppv = (LPVOID)this;
  23. ((LPUNKNOWN)*ppv)->AddRef();
  24. return NOERROR;
  25. }
  26. return ResultFromScode(E_NOINTERFACE);
  27. }
  28. STDMETHODIMP_(ULONG)
  29. CStgMedIf::AddRef(void)
  30. {
  31. return ++m_cRef;
  32. }
  33. STDMETHODIMP_(ULONG)
  34. CStgMedIf::Release(void)
  35. {
  36. ULONG cRefT;
  37. cRefT = --m_cRef;
  38. if (0==cRefT)
  39. {
  40. TCHAR chBuf[80];
  41. wsprintf(chBuf, TEXT("Reference Count is %d"), cRefT);
  42. MessageBox(0,
  43. chBuf,
  44. TEXT("STGMED pUnkForRelease"),
  45. MB_OK);
  46. delete this;
  47. }
  48. return cRefT;
  49. }
  50.