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.

104 lines
4.2 KiB

  1. // WbemClassObject.h: interface for the CWbemClassObject class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_WBEMCLASSOBJECT_H__8B6E3039_FA29_11D1_8349_0000F87A3912__INCLUDED_)
  5. #define AFX_WBEMCLASSOBJECT_H__8B6E3039_FA29_11D1_8349_0000F87A3912__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <wbemcli.h>
  10. class CWbemEventListener;
  11. class CWbemClassObject : public CObject
  12. {
  13. DECLARE_DYNCREATE(CWbemClassObject)
  14. // Constructors
  15. public:
  16. CWbemClassObject();
  17. // Destructor
  18. public:
  19. virtual ~CWbemClassObject();
  20. // Create/Destroy
  21. public:
  22. virtual HRESULT Create(const CString& sMachineName);
  23. virtual HRESULT Create(IWbemClassObject* pObject);
  24. virtual void Destroy();
  25. // Property Operations
  26. public:
  27. // v-marfin
  28. HRESULT GetRawProperty(const CString& sProperty, VARIANT& vPropValue);
  29. HRESULT SetRawProperty(const CString& sProperty, VARIANT& vPropValue);
  30. HRESULT GetPropertyNames(CStringArray& saNames);
  31. HRESULT GetPropertyType(const CString& sPropertyName, CString& sType);
  32. HRESULT GetPropertyType(const CString& sPropertyName, CIMTYPE& Type);
  33. virtual HRESULT GetAllProperties() { return S_OK; }
  34. virtual HRESULT SaveAllProperties();
  35. static bool GetPropertyValueFromString(const CString& sObjectPath, const CString& sPropName, CString& sProperty);
  36. // WBEM Operations
  37. public:
  38. HRESULT GetClassName(CString& sClass) { return GetProperty(_T("__CLASS"),sClass); }
  39. HRESULT GetObject(const CString& sObjectPath);
  40. HRESULT GetObjectText(CString& sText);
  41. HRESULT ExecQuery(BSTR bsQueryString);
  42. HRESULT ExecQueryAsync(BSTR bsQueryString, CWbemEventListener* pListener);
  43. HRESULT CreateEnumerator(BSTR bsClassName);
  44. HRESULT CreateClassEnumerator(BSTR bsClassName);
  45. HRESULT CreateAsyncEnumerator(BSTR bsClassName, CWbemEventListener* pListener);
  46. HRESULT GetNextObject(ULONG& uReturned);
  47. HRESULT Reset();
  48. HRESULT CreateInstance(BSTR bsClassName);
  49. HRESULT DeleteInstance(const CString& sClassObjectPath);
  50. HRESULT GetMethod(const CString& sMethodName, CWbemClassObject& MethodInput);
  51. HRESULT ExecuteMethod(const CString& sMethodName, const CString& sArgumentName, const CString& sArgumentValue, int& iReturnValue);
  52. HRESULT ExecuteMethod(const CString& sMethodName, CWbemClassObject& InInstance, CWbemClassObject& OutInstance);
  53. HRESULT GetLocaleStringProperty(const CString& sProperty, CString& sPropertyValue);
  54. HRESULT GetProperty(const CString& sProperty, CString& sPropertyValue);
  55. HRESULT GetProperty(const CString& sProperty, int& iPropertyValue);
  56. HRESULT GetProperty(const CString& sProperty, bool& bPropertyValue);
  57. HRESULT GetProperty(const CString& sProperty, float& fPropertyValue);
  58. HRESULT GetProperty(const CString& sProperty, COleSafeArray& ArrayPropertyValue);
  59. HRESULT GetProperty(const CString& sProperty, CStringArray& saPropertyValues);
  60. HRESULT GetProperty(const CString& sProperty, CTime& timePropertyValue, bool ConvertToLocalTime = true);
  61. HRESULT SetProperty(const CString& sProperty, CString sPropertyValue);
  62. HRESULT SetProperty(const CString& sProperty, int iPropertyValue);
  63. HRESULT SetProperty(const CString& sProperty, bool bPropertyValue);
  64. HRESULT SetProperty(const CString& sProperty, float fPropertyValue);
  65. HRESULT SetProperty(const CString& sProperty, CTime timePropertyValue, bool bConvertToGMTTime = true);
  66. HRESULT SetProperty(const CString& sProperty, COleSafeArray& ArrayPropertyValue);
  67. HRESULT SetProperty(const CString& sProperty, const CStringArray& saPropertyValues);
  68. protected:
  69. HRESULT Connect(IWbemServices*& pServices);
  70. HRESULT SetBlanket(LPUNKNOWN pIUnk);
  71. void DisplayErrorMsgBox(HRESULT hr);
  72. // Accessors
  73. public:
  74. void SetMachineName(const CString& sMachineName) { m_sMachineName = sMachineName; }
  75. const CString& GetMachineName() const { return m_sMachineName; }
  76. void SetNamespace(const CString& sNamespace) { m_sNamespace = sNamespace; }
  77. const CString& GetNamespace() const { return m_sNamespace; }
  78. IWbemClassObject* GetClassObject() { m_pIWbemClassObject->AddRef(); return m_pIWbemClassObject; }
  79. // Implementation Attributes
  80. protected:
  81. IEnumWbemClassObject* m_pIEnumerator;
  82. IWbemClassObject* m_pIWbemClassObject;
  83. CString m_sMachineName;
  84. CString m_sNamespace;
  85. };
  86. #endif // !defined(AFX_WBEMCLASSOBJECT_H__8B6E3039_FA29_11D1_8349_0000F87A3912__INCLUDED_)