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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // True while the key is valid. | 59 // True while the key is valid. |
60 bool Valid() const { return key_ != NULL; } | 60 bool Valid() const { return key_ != NULL; } |
61 | 61 |
62 // 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 |
63 // it. | 63 // it. |
64 LONG DeleteKey(const wchar_t* name); | 64 LONG DeleteKey(const wchar_t* name); |
65 | 65 |
66 // Deletes a single value within the key. | 66 // Deletes a single value within the key. |
67 LONG DeleteValue(const wchar_t* name); | 67 LONG DeleteValue(const wchar_t* name); |
68 | 68 |
69 LONG ReadValue(const wchar_t* name, void* data, DWORD* dsize, | 69 // Getters: |
| 70 |
| 71 // Returns an int32 value. If |name| is NULL or empty, returns the default |
| 72 // value, if any. |
| 73 LONG ReadValueDW(const wchar_t* name, DWORD* out_value) const; |
| 74 |
| 75 // Returns an int64 value. If |name| is NULL or empty, returns the default |
| 76 // value, if any. |
| 77 LONG ReadInt64(const wchar_t* name, int64* out_value) const; |
| 78 |
| 79 // Returns a string value. If |name| is NULL or empty, returns the default |
| 80 // value, if any. |
| 81 LONG ReadValue(const wchar_t* name, std::wstring* out_value) const; |
| 82 |
| 83 // Returns raw data. If |name| is NULL or empty, returns the default |
| 84 // value, if any. |
| 85 LONG ReadValue(const wchar_t* name, |
| 86 void* data, |
| 87 DWORD* dsize, |
70 DWORD* dtype) const; | 88 DWORD* dtype) const; |
71 LONG ReadValue(const wchar_t* name, std::wstring* value) const; | |
72 LONG ReadValueDW(const wchar_t* name, DWORD* value) const; | |
73 LONG ReadInt64(const wchar_t* name, int64* value) const; | |
74 | 89 |
75 LONG WriteValue(const wchar_t* name, const void* data, DWORD dsize, | 90 // Setters: |
| 91 |
| 92 // Sets an int32 value. |
| 93 LONG WriteValue(const wchar_t* name, DWORD in_value); |
| 94 |
| 95 // Sets a string value. |
| 96 LONG WriteValue(const wchar_t* name, const wchar_t* in_value); |
| 97 |
| 98 // Sets raw data, including type. |
| 99 LONG WriteValue(const wchar_t* name, |
| 100 const void* data, |
| 101 DWORD dsize, |
76 DWORD dtype); | 102 DWORD dtype); |
77 LONG WriteValue(const wchar_t* name, const wchar_t* value); | |
78 LONG WriteValue(const wchar_t* name, DWORD value); | |
79 | 103 |
80 // Starts watching the key to see if any of its values have changed. | 104 // Starts watching the key to see if any of its values have changed. |
81 // The key must have been opened with the KEY_NOTIFY access privilege. | 105 // The key must have been opened with the KEY_NOTIFY access privilege. |
82 LONG StartWatching(); | 106 LONG StartWatching(); |
83 | 107 |
84 // If StartWatching hasn't been called, always returns false. | 108 // If StartWatching hasn't been called, always returns false. |
85 // Otherwise, returns true if anything under the key has changed. | 109 // Otherwise, returns true if anything under the key has changed. |
86 // This can't be const because the |watch_event_| may be refreshed. | 110 // This can't be const because the |watch_event_| may be refreshed. |
87 bool HasChanged(); | 111 bool HasChanged(); |
88 | 112 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 199 |
176 wchar_t name_[MAX_PATH]; | 200 wchar_t name_[MAX_PATH]; |
177 | 201 |
178 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); | 202 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); |
179 }; | 203 }; |
180 | 204 |
181 } // namespace win | 205 } // namespace win |
182 } // namespace base | 206 } // namespace base |
183 | 207 |
184 #endif // BASE_WIN_REGISTRY_H_ | 208 #endif // BASE_WIN_REGISTRY_H_ |
OLD | NEW |