Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 <sddl.h> | 8 #include <sddl.h> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/registry.h" | 11 #include "base/registry.h" |
| 11 #include "base/scoped_handle.h" | 12 #include "base/scoped_handle.h" |
| 12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 14 | 15 |
| 15 namespace win_util { | 16 namespace win_util { |
| 16 | 17 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 } | 378 } |
| 378 | 379 |
| 379 WORD KeyboardCodeToWin(base::KeyboardCode keycode) { | 380 WORD KeyboardCodeToWin(base::KeyboardCode keycode) { |
| 380 return static_cast<WORD>(keycode); | 381 return static_cast<WORD>(keycode); |
| 381 } | 382 } |
| 382 | 383 |
| 383 base::KeyboardCode WinToKeyboardCode(WORD keycode) { | 384 base::KeyboardCode WinToKeyboardCode(WORD keycode) { |
| 384 return static_cast<base::KeyboardCode>(keycode); | 385 return static_cast<base::KeyboardCode>(keycode); |
| 385 } | 386 } |
| 386 | 387 |
| 388 bool SetAppIdForPropertyStore(IPropertyStore* property_store, | |
| 389 const wchar_t* app_id) { | |
| 390 DCHECK(property_store); | |
| 391 | |
| 392 // App id should be less than 128 chars and contain no space. And recommended | |
| 393 // format is CompanyName.ProductName[.SubProduct.ProductNumber]. | |
| 394 // See http://msdn.microsoft.com/en-us/library/dd378459%28VS.85%29.aspx | |
| 395 DCHECK(lstrlen(app_id) < 128 && wcschr(app_id, L' ') == NULL); | |
| 396 | |
| 397 static const PROPERTYKEY PKEY_AppUserModel_ID = | |
|
Hironori Bono
2009/11/19 04:35:47
nit: the name of a const variable should use a k f
xiyuan
2009/11/19 07:30:18
Done.
| |
| 398 { { 0x9F4C2855, 0x9F79, 0x4B39, | |
| 399 { 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, } }, 5 }; | |
| 400 | |
| 401 PROPVARIANT property_value; | |
| 402 if (FAILED(InitPropVariantFromString(app_id, &property_value))) | |
| 403 return false; | |
| 404 | |
| 405 HRESULT result = property_store->SetValue(PKEY_AppUserModel_ID, | |
| 406 property_value); | |
| 407 if (S_OK == result) | |
| 408 result = property_store->Commit(); | |
| 409 | |
| 410 PropVariantClear(&property_value); | |
| 411 return SUCCEEDED(result); | |
| 412 } | |
| 413 | |
| 387 } // namespace win_util | 414 } // namespace win_util |
| 388 | 415 |
| 389 #ifdef _MSC_VER | 416 #ifdef _MSC_VER |
| 390 // | 417 // |
| 391 // If the ASSERT below fails, please install Visual Studio 2005 Service Pack 1. | 418 // If the ASSERT below fails, please install Visual Studio 2005 Service Pack 1. |
| 392 // | 419 // |
| 393 extern char VisualStudio2005ServicePack1Detection[10]; | 420 extern char VisualStudio2005ServicePack1Detection[10]; |
| 394 COMPILE_ASSERT(sizeof(&VisualStudio2005ServicePack1Detection) == sizeof(void*), | 421 COMPILE_ASSERT(sizeof(&VisualStudio2005ServicePack1Detection) == sizeof(void*), |
| 395 VS2005SP1Detect); | 422 VS2005SP1Detect); |
| 396 // | 423 // |
| 397 // Chrome requires at least Service Pack 1 for Visual Studio 2005. | 424 // Chrome requires at least Service Pack 1 for Visual Studio 2005. |
| 398 // | 425 // |
| 399 #endif // _MSC_VER | 426 #endif // _MSC_VER |
| 400 | 427 |
| 401 #ifndef COPY_FILE_COPY_SYMLINK | 428 #ifndef COPY_FILE_COPY_SYMLINK |
| 402 #error You must install the Windows 2008 or Vista Software Development Kit and \ | 429 #error You must install the Windows 2008 or Vista Software Development Kit and \ |
| 403 set it as your default include path to build this library. You can grab it by \ | 430 set it as your default include path to build this library. You can grab it by \ |
| 404 searching for "download windows sdk 2008" in your favorite web search engine. \ | 431 searching for "download windows sdk 2008" in your favorite web search engine. \ |
| 405 Also make sure you register the SDK with Visual Studio, by selecting \ | 432 Also make sure you register the SDK with Visual Studio, by selecting \ |
| 406 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ | 433 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ |
| 407 menu (see Start - All Programs - Microsoft Windows SDK - \ | 434 menu (see Start - All Programs - Microsoft Windows SDK - \ |
| 408 Visual Studio Registration). | 435 Visual Studio Registration). |
| 409 #endif | 436 #endif |
| OLD | NEW |