| OLD | NEW |
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |