|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 #ifndef BASE_WIN_UTIL_H__ |
|
6 #define BASE_WIN_UTIL_H__ |
|
7 |
|
8 #include <windows.h> |
|
9 #include <aclapi.h> |
|
10 |
|
11 #include <string> |
|
12 |
|
13 #include "base/tracked.h" |
|
14 |
|
15 namespace win_util { |
|
16 |
|
17 // NOTE: Keep these in order so callers can do things like |
|
18 // "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, |
|
19 // though. |
|
20 enum WinVersion { |
|
21 WINVERSION_PRE_2000 = 0, // Not supported |
|
22 WINVERSION_2000 = 1, |
|
23 WINVERSION_XP = 2, |
|
24 WINVERSION_SERVER_2003 = 3, |
|
25 WINVERSION_VISTA = 4, |
|
26 WINVERSION_2008 = 5, |
|
27 WINVERSION_WIN7 = 6 |
|
28 }; |
|
29 |
|
30 // Returns the running version of Windows. |
|
31 WinVersion GetWinVersion(); |
|
32 |
|
33 // Returns true if the shift key is currently pressed. |
|
34 bool IsShiftPressed(); |
|
35 |
|
36 // Returns true if the ctrl key is currently pressed. |
|
37 bool IsCtrlPressed(); |
|
38 |
|
39 // Returns true if the alt key is currently pressed. |
|
40 bool IsAltPressed(); |
|
41 |
|
42 // Use the Win32 API FormatMessage() function to generate a string, using |
|
43 // Windows's default Message Compiled resources; ignoring the inserts. |
|
44 std::wstring FormatMessage(unsigned messageid); |
|
45 |
|
46 // Uses the last Win32 error to generate a human readable message string. |
|
47 std::wstring FormatLastWin32Error(); |
|
48 |
|
49 } // namespace win_util |
|
50 |
|
51 #endif // BASE_WIN_UTIL_H__ |