OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2003 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2003 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 HRESULT Open(HKEY parent_key, const wchar_t* key_name, REGSAM sam_desired); | 58 HRESULT Open(HKEY parent_key, const wchar_t* key_name, REGSAM sam_desired); |
59 | 59 |
60 // close this reg key | 60 // close this reg key |
61 HRESULT Close(); | 61 HRESULT Close(); |
62 | 62 |
63 // check if the key has a specified value | 63 // check if the key has a specified value |
64 bool HasValue(const wchar_t* value_name) const; | 64 bool HasValue(const wchar_t* value_name) const; |
65 | 65 |
66 // get the number of values for this key | 66 // get the number of values for this key |
67 uint32 GetValueCount(); | 67 uint32_t GetValueCount(); |
68 | 68 |
69 // Called to get the value name for the given value name index | 69 // Called to get the value name for the given value name index |
70 // Use GetValueCount() to get the total value_name count for this key | 70 // Use GetValueCount() to get the total value_name count for this key |
71 // Returns failure if no key at the specified index | 71 // Returns failure if no key at the specified index |
72 // If you modify the key while enumerating, the indexes will be out of order. | 72 // If you modify the key while enumerating, the indexes will be out of order. |
73 // Since the index order is not guaranteed, you need to reset your counting | 73 // Since the index order is not guaranteed, you need to reset your counting |
74 // loop. | 74 // loop. |
75 // 'type' refers to REG_DWORD, REG_QWORD, etc.. | 75 // 'type' refers to REG_DWORD, REG_QWORD, etc.. |
76 // 'type' can be NULL if not interested in the value type | 76 // 'type' can be NULL if not interested in the value type |
77 HRESULT GetValueNameAt(int index, std::wstring* value_name, DWORD* type); | 77 HRESULT GetValueNameAt(int index, std::wstring* value_name, DWORD* type); |
78 | 78 |
79 // check if the current key has the specified subkey | 79 // check if the current key has the specified subkey |
80 bool HasSubkey(const wchar_t* key_name) const; | 80 bool HasSubkey(const wchar_t* key_name) const; |
81 | 81 |
82 // get the number of subkeys for this key | 82 // get the number of subkeys for this key |
83 uint32 GetSubkeyCount(); | 83 uint32_t GetSubkeyCount(); |
84 | 84 |
85 // Called to get the key name for the given key index | 85 // Called to get the key name for the given key index |
86 // Use GetSubkeyCount() to get the total count for this key | 86 // Use GetSubkeyCount() to get the total count for this key |
87 // Returns failure if no key at the specified index | 87 // Returns failure if no key at the specified index |
88 // If you modify the key while enumerating, the indexes will be out of order. | 88 // If you modify the key while enumerating, the indexes will be out of order. |
89 // Since the index order is not guaranteed, you need to reset your counting | 89 // Since the index order is not guaranteed, you need to reset your counting |
90 // loop. | 90 // loop. |
91 HRESULT GetSubkeyNameAt(int index, std::wstring* key_name); | 91 HRESULT GetSubkeyNameAt(int index, std::wstring* key_name); |
92 | 92 |
93 // SETTERS | 93 // SETTERS |
94 | 94 |
95 // set an int32 value - use when reading multiple values from a key | 95 // set an int32_t value - use when reading multiple values from a key |
96 HRESULT SetValue(const wchar_t* value_name, DWORD value) const; | 96 HRESULT SetValue(const wchar_t* value_name, DWORD value) const; |
97 | 97 |
98 // set an int64 value | 98 // set an int64_t value |
99 HRESULT SetValue(const wchar_t* value_name, DWORD64 value) const; | 99 HRESULT SetValue(const wchar_t* value_name, DWORD64 value) const; |
100 | 100 |
101 // set a string value | 101 // set a string value |
102 HRESULT SetValue(const wchar_t* value_name, const wchar_t* value) const; | 102 HRESULT SetValue(const wchar_t* value_name, const wchar_t* value) const; |
103 | 103 |
104 // set binary data | 104 // set binary data |
105 HRESULT SetValue(const wchar_t* value_name, | 105 HRESULT SetValue(const wchar_t* value_name, |
106 const uint8* value, | 106 const uint8_t* value, |
107 DWORD byte_count) const; | 107 DWORD byte_count) const; |
108 | 108 |
109 // set raw data, including type | 109 // set raw data, including type |
110 HRESULT SetValue(const wchar_t* value_name, | 110 HRESULT SetValue(const wchar_t* value_name, |
111 const uint8* value, | 111 const uint8_t* value, |
112 DWORD byte_count, | 112 DWORD byte_count, |
113 DWORD type) const; | 113 DWORD type) const; |
114 | 114 |
115 // GETTERS | 115 // GETTERS |
116 | 116 |
117 // get an int32 value | 117 // get an int32_t value |
118 HRESULT GetValue(const wchar_t* value_name, DWORD* value) const; | 118 HRESULT GetValue(const wchar_t* value_name, DWORD* value) const; |
119 | 119 |
120 // get an int64 value | 120 // get an int64_t value |
121 HRESULT GetValue(const wchar_t* value_name, DWORD64* value) const; | 121 HRESULT GetValue(const wchar_t* value_name, DWORD64* value) const; |
122 | 122 |
123 // get a string value - the caller must free the return buffer | 123 // get a string value - the caller must free the return buffer |
124 HRESULT GetValue(const wchar_t* value_name, wchar_t** value) const; | 124 HRESULT GetValue(const wchar_t* value_name, wchar_t** value) const; |
125 | 125 |
126 // get a string value | 126 // get a string value |
127 HRESULT GetValue(const wchar_t* value_name, std::wstring* value) const; | 127 HRESULT GetValue(const wchar_t* value_name, std::wstring* value) const; |
128 | 128 |
129 // get a std::vector<std::wstring> value from REG_MULTI_SZ type | 129 // get a std::vector<std::wstring> value from REG_MULTI_SZ type |
130 HRESULT GetValue(const wchar_t* value_name, | 130 HRESULT GetValue(const wchar_t* value_name, |
131 std::vector<std::wstring>* value) const; | 131 std::vector<std::wstring>* value) const; |
132 | 132 |
133 // get binary data - the caller must free the return buffer | 133 // get binary data - the caller must free the return buffer |
134 HRESULT GetValue(const wchar_t* value_name, | 134 HRESULT GetValue(const wchar_t* value_name, |
135 uint8** value, | 135 uint8_t** value, |
136 DWORD* byte_count) const; | 136 DWORD* byte_count) const; |
137 | 137 |
138 // get raw data, including type - the caller must free the return buffer | 138 // get raw data, including type - the caller must free the return buffer |
139 HRESULT GetValue(const wchar_t* value_name, | 139 HRESULT GetValue(const wchar_t* value_name, |
140 uint8** value, | 140 uint8_t** value, |
141 DWORD* byte_count, | 141 DWORD* byte_count, |
142 DWORD* type) const; | 142 DWORD* type) const; |
143 | 143 |
144 // STATIC VERSIONS | 144 // STATIC VERSIONS |
145 | 145 |
146 // flush | 146 // flush |
147 static HRESULT FlushKey(const wchar_t* full_key_name); | 147 static HRESULT FlushKey(const wchar_t* full_key_name); |
148 | 148 |
149 // check if a key exists | 149 // check if a key exists |
150 static bool HasKey(const wchar_t* full_key_name); | 150 static bool HasKey(const wchar_t* full_key_name); |
151 | 151 |
152 // check if the key has a specified value | 152 // check if the key has a specified value |
153 static bool HasValue(const wchar_t* full_key_name, const wchar_t* value_name); | 153 static bool HasValue(const wchar_t* full_key_name, const wchar_t* value_name); |
154 | 154 |
155 // SETTERS | 155 // SETTERS |
156 | 156 |
157 // STATIC int32 set | 157 // STATIC int32_t set |
158 static HRESULT SetValue(const wchar_t* full_key_name, | 158 static HRESULT SetValue(const wchar_t* full_key_name, |
159 const wchar_t* value_name, | 159 const wchar_t* value_name, |
160 DWORD value); | 160 DWORD value); |
161 | 161 |
162 // STATIC int64 set | 162 // STATIC int64_t set |
163 static HRESULT SetValue(const wchar_t* full_key_name, | 163 static HRESULT SetValue(const wchar_t* full_key_name, |
164 const wchar_t* value_name, | 164 const wchar_t* value_name, |
165 DWORD64 value); | 165 DWORD64 value); |
166 | 166 |
167 // STATIC float set | 167 // STATIC float set |
168 static HRESULT SetValue(const wchar_t* full_key_name, | 168 static HRESULT SetValue(const wchar_t* full_key_name, |
169 const wchar_t* value_name, | 169 const wchar_t* value_name, |
170 float value); | 170 float value); |
171 | 171 |
172 // STATIC double set | 172 // STATIC double set |
173 static HRESULT SetValue(const wchar_t* full_key_name, | 173 static HRESULT SetValue(const wchar_t* full_key_name, |
174 const wchar_t* value_name, | 174 const wchar_t* value_name, |
175 double value); | 175 double value); |
176 | 176 |
177 // STATIC string set | 177 // STATIC string set |
178 static HRESULT SetValue(const wchar_t* full_key_name, | 178 static HRESULT SetValue(const wchar_t* full_key_name, |
179 const wchar_t* value_name, | 179 const wchar_t* value_name, |
180 const wchar_t* value); | 180 const wchar_t* value); |
181 | 181 |
182 // STATIC binary data set | 182 // STATIC binary data set |
183 static HRESULT SetValue(const wchar_t* full_key_name, | 183 static HRESULT SetValue(const wchar_t* full_key_name, |
184 const wchar_t* value_name, | 184 const wchar_t* value_name, |
185 const uint8* value, | 185 const uint8_t* value, |
186 DWORD byte_count); | 186 DWORD byte_count); |
187 | 187 |
188 // STATIC multi-string set | 188 // STATIC multi-string set |
189 static HRESULT SetValueMultiSZ(const wchar_t* full_key_name, | 189 static HRESULT SetValueMultiSZ(const wchar_t* full_key_name, |
190 const TCHAR* value_name, | 190 const TCHAR* value_name, |
191 const uint8* value, | 191 const uint8_t* value, |
192 DWORD byte_count); | 192 DWORD byte_count); |
193 | 193 |
194 // GETTERS | 194 // GETTERS |
195 | 195 |
196 // STATIC int32 get | 196 // STATIC int32_t get |
197 static HRESULT GetValue(const wchar_t* full_key_name, | 197 static HRESULT GetValue(const wchar_t* full_key_name, |
198 const wchar_t* value_name, | 198 const wchar_t* value_name, |
199 DWORD* value); | 199 DWORD* value); |
200 | 200 |
201 // STATIC int64 get | 201 // STATIC int64_t get |
202 // | 202 // |
203 // Note: if you are using time64 you should | 203 // Note: if you are using time64 you should |
204 // likely use GetLimitedTimeValue (util.h) instead of this method. | 204 // likely use GetLimitedTimeValue (util.h) instead of this method. |
205 static HRESULT GetValue(const wchar_t* full_key_name, | 205 static HRESULT GetValue(const wchar_t* full_key_name, |
206 const wchar_t* value_name, | 206 const wchar_t* value_name, |
207 DWORD64* value); | 207 DWORD64* value); |
208 | 208 |
209 // STATIC float get | 209 // STATIC float get |
210 static HRESULT GetValue(const wchar_t* full_key_name, | 210 static HRESULT GetValue(const wchar_t* full_key_name, |
211 const wchar_t* value_name, | 211 const wchar_t* value_name, |
(...skipping 14 matching lines...) Expand all Loading... |
226 std::wstring* value); | 226 std::wstring* value); |
227 | 227 |
228 // STATIC REG_MULTI_SZ get | 228 // STATIC REG_MULTI_SZ get |
229 static HRESULT GetValue(const wchar_t* full_key_name, | 229 static HRESULT GetValue(const wchar_t* full_key_name, |
230 const wchar_t* value_name, | 230 const wchar_t* value_name, |
231 std::vector<std::wstring>* value); | 231 std::vector<std::wstring>* value); |
232 | 232 |
233 // STATIC get binary data - the caller must free the return buffer | 233 // STATIC get binary data - the caller must free the return buffer |
234 static HRESULT GetValue(const wchar_t* full_key_name, | 234 static HRESULT GetValue(const wchar_t* full_key_name, |
235 const wchar_t* value_name, | 235 const wchar_t* value_name, |
236 uint8** value, | 236 uint8_t** value, |
237 DWORD* byte_count); | 237 DWORD* byte_count); |
238 | 238 |
239 // Get type of a registry value | 239 // Get type of a registry value |
240 static HRESULT GetValueType(const wchar_t* full_key_name, | 240 static HRESULT GetValueType(const wchar_t* full_key_name, |
241 const wchar_t* value_name, | 241 const wchar_t* value_name, |
242 DWORD* value_type); | 242 DWORD* value_type); |
243 | 243 |
244 // delete a subkey of the current key (with no subkeys) | 244 // delete a subkey of the current key (with no subkeys) |
245 HRESULT DeleteSubKey(const wchar_t* key_name); | 245 HRESULT DeleteSubKey(const wchar_t* key_name); |
246 | 246 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 const wchar_t* file_name); | 290 const wchar_t* file_name); |
291 | 291 |
292 // Is the key empty: having no sub-keys and values | 292 // Is the key empty: having no sub-keys and values |
293 static bool IsKeyEmpty(const wchar_t* full_key_name); | 293 static bool IsKeyEmpty(const wchar_t* full_key_name); |
294 | 294 |
295 private: | 295 private: |
296 | 296 |
297 // helper function to get any value from the registry | 297 // helper function to get any value from the registry |
298 // used when the size of the data is unknown | 298 // used when the size of the data is unknown |
299 HRESULT GetValueHelper(const wchar_t* value_name, | 299 HRESULT GetValueHelper(const wchar_t* value_name, |
300 DWORD* type, uint8** value, | 300 DWORD* type, |
| 301 uint8_t** value, |
301 DWORD* byte_count) const; | 302 DWORD* byte_count) const; |
302 | 303 |
303 // helper function to get the parent key name and the subkey from a string | 304 // helper function to get the parent key name and the subkey from a string |
304 // modifies the argument in place and returns the key name | 305 // modifies the argument in place and returns the key name |
305 // Necessary for the static versions that use the full name of the reg key | 306 // Necessary for the static versions that use the full name of the reg key |
306 static std::wstring GetParentKeyInfo(std::wstring* key_name); | 307 static std::wstring GetParentKeyInfo(std::wstring* key_name); |
307 | 308 |
308 // common SET Helper for the static case | 309 // common SET Helper for the static case |
309 static HRESULT SetValueStaticHelper(const wchar_t* full_key_name, | 310 static HRESULT SetValueStaticHelper(const wchar_t* full_key_name, |
310 const wchar_t* value_name, | 311 const wchar_t* value_name, |
311 DWORD type, | 312 DWORD type, |
312 LPVOID value, | 313 LPVOID value, |
313 DWORD byte_count = 0); | 314 DWORD byte_count = 0); |
314 | 315 |
315 // common GET Helper for the static case | 316 // common GET Helper for the static case |
316 static HRESULT GetValueStaticHelper(const wchar_t* full_key_name, | 317 static HRESULT GetValueStaticHelper(const wchar_t* full_key_name, |
317 const wchar_t* value_name, | 318 const wchar_t* value_name, |
318 DWORD type, | 319 DWORD type, |
319 LPVOID value, | 320 LPVOID value, |
320 DWORD* byte_count = NULL); | 321 DWORD* byte_count = NULL); |
321 | 322 |
322 // convert REG_MULTI_SZ bytes to string array | 323 // convert REG_MULTI_SZ bytes to string array |
323 static HRESULT MultiSZBytesToStringArray(const uint8* buffer, | 324 static HRESULT MultiSZBytesToStringArray(const uint8_t* buffer, |
324 DWORD byte_count, | 325 DWORD byte_count, |
325 std::vector<std::wstring>* value); | 326 std::vector<std::wstring>* value); |
326 | 327 |
327 // the HKEY for the current key | 328 // the HKEY for the current key |
328 HKEY h_key_; | 329 HKEY h_key_; |
329 | 330 |
330 // for unittest | 331 // for unittest |
331 friend void RegKeyHelperFunctionsTest(); | 332 friend void RegKeyHelperFunctionsTest(); |
332 | 333 |
333 RTC_DISALLOW_COPY_AND_ASSIGN(RegKey); | 334 RTC_DISALLOW_COPY_AND_ASSIGN(RegKey); |
334 }; | 335 }; |
335 | 336 |
336 } // namespace rtc | 337 } // namespace rtc |
337 | 338 |
338 #endif // WEBRTC_BASE_WIN32REGKEY_H_ | 339 #endif // WEBRTC_BASE_WIN32REGKEY_H_ |
OLD | NEW |