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> |
11 | 11 |
12 #include "base/base_api.h" | 12 #include "base/base_export.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 namespace win { | 16 namespace win { |
17 | 17 |
18 // Utility class to read, write and manipulate the Windows Registry. | 18 // Utility class to read, write and manipulate the Windows Registry. |
19 // Registry vocabulary primer: a "key" is like a folder, in which there | 19 // Registry vocabulary primer: a "key" is like a folder, in which there |
20 // are "values", which are <name, data> pairs, with an associated data type. | 20 // are "values", which are <name, data> pairs, with an associated data type. |
21 // | 21 // |
22 // Note: | 22 // Note: |
23 // ReadValue family of functions guarantee that the return arguments | 23 // ReadValue family of functions guarantee that the return arguments |
24 // are not touched in case of failure. | 24 // are not touched in case of failure. |
25 class BASE_API RegKey { | 25 class BASE_EXPORT RegKey { |
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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 HKEY key_; // The registry key being iterated. | 92 HKEY key_; // The registry key being iterated. |
93 HANDLE watch_event_; | 93 HANDLE watch_event_; |
94 | 94 |
95 DISALLOW_COPY_AND_ASSIGN(RegKey); | 95 DISALLOW_COPY_AND_ASSIGN(RegKey); |
96 }; | 96 }; |
97 | 97 |
98 // Iterates the entries found in a particular folder on the registry. | 98 // Iterates the entries found in a particular folder on the registry. |
99 // For this application I happen to know I wont need data size larger | 99 // For this application I happen to know I wont need data size larger |
100 // than MAX_PATH, but in real life this wouldn't neccessarily be | 100 // than MAX_PATH, but in real life this wouldn't neccessarily be |
101 // adequate. | 101 // adequate. |
102 class BASE_API RegistryValueIterator { | 102 class BASE_EXPORT RegistryValueIterator { |
103 public: | 103 public: |
104 RegistryValueIterator(HKEY root_key, const wchar_t* folder_key); | 104 RegistryValueIterator(HKEY root_key, const wchar_t* folder_key); |
105 | 105 |
106 ~RegistryValueIterator(); | 106 ~RegistryValueIterator(); |
107 | 107 |
108 DWORD ValueCount() const; | 108 DWORD ValueCount() const; |
109 | 109 |
110 // True while the iterator is valid. | 110 // True while the iterator is valid. |
111 bool Valid() const; | 111 bool Valid() const; |
112 | 112 |
(...skipping 19 matching lines...) Expand all Loading... |
132 | 132 |
133 // Current values. | 133 // Current values. |
134 wchar_t name_[MAX_PATH]; | 134 wchar_t name_[MAX_PATH]; |
135 wchar_t value_[MAX_PATH]; | 135 wchar_t value_[MAX_PATH]; |
136 DWORD value_size_; | 136 DWORD value_size_; |
137 DWORD type_; | 137 DWORD type_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(RegistryValueIterator); | 139 DISALLOW_COPY_AND_ASSIGN(RegistryValueIterator); |
140 }; | 140 }; |
141 | 141 |
142 class BASE_API RegistryKeyIterator { | 142 class BASE_EXPORT RegistryKeyIterator { |
143 public: | 143 public: |
144 RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key); | 144 RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key); |
145 | 145 |
146 ~RegistryKeyIterator(); | 146 ~RegistryKeyIterator(); |
147 | 147 |
148 DWORD SubkeyCount() const; | 148 DWORD SubkeyCount() const; |
149 | 149 |
150 // True while the iterator is valid. | 150 // True while the iterator is valid. |
151 bool Valid() const; | 151 bool Valid() const; |
152 | 152 |
(...skipping 16 matching lines...) Expand all Loading... |
169 | 169 |
170 wchar_t name_[MAX_PATH]; | 170 wchar_t name_[MAX_PATH]; |
171 | 171 |
172 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); | 172 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); |
173 }; | 173 }; |
174 | 174 |
175 } // namespace win | 175 } // namespace win |
176 } // namespace base | 176 } // namespace base |
177 | 177 |
178 #endif // BASE_WIN_REGISTRY_H_ | 178 #endif // BASE_WIN_REGISTRY_H_ |
OLD | NEW |