Index: chrome/installer/util/shell_util.cc |
=================================================================== |
--- chrome/installer/util/shell_util.cc (revision 150342) |
+++ chrome/installer/util/shell_util.cc (working copy) |
@@ -1657,6 +1657,48 @@ |
ConvertShellUtilShortcutOptionsToFileUtil(options)); |
} |
+ShellUtil::VerifyShortcuts ShellUtil::VerifyChromeShortcut( |
+ const string16& exe_path, const string16& shortcut, |
+ const string16& description, int icon_index) { |
+ base::win::ScopedComPtr<IShellLink> i_shell_link; |
+ base::win::ScopedComPtr<IPersistFile> i_persist_file; |
+ |
+ // Get pointer to the IShellLink interface |
+ if (FAILED(i_shell_link.CreateInstance(CLSID_ShellLink, NULL, |
+ CLSCTX_INPROC_SERVER))) |
+ return VERIFY_SHORTCUT_FAILURE_CREATE_SHELL_LINK_INSTANCE; |
+ |
+ // Query IShellLink for the IPersistFile interface |
+ if (FAILED(i_persist_file.QueryFrom(i_shell_link))) |
+ return VERIFY_SHORTCUT_FAILURE_QUERY_FROM_PERSIST; |
+ |
+ if (FAILED(i_persist_file->Load(shortcut.c_str(), 0))) |
+ return VERIFY_SHORTCUT_FAILURE_LOAD_FROM_PERSIST; |
+ |
+ wchar_t long_path[MAX_PATH] = {0}; |
+ wchar_t short_path[MAX_PATH] = {0}; |
+ |
+ if (::GetLongPathName(exe_path.c_str(), long_path, MAX_PATH) == 0 || |
+ ::GetShortPathName(exe_path.c_str(), short_path, MAX_PATH) == 0) |
+ return VERIFY_SHORTCUT_FAILURE_GET_PATH_NAMES; |
+ |
+ wchar_t file_path[MAX_PATH] = {0}; |
+ wchar_t desc[MAX_PATH] = {0}; |
+ wchar_t icon_path[MAX_PATH] = {0}; |
+ int index = 0; |
+ |
+ if (FAILED(i_shell_link->GetPath(file_path, MAX_PATH, NULL, |
gab
2012/08/08 20:41:14
It's the opposite we want.
i.e. the things that s
Halli
2012/08/08 21:06:20
Done.
|
+ SLGP_UNCPRIORITY)) || FilePath(file_path) != FilePath(long_path) && |
+ FilePath(file_path) != FilePath(short_path) || |
+ FAILED(i_shell_link->GetDescription(desc, MAX_PATH)) || |
+ string16(desc) != string16(description) || |
+ FAILED(i_shell_link->GetIconLocation(icon_path, MAX_PATH, &index)) || |
+ index != icon_index) |
+ return VERIFY_SHORTCUT_FAILURE; |
+ |
+ return VERIFY_SHORTCUT_SUCCESS; |
+} |
+ |
bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { |
// Use a thread-safe cache for the user's suffix. |
static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = |