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.

91 lines
2.1 KiB

  1. // HMPropertyStatusInstance.cpp: implementation of the CHMPropertyStatusInstance class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "snapin.h"
  6. #include "HMPropertyStatusInstance.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. IMPLEMENT_DYNCREATE(CHMPropertyStatusInstance,CWbemClassObject)
  13. //////////////////////////////////////////////////////////////////////
  14. // Construction/Destruction
  15. //////////////////////////////////////////////////////////////////////
  16. CHMPropertyStatusInstance::CHMPropertyStatusInstance()
  17. {
  18. }
  19. CHMPropertyStatusInstance::~CHMPropertyStatusInstance()
  20. {
  21. Destroy();
  22. }
  23. //////////////////////////////////////////////////////////////////////
  24. // Create
  25. //////////////////////////////////////////////////////////////////////
  26. HRESULT CHMPropertyStatusInstance::Create(const CString& sMachineName)
  27. {
  28. HRESULT hr = CWbemClassObject::Create(sMachineName);
  29. if( !CHECKHRESULT(hr) )
  30. {
  31. return hr;
  32. }
  33. return hr;
  34. }
  35. HRESULT CHMPropertyStatusInstance::Create(IWbemClassObject* pObject)
  36. {
  37. HRESULT hr = CWbemClassObject::Create(pObject);
  38. if( !CHECKHRESULT(hr) )
  39. {
  40. return hr;
  41. }
  42. return hr;
  43. }
  44. //////////////////////////////////////////////////////////////////////
  45. // Property Retrieval Operations
  46. //////////////////////////////////////////////////////////////////////
  47. HRESULT CHMPropertyStatusInstance::GetAllProperties()
  48. {
  49. ASSERT(m_pIWbemClassObject);
  50. if( m_pIWbemClassObject == NULL )
  51. {
  52. ASSERT(FALSE);
  53. return S_FALSE;
  54. }
  55. HRESULT hr = S_OK;
  56. // InstanceName
  57. hr = GetProperty(IDS_STRING_MOF_INSTANCENAME,m_sInstanceName);
  58. // CurrentValue
  59. hr = GetProperty(IDS_STRING_MOF_CURRENTVALUE,m_sCurrentValue);
  60. m_lCurrentValue = _ttoi(m_sCurrentValue);
  61. // MinValue
  62. hr = GetProperty(IDS_STRING_MOF_MINVALUE,m_sMinValue);
  63. m_lMinValue = _ttoi(m_sMinValue);
  64. // MaxValue
  65. hr = GetProperty(IDS_STRING_MOF_MAXVALUE,m_sMaxValue);
  66. m_lMaxValue = _ttoi(m_sMaxValue);
  67. // AvgValue
  68. hr = GetProperty(IDS_STRING_MOF_AVGVALUE,m_sAvgValue);
  69. m_lAvgValue = _ttoi(m_sAvgValue);
  70. return hr;
  71. }