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.

182 lines
4.3 KiB

  1. //*************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation 1999 - 2000
  4. // All rights reserved
  5. //
  6. // polbase.hxx
  7. //
  8. // Contains declarations for classes related to the
  9. // policy database abstraction
  10. //
  11. // Created: 7-15-1999 adamed
  12. //
  13. //*************************************************************/
  14. #if !defined (_POLBASE_HXX_)
  15. #define _POLBASE_HXX_
  16. class CPolicyRecord;
  17. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  18. //
  19. // Class: CPolicyDatabase
  20. //
  21. // Synopsis: This class provides an abstraction for logging
  22. // policy information into a database. Used primarly
  23. // by other classes in this module.
  24. //
  25. // Notes: Currently, only one instances of this class may exist
  26. // at one time. Additionally, this class is not threadsafe
  27. // and thus is designed to be used only on one thread.
  28. //
  29. //-------------------------------------------------------------
  30. class CPolicyDatabase
  31. {
  32. public:
  33. CPolicyDatabase();
  34. ~CPolicyDatabase();
  35. HRESULT Bind(
  36. WCHAR* wszRequestedNameSpace,
  37. IWbemServices** ppWbemServices);
  38. private:
  39. HRESULT InitializeCOM();
  40. OLE32_API * _pOle32Api; // pointer to set of COM api's used to access db
  41. HRESULT _hrInit; // Success status of COMinit -- used to
  42. // ensure the destructor knows what to uninit
  43. };
  44. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  45. //
  46. // Class: CPolicyRecord
  47. //
  48. // Synopsis: This class provides an abstraction for records
  49. // logged into the policy database for a unit of policy
  50. //
  51. // Notes: This class should be used as a base class for
  52. // an existing class that models a unit of policy.
  53. //
  54. // The Write() method should be overriden by derived
  55. // classes.
  56. //
  57. //-------------------------------------------------------------
  58. class CPolicyRecord : public CVariantArg
  59. {
  60. public:
  61. friend class CPolicyLog;
  62. CPolicyRecord() : _bNewRecord( TRUE ) {}
  63. virtual ~CPolicyRecord() {}
  64. HRESULT GetUnknown(IUnknown** ppUnk);
  65. void InitRecord(IWbemClassObject* pRecordInterface);
  66. virtual HRESULT Write(){ return S_OK; }
  67. virtual HRESULT GetPath( WCHAR* wszPath, DWORD* pcbPath ) { return E_FAIL; }
  68. //
  69. // These following set methods can be used by the Write()
  70. // method to set database record properties.
  71. //
  72. HRESULT SetValue(
  73. WCHAR* wszValueName,
  74. WCHAR* wszalue);
  75. HRESULT SetValue(
  76. WCHAR* wszValueName,
  77. LONG Value);
  78. HRESULT SetValue(
  79. WCHAR* wszValueName,
  80. BOOL bValue);
  81. HRESULT SetValue(
  82. WCHAR* wszValueName,
  83. SYSTEMTIME* pTimeValue);
  84. HRESULT SetValue(
  85. WCHAR* wszValueName,
  86. WCHAR** rgwszValues,
  87. DWORD cMaxElements);
  88. HRESULT SetValue(
  89. WCHAR* wszValueName,
  90. LONG* rgValues,
  91. DWORD cMaxElements);
  92. HRESULT SetValue(
  93. WCHAR* wszValueName,
  94. BYTE* rgValues,
  95. DWORD cMaxElements);
  96. HRESULT ClearValue(
  97. WCHAR* wszValueName);
  98. HRESULT GetValue(
  99. WCHAR* wszValueName,
  100. LONG* pValue);
  101. HRESULT GetValue(
  102. WCHAR* wszValueName,
  103. WCHAR* wszValue,
  104. LONG* pcchValue);
  105. BOOL AlreadyExists() { return ! _bNewRecord; }
  106. protected:
  107. IWbemClassObject* GetRecordInterface();
  108. private:
  109. XInterface<IWbemClassObject> _xRecordInterface; // Interface to access the record in the db
  110. BOOL _bNewRecord; // TRUE if this is a new record, false if this is an existing record
  111. };
  112. class CPolicyRecordStatus
  113. {
  114. public:
  115. CPolicyRecordStatus();
  116. void SetRsopFailureStatus(
  117. DWORD dwStatus,
  118. DWORD dwEventId);
  119. protected:
  120. SETTINGSTATUS _SettingStatus; // Indicates the status (applied or failed) of this record
  121. SYSTEMTIME _StatusTime; // The time at which this record's status (failed or applied) was recorded in the event log
  122. DWORD _dwEventId; // Event ID corresponding to the failure for this application
  123. };
  124. #endif // !defined (_POLBASE_HXX_)