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.

175 lines
3.4 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cLargeInteger.cxx
  7. //
  8. // Contents: LargeInteger object
  9. //
  10. // History: 11-1-95 krishnag Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "oleds.hxx"
  14. #pragma hdrstop
  15. // Class CLargeInteger
  16. DEFINE_IDispatch_Implementation(CLargeInteger)
  17. CLargeInteger::CLargeInteger():
  18. _pDispMgr(NULL),
  19. _dwHighPart(0),
  20. _dwLowPart(0)
  21. {
  22. ENLIST_TRACKING(CLargeInteger);
  23. }
  24. HRESULT
  25. CLargeInteger::CreateLargeInteger(
  26. REFIID riid,
  27. void **ppvObj
  28. )
  29. {
  30. CLargeInteger FAR * pLargeInteger = NULL;
  31. HRESULT hr = S_OK;
  32. hr = AllocateLargeIntegerObject(&pLargeInteger);
  33. BAIL_ON_FAILURE(hr);
  34. hr = pLargeInteger->QueryInterface(riid, ppvObj);
  35. BAIL_ON_FAILURE(hr);
  36. pLargeInteger->Release();
  37. RRETURN(hr);
  38. error:
  39. delete pLargeInteger;
  40. RRETURN_EXP_IF_ERR(hr);
  41. }
  42. CLargeInteger::~CLargeInteger( )
  43. {
  44. delete _pDispMgr;
  45. }
  46. STDMETHODIMP
  47. CLargeInteger::QueryInterface(
  48. REFIID iid,
  49. LPVOID FAR* ppv
  50. )
  51. {
  52. if (IsEqualIID(iid, IID_IUnknown))
  53. {
  54. *ppv = (IADsLargeInteger FAR *) this;
  55. }
  56. else if (IsEqualIID(iid, IID_IADsLargeInteger))
  57. {
  58. *ppv = (IADsLargeInteger FAR *) this;
  59. }
  60. else if (IsEqualIID(iid, IID_IDispatch))
  61. {
  62. *ppv = (IADsLargeInteger FAR *) this;
  63. }
  64. else if (IsEqualIID(iid, IID_ISupportErrorInfo))
  65. {
  66. *ppv = (ISupportErrorInfo FAR *) this;
  67. }
  68. else
  69. {
  70. *ppv = NULL;
  71. return E_NOINTERFACE;
  72. }
  73. AddRef();
  74. return NOERROR;
  75. }
  76. HRESULT
  77. CLargeInteger::AllocateLargeIntegerObject(
  78. CLargeInteger ** ppLargeInteger
  79. )
  80. {
  81. CLargeInteger FAR * pLargeInteger = NULL;
  82. CDispatchMgr FAR * pDispMgr = NULL;
  83. HRESULT hr = S_OK;
  84. pLargeInteger = new CLargeInteger();
  85. if (pLargeInteger == NULL) {
  86. hr = E_OUTOFMEMORY;
  87. }
  88. BAIL_ON_FAILURE(hr);
  89. pDispMgr = new CDispatchMgr;
  90. if (pDispMgr == NULL) {
  91. hr = E_OUTOFMEMORY;
  92. }
  93. BAIL_ON_FAILURE(hr);
  94. hr = LoadTypeInfoEntry(
  95. pDispMgr,
  96. LIBID_ADs,
  97. IID_IADsLargeInteger,
  98. (IADsLargeInteger *)pLargeInteger,
  99. DISPID_REGULAR
  100. );
  101. BAIL_ON_FAILURE(hr);
  102. pLargeInteger->_pDispMgr = pDispMgr;
  103. *ppLargeInteger = pLargeInteger;
  104. RRETURN(hr);
  105. error:
  106. delete pLargeInteger;
  107. delete pDispMgr;
  108. RRETURN_EXP_IF_ERR(hr);
  109. }
  110. STDMETHODIMP
  111. CLargeInteger::InterfaceSupportsErrorInfo(THIS_ REFIID riid)
  112. {
  113. if (IsEqualIID(riid, IID_IADsLargeInteger)) {
  114. return S_OK;
  115. } else {
  116. return S_FALSE;
  117. }
  118. }
  119. STDMETHODIMP
  120. CLargeInteger::get_HighPart(THIS_ LONG *retval)
  121. {
  122. *retval = _dwHighPart;
  123. RRETURN(S_OK);
  124. }
  125. STDMETHODIMP
  126. CLargeInteger::put_HighPart(THIS_ LONG lnHighPart)
  127. {
  128. _dwHighPart = lnHighPart;
  129. RRETURN(S_OK);
  130. }
  131. STDMETHODIMP
  132. CLargeInteger::get_LowPart(THIS_ LONG *retval)
  133. {
  134. *retval = _dwLowPart;
  135. RRETURN(S_OK);
  136. }
  137. STDMETHODIMP
  138. CLargeInteger::put_LowPart(THIS_ LONG lnLowPart)
  139. {
  140. _dwLowPart = lnLowPart;
  141. RRETURN(S_OK);
  142. }
  143.