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

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

Issue 275103012: Add WOW64 support and DeleteEmptyKey to base::win::registry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar code review changes Created 6 years, 7 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 | Annotate | Revision Log
« 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>
11 11
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 15
16 namespace base { 16 namespace base {
17 namespace win { 17 namespace win {
18 18
19 // Utility class to read, write and manipulate the Windows Registry. 19 // Utility class to read, write and manipulate the Windows Registry.
20 // Registry vocabulary primer: a "key" is like a folder, in which there 20 // Registry vocabulary primer: a "key" is like a folder, in which there
21 // are "values", which are <name, data> pairs, with an associated data type. 21 // are "values", which are <name, data> pairs, with an associated data type.
22 // 22 //
23 // Note: 23 // Note:
24 // ReadValue family of functions guarantee that the return arguments 24 // ReadValue family of functions guarantee that the return arguments
25 // are not touched in case of failure. 25 // are not touched in case of failure.
26 class BASE_EXPORT RegKey { 26 class BASE_EXPORT RegKey {
27 public: 27 public:
28 RegKey(); 28 RegKey();
29 explicit RegKey(HKEY key); 29 explicit RegKey(HKEY key);
grt (UTC plus 2) 2014/05/20 17:46:56 please remove this constructor, the Set() method,
Will Harris 2014/05/20 19:22:40 http://crbug.com/375400 raised, will be done in a
30 RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access); 30 RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access);
31 ~RegKey(); 31 ~RegKey();
32 32
33 LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access); 33 LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access);
34 34
35 LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, 35 LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
36 DWORD* disposition, REGSAM access); 36 DWORD* disposition, REGSAM access);
37 37
38 // Creates a subkey or open it if it already exists. 38 // Creates a subkey or open it if it already exists.
39 LONG CreateKey(const wchar_t* name, REGSAM access); 39 LONG CreateKey(const wchar_t* name, REGSAM access);
(...skipping 24 matching lines...) Expand all
64 // Determine the nth value's name. 64 // Determine the nth value's name.
65 LONG GetValueNameAt(int index, std::wstring* name) const; 65 LONG GetValueNameAt(int index, std::wstring* name) const;
66 66
67 // True while the key is valid. 67 // True while the key is valid.
68 bool Valid() const { return key_ != NULL; } 68 bool Valid() const { return key_ != NULL; }
69 69
70 // Kill a key and everything that live below it; please be careful when using 70 // Kill a key and everything that live below it; please be careful when using
71 // it. 71 // it.
72 LONG DeleteKey(const wchar_t* name); 72 LONG DeleteKey(const wchar_t* name);
73 73
74 // Deletes an empty subkey. If the subkey has subkeys or values then this
75 // will fail.
76 LONG DeleteEmptyKey(const wchar_t* name);
77
74 // Deletes a single value within the key. 78 // Deletes a single value within the key.
75 LONG DeleteValue(const wchar_t* name); 79 LONG DeleteValue(const wchar_t* name);
76 80
77 // Getters: 81 // Getters:
78 82
79 // Returns an int32 value. If |name| is NULL or empty, returns the default 83 // Returns an int32 value. If |name| is NULL or empty, returns the default
80 // value, if any. 84 // value, if any.
81 LONG ReadValueDW(const wchar_t* name, DWORD* out_value) const; 85 LONG ReadValueDW(const wchar_t* name, DWORD* out_value) const;
82 86
83 // Returns an int64 value. If |name| is NULL or empty, returns the default 87 // Returns an int64 value. If |name| is NULL or empty, returns the default
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 129
126 // Will automatically be called by destructor if not manually called 130 // Will automatically be called by destructor if not manually called
127 // beforehand. Returns true if it was watching, false otherwise. 131 // beforehand. Returns true if it was watching, false otherwise.
128 LONG StopWatching(); 132 LONG StopWatching();
129 133
130 inline bool IsWatching() const { return watch_event_ != 0; } 134 inline bool IsWatching() const { return watch_event_ != 0; }
131 HANDLE watch_event() const { return watch_event_; } 135 HANDLE watch_event() const { return watch_event_; }
132 HKEY Handle() const { return key_; } 136 HKEY Handle() const { return key_; }
133 137
134 private: 138 private:
139 // Calls RegDeleteKeyEx on supported platforms, alternatively falls back to
140 // RegDeleteKey.
141 static LONG RegDeleteKeyExWrapper(HKEY hKey,
142 const wchar_t* lpSubKey,
143 REGSAM samDesired,
144 DWORD Reserved);
145
146 // Recursively deletes a key and all of its subkeys.
147 static LONG RegDelRecurse(HKEY root_key,
148 const std::wstring& name,
149 REGSAM access);
135 HKEY key_; // The registry key being iterated. 150 HKEY key_; // The registry key being iterated.
136 HANDLE watch_event_; 151 HANDLE watch_event_;
152 REGSAM wow64access_;
137 153
138 DISALLOW_COPY_AND_ASSIGN(RegKey); 154 DISALLOW_COPY_AND_ASSIGN(RegKey);
139 }; 155 };
140 156
141 // Iterates the entries found in a particular folder on the registry. 157 // Iterates the entries found in a particular folder on the registry.
142 class BASE_EXPORT RegistryValueIterator { 158 class BASE_EXPORT RegistryValueIterator {
143 public: 159 public:
144 RegistryValueIterator(HKEY root_key, const wchar_t* folder_key); 160 RegistryValueIterator(HKEY root_key, const wchar_t* folder_key);
145 161
146 ~RegistryValueIterator(); 162 ~RegistryValueIterator();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 226
211 wchar_t name_[MAX_PATH]; 227 wchar_t name_[MAX_PATH];
212 228
213 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); 229 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator);
214 }; 230 };
215 231
216 } // namespace win 232 } // namespace win
217 } // namespace base 233 } // namespace base
218 234
219 #endif // BASE_WIN_REGISTRY_H_ 235 #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