registry.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando / G Library *
  23. * *
  24. * $Archive:: /Commando/Code/wwlib/registry.h $*
  25. * *
  26. * $Author:: Steve_t $*
  27. * *
  28. * $Modtime:: 11/21/01 3:42p $*
  29. * *
  30. * $Revision:: 12 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  34. #if _MSC_VER >= 1000
  35. #pragma once
  36. #endif // _MSC_VER >= 1000
  37. #ifndef REGISTRY_H
  38. #define REGISTRY_H
  39. #ifndef ALWAYS_H
  40. #include "always.h"
  41. #endif
  42. #include "vector.h"
  43. #include "wwstring.h"
  44. #include "widestring.h"
  45. class INIClass;
  46. /*
  47. **
  48. */
  49. class RegistryClass {
  50. public:
  51. static bool Exists(const char* sub_key);
  52. // Constructor & Destructor
  53. RegistryClass( const char * sub_key, bool create = true );
  54. ~RegistryClass( void );
  55. bool Is_Valid( void ) { return IsValid; }
  56. // Int data type access
  57. int Get_Int( const char * name, int def_value = 0 );
  58. void Set_Int( const char * name, int value );
  59. // Bool data type access
  60. bool Get_Bool( const char * name, bool def_value = false );
  61. void Set_Bool( const char * name, bool value );
  62. // Float data type access
  63. float Get_Float( const char * name, float def_value = 0.0f );
  64. void Set_Float( const char * name, float value );
  65. // String data type access
  66. char *Get_String( const char * name, char *value, int value_size,
  67. const char * default_string = NULL );
  68. void Get_String( const char * name, StringClass &string, const char *default_string = NULL);
  69. void Set_String( const char * name, const char *value );
  70. // Wide string data type access
  71. void Get_String( const WCHAR * name, WideStringClass &string, const WCHAR *default_string = NULL);
  72. void Set_String( const WCHAR * name, const WCHAR *value );
  73. // Binary data type access
  74. void Get_Bin( const char * name, void *buffer, int buffer_size );
  75. int Get_Bin_Size( const char * name );
  76. void Set_Bin( const char * name, const void *buffer, int buffer_size );
  77. // Value enumeration support
  78. void Get_Value_List( DynamicVectorClass<StringClass> &list );
  79. // Delete support
  80. void Delete_Value( const char * name);
  81. void Deleta_All_Values( void );
  82. // Read only.
  83. static void Set_Read_Only(bool set) {IsLocked = set;}
  84. //
  85. // Bulk registry operations. BE VERY VERY CAREFUL USING THESE
  86. //
  87. static void Delete_Registry_Tree(char *path);
  88. static void Load_Registry(const char *filename, char *old_path, char *new_path);
  89. static void Save_Registry(const char *filename, char *path);
  90. private:
  91. static void Delete_Registry_Values(HKEY key);
  92. static void Save_Registry_Tree(char *path, INIClass *ini);
  93. static void Save_Registry_Values(HKEY key, char *path, INIClass *ini);
  94. int Key;
  95. bool IsValid;
  96. //
  97. // Use this to make the registry 'read only'. Useful for running multiple copies of the app.
  98. //
  99. static bool IsLocked;
  100. };
  101. #endif // REGISTRY_H