OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_WIN_REGISTRY_H_ | 5 #ifndef BASE_WIN_REGISTRY_H_ |
6 #define BASE_WIN_REGISTRY_H_ | 6 #define BASE_WIN_REGISTRY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 RegKey(); | 27 RegKey(); |
28 RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access); | 28 RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access); |
29 ~RegKey(); | 29 ~RegKey(); |
30 | 30 |
31 LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access); | 31 LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access); |
32 | 32 |
33 LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, | 33 LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, |
34 DWORD* disposition, REGSAM access); | 34 DWORD* disposition, REGSAM access); |
35 | 35 |
36 LONG Open(HKEY rootkey, const wchar_t* subkey, REGSAM access); | |
37 | |
38 // Creates a subkey or open it if it already exists. | 36 // Creates a subkey or open it if it already exists. |
39 LONG CreateKey(const wchar_t* name, REGSAM access); | 37 LONG CreateKey(const wchar_t* name, REGSAM access); |
40 | 38 |
41 // Opens a subkey | 39 // Opens an existing reg key. |
42 LONG OpenKey(const wchar_t* name, REGSAM access); | 40 LONG Open(HKEY rootkey, const wchar_t* subkey, REGSAM access); |
43 | 41 |
| 42 // Opens an existing reg key, given the relative key name. |
| 43 LONG OpenKey(const wchar_t* relative_key_name, REGSAM access); |
| 44 |
| 45 // Closes this reg key. |
44 void Close(); | 46 void Close(); |
45 | 47 |
46 DWORD ValueCount() const; | 48 // Returns false if this key does not have the specified value, of if an error |
| 49 // occurrs while attempting to access it. |
| 50 bool HasValue(const wchar_t* value_name) const; |
| 51 |
| 52 // Returns the number of values for this key, of 0 if the number cannot be |
| 53 // determined. |
| 54 DWORD GetValueCount() const; |
47 | 55 |
48 // Determine the nth value's name. | 56 // Determine the nth value's name. |
49 LONG ReadName(int index, std::wstring* name) const; | 57 LONG GetValueNameAt(int index, std::wstring* name) const; |
50 | 58 |
51 // True while the key is valid. | 59 // True while the key is valid. |
52 bool Valid() const { return key_ != NULL; } | 60 bool Valid() const { return key_ != NULL; } |
53 | 61 |
54 // Kill a key and everything that live below it; please be careful when using | 62 // Kill a key and everything that live below it; please be careful when using |
55 // it. | 63 // it. |
56 LONG DeleteKey(const wchar_t* name); | 64 LONG DeleteKey(const wchar_t* name); |
57 | 65 |
58 // Deletes a single value within the key. | 66 // Deletes a single value within the key. |
59 LONG DeleteValue(const wchar_t* name); | 67 LONG DeleteValue(const wchar_t* name); |
60 | 68 |
61 bool ValueExists(const wchar_t* name) const; | |
62 | |
63 LONG ReadValue(const wchar_t* name, void* data, DWORD* dsize, | 69 LONG ReadValue(const wchar_t* name, void* data, DWORD* dsize, |
64 DWORD* dtype) const; | 70 DWORD* dtype) const; |
65 LONG ReadValue(const wchar_t* name, std::wstring* value) const; | 71 LONG ReadValue(const wchar_t* name, std::wstring* value) const; |
66 LONG ReadValueDW(const wchar_t* name, DWORD* value) const; | 72 LONG ReadValueDW(const wchar_t* name, DWORD* value) const; |
67 LONG ReadInt64(const wchar_t* name, int64* value) const; | 73 LONG ReadInt64(const wchar_t* name, int64* value) const; |
68 | 74 |
69 LONG WriteValue(const wchar_t* name, const void* data, DWORD dsize, | 75 LONG WriteValue(const wchar_t* name, const void* data, DWORD dsize, |
70 DWORD dtype); | 76 DWORD dtype); |
71 LONG WriteValue(const wchar_t* name, const wchar_t* value); | 77 LONG WriteValue(const wchar_t* name, const wchar_t* value); |
72 LONG WriteValue(const wchar_t* name, DWORD value); | 78 LONG WriteValue(const wchar_t* name, DWORD value); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 175 |
170 wchar_t name_[MAX_PATH]; | 176 wchar_t name_[MAX_PATH]; |
171 | 177 |
172 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); | 178 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); |
173 }; | 179 }; |
174 | 180 |
175 } // namespace win | 181 } // namespace win |
176 } // namespace base | 182 } // namespace base |
177 | 183 |
178 #endif // BASE_WIN_REGISTRY_H_ | 184 #endif // BASE_WIN_REGISTRY_H_ |
OLD | NEW |