unknown.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 1k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. //*******************************************************************************************
  2. //
  3. // Filename : Unknown.cpp
  4. //
  5. // Customized CUnknown implmentations
  6. //
  7. // Copyright (c) 1994 - 1996 Microsoft Corporation. All rights reserved
  8. //
  9. //*******************************************************************************************
  10. #include "Pch.H"
  11. #include "ThisDll.H"
  12. #include "Unknown.H"
  13. CUnknown::~CUnknown()
  14. {
  15. }
  16. HRESULT CUnknown::QIHelper(REFIID riid, LPVOID *ppvObj, const IID *apiid[],
  17. LPUNKNOWN aobj[])
  18. {
  19. *ppvObj = NULL;
  20. LPUNKNOWN pObj;
  21.  
  22. if (riid == IID_IUnknown)
  23. {
  24. pObj = aobj[0]; 
  25. }
  26. else
  27. {
  28. for (int i=0; ; ++i)
  29. {
  30. if (!apiid[i])
  31. {
  32.     return(E_NOINTERFACE);
  33. }
  34. if (*apiid[i] == riid)
  35. {
  36. pObj = aobj[i];
  37. break;
  38. }
  39. }
  40. }
  41. pObj->AddRef();
  42. *ppvObj = pObj;
  43. return(NOERROR);
  44. }
  45. ULONG CUnknown::AddRefHelper()
  46. {
  47. return(m_cRef.AddRef());
  48. }
  49. ULONG CUnknown::ReleaseHelper()
  50. {
  51. if (!m_cRef.Release())
  52. {
  53.     delete this;
  54. return(0);
  55. }
  56. return(m_cRef.GetRef());
  57. }