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.

105 lines
3.1 KiB

  1. /*++
  2. Copyright (C) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. PERSISTCFG.H
  5. Abstract:
  6. This file implements the WinMgmt persistent configuration operations.
  7. Classes implemented:
  8. CPersistentConfig persistent configuration manager
  9. History:
  10. 1/13/98 paulall Created.
  11. --*/
  12. #ifndef _persistcfg_h_
  13. #define _persistcfg_h_
  14. #include "corepol.h"
  15. #include "statsync.h"
  16. enum PERSIST_CFGVAL
  17. {
  18. PERSIST_CFGVAL_CORE_DATABASE_DIRTY,
  19. PERSIST_CFGVAL_CORE_ESS_NEEDS_LOADING,
  20. PERSIST_CFGVAL_CORE_NEEDSBACKUPCHECK,
  21. PERSIST_CFGVAL_CORE_FSREP_VERSION,
  22. PERSIST_CFGVAL_CORE_ESS_TO_BE_INITIALIZED,
  23. PERSIST_CFGVAL_MAX_NUM_EVENTS // keep this last
  24. };
  25. class CDirectoryPath
  26. {
  27. TCHAR *pszDirectory ;
  28. public:
  29. CDirectoryPath();
  30. ~CDirectoryPath(){ delete [] pszDirectory;};
  31. TCHAR * GetStr(void){return pszDirectory;};
  32. };
  33. /*=============================================================================
  34. *
  35. * class CPersistentConfig
  36. *
  37. * Retrieves and stores persistent configuration in the $WinMgmt.CFG file.
  38. * All writes are going to be committed to disk by the return of the
  39. * operation.
  40. *=============================================================================
  41. */
  42. #pragma warning (disable : 4251)
  43. class POLARITY CPersistentConfig
  44. {
  45. public:
  46. //Number of items in the config array. Requesting/setting values
  47. //outside this range will fail the operation.
  48. enum { MaxNumberConfigEntries = PERSIST_CFGVAL_MAX_NUM_EVENTS };
  49. //Retrieves the configuration from the configuration file if it
  50. //has not yet been retrieved into memory, or retrieves it from a
  51. //memory cache.
  52. // dwOffset needs to be less than MaxNumberConfigEntries and specifies
  53. // the configuration entry required.
  54. // dwValue if sucessful this will contain the value. If the value
  55. // has not been set this will return 0.
  56. // BOOL returns TRUE if successful.
  57. BOOL GetPersistentCfgValue(DWORD dwOffset, DWORD &dwValue);
  58. //Stores the value into the configuration file and to the
  59. //memory cache if it exists. The replacment of the original
  60. //file (if it exists) is the last thing it does.
  61. // dwOffset needs to be less than MaxNumberConfigEntries and specifies
  62. // the configuration entry required.
  63. // dwValue is the value to set the configuration to.
  64. // BOOL returns TRUE if successful.
  65. BOOL SetPersistentCfgValue(DWORD dwOffset, DWORD dwValue);
  66. //Should be called once at startup to make sure the configuration files are
  67. //in a stable state.
  68. void CPersistentConfig::TidyUp();
  69. private:
  70. //Directory of persistent date
  71. static CDirectoryPath m_Directory ;
  72. //Returns a filename with a full DB path prepended to the
  73. //specified filename. Need to delete[] the string returned.
  74. TCHAR *GetFullFilename(const TCHAR *pszFilename);
  75. //Returns TRUE if the file exists, FALSE otherwise (or if an error
  76. //occurs while opening the file.
  77. BOOL FileExists(const TCHAR *pszFilename);
  78. };
  79. #endif