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

Side by Side Diff: base/win/win_util.cc

Issue 6090006: Regkey functions return error code instead of bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "base/win/win_util.h" 5 #include "base/win/win_util.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 #include <shobjidl.h> // Must be before propkey. 8 #include <shobjidl.h> // Must be before propkey.
9 #include <propkey.h> 9 #include <propkey.h>
10 #include <propvarutil.h> 10 #include <propvarutil.h>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool UserAccountControlIsEnabled() { 86 bool UserAccountControlIsEnabled() {
87 // This can be slow if Windows ends up going to disk. Should watch this key 87 // This can be slow if Windows ends up going to disk. Should watch this key
88 // for changes and only read it once, preferably on the file thread. 88 // for changes and only read it once, preferably on the file thread.
89 // http://code.google.com/p/chromium/issues/detail?id=61644 89 // http://code.google.com/p/chromium/issues/detail?id=61644
90 base::ThreadRestrictions::ScopedAllowIO allow_io; 90 base::ThreadRestrictions::ScopedAllowIO allow_io;
91 91
92 base::win::RegKey key(HKEY_LOCAL_MACHINE, 92 base::win::RegKey key(HKEY_LOCAL_MACHINE,
93 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 93 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
94 KEY_READ); 94 KEY_READ);
95 DWORD uac_enabled; 95 DWORD uac_enabled;
96 if (!key.ReadValueDW(L"EnableLUA", &uac_enabled)) 96 if (key.ReadValueDW(L"EnableLUA", &uac_enabled) != ERROR_SUCCESS)
97 return true; 97 return true;
98 // Users can set the EnableLUA value to something arbitrary, like 2, which 98 // Users can set the EnableLUA value to something arbitrary, like 2, which
99 // Vista will treat as UAC enabled, so we make sure it is not set to 0. 99 // Vista will treat as UAC enabled, so we make sure it is not set to 0.
100 return (uac_enabled != 0); 100 return (uac_enabled != 0);
101 } 101 }
102 102
103 bool SetAppIdForPropertyStore(IPropertyStore* property_store, 103 bool SetAppIdForPropertyStore(IPropertyStore* property_store,
104 const wchar_t* app_id) { 104 const wchar_t* app_id) {
105 DCHECK(property_store); 105 DCHECK(property_store);
106 106
(...skipping 14 matching lines...) Expand all
121 PropVariantClear(&property_value); 121 PropVariantClear(&property_value);
122 return SUCCEEDED(result); 122 return SUCCEEDED(result);
123 } 123 }
124 124
125 static const char16 kAutoRunKeyPath[] = 125 static const char16 kAutoRunKeyPath[] =
126 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; 126 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
127 127
128 bool AddCommandToAutoRun(HKEY root_key, const string16& name, 128 bool AddCommandToAutoRun(HKEY root_key, const string16& name,
129 const string16& command) { 129 const string16& command) {
130 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); 130 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE);
131 return autorun_key.WriteValue(name.c_str(), command.c_str()); 131 LONG result = autorun_key.WriteValue(name.c_str(), command.c_str());
132 return (result == ERROR_SUCCESS);
132 } 133 }
133 134
134 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) { 135 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) {
135 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); 136 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE);
136 return autorun_key.DeleteValue(name.c_str()); 137 return (autorun_key.DeleteValue(name.c_str()) == ERROR_SUCCESS);
137 } 138 }
138 139
139 } // namespace win 140 } // namespace win
140 } // namespace base 141 } // namespace base
141 142
142 #ifdef _MSC_VER 143 #ifdef _MSC_VER
143 // 144 //
144 // If the ASSERT below fails, please install Visual Studio 2005 Service Pack 1. 145 // If the ASSERT below fails, please install Visual Studio 2005 Service Pack 1.
145 // 146 //
146 extern char VisualStudio2005ServicePack1Detection[10]; 147 extern char VisualStudio2005ServicePack1Detection[10];
147 COMPILE_ASSERT(sizeof(&VisualStudio2005ServicePack1Detection) == sizeof(void*), 148 COMPILE_ASSERT(sizeof(&VisualStudio2005ServicePack1Detection) == sizeof(void*),
148 VS2005SP1Detect); 149 VS2005SP1Detect);
149 // 150 //
150 // Chrome requires at least Service Pack 1 for Visual Studio 2005. 151 // Chrome requires at least Service Pack 1 for Visual Studio 2005.
151 // 152 //
152 #endif // _MSC_VER 153 #endif // _MSC_VER
153 154
154 #ifndef COPY_FILE_COPY_SYMLINK 155 #ifndef COPY_FILE_COPY_SYMLINK
155 #error You must install the Windows 2008 or Vista Software Development Kit and \ 156 #error You must install the Windows 2008 or Vista Software Development Kit and \
156 set it as your default include path to build this library. You can grab it by \ 157 set it as your default include path to build this library. You can grab it by \
157 searching for "download windows sdk 2008" in your favorite web search engine. \ 158 searching for "download windows sdk 2008" in your favorite web search engine. \
158 Also make sure you register the SDK with Visual Studio, by selecting \ 159 Also make sure you register the SDK with Visual Studio, by selecting \
159 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ 160 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \
160 menu (see Start - All Programs - Microsoft Windows SDK - \ 161 menu (see Start - All Programs - Microsoft Windows SDK - \
161 Visual Studio Registration). 162 Visual Studio Registration).
162 #endif 163 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698