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.

130 lines
2.0 KiB

  1. //-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: oletest.cxx
  7. //
  8. // Contents: Simple OLE test object
  9. //
  10. // Classes: COleTestClass
  11. //
  12. // Functions:
  13. //
  14. // History: 1-July-93 t-martig Created
  15. //
  16. //--------------------------------------------------------------------------
  17. #include <oletest.hxx>
  18. ULONG objCount = 0, lockCount = 0;
  19. COleTestClassFactory theFactory;
  20. COleTestClass::COleTestClass ()
  21. {
  22. refCount = 1;
  23. objCount++;
  24. }
  25. COleTestClass::~COleTestClass ()
  26. {
  27. objCount--;
  28. }
  29. SCODE COleTestClass::QueryInterface (THIS_ REFIID riid, LPVOID FAR* ppvObj)
  30. {
  31. if (IsEqualIID (riid, IID_IUnknown))
  32. *ppvObj = (LPVOID FAR)(IUnknown*)this;
  33. else
  34. {
  35. *ppvObj = NULL;
  36. return E_NOINTERFACE;
  37. }
  38. AddRef();
  39. return S_OK;
  40. }
  41. ULONG COleTestClass::AddRef (THIS)
  42. {
  43. return (refCount++);
  44. }
  45. ULONG COleTestClass::Release (THIS)
  46. {
  47. refCount--;
  48. if (refCount == 0)
  49. {
  50. delete this;
  51. return 0;
  52. }
  53. return refCount;
  54. }
  55. SCODE COleTestClassFactory::QueryInterface (THIS_ REFIID riid, LPVOID FAR* ppvObj)
  56. {
  57. if (IsEqualIID (riid, IID_IUnknown))
  58. *ppvObj = (LPVOID FAR)(IUnknown*)this;
  59. else
  60. {
  61. if (IsEqualIID (riid, IID_IClassFactory))
  62. *ppvObj = (LPVOID FAR)(IClassFactory*)this;
  63. else
  64. {
  65. *ppvObj = NULL;
  66. return E_NOINTERFACE;
  67. }
  68. }
  69. return S_OK;
  70. }
  71. ULONG COleTestClassFactory::AddRef (THIS)
  72. {
  73. return 1;
  74. }
  75. ULONG COleTestClassFactory::Release (THIS)
  76. {
  77. return 1;
  78. }
  79. SCODE COleTestClassFactory::CreateInstance (THIS_ LPUNKNOWN pUnkOuter,
  80. REFIID riid, LPVOID FAR* ppvObject)
  81. {
  82. *ppvObject = (LPVOID FAR*)(IStream*)new COleTestClass;
  83. return S_OK;
  84. }
  85. SCODE COleTestClassFactory::LockServer (THIS_ BOOL fLock)
  86. {
  87. if (fLock)
  88. lockCount++;
  89. else
  90. lockCount--;
  91. return S_OK;
  92. }