diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 02:31:32 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 02:31:32 +0000 |
commit | a7357eebfa9cdcc290905d09e60b1a1ce462f1f6 (patch) | |
tree | 520ab60a64ef3ca3124aa3a5f32131fa7b801407 /base | |
parent | a7b716fd5b82f2f08c0942daa094c64eb751453e (diff) | |
download | chromium_src-a7357eebfa9cdcc290905d09e60b1a1ce462f1f6.zip chromium_src-a7357eebfa9cdcc290905d09e60b1a1ce462f1f6.tar.gz chromium_src-a7357eebfa9cdcc290905d09e60b1a1ce462f1f6.tar.bz2 |
Make DeleteKey support GetLastError.
When SHDeleteKey returns, the last error value hasn't been set.
With this change, it's possible to have checks like:
if (!key.DeleteKey(...) && GetLastError() != ERROR_NOT_FOUND) {
HandleErrorCase();
return false;
}
return true;
As it stands, the last error value will always be ERROR_SUCCESS, which is not all that useful.
In fact there is code in the installer that attempts to do this, but doesn't currently work correctly (also because it's checking for the wrong GLE value, but I'm fixing that in a separate change).
BUG=none
TEST=Should have no side effects.
Review URL: http://codereview.chromium.org/5182009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67049 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/win/registry.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/base/win/registry.cc b/base/win/registry.cc index 977ea00..3372cf4 100644 --- a/base/win/registry.cc +++ b/base/win/registry.cc @@ -357,7 +357,12 @@ bool RegKey::WriteValue(const wchar_t* name, DWORD value) { bool RegKey::DeleteKey(const wchar_t* name) { base::ThreadRestrictions::AssertIOAllowed(); - return (!key_) ? false : (ERROR_SUCCESS == SHDeleteKey(key_, name)); + if (!key_) + return false; + LSTATUS ret = SHDeleteKey(key_, name); + if (ERROR_SUCCESS != ret) + SetLastError(ret); + return ERROR_SUCCESS == ret; } bool RegKey::DeleteValue(const wchar_t* value_name) { |