| 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 #include "base/win_util.h" | 5 #include "base/win_util.h" |
| 6 | 6 |
| 7 #include <propvarutil.h> | 7 #include <propvarutil.h> |
| 8 #include <sddl.h> | 8 #include <sddl.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/registry.h" | 11 #include "base/registry.h" |
| 12 #include "base/scoped_handle.h" | 12 #include "base/scoped_handle.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/string_util.h" | 14 #include "base/stringprintf.h" |
| 15 | 15 |
| 16 namespace win_util { | 16 namespace win_util { |
| 17 | 17 |
| 18 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ | 18 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ |
| 19 offsetof(struct_name, member) + \ | 19 offsetof(struct_name, member) + \ |
| 20 (sizeof static_cast<struct_name*>(NULL)->member) | 20 (sizeof static_cast<struct_name*>(NULL)->member) |
| 21 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ | 21 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ |
| 22 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) | 22 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) |
| 23 | 23 |
| 24 const PROPERTYKEY kPKEYAppUserModelID = | 24 const PROPERTYKEY kPKEYAppUserModelID = |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | | 366 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | |
| 367 FORMAT_MESSAGE_IGNORE_INSERTS, NULL, messageid, 0, | 367 FORMAT_MESSAGE_IGNORE_INSERTS, NULL, messageid, 0, |
| 368 reinterpret_cast<wchar_t *>(&string_buffer), 0, NULL); | 368 reinterpret_cast<wchar_t *>(&string_buffer), 0, NULL); |
| 369 | 369 |
| 370 std::wstring formatted_string; | 370 std::wstring formatted_string; |
| 371 if (string_buffer) { | 371 if (string_buffer) { |
| 372 formatted_string = string_buffer; | 372 formatted_string = string_buffer; |
| 373 LocalFree(reinterpret_cast<HLOCAL>(string_buffer)); | 373 LocalFree(reinterpret_cast<HLOCAL>(string_buffer)); |
| 374 } else { | 374 } else { |
| 375 // The formating failed. simply convert the message value into a string. | 375 // The formating failed. simply convert the message value into a string. |
| 376 SStringPrintf(&formatted_string, L"message number %d", messageid); | 376 base::SStringPrintf(&formatted_string, L"message number %d", messageid); |
| 377 } | 377 } |
| 378 return formatted_string; | 378 return formatted_string; |
| 379 } | 379 } |
| 380 | 380 |
| 381 std::wstring FormatLastWin32Error() { | 381 std::wstring FormatLastWin32Error() { |
| 382 return FormatMessage(GetLastError()); | 382 return FormatMessage(GetLastError()); |
| 383 } | 383 } |
| 384 | 384 |
| 385 WORD KeyboardCodeToWin(base::KeyboardCode keycode) { | 385 WORD KeyboardCodeToWin(base::KeyboardCode keycode) { |
| 386 return static_cast<WORD>(keycode); | 386 return static_cast<WORD>(keycode); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 #ifndef COPY_FILE_COPY_SYMLINK | 429 #ifndef COPY_FILE_COPY_SYMLINK |
| 430 #error You must install the Windows 2008 or Vista Software Development Kit and \ | 430 #error You must install the Windows 2008 or Vista Software Development Kit and \ |
| 431 set it as your default include path to build this library. You can grab it by \ | 431 set it as your default include path to build this library. You can grab it by \ |
| 432 searching for "download windows sdk 2008" in your favorite web search engine. \ | 432 searching for "download windows sdk 2008" in your favorite web search engine. \ |
| 433 Also make sure you register the SDK with Visual Studio, by selecting \ | 433 Also make sure you register the SDK with Visual Studio, by selecting \ |
| 434 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ | 434 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ |
| 435 menu (see Start - All Programs - Microsoft Windows SDK - \ | 435 menu (see Start - All Programs - Microsoft Windows SDK - \ |
| 436 Visual Studio Registration). | 436 Visual Studio Registration). |
| 437 #endif | 437 #endif |
| OLD | NEW |