Module: wine Branch: stable Commit: 4fc905841a89a9e175700c2900c48478931d1c32 URL: https://gitlab.winehq.org/wine/wine/-/commit/4fc905841a89a9e175700c2900c4847...
Author: Alex Henrie alexhenrie24@gmail.com Date: Fri Feb 24 19:55:12 2023 -0700
shell32: Add support for Program Manager icons with arguments.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52506 (cherry picked from commit aa21d1acb28839177e8d7e74bab65bf1886d6596)
---
dlls/shell32/dde.c | 21 +++++++++++++++------ dlls/shell32/tests/progman_dde.c | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/dlls/shell32/dde.c b/dlls/shell32/dde.c index 96b5a243f93..4fbc6898d38 100644 --- a/dlls/shell32/dde.c +++ b/dlls/shell32/dde.c @@ -251,7 +251,7 @@ static DWORD PROGMAN_OnExecute(WCHAR *command, int argc, WCHAR **argv) } else if (!wcsicmp(command, L"AddItem")) { - WCHAR *path, *name; + WCHAR *target, *space = NULL, *path, *name; IShellLinkW *link; IPersistFile *file; HRESULT hres; @@ -262,15 +262,24 @@ static DWORD PROGMAN_OnExecute(WCHAR *command, int argc, WCHAR **argv) &IID_IShellLinkW, (void **)&link); if (FAILED(hres)) return DDE_FNOTPROCESSED;
- len = SearchPathW(NULL, argv[0], L".exe", 0, NULL, NULL); - if (len == 0) + target = wcsdup(argv[0]); + while (!(len = SearchPathW(NULL, target, L".exe", 0, NULL, NULL))) { - IShellLinkW_Release(link); - return DDE_FNOTPROCESSED; + /* progressively remove words from the end of the command line until we get a valid file name */ + space = wcsrchr(target, ' '); + if (!space) + { + IShellLinkW_Release(link); + free(target); + return DDE_FNOTPROCESSED; + } + *space = 0; } path = malloc(len * sizeof(WCHAR)); - SearchPathW(NULL, argv[0], L".exe", len, path, NULL); + SearchPathW(NULL, target, L".exe", len, path, NULL); IShellLinkW_SetPath(link, path); + if (space) IShellLinkW_SetArguments(link, argv[0] + (space - target) + 1); + free(target); free(path);
if (argc >= 2) IShellLinkW_SetDescription(link, argv[1]); diff --git a/dlls/shell32/tests/progman_dde.c b/dlls/shell32/tests/progman_dde.c index 5a7e8c912e5..b15295c5a21 100644 --- a/dlls/shell32/tests/progman_dde.c +++ b/dlls/shell32/tests/progman_dde.c @@ -231,10 +231,25 @@ static void test_parser(DWORD instance, HCONV hConv) ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); ok(check_exists("test/foobar.lnk"), "link not created\n");
- error = dde_execute(instance, hConv, "[AddItem(notepad,foo bar)]"); + error = dde_execute(instance, hConv, "[AddItem(notepad\tfoo.txt,foo)]"); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error); + + error = dde_execute(instance, hConv, "[AddItem(notepad foo.txt,foo)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/foo.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[AddItem(notepad foo.txt bar.txt,foo bar)]"); ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); ok(check_exists("test/foo bar.lnk"), "link not created\n");
+ error = dde_execute(instance, hConv, "[AddItem(C:\Program Files\Internet Explorer\iexplore.exe,IE)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/IE.lnk"), "link not created\n"); + + error = dde_execute(instance, hConv, "[AddItem(C:\Program Files\Internet Explorer\iexplore.exe https://www.winehq.org/,WineHQ)]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error); + ok(check_exists("test/WineHQ.lnk"), "link not created\n"); + error = dde_execute(instance, hConv, "[AddItem(notepad,a[b,c]d)]"); ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);