Source code of Windows XP (NT5)
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.

174 lines
3.2 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 pDispMgr;
  107. RRETURN_EXP_IF_ERR(hr);
  108. }
  109. STDMETHODIMP
  110. CLargeInteger::InterfaceSupportsErrorInfo(THIS_ REFIID riid)
  111. {
  112. if (IsEqualIID(riid, IID_IADsLargeInteger)) {
  113. return S_OK;
  114. } else {
  115. return S_FALSE;
  116. }
  117. }
  118. STDMETHODIMP
  119. CLargeInteger::get_HighPart(THIS_ LONG *retval)
  120. {
  121. *retval = _dwHighPart;
  122. RRETURN(S_OK);
  123. }
  124. STDMETHODIMP
  125. CLargeInteger::put_HighPart(THIS_ LONG lnHighPart)
  126. {
  127. _dwHighPart = lnHighPart;
  128. RRETURN(S_OK);
  129. }
  130. STDMETHODIMP
  131. CLargeInteger::get_LowPart(THIS_ LONG *retval)
  132. {
  133. *retval = _dwLowPart;
  134. RRETURN(S_OK);
  135. }
  136. STDMETHODIMP
  137. CLargeInteger::put_LowPart(THIS_ LONG lnLowPart)
  138. {
  139. _dwLowPart = lnLowPart;
  140. RRETURN(S_OK);
  141. }
  142.