Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031
00032
00033 #pragma once
00034
00035 #ifdef WIN32
00036
00037 #include "../api_core.h"
00038 #include "databuffer.h"
00039 #include <vector>
00040
00041 class CL_RegistryKey_Impl;
00042
00044
00046 class CL_API_CORE CL_RegistryKey
00047 {
00050
00051 public:
00052 enum PredefinedKey
00053 {
00054 key_classes_root,
00055 key_current_config,
00056 key_current_user,
00057 key_local_machine,
00058 key_users
00059 };
00060
00061 enum CreateFlags
00062 {
00063 create_always = 0,
00064 create_new = 1,
00065 create_volatile = 2
00066 };
00067
00068
00069 CL_RegistryKey();
00070
00071 CL_RegistryKey(PredefinedKey key, const CL_StringRef &subkey, unsigned int access_rights = KEY_ALL_ACCESS, unsigned int create_flags = create_always);
00072
00073 CL_RegistryKey(HKEY key);
00074
00075 ~CL_RegistryKey();
00076
00077
00081
00082 public:
00084 bool is_null() const { return !impl; }
00085
00087 void throw_if_null() const;
00088
00089 HKEY get_key() const;
00090
00091 std::vector<CL_String> get_subkey_names() const;
00092
00093 std::vector<CL_String> get_value_names() const;
00094
00095 int get_value_int(const CL_StringRef &name, int default_value = 0) const;
00096
00097 CL_DataBuffer get_value_binary(const CL_StringRef &name, const CL_DataBuffer &default_value = CL_DataBuffer()) const;
00098
00099 CL_String get_value_string(const CL_StringRef &name, const CL_StringRef &default_value = CL_StringRef()) const;
00100
00101 std::vector<CL_String> get_value_multi_string(const CL_StringRef &name, const std::vector<CL_String> &default_value = std::vector<CL_String>()) const;
00102
00103
00107
00108 public:
00109 CL_RegistryKey open_key(const CL_StringRef &subkey, unsigned int access_rights = KEY_ALL_ACCESS);
00110
00111 CL_RegistryKey create_key(const CL_StringRef &subkey, unsigned int access_rights = KEY_ALL_ACCESS, CreateFlags create_flags = create_always);
00112
00113 void delete_key(const CL_StringRef &subkey, bool recursive);
00114
00115 static void delete_key(PredefinedKey key, const CL_StringRef &subkey, bool recursive);
00116
00117 void set_value_int(const CL_StringRef &name, int value);
00118
00119 void set_value_binary(const CL_StringRef &name, const CL_DataBuffer &value);
00120
00121 void set_value_string(const CL_StringRef &name, const CL_StringRef &value);
00122
00123
00124
00125 void delete_value(const CL_StringRef &name);
00126
00127
00131
00132 private:
00133 CL_SharedPtr<CL_RegistryKey_Impl> impl;
00135 };
00136
00137 #endif
00138