Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Unified Diff: base/file_util_win.cc

Issue 10837034: Remove packaged app Windows shortcuts when app is uninstalled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tidy up; linux and mac Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util.h ('k') | chrome/browser/extensions/app_shortcut_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « base/file_util.h ('k') | chrome/browser/extensions/app_shortcut_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698