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

Side by Side Diff: base/win_util.h

Issue 3823002: Move windows version-related stuff out of base/win_util and into base/win/win... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 #ifndef BASE_WIN_UTIL_H__ 5 #ifndef BASE_WIN_UTIL_H__
6 #define BASE_WIN_UTIL_H__ 6 #define BASE_WIN_UTIL_H__
7 #pragma once 7 #pragma once
8 8
9 #include <windows.h> 9 #include <windows.h>
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/string16.h" 13 #include "base/string16.h"
14 14
15 struct IPropertyStore; 15 struct IPropertyStore;
16 struct _tagpropertykey; 16 struct _tagpropertykey;
17 typedef _tagpropertykey PROPERTYKEY; 17 typedef _tagpropertykey PROPERTYKEY;
18 18
19 namespace win_util { 19 namespace win_util {
20 20
21 // NOTE: Keep these in order so callers can do things like 21 void GetNonClientMetrics(NONCLIENTMETRICS* metrics);
22 // "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, 22
23 // though. 23 // TODO(brettw) remove this once RLZ is updated to use the new version in
24 // base/win/windows_version.h.
25 #if defined(RLZ_WIN_LIB_LIB_MUTEX_H_) || defined(RLZ_WIN_LIB_USER_KEY_H_) \
26 || defined(RLZ_WIN_LIB_PROCESS_INFO_H_)
27 #include "base/win/windows_version.h"
28 // These must match the values in base::win!
24 enum WinVersion { 29 enum WinVersion {
25 WINVERSION_PRE_2000 = 0, // Not supported 30 WINVERSION_PRE_2000 = 0, // Not supported
26 WINVERSION_2000 = 1, // Not supported 31 WINVERSION_2000 = 1, // Not supported
27 WINVERSION_XP = 2, 32 WINVERSION_XP = 2,
28 WINVERSION_SERVER_2003 = 3, 33 WINVERSION_SERVER_2003 = 3,
29 WINVERSION_VISTA = 4, 34 WINVERSION_VISTA = 4,
30 WINVERSION_2008 = 5, 35 WINVERSION_2008 = 5,
31 WINVERSION_WIN7 = 6, 36 WINVERSION_WIN7 = 6,
32 }; 37 };
33 38 inline WinVersion GetWinVersion() {
34 // Property key for System.AppUserModel.ID. 39 return static_cast<WinVersion>(base::win::GetVersion());
35 // <http://msdn.microsoft.com/en-us/library/dd391569(VS.85).aspx> 40 }
36 // TODO(xiyuan): Remove this once we compile with Win7 SDK. 41 #endif // RLZ_*
37 extern const PROPERTYKEY kPKEYAppUserModelID;
38
39 void GetNonClientMetrics(NONCLIENTMETRICS* metrics);
40
41 // Returns the running version of Windows.
42 WinVersion GetWinVersion();
43
44 // Returns the major and minor version of the service pack installed.
45 void GetServicePackLevel(int* major, int* minor);
46
47 // Adds an ACE in the DACL of the object referenced by handle. The ACE is
48 // granting |access| to the user |known_sid|.
49 // If |known_sid| is WinSelfSid, the sid of the current user will be added to
50 // the DACL.
51 bool AddAccessToKernelObject(HANDLE handle, WELL_KNOWN_SID_TYPE known_sid,
52 ACCESS_MASK access);
53 42
54 // Returns the string representing the current user sid. 43 // Returns the string representing the current user sid.
55 bool GetUserSidString(std::wstring* user_sid); 44 bool GetUserSidString(std::wstring* user_sid);
56 45
57 // Creates a security descriptor with a DACL that has one ace giving full
58 // access to the current logon session.
59 // The security descriptor returned must be freed using LocalFree.
60 // The function returns true if it succeeds, false otherwise.
61 bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor);
62
63 // Useful for subclassing a HWND. Returns the previous window procedure. 46 // Useful for subclassing a HWND. Returns the previous window procedure.
64 WNDPROC SetWindowProc(HWND hwnd, WNDPROC wndproc); 47 WNDPROC SetWindowProc(HWND hwnd, WNDPROC wndproc);
65 48
66 // Returns true if the existing window procedure is the same as |subclass_proc|.
67 bool IsSubclassed(HWND window, WNDPROC subclass_proc);
68
69 // Subclasses a window, replacing its existing window procedure with the
70 // specified one. Returns true if the current window procedure was replaced,
71 // false if the window has already been subclassed with the specified
72 // subclass procedure.
73 bool Subclass(HWND window, WNDPROC subclass_proc);
74
75 // Unsubclasses a window subclassed using Subclass. Returns true if
76 // the window was subclassed with the specified |subclass_proc| and the window
77 // was successfully unsubclassed, false if the window's window procedure is not
78 // |subclass_proc|.
79 bool Unsubclass(HWND window, WNDPROC subclass_proc);
80
81 // Retrieves the original WNDPROC of a window subclassed using
82 // SubclassWindow.
83 WNDPROC GetSuperclassWNDPROC(HWND window);
84
85 // Pointer-friendly wrappers around Get/SetWindowLong(..., GWLP_USERDATA, ...) 49 // Pointer-friendly wrappers around Get/SetWindowLong(..., GWLP_USERDATA, ...)
86 // Returns the previously set value. 50 // Returns the previously set value.
87 void* SetWindowUserData(HWND hwnd, void* user_data); 51 void* SetWindowUserData(HWND hwnd, void* user_data);
88 void* GetWindowUserData(HWND hwnd); 52 void* GetWindowUserData(HWND hwnd);
89 53
90 // Returns true if the shift key is currently pressed. 54 // Returns true if the shift key is currently pressed.
91 bool IsShiftPressed(); 55 bool IsShiftPressed();
92 56
93 // Returns true if the ctrl key is currently pressed. 57 // Returns true if the ctrl key is currently pressed.
94 bool IsCtrlPressed(); 58 bool IsCtrlPressed();
(...skipping 30 matching lines...) Expand all
125 // |root_key| could be HKCU or HKLM or the root of any user hive. 89 // |root_key| could be HKCU or HKLM or the root of any user hive.
126 bool AddCommandToAutoRun(HKEY root_key, const string16& name, 90 bool AddCommandToAutoRun(HKEY root_key, const string16& name,
127 const string16& command); 91 const string16& command);
128 // Removes the command specified by |name| from the AutoRun key. |root_key| 92 // Removes the command specified by |name| from the AutoRun key. |root_key|
129 // could be HKCU or HKLM or the root of any user hive. 93 // could be HKCU or HKLM or the root of any user hive.
130 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name); 94 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name);
131 95
132 } // namespace win_util 96 } // namespace win_util
133 97
134 #endif // BASE_WIN_UTIL_H__ 98 #endif // BASE_WIN_UTIL_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698