summaryrefslogtreecommitdiffstats
path: root/base/win_util.cc
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-10-19 14:37:37 +0100
committerIain Merrick <husky@google.com>2010-10-19 14:37:37 +0100
commit3345a6884c488ff3a535c2c9acdd33d74b37e311 (patch)
tree7784b988ef1698cb6967ea1bdf07616237716c6c /base/win_util.cc
parentefc8475837ec58186051f23bb03542620424f6ce (diff)
downloadexternal_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.zip
external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.gz
external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.bz2
Merge Chromium at 7.0.540.0 : Initial merge by git
Not including third_party/icu as it contains huge data files that break Gerrit, and aren't actually used. Change-Id: I428a386e70f3b58cacd28677b8cfda282e891e15
Diffstat (limited to 'base/win_util.cc')
-rw-r--r--base/win_util.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/base/win_util.cc b/base/win_util.cc
index 12cf241..b87e441 100644
--- a/base/win_util.cc
+++ b/base/win_util.cc
@@ -1,17 +1,20 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/win_util.h"
+#include <aclapi.h>
#include <propvarutil.h>
#include <sddl.h>
+#include <shlobj.h>
#include "base/logging.h"
#include "base/registry.h"
#include "base/scoped_handle.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
+#include "base/stringprintf.h"
namespace win_util {
@@ -350,7 +353,8 @@ std::wstring GetClassName(HWND window) {
bool UserAccountControlIsEnabled() {
RegKey key(HKEY_LOCAL_MACHINE,
- L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
+ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
+ KEY_READ);
DWORD uac_enabled;
if (!key.ReadValueDW(L"EnableLUA", &uac_enabled))
return true;
@@ -372,7 +376,7 @@ std::wstring FormatMessage(unsigned messageid) {
LocalFree(reinterpret_cast<HLOCAL>(string_buffer));
} else {
// The formating failed. simply convert the message value into a string.
- SStringPrintf(&formatted_string, L"message number %d", messageid);
+ base::SStringPrintf(&formatted_string, L"message number %d", messageid);
}
return formatted_string;
}
@@ -381,14 +385,6 @@ std::wstring FormatLastWin32Error() {
return FormatMessage(GetLastError());
}
-WORD KeyboardCodeToWin(base::KeyboardCode keycode) {
- return static_cast<WORD>(keycode);
-}
-
-base::KeyboardCode WinToKeyboardCode(WORD keycode) {
- return static_cast<base::KeyboardCode>(keycode);
-}
-
bool SetAppIdForPropertyStore(IPropertyStore* property_store,
const wchar_t* app_id) {
DCHECK(property_store);
@@ -411,6 +407,20 @@ bool SetAppIdForPropertyStore(IPropertyStore* property_store,
return SUCCEEDED(result);
}
+static const char16 kAutoRunKeyPath[] =
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
+
+bool AddCommandToAutoRun(HKEY root_key, const string16& name,
+ const string16& command) {
+ RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE);
+ return autorun_key.WriteValue(name.c_str(), command.c_str());
+}
+
+bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) {
+ RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE);
+ return autorun_key.DeleteValue(name.c_str());
+}
+
} // namespace win_util
#ifdef _MSC_VER