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

Side by Side Diff: base/win/windows_version.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_WINDOWS_VERSION_H_
6 #define BASE_WIN_UTIL_H__ 6 #define BASE_WIN_WINDOWS_VERSION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <windows.h> 9 namespace base {
10 10 namespace win {
11 #include <string>
12
13 #include "base/string16.h"
14
15 struct IPropertyStore;
16 struct _tagpropertykey;
17 typedef _tagpropertykey PROPERTYKEY;
18
19 namespace win_util {
20 11
21 // NOTE: Keep these in order so callers can do things like 12 // NOTE: Keep these in order so callers can do things like
22 // "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, 13 // "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values,
23 // though. 14 // though.
24 enum WinVersion { 15 enum Version {
25 WINVERSION_PRE_2000 = 0, // Not supported 16 VERSION_PRE_2000 = 0, // Not supported
26 WINVERSION_2000 = 1, // Not supported 17 VERSION_2000 = 1, // Not supported
27 WINVERSION_XP = 2, 18 VERSION_XP = 2,
28 WINVERSION_SERVER_2003 = 3, 19 VERSION_SERVER_2003 = 3,
29 WINVERSION_VISTA = 4, 20 VERSION_VISTA = 4,
30 WINVERSION_2008 = 5, 21 VERSION_2008 = 5,
31 WINVERSION_WIN7 = 6, 22 VERSION_WIN7 = 6,
32 }; 23 };
33 24
34 // Property key for System.AppUserModel.ID.
35 // <http://msdn.microsoft.com/en-us/library/dd391569(VS.85).aspx>
36 // TODO(xiyuan): Remove this once we compile with Win7 SDK.
37 extern const PROPERTYKEY kPKEYAppUserModelID;
38
39 void GetNonClientMetrics(NONCLIENTMETRICS* metrics);
40
41 // Returns the running version of Windows. 25 // Returns the running version of Windows.
42 WinVersion GetWinVersion(); 26 Version GetVersion();
43 27
44 // Returns the major and minor version of the service pack installed. 28 // Returns the major and minor version of the service pack installed.
45 void GetServicePackLevel(int* major, int* minor); 29 void GetServicePackLevel(int* major, int* minor);
46 30
47 // Adds an ACE in the DACL of the object referenced by handle. The ACE is 31 } // namespace win
48 // granting |access| to the user |known_sid|. 32 } // namespace base
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 33
54 // Returns the string representing the current user sid. 34 #endif // BASE_WIN_WINDOWS_VERSION_H_
55 bool GetUserSidString(std::wstring* user_sid);
56
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.
64 WNDPROC SetWindowProc(HWND hwnd, WNDPROC wndproc);
65
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, ...)
86 // Returns the previously set value.
87 void* SetWindowUserData(HWND hwnd, void* user_data);
88 void* GetWindowUserData(HWND hwnd);
89
90 // Returns true if the shift key is currently pressed.
91 bool IsShiftPressed();
92
93 // Returns true if the ctrl key is currently pressed.
94 bool IsCtrlPressed();
95
96 // Returns true if the alt key is currently pressed.
97 bool IsAltPressed();
98
99 // A version of the GetClassNameW API that returns the class name in an
100 // std::wstring. An empty result indicates a failure to get the class name.
101 std::wstring GetClassName(HWND window);
102
103 // Returns false if user account control (UAC) has been disabled with the
104 // EnableLUA registry flag. Returns true if user account control is enabled.
105 // NOTE: The EnableLUA registry flag, which is ignored on Windows XP
106 // machines, might still exist and be set to 0 (UAC disabled), in which case
107 // this function will return false. You should therefore check this flag only
108 // if the OS is Vista.
109 bool UserAccountControlIsEnabled();
110
111 // Use the Win32 API FormatMessage() function to generate a string, using
112 // Windows's default Message Compiled resources; ignoring the inserts.
113 std::wstring FormatMessage(unsigned messageid);
114
115 // Uses the last Win32 error to generate a human readable message string.
116 std::wstring FormatLastWin32Error();
117
118 // Sets the application id in given IPropertyStore. The function is intended
119 // for tagging application/chromium shortcut, browser window and jump list for
120 // Win7.
121 bool SetAppIdForPropertyStore(IPropertyStore* property_store,
122 const wchar_t* app_id);
123
124 // Adds the specified |command| using the specified |name| to the AutoRun key.
125 // |root_key| could be HKCU or HKLM or the root of any user hive.
126 bool AddCommandToAutoRun(HKEY root_key, const string16& name,
127 const string16& command);
128 // 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.
130 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name);
131
132 } // namespace win_util
133
134 #endif // BASE_WIN_UTIL_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698