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.

114 lines
3.8 KiB

  1. #ifndef _INC_DSKQUOTA_POLICY_H
  2. #define _INC_DSKQUOTA_POLICY_H
  3. ///////////////////////////////////////////////////////////////////////////////
  4. /* File: policy.h
  5. Description: Header for policy.cpp.
  6. See policy.cpp for functional description.
  7. Revision History:
  8. Date Description Programmer
  9. -------- --------------------------------------------------- ----------
  10. 02/14/98 Initial creation. BrianAu
  11. */
  12. ///////////////////////////////////////////////////////////////////////////////
  13. #ifndef _GPEDIT_H_
  14. # include <gpedit.h>
  15. #endif
  16. #ifndef _INC_DSKQUOTA_EVENTLOG_H
  17. # include "eventlog.h"
  18. #endif
  19. #ifndef _INC_DSKQUOTA_REGISTRY_H
  20. # include "registry.h"
  21. #endif
  22. //
  23. // Structure used for storing and transferring disk quota policy.
  24. //
  25. struct DISKQUOTAPOLICYINFO
  26. {
  27. LONGLONG llDefaultQuotaThreshold; // Default user quota threshold (bytes).
  28. LONGLONG llDefaultQuotaLimit; // Default user quota limit (bytes).
  29. DWORD dwQuotaState; // NTFS quota state flags.
  30. DWORD dwQuotaLogFlags; // NTFS quota logging flags.
  31. bool bRemovableMedia; // Apply policy to removable media?
  32. };
  33. typedef DISKQUOTAPOLICYINFO *LPDISKQUOTAPOLICYINFO;
  34. typedef const DISKQUOTAPOLICYINFO *LPCDISKQUOTAPOLICYINFO;
  35. #undef INTERFACE
  36. #define INTERFACE IDiskQuotaPolicy
  37. DECLARE_INTERFACE_(IDiskQuotaPolicy, IUnknown)
  38. {
  39. //
  40. // IUnknown methods
  41. //
  42. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  43. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  44. STDMETHOD_(ULONG,Release)(THIS) PURE;
  45. //
  46. // IDiskQuotaPolicy methods
  47. //
  48. STDMETHOD(Initialize)(THIS_ LPGPEINFORMATION pGPEInfo, HKEY hkeyRoot) PURE;
  49. #ifdef POLICY_MMC_SNAPIN
  50. STDMETHOD(Save)(THIS_ LPCDISKQUOTAPOLICYINFO pInfo) PURE;
  51. #endif
  52. STDMETHOD(Load)(THIS_ LPDISKQUOTAPOLICYINFO pInfo) PURE;
  53. STDMETHOD(Apply)(THIS_ LPCDISKQUOTAPOLICYINFO pInfo) PURE;
  54. };
  55. typedef IDiskQuotaPolicy *LPDISKQUOTAPOLICY;
  56. //
  57. // Class for saving/loading/applying disk quota policy information.
  58. // Used by both the MMC policy snapin (server) and the GPE extension (client).
  59. //
  60. class CDiskQuotaPolicy : public IDiskQuotaPolicy
  61. {
  62. public:
  63. explicit CDiskQuotaPolicy(LPGPEINFORMATION pGPEInfo = NULL, HKEY hkeyRoot = NULL, bool bVerboseEventLog = false, BOOL *pbAbort = NULL);
  64. ~CDiskQuotaPolicy(void);
  65. //
  66. // IUnknown interface.
  67. //
  68. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);
  69. STDMETHODIMP_(ULONG) AddRef(void);
  70. STDMETHODIMP_(ULONG) Release(void);
  71. //
  72. // IDiskQuotaPolicy interface.
  73. //
  74. STDMETHODIMP Initialize(LPGPEINFORMATION pGPEInfo, HKEY hkeyRoot);
  75. #ifdef POLICY_MMC_SNAPIN
  76. STDMETHODIMP Save(const DISKQUOTAPOLICYINFO *pPolicyInfo);
  77. #endif
  78. STDMETHODIMP Load(DISKQUOTAPOLICYINFO *pPolicyInfo);
  79. STDMETHODIMP Apply(const DISKQUOTAPOLICYINFO *pPolicyInfo);
  80. private:
  81. LONG m_cRef;
  82. LPGPEINFORMATION m_pGPEInfo;
  83. HKEY m_hkeyRoot;
  84. BOOL *m_pbAbort; // Monitor to detect abort.
  85. bool m_bRootKeyOpened; // Need to close root key?
  86. bool m_bVerboseEventLog; // Verbose log output?
  87. static const TCHAR m_szRegKeyPolicy[];
  88. #ifdef POLICY_MMC_SNAPIN
  89. static const TCHAR m_szRegValPolicy[];
  90. #endif
  91. static HRESULT GetDriveNames(CArray<CString> *prgstrDrives, bool bRemovableMedia);
  92. static HRESULT OkToApplyPolicy(LPCTSTR pszDrive, bool RemovableMedia);
  93. static void InitPolicyInfo(LPDISKQUOTAPOLICYINFO pInfo);
  94. static void LoadPolicyInfo(const RegKey& key, LPDISKQUOTAPOLICYINFO pInfo);
  95. };
  96. #endif // _INC_DSKQUOTA_POLICY_H