OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 20 matching lines...) Expand all Loading... |
31 bool Open(HKEY rootkey, const wchar_t* subkey, REGSAM access); | 31 bool Open(HKEY rootkey, const wchar_t* subkey, REGSAM access); |
32 | 32 |
33 // Creates a subkey or open it if it already exists. | 33 // Creates a subkey or open it if it already exists. |
34 bool CreateKey(const wchar_t* name, REGSAM access); | 34 bool CreateKey(const wchar_t* name, REGSAM access); |
35 | 35 |
36 // Opens a subkey | 36 // Opens a subkey |
37 bool OpenKey(const wchar_t* name, REGSAM access); | 37 bool OpenKey(const wchar_t* name, REGSAM access); |
38 | 38 |
39 void Close(); | 39 void Close(); |
40 | 40 |
41 DWORD ValueCount(); | 41 DWORD ValueCount() const; |
42 | 42 |
43 // Determine the nth value's name. | 43 // Determine the nth value's name. |
44 bool ReadName(int index, std::wstring* name); | 44 bool ReadName(int index, std::wstring* name) const; |
45 | 45 |
46 // True while the key is valid. | 46 // True while the key is valid. |
47 bool Valid() const { return key_ != NULL; } | 47 bool Valid() const { return key_ != NULL; } |
48 | 48 |
49 // Kill a key and everything that live below it; please be careful when using | 49 // Kill a key and everything that live below it; please be careful when using |
50 // it. | 50 // it. |
51 bool DeleteKey(const wchar_t* name); | 51 bool DeleteKey(const wchar_t* name); |
52 | 52 |
53 // Deletes a single value within the key. | 53 // Deletes a single value within the key. |
54 bool DeleteValue(const wchar_t* name); | 54 bool DeleteValue(const wchar_t* name); |
55 | 55 |
56 bool ValueExists(const wchar_t* name); | 56 bool ValueExists(const wchar_t* name); |
57 | 57 |
58 bool ReadValue(const wchar_t* name, void* data, DWORD* dsize, DWORD* dtype); | 58 bool ReadValue(const wchar_t* name, void* data, DWORD* dsize, |
59 bool ReadValue(const wchar_t* name, std::wstring* value); | 59 DWORD* dtype) const; |
60 bool ReadValueDW(const wchar_t* name, DWORD* value); | 60 bool ReadValue(const wchar_t* name, std::wstring* value) const; |
| 61 bool ReadValueDW(const wchar_t* name, DWORD* value) const; |
61 | 62 |
62 bool WriteValue(const wchar_t* name, const void* data, DWORD dsize, | 63 bool WriteValue(const wchar_t* name, const void* data, DWORD dsize, |
63 DWORD dtype); | 64 DWORD dtype); |
64 bool WriteValue(const wchar_t* name, const wchar_t* value); | 65 bool WriteValue(const wchar_t* name, const wchar_t* value); |
65 bool WriteValue(const wchar_t* name, DWORD value); | 66 bool WriteValue(const wchar_t* name, DWORD value); |
66 | 67 |
67 // Starts watching the key to see if any of its values have changed. | 68 // Starts watching the key to see if any of its values have changed. |
68 // The key must have been opened with the KEY_NOTIFY access privelege. | 69 // The key must have been opened with the KEY_NOTIFY access privilege. |
69 bool StartWatching(); | 70 bool StartWatching(); |
70 | 71 |
71 // If StartWatching hasn't been called, always returns false. | 72 // If StartWatching hasn't been called, always returns false. |
72 // Otherwise, returns true if anything under the key has changed. | 73 // Otherwise, returns true if anything under the key has changed. |
73 // This can't be const because the |watch_event_| may be refreshed. | 74 // This can't be const because the |watch_event_| may be refreshed. |
74 bool HasChanged(); | 75 bool HasChanged(); |
75 | 76 |
76 // Will automatically be called by destructor if not manually called | 77 // Will automatically be called by destructor if not manually called |
77 // beforehand. Returns true if it was watching, false otherwise. | 78 // beforehand. Returns true if it was watching, false otherwise. |
78 bool StopWatching(); | 79 bool StopWatching(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 163 |
163 wchar_t name_[MAX_PATH]; | 164 wchar_t name_[MAX_PATH]; |
164 | 165 |
165 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); | 166 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); |
166 }; | 167 }; |
167 | 168 |
168 } // namespace win | 169 } // namespace win |
169 } // namespace base | 170 } // namespace base |
170 | 171 |
171 #endif // BASE_WIN_REGISTRY_H_ | 172 #endif // BASE_WIN_REGISTRY_H_ |
OLD | NEW |