winemenubuilder: launch .lnk files directly from menus

Damjan Jovanovic damjan.jov at gmail.com
Fri May 7 01:29:02 CDT 2010


Changelog:
* launch .lnk files directly from menus

The arguments of a .lnk file are complex, with quoting and escaping
rules and %windir%-style variable expansion, so winemenubuilder cannot
always convert them accurately to a .desktop file. But start.exe and
shell32 on the other hand can parse the .lnk file and run it
themselves, so use them instead.

For now we only do this for menus, not files in ~/Desktop. This is
because applications installing .lnk files to the current user's
desktop (as opposed to the desktop for all users) end up generating
those .lnk files in ~/Desktop, where the user might delete them, thus
breaking the .desktop file too.

Closes #13303 and probably #17863, #20812, #21217.

Damjan Jovanovic
-------------- next part --------------
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 4884d7e..6569c0d 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -2340,7 +2340,24 @@ static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bWait )
         }
     }
     else
-        r = !write_menu_entry(unix_link, link_name, escaped_path, escaped_args, escaped_description, work_dir, icon_name);
+    {
+        char *arg = heap_printf("/Unix \"%s\"", unix_link);
+        if (arg)
+        {
+            WCHAR *warg = utf8_chars_to_wchars(arg);
+            if (warg)
+            {
+                char *menuarg = escape(warg);
+                if (menuarg)
+                {
+                    r = !write_menu_entry(unix_link, link_name, "start", menuarg, escaped_description, work_dir, icon_name);
+                    HeapFree(GetProcessHeap(), 0, menuarg);
+                }
+                HeapFree(GetProcessHeap(), 0, warg);
+            }
+            HeapFree(GetProcessHeap(), 0, arg);
+        }
+    }
 
     ReleaseSemaphore( hsem, 1, NULL );
 


More information about the wine-patches mailing list