Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: base/win/registry.h

Issue 616173003: Allow Registry Iterator functions to use a specified WOW64 mode when iterating. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add second constructor Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/win/registry.cc » ('j') | base/win/registry.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 HKEY key_; // The registry key being iterated. 150 HKEY key_; // The registry key being iterated.
151 HANDLE watch_event_; 151 HANDLE watch_event_;
152 REGSAM wow64access_; 152 REGSAM wow64access_;
153 153
154 DISALLOW_COPY_AND_ASSIGN(RegKey); 154 DISALLOW_COPY_AND_ASSIGN(RegKey);
155 }; 155 };
156 156
157 // Iterates the entries found in a particular folder on the registry. 157 // Iterates the entries found in a particular folder on the registry.
158 class BASE_EXPORT RegistryValueIterator { 158 class BASE_EXPORT RegistryValueIterator {
159 public: 159 public:
160 // Construct a Registry Value Iterator with default WOW64 access.
160 RegistryValueIterator(HKEY root_key, const wchar_t* folder_key); 161 RegistryValueIterator(HKEY root_key, const wchar_t* folder_key);
161 162
163 // Construct a Registry Key Iterator with specific WOW64 access, one of
164 // KEY_WOW64_32KEY or KEY_WOW64_64KEY, or 0.
165 // Note: |wow64access| should be the same access used to open |root_key|
166 // previously, or a predefined key (e.g. HKEY_LOCAL_MACHINE).
167 // See http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129.aspx.
168 RegistryValueIterator(HKEY root_key,
169 const wchar_t* folder_key,
170 REGSAM wow64access);
171
172
162 ~RegistryValueIterator(); 173 ~RegistryValueIterator();
163 174
164 DWORD ValueCount() const; 175 DWORD ValueCount() const;
165 176
166 // True while the iterator is valid. 177 // True while the iterator is valid.
167 bool Valid() const; 178 bool Valid() const;
168 179
169 // Advances to the next registry entry. 180 // Advances to the next registry entry.
170 void operator++(); 181 void operator++();
171 182
172 const wchar_t* Name() const { return name_.c_str(); } 183 const wchar_t* Name() const { return name_.c_str(); }
173 const wchar_t* Value() const { return vector_as_array(&value_); } 184 const wchar_t* Value() const { return vector_as_array(&value_); }
174 // ValueSize() is in bytes. 185 // ValueSize() is in bytes.
175 DWORD ValueSize() const { return value_size_; } 186 DWORD ValueSize() const { return value_size_; }
176 DWORD Type() const { return type_; } 187 DWORD Type() const { return type_; }
177 188
178 int Index() const { return index_; } 189 int Index() const { return index_; }
179 190
180 private: 191 private:
181 // Read in the current values. 192 // Read in the current values.
182 bool Read(); 193 bool Read();
183 194
195 void Initialize(HKEY root_key, const wchar_t* folder_key, REGSAM wow64access);
196
184 // The registry key being iterated. 197 // The registry key being iterated.
185 HKEY key_; 198 HKEY key_;
186 199
187 // Current index of the iteration. 200 // Current index of the iteration.
188 int index_; 201 int index_;
189 202
190 // Current values. 203 // Current values.
191 std::wstring name_; 204 std::wstring name_;
192 std::vector<wchar_t> value_; 205 std::vector<wchar_t> value_;
193 DWORD value_size_; 206 DWORD value_size_;
194 DWORD type_; 207 DWORD type_;
195 208
196 DISALLOW_COPY_AND_ASSIGN(RegistryValueIterator); 209 DISALLOW_COPY_AND_ASSIGN(RegistryValueIterator);
197 }; 210 };
198 211
199 class BASE_EXPORT RegistryKeyIterator { 212 class BASE_EXPORT RegistryKeyIterator {
200 public: 213 public:
214 // Construct a Registry Key Iterator with default WOW64 access.
201 RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key); 215 RegistryKeyIterator(HKEY root_key, const wchar_t* folder_key);
202 216
217 // Construct a Registry Value Iterator with specific WOW64 access, one of
218 // KEY_WOW64_32KEY or KEY_WOW64_64KEY, or 0.
219 // Note: |wow64access| should be the same access used to open |root_key|
220 // previously, or a predefined key (e.g. HKEY_LOCAL_MACHINE).
221 // See http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129.aspx.
222 RegistryKeyIterator(HKEY root_key,
223 const wchar_t* folder_key,
224 REGSAM wow64access);
225
203 ~RegistryKeyIterator(); 226 ~RegistryKeyIterator();
204 227
205 DWORD SubkeyCount() const; 228 DWORD SubkeyCount() const;
206 229
207 // True while the iterator is valid. 230 // True while the iterator is valid.
208 bool Valid() const; 231 bool Valid() const;
209 232
210 // Advances to the next entry in the folder. 233 // Advances to the next entry in the folder.
211 void operator++(); 234 void operator++();
212 235
213 const wchar_t* Name() const { return name_; } 236 const wchar_t* Name() const { return name_; }
214 237
215 int Index() const { return index_; } 238 int Index() const { return index_; }
216 239
217 private: 240 private:
218 // Read in the current values. 241 // Read in the current values.
219 bool Read(); 242 bool Read();
220 243
244 void Initialize(HKEY root_key, const wchar_t* folder_key, REGSAM wow64access);
245
221 // The registry key being iterated. 246 // The registry key being iterated.
222 HKEY key_; 247 HKEY key_;
223 248
224 // Current index of the iteration. 249 // Current index of the iteration.
225 int index_; 250 int index_;
226 251
227 wchar_t name_[MAX_PATH]; 252 wchar_t name_[MAX_PATH];
228 253
229 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); 254 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator);
230 }; 255 };
231 256
232 } // namespace win 257 } // namespace win
233 } // namespace base 258 } // namespace base
234 259
235 #endif // BASE_WIN_REGISTRY_H_ 260 #endif // BASE_WIN_REGISTRY_H_
OLDNEW
« no previous file with comments | « no previous file | base/win/registry.cc » ('j') | base/win/registry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698