| OLD | NEW |
| 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 void GetNonClientMetrics(NONCLIENTMETRICS* metrics); | 21 void GetNonClientMetrics(NONCLIENTMETRICS* metrics); |
| 22 | 22 |
| 23 // Returns the string representing the current user sid. | 23 // Returns the string representing the current user sid. |
| 24 bool GetUserSidString(std::wstring* user_sid); | 24 bool GetUserSidString(std::wstring* user_sid); |
| 25 | 25 |
| 26 // Useful for subclassing a HWND. Returns the previous window procedure. | |
| 27 WNDPROC SetWindowProc(HWND hwnd, WNDPROC wndproc); | |
| 28 | |
| 29 // Pointer-friendly wrappers around Get/SetWindowLong(..., GWLP_USERDATA, ...) | |
| 30 // Returns the previously set value. | |
| 31 void* SetWindowUserData(HWND hwnd, void* user_data); | |
| 32 void* GetWindowUserData(HWND hwnd); | |
| 33 | |
| 34 // Returns true if the shift key is currently pressed. | 26 // Returns true if the shift key is currently pressed. |
| 35 bool IsShiftPressed(); | 27 bool IsShiftPressed(); |
| 36 | 28 |
| 37 // Returns true if the ctrl key is currently pressed. | 29 // Returns true if the ctrl key is currently pressed. |
| 38 bool IsCtrlPressed(); | 30 bool IsCtrlPressed(); |
| 39 | 31 |
| 40 // Returns true if the alt key is currently pressed. | 32 // Returns true if the alt key is currently pressed. |
| 41 bool IsAltPressed(); | 33 bool IsAltPressed(); |
| 42 | 34 |
| 43 // A version of the GetClassNameW API that returns the class name in an | |
| 44 // std::wstring. An empty result indicates a failure to get the class name. | |
| 45 std::wstring GetClassName(HWND window); | |
| 46 | |
| 47 // Returns false if user account control (UAC) has been disabled with the | 35 // Returns false if user account control (UAC) has been disabled with the |
| 48 // EnableLUA registry flag. Returns true if user account control is enabled. | 36 // EnableLUA registry flag. Returns true if user account control is enabled. |
| 49 // NOTE: The EnableLUA registry flag, which is ignored on Windows XP | 37 // NOTE: The EnableLUA registry flag, which is ignored on Windows XP |
| 50 // machines, might still exist and be set to 0 (UAC disabled), in which case | 38 // machines, might still exist and be set to 0 (UAC disabled), in which case |
| 51 // this function will return false. You should therefore check this flag only | 39 // this function will return false. You should therefore check this flag only |
| 52 // if the OS is Vista. | 40 // if the OS is Vista. |
| 53 bool UserAccountControlIsEnabled(); | 41 bool UserAccountControlIsEnabled(); |
| 54 | 42 |
| 55 // Use the Win32 API FormatMessage() function to generate a string, using | |
| 56 // Windows's default Message Compiled resources; ignoring the inserts. | |
| 57 std::wstring FormatMessage(unsigned messageid); | |
| 58 | |
| 59 // Uses the last Win32 error to generate a human readable message string. | |
| 60 std::wstring FormatLastWin32Error(); | |
| 61 | |
| 62 // Sets the application id in given IPropertyStore. The function is intended | 43 // Sets the application id in given IPropertyStore. The function is intended |
| 63 // for tagging application/chromium shortcut, browser window and jump list for | 44 // for tagging application/chromium shortcut, browser window and jump list for |
| 64 // Win7. | 45 // Win7. |
| 65 bool SetAppIdForPropertyStore(IPropertyStore* property_store, | 46 bool SetAppIdForPropertyStore(IPropertyStore* property_store, |
| 66 const wchar_t* app_id); | 47 const wchar_t* app_id); |
| 67 | 48 |
| 68 // Adds the specified |command| using the specified |name| to the AutoRun key. | 49 // Adds the specified |command| using the specified |name| to the AutoRun key. |
| 69 // |root_key| could be HKCU or HKLM or the root of any user hive. | 50 // |root_key| could be HKCU or HKLM or the root of any user hive. |
| 70 bool AddCommandToAutoRun(HKEY root_key, const string16& name, | 51 bool AddCommandToAutoRun(HKEY root_key, const string16& name, |
| 71 const string16& command); | 52 const string16& command); |
| 72 // Removes the command specified by |name| from the AutoRun key. |root_key| | 53 // Removes the command specified by |name| from the AutoRun key. |root_key| |
| 73 // could be HKCU or HKLM or the root of any user hive. | 54 // could be HKCU or HKLM or the root of any user hive. |
| 74 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name); | 55 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name); |
| 75 | 56 |
| 76 } // namespace win_util | 57 } // namespace win_util |
| 77 | 58 |
| 78 #endif // BASE_WIN_UTIL_H_ | 59 #endif // BASE_WIN_UTIL_H_ |
| OLD | NEW |