diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 15:01:12 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 15:01:12 +0000 |
commit | 52a261f59b20e89f8c5936bce642362f8e367b57 (patch) | |
tree | fcc7b3c100caaf43848cd9a241beafc883f93b7d /base/registry.cc | |
parent | 7d926f9072ac496db6df715cc6a6bd5d3f9bd011 (diff) | |
download | chromium_src-52a261f59b20e89f8c5936bce642362f8e367b57.zip chromium_src-52a261f59b20e89f8c5936bce642362f8e367b57.tar.gz chromium_src-52a261f59b20e89f8c5936bce642362f8e367b57.tar.bz2 |
NO CODE CHANGE (except one global std::wstring changed to const wchar_t* const per style compliance).
Preliminary work to enforce new PRESUBMIT.py rules:
- <=80 cols
- no trailing whitespaces
- svn:eol-style=LF
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/registry.cc')
-rw-r--r-- | base/registry.cc | 75 |
1 files changed, 19 insertions, 56 deletions
diff --git a/base/registry.cc b/base/registry.cc index 8e2e5e8..b5e5b32 100644 --- a/base/registry.cc +++ b/base/registry.cc @@ -3,12 +3,12 @@ // found in the LICENSE file. // All Rights Reserved. +#include "base/registry.h" + #include <assert.h> #include <shlwapi.h> #include <windows.h> -#include "base/registry.h" - #pragma comment(lib, "shlwapi.lib") // for SHDeleteKey // local types (see the same declarations in the header file) @@ -20,7 +20,6 @@ // RegistryValueIterator // - RegistryValueIterator::RegistryValueIterator(HKEY root_key, LPCTSTR folder_key) { LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); @@ -52,14 +51,12 @@ bool RegistryValueIterator::Valid() const { return key_ != NULL && index_ >= 0; } - void RegistryValueIterator::operator ++ () { // advance to the next entry in the folder --index_; Read(); } - bool RegistryValueIterator::Read() { if (Valid()) { DWORD ncount = sizeof(name_)/sizeof(*name_); @@ -76,11 +73,11 @@ bool RegistryValueIterator::Read() { return false; } - DWORD RegistryValueIterator::ValueCount() const { DWORD count = 0; - HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count, NULL, NULL, NULL, NULL); + HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, + &count, NULL, NULL, NULL, NULL); if (result != ERROR_SUCCESS) return 0; @@ -88,12 +85,10 @@ DWORD RegistryValueIterator::ValueCount() const { return count; } - // // RegistryKeyIterator // - RegistryKeyIterator::RegistryKeyIterator(HKEY root_key, LPCTSTR folder_key) { LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); @@ -125,14 +120,12 @@ bool RegistryKeyIterator::Valid() const { return key_ != NULL && index_ >= 0; } - void RegistryKeyIterator::operator ++ () { // advance to the next entry in the folder --index_; Read(); } - bool RegistryKeyIterator::Read() { if (Valid()) { DWORD ncount = sizeof(name_)/sizeof(*name_); @@ -147,7 +140,6 @@ bool RegistryKeyIterator::Read() { return false; } - DWORD RegistryKeyIterator::SubkeyCount() const { DWORD count = 0; @@ -160,13 +152,10 @@ DWORD RegistryKeyIterator::SubkeyCount() const { return count; } - // // RegKey // - - RegKey::RegKey(HKEY rootkey, const tchar* subkey, REGSAM access) : key_(NULL), watch_event_(0) { if (rootkey) { @@ -178,8 +167,6 @@ RegKey::RegKey(HKEY rootkey, const tchar* subkey, REGSAM access) else assert(!subkey); } - - void RegKey::Close() { StopWatching(); if (key_) { @@ -188,15 +175,11 @@ void RegKey::Close() { } } - - bool RegKey::Create(HKEY rootkey, const tchar* subkey, REGSAM access) { DWORD disposition_value; return CreateWithDisposition(rootkey, subkey, &disposition_value, access); } - - bool RegKey::CreateWithDisposition(HKEY rootkey, const tchar* subkey, DWORD* disposition, REGSAM access) { assert(rootkey && subkey && access && disposition); @@ -218,8 +201,6 @@ bool RegKey::CreateWithDisposition(HKEY rootkey, const tchar* subkey, else return true; } - - bool RegKey::Open(HKEY rootkey, const tchar* subkey, REGSAM access) { assert(rootkey && subkey && access); this->Close(); @@ -233,8 +214,6 @@ bool RegKey::Open(HKEY rootkey, const tchar* subkey, REGSAM access) { else return true; } - - bool RegKey::CreateKey(const tchar* name, REGSAM access) { assert(name && access); @@ -248,8 +227,6 @@ bool RegKey::CreateKey(const tchar* name, REGSAM access) { return (result == ERROR_SUCCESS); } - - bool RegKey::OpenKey(const tchar* name, REGSAM access) { assert(name && access); @@ -262,9 +239,6 @@ bool RegKey::OpenKey(const tchar* name, REGSAM access) { return (result == ERROR_SUCCESS); } - - - DWORD RegKey::ValueCount() { DWORD count = 0; HRESULT const result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, @@ -272,7 +246,6 @@ DWORD RegKey::ValueCount() { return (result != ERROR_SUCCESS) ? 0 : count; } - bool RegKey::ReadName(int index, tstr* name) { tchar buf[256]; DWORD bufsize = sizeof(buf)/sizeof(*buf); @@ -285,15 +258,12 @@ bool RegKey::ReadName(int index, tstr* name) { return true; } - bool RegKey::ValueExists(const tchar* name) { if (!key_) return false; const HRESULT result = RegQueryValueEx(key_, name, 0, NULL, NULL, NULL); return (result == ERROR_SUCCESS); } - - bool RegKey::ReadValue(const tchar* name, void* data, DWORD* dsize, DWORD* dtype) { if (!key_) return false; @@ -303,8 +273,6 @@ bool RegKey::ReadValue(const tchar* name, void* data, return (result == ERROR_SUCCESS); } - - bool RegKey::ReadValue(const tchar* name, tstr * value) { assert(value); static const size_t kMaxStringLength = 1024; // This is after expansion. @@ -332,8 +300,6 @@ bool RegKey::ReadValue(const tchar* name, tstr * value) { else return false; } - - bool RegKey::ReadValueDW(const tchar* name, DWORD * value) { assert(value); DWORD type = REG_DWORD, size = sizeof(DWORD), result = 0; @@ -346,33 +312,32 @@ bool RegKey::ReadValueDW(const tchar* name, DWORD * value) { else return false; } - - -bool RegKey::WriteValue(const tchar* name, const void * data, DWORD dsize, DWORD dtype) { +bool RegKey::WriteValue(const tchar* name, + const void * data, + DWORD dsize, + DWORD dtype) { assert(data); if (!key_) return false; - HRESULT const result = RegSetValueEx(key_, name, 0, - dtype, - reinterpret_cast<LPBYTE>(const_cast<void*>(data)), - dsize); + HRESULT const result = RegSetValueEx( + key_, + name, + 0, + dtype, + reinterpret_cast<LPBYTE>(const_cast<void*>(data)), + dsize); return (result == ERROR_SUCCESS); } - - bool RegKey::WriteValue(const tchar * name, const tchar * value) { return this->WriteValue(name, value, static_cast<DWORD>(sizeof(*value) * (_tcslen(value) + 1)), REG_SZ); } - bool RegKey::WriteValue(const tchar * name, DWORD value) { return this->WriteValue(name, &value, static_cast<DWORD>(sizeof(value)), REG_DWORD); } - - bool RegKey::DeleteKey(const tchar * name) { if (!key_) return false; return (ERROR_SUCCESS == SHDeleteKey(key_, name)); @@ -428,9 +393,10 @@ bool RegKey::HasChanged() { return false; } - // Register a COM object with the most usual properties. -bool RegisterCOMServer(const tchar* guid, const tchar* name, const tchar* path) { +bool RegisterCOMServer(const tchar* guid, + const tchar* name, + const tchar* path) { RegKey key(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_WRITE); key.CreateKey(guid, KEY_WRITE); key.WriteValue(NULL, name); @@ -438,7 +404,7 @@ bool RegisterCOMServer(const tchar* guid, const tchar* name, const tchar* path) key.WriteValue(NULL, path); key.WriteValue(_T("ThreadingModel"), _T("Apartment")); return true; -}; +} bool RegisterCOMServer(const tchar* guid, const tchar* name, HINSTANCE module) { tchar module_path[MAX_PATH]; @@ -452,6 +418,3 @@ bool UnregisterCOMServer(const tchar* guid) { key.DeleteKey(guid); return true; } - -// LocalWords: RegKey - |