Leaked source code of windows server 2003
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.

88 lines
2.2 KiB

  1. // ObjAccess.h
  2. #ifndef _OBJACCESS_H
  3. #define _OBJACCESS_H
  4. #include <wbemcli.h>
  5. #include <wbemint.h>
  6. #include "array.h"
  7. class CProp
  8. {
  9. public:
  10. CProp() :
  11. m_lHandle(0),
  12. m_dwSize(0),
  13. m_pData(NULL)
  14. {
  15. }
  16. CIMTYPE m_type;
  17. long m_lHandle;
  18. _bstr_t m_strName;
  19. DWORD m_dwSize;
  20. LPVOID m_pData;
  21. };
  22. typedef CArray<CProp, CProp&> CPropArray;
  23. class CObjAccess
  24. {
  25. public:
  26. CObjAccess();
  27. CObjAccess(const CObjAccess& other);
  28. ~CObjAccess();
  29. const CObjAccess& operator=(const CObjAccess& other);
  30. enum INIT_FAILED_PROP_TYPE
  31. {
  32. // Init returns FALSE if a property isn't found.
  33. FAILED_PROP_FAIL,
  34. // See if this property is an array.
  35. FAILED_PROP_TRY_ARRAY,
  36. // If the property isn't found just set the handle to 0 and go on.
  37. FAILED_PROP_IGNORE
  38. };
  39. BOOL Init(
  40. IWbemServices *pSvc,
  41. LPCWSTR szClass,
  42. LPCWSTR *pszPropNames,
  43. DWORD nProps,
  44. INIT_FAILED_PROP_TYPE type = FAILED_PROP_FAIL);
  45. BOOL WriteArrayData(DWORD dwIndex, LPVOID pData, DWORD dwItemSize);
  46. BOOL WriteNonPackedArrayData(DWORD dwIndex, LPVOID pData, DWORD dwItems,
  47. DWORD dwTotalSize);
  48. BOOL WriteData(DWORD dwIndex, LPVOID pData, DWORD dwSize);
  49. BOOL WriteString(DWORD dwIndex, LPCWSTR szValue);
  50. BOOL WriteString(DWORD dwIndex, LPCSTR szValue);
  51. BOOL WriteDWORD(DWORD dwIndex, DWORD dwValue);
  52. BOOL WriteDWORD64(DWORD dwIndex, DWORD64 dwValue);
  53. BOOL WriteNULL(DWORD dwIndex);
  54. IWbemClassObject **GetObjForIndicate() { return &m_pObj; }
  55. IWbemClassObject *GetObj() { return m_pObj; }
  56. _IWmiObject *GetWmiObj() { return m_pWmiObj; }
  57. HRESULT SetProp(DWORD dwIndex, DWORD dwSize, LPVOID pData)
  58. {
  59. return
  60. m_pWmiObj->SetPropByHandle(
  61. m_pProps[dwIndex].m_lHandle,
  62. 0,
  63. dwSize,
  64. pData);
  65. }
  66. protected:
  67. IWbemObjectAccess *m_pObjAccess;
  68. IWbemClassObject *m_pObj;
  69. _IWmiObject *m_pWmiObj;
  70. CPropArray m_pProps;
  71. };
  72. #endif