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.

109 lines
2.3 KiB

  1. // HMPropertyStatus.cpp: implementation of the CHMPropertyStatus class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "snapin.h"
  6. #include "HMPropertyStatus.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. IMPLEMENT_DYNCREATE(CHMPropertyStatus,CWbemClassObject)
  13. //////////////////////////////////////////////////////////////////////
  14. // Construction/Destruction
  15. //////////////////////////////////////////////////////////////////////
  16. CHMPropertyStatus::CHMPropertyStatus()
  17. {
  18. }
  19. CHMPropertyStatus::~CHMPropertyStatus()
  20. {
  21. for( int i = 0; i < m_PropStatusInstances.GetSize(); i++ )
  22. {
  23. delete m_PropStatusInstances[i];
  24. }
  25. m_PropStatusInstances.RemoveAll();
  26. Destroy();
  27. }
  28. //////////////////////////////////////////////////////////////////////
  29. // Create
  30. //////////////////////////////////////////////////////////////////////
  31. HRESULT CHMPropertyStatus::Create(const CString& sMachineName)
  32. {
  33. HRESULT hr = CWbemClassObject::Create(sMachineName);
  34. if( !CHECKHRESULT(hr) )
  35. {
  36. return hr;
  37. }
  38. return hr;
  39. }
  40. HRESULT CHMPropertyStatus::Create(IWbemClassObject* pObject)
  41. {
  42. HRESULT hr = CWbemClassObject::Create(pObject);
  43. if( !CHECKHRESULT(hr) )
  44. {
  45. return hr;
  46. }
  47. return hr;
  48. }
  49. //////////////////////////////////////////////////////////////////////
  50. // Property Retrieval Operations
  51. //////////////////////////////////////////////////////////////////////
  52. HRESULT CHMPropertyStatus::GetAllProperties()
  53. {
  54. ASSERT(m_pIWbemClassObject);
  55. if( m_pIWbemClassObject == NULL )
  56. {
  57. ASSERT(FALSE);
  58. return S_FALSE;
  59. }
  60. HRESULT hr = S_OK;
  61. // PropertyName
  62. hr = GetProperty(IDS_STRING_MOF_PROPERTYNAME,m_sPropertyName);
  63. // Instances
  64. hr = GetProperty(IDS_STRING_MOF_INSTANCES,m_Instances);
  65. long lLower = 0L;
  66. long lUpper = -1L;
  67. if( hr != S_FALSE )
  68. {
  69. m_Instances.GetLBound(1L,&lLower);
  70. m_Instances.GetUBound(1L,&lUpper);
  71. }
  72. for( long i = lLower; i <= lUpper; i++ )
  73. {
  74. IWbemClassObject* pIWBCO = NULL;
  75. m_Instances.GetElement(&i,&pIWBCO);
  76. CHMPropertyStatusInstance* pPSI = new CHMPropertyStatusInstance;
  77. pPSI->Create(pIWBCO);
  78. pPSI->GetAllProperties();
  79. m_PropStatusInstances.Add(pPSI);
  80. pPSI->Destroy();
  81. }
  82. m_Instances.Destroy();
  83. m_Instances.Detach();
  84. return hr;
  85. }