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.

133 lines
5.2 KiB

  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. // Microsoft WMI OLE DB Provider
  3. //
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // Module : CMDPROP.CPP - ICommandProperties interface implementation
  7. //
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. #include "headers.h"
  10. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  11. STDMETHODIMP_(ULONG) CImpICommandProperties::AddRef(void)
  12. {
  13. DEBUGCODE(InterlockedIncrement((long*) &m_cRef ));
  14. return m_pcmd->GetOuterUnknown()->AddRef();
  15. }
  16. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17. STDMETHODIMP_(ULONG) CImpICommandProperties::Release(void)
  18. {
  19. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef));
  20. DEBUGCODE(if( lRef < 0 ){
  21. ASSERT("Reference count on Object went below 0!")
  22. });
  23. return m_pcmd->GetOuterUnknown()->Release();
  24. }
  25. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  26. STDMETHODIMP CImpICommandProperties::QueryInterface( REFIID riid, LPVOID * ppv )
  27. {
  28. return m_pcmd->GetOuterUnknown()->QueryInterface(riid, ppv);
  29. }
  30. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. STDMETHODIMP CImpICommandProperties::GetProperties( const ULONG cPropertySets, //@parm IN | Number of property sets
  32. const DBPROPIDSET rgPropertySets[], //@parm IN | Property Sets
  33. ULONG* pcProperties, //@parm OUT | Count of structs returned
  34. DBPROPSET** prgProperties //@parm OUT | Array of Properties
  35. )
  36. {
  37. HRESULT hr;
  38. CSetStructuredExceptionHandler seh;
  39. TRY_BLOCK;
  40. //=============================================================================
  41. // At the creation of the CAutoBlock object a critical section
  42. // is entered. This is because the method manipulates shared structures
  43. // access to which must be serialized . The critical
  44. // section is left when this method terminate and the destructor
  45. // for CAutoBlock is called.
  46. //=============================================================================
  47. CAutoBlock cab( m_pcmd->GetCriticalSection() );
  48. assert( m_pcmd );
  49. //=============================================================================
  50. //NOTE: Since we are non-chaptered, we just ignore the
  51. // rowset name argument.
  52. //=============================================================================
  53. g_pCError->ClearErrorInfo();
  54. hr = m_pcmd->m_pUtilProps->GetPropertiesArgChk(PROPSET_COMMAND, cPropertySets, rgPropertySets, pcProperties, prgProperties,TRUE);
  55. if ( SUCCEEDED(hr) ){
  56. // NTRaid: 135246
  57. hr = m_pcmd->m_pUtilProps->GetProperties(PROPSET_COMMAND,cPropertySets, rgPropertySets, pcProperties,prgProperties);
  58. }
  59. hr = hr != S_OK ? g_pCError->PostHResult(hr, &IID_ICommandProperties): hr;
  60. CATCH_BLOCK_HRESULT(hr,L"ICommandProperties::GetProperties");
  61. return hr;
  62. }
  63. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  64. STDMETHODIMP CImpICommandProperties::SetProperties( ULONG cPropertySets, //@parm IN | Count of structs returned
  65. DBPROPSET rgPropertySets[]) //@parm IN | Array of Properties
  66. {
  67. HRESULT hr = S_OK;
  68. CSetStructuredExceptionHandler seh;
  69. TRY_BLOCK;
  70. assert( m_pcmd );
  71. //=============================================================================
  72. // At the creation of the CAutoBlock object a critical section
  73. // is entered. This is because the method manipulates shared structures
  74. // access to which must be serialized . The critical
  75. // section is left when this method terminate and the destructor
  76. // for CAutoBlock is called.
  77. //=============================================================================
  78. CAutoBlock cab( m_pcmd->GetCriticalSection() );
  79. //=============================================================================
  80. //NOTE: Since we are non-chaptered, we just ignore the rowset name argument.
  81. //=============================================================================
  82. g_pCError->ClearErrorInfo();
  83. //=============================================================================
  84. // Quick return if the Count of Properties is 0
  85. //=============================================================================
  86. if ( cPropertySets != 0 )
  87. {
  88. hr = m_pcmd->m_pUtilProps->SetPropertiesArgChk(cPropertySets, rgPropertySets);
  89. if ( SUCCEEDED(hr) ){
  90. //=========================================================================
  91. // Don't allow properties to be set if we've got a rowset open
  92. //=========================================================================
  93. if ( m_pcmd->IsRowsetOpen() )
  94. {
  95. hr = DB_E_OBJECTOPEN;
  96. }
  97. else
  98. {
  99. hr = m_pcmd->m_pUtilProps->SetProperties(PROPSET_COMMAND,cPropertySets, rgPropertySets);
  100. }
  101. }
  102. }
  103. hr = hr != S_OK ? g_pCError->PostHResult(hr, &IID_ICommandProperties): hr;
  104. CATCH_BLOCK_HRESULT(hr,L"ICommandProperties::SetProperties");
  105. return hr;
  106. }