Enable MSVC warning for unused locals.
[chromium-blink-merge.git] / chrome / installer / util / registry_key_backup.h
blob68f29c336ea8a4e8b573b9347241af63e374fc3a
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
3 // found in the LICENSE file.
5 #ifndef CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_
6 #define CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_
8 #include <windows.h>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
13 // A container for a registry key, its values, and its subkeys. We don't use
14 // more obvious methods for various reasons:
15 // - RegCopyTree isn't supported pre-Vista, so we'd have to do something
16 // different for XP anyway.
17 // - SHCopyKey can't copy subkeys into a volatile destination, so we'd have to
18 // worry about polluting the registry.
19 // We don't persist security attributes since we only delete keys that we own,
20 // and we don't set custom attributes on them anyway.
21 class RegistryKeyBackup {
22 public:
23 RegistryKeyBackup();
24 ~RegistryKeyBackup();
26 // Recursively reads |key_path| into this instance. Backing up a non-existent
27 // key is valid. Returns true if the backup was successful; false otherwise,
28 // in which case the state of this instance is not modified.
29 bool Initialize(HKEY root, const wchar_t* key_path, REGSAM wow64_acccess);
31 // Writes the contents of this instance into |key|. The contents of
32 // |key_path| are not modified If this instance is uninitialized or was
33 // initialized from a non-existent key.
34 bool WriteTo(HKEY root, const wchar_t* key_path, REGSAM wow64_acccess) const;
36 void swap(RegistryKeyBackup& other) {
37 key_data_.swap(other.key_data_);
40 private:
41 class KeyData;
43 // The values and subkeys of the backed-up key.
44 scoped_ptr<KeyData> key_data_;
46 DISALLOW_COPY_AND_ASSIGN(RegistryKeyBackup);
49 #endif // CHROME_INSTALLER_UTIL_REGISTRY_KEY_BACKUP_H_