Chromium Code Reviews| Index: base/file_util_win.cc |
| diff --git a/base/file_util_win.cc b/base/file_util_win.cc |
| index bf9dd9cb7046b2f58ce05b3215b2180afc394240..09221c7ebc767bdf7d499aa24e422d56006a4e3a 100644 |
| --- a/base/file_util_win.cc |
| +++ b/base/file_util_win.cc |
| @@ -347,13 +347,13 @@ bool ResolveShortcut(FilePath* path) { |
| // Query IShellLink for the IPersistFile interface |
| result = persist.QueryFrom(i_shell_link); |
| if (SUCCEEDED(result)) { |
| - WCHAR temp_path[MAX_PATH]; |
| // Load the shell link |
| result = persist->Load(path->value().c_str(), STGM_READ); |
| if (SUCCEEDED(result)) { |
| // Try to find the target of a shortcut |
| result = i_shell_link->Resolve(0, SLR_NO_UI); |
| if (SUCCEEDED(result)) { |
| + WCHAR temp_path[MAX_PATH]; |
| result = i_shell_link->GetPath(temp_path, MAX_PATH, |
| NULL, SLGP_UNCPRIORITY); |
| *path = FilePath(temp_path); |
| @@ -366,6 +366,36 @@ bool ResolveShortcut(FilePath* path) { |
| return is_resolved; |
| } |
| +bool GetShortcutArguments(const FilePath& shortcut_path, string16* args) { |
|
brettw
2012/08/05 05:24:25
There's too much copy-and-pasted code here from th
brettw
2012/08/05 17:55:24
Maybe we should add a function to return a ScopedC
benwells
2012/08/07 12:24:05
OK, that all makes sense. For now I've merged thes
|
| + base::ThreadRestrictions::AssertIOAllowed(); |
| + DCHECK(args); |
| + |
| + HRESULT result; |
| + base::win::ScopedComPtr<IShellLink> i_shell_link; |
| + |
| + // Get pointer to the IShellLink interface |
| + result = i_shell_link.CreateInstance(CLSID_ShellLink, NULL, |
| + CLSCTX_INPROC_SERVER); |
| + if (SUCCEEDED(result)) { |
| + base::win::ScopedComPtr<IPersistFile> persist; |
| + // Query IShellLink for the IPersistFile interface |
| + result = persist.QueryFrom(i_shell_link); |
| + if (SUCCEEDED(result)) { |
| + // Load the shell link |
| + result = persist->Load(shortcut_path.value().c_str(), STGM_READ); |
| + if (SUCCEEDED(result)) { |
| + // Try to find the target of a shortcut |
| + WCHAR temp_args[MAX_PATH]; |
| + result = i_shell_link->GetArguments(temp_args, MAX_PATH); |
| + *args = string16(temp_args); |
| + return true; |
| + } |
| + } |
| + } |
| + |
| + return false; |
| +} |
| + |
| bool CreateOrUpdateShortcutLink(const wchar_t *source, |
| const wchar_t *destination, |
| const wchar_t *working_dir, |