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.

105 lines
2.7 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. //
  5. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  6. //
  7. // ICHAPROWSET.CPP IChapteredRowset interface implementation
  8. //
  9. ///////////////////////////////////////////////////////////////////////////
  10. #include "headers.h"
  11. /////////////////////////////////////////////////////////////////////////////////////////////////
  12. //
  13. // Adds a reference to a chapter
  14. //
  15. // Returns one of the following values:
  16. // S_OK Method Succeeded
  17. // DB_E_BADCHAPTER The HCHAPTER given is invalid
  18. // E_FAIL General Error
  19. //
  20. /////////////////////////////////////////////////////////////////////////////////////////////////
  21. STDMETHODIMP CImpIChapteredRowset::AddRefChapter (HCHAPTER hChapter, DBREFCOUNT * pcRefCount)
  22. {
  23. HRESULT hr = E_UNEXPECTED;
  24. CSetStructuredExceptionHandler seh;
  25. TRY_BLOCK;
  26. // Serialize the object
  27. CAutoBlock cab(ROWSET->GetCriticalSection());
  28. // Clear ErrorInfo
  29. g_pCError->ClearErrorInfo();
  30. // Initialize the output variable
  31. if(pcRefCount != NULL)
  32. {
  33. *pcRefCount = -1;
  34. }
  35. if((m_pObj->m_bIsChildRs == TRUE && hChapter == DB_NULL_HCHAPTER) || (LONG_PTR)hChapter < 0 ||
  36. m_pObj->m_bIsChildRs == FALSE && hChapter != 0)
  37. {
  38. hr = DB_E_BADCHAPTER;
  39. }
  40. else
  41. {
  42. hr = m_pObj->AddRefChapter(hChapter,pcRefCount);
  43. }
  44. hr = hr == S_OK ? hr :g_pCError->PostHResult(hr,&IID_IChapteredRowset);
  45. CATCH_BLOCK_HRESULT(hr,L"IChapteredRowset::AddRefChapter");
  46. return hr;
  47. }
  48. /////////////////////////////////////////////////////////////////////////////////////////////////
  49. //
  50. // Releases a reference to the chapter
  51. //
  52. // Returns one of the following values:
  53. // S_OK Method Succeeded
  54. // DB_E_BADCHAPTER The HCHAPTER given is invalid
  55. // E_FAIL General Error
  56. //
  57. /////////////////////////////////////////////////////////////////////////////////////////////////
  58. STDMETHODIMP CImpIChapteredRowset::ReleaseChapter (HCHAPTER hChapter,DBREFCOUNT * pcRefCount)
  59. {
  60. HRESULT hr = E_UNEXPECTED;
  61. CSetStructuredExceptionHandler seh;
  62. TRY_BLOCK;
  63. // Serialize the object
  64. CAutoBlock cab(ROWSET->GetCriticalSection());
  65. // Clear ErrorInfo
  66. g_pCError->ClearErrorInfo();
  67. // Initialize the output variable
  68. if(pcRefCount != NULL)
  69. {
  70. *pcRefCount = -1;
  71. }
  72. if((m_pObj->m_bIsChildRs == TRUE && hChapter == DB_NULL_HCHAPTER) || (LONG_PTR)hChapter < 0 ||
  73. m_pObj->m_bIsChildRs == FALSE && hChapter != 0)
  74. {
  75. hr = DB_E_BADCHAPTER;
  76. }
  77. else
  78. {
  79. hr = m_pObj->ReleaseRefChapter(hChapter,pcRefCount);
  80. }
  81. hr = hr == S_OK ? hr :g_pCError->PostHResult(hr,&IID_IChapteredRowset);
  82. CATCH_BLOCK_HRESULT(hr,L"IChapteredRowset::ReleaseChapter");
  83. return hr;
  84. }