Index: base/win_util.cc |
diff --git a/base/win_util.cc b/base/win_util.cc |
index e66dc1c4e31f03ac0e0d9779eddb384b74609fba..6ff546f558685124147f3109c3a9a73ec0f211f8 100644 |
--- a/base/win_util.cc |
+++ b/base/win_util.cc |
@@ -4,6 +4,7 @@ |
#include "base/win_util.h" |
+#include <propvarutil.h> |
#include <sddl.h> |
#include "base/logging.h" |
@@ -384,6 +385,32 @@ base::KeyboardCode WinToKeyboardCode(WORD keycode) { |
return static_cast<base::KeyboardCode>(keycode); |
} |
+bool SetAppIdForPropertyStore(IPropertyStore* property_store, |
+ const wchar_t* app_id) { |
+ DCHECK(property_store); |
+ |
+ // App id should be less than 128 chars and contain no space. And recommended |
+ // format is CompanyName.ProductName[.SubProduct.ProductNumber]. |
+ // See http://msdn.microsoft.com/en-us/library/dd378459%28VS.85%29.aspx |
+ DCHECK(lstrlen(app_id) < 128 && wcschr(app_id, L' ') == NULL); |
+ |
+ 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.
|
+ { { 0x9F4C2855, 0x9F79, 0x4B39, |
+ { 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, } }, 5 }; |
+ |
+ PROPVARIANT property_value; |
+ if (FAILED(InitPropVariantFromString(app_id, &property_value))) |
+ return false; |
+ |
+ HRESULT result = property_store->SetValue(PKEY_AppUserModel_ID, |
+ property_value); |
+ if (S_OK == result) |
+ result = property_store->Commit(); |
+ |
+ PropVariantClear(&property_value); |
+ return SUCCEEDED(result); |
+} |
+ |
} // namespace win_util |
#ifdef _MSC_VER |