shell32: Fix FindExecutable search path when a default directory is supplied.
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index 77212f0..e351d86 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -603,7 +603,13 @@
{
TRACE("SearchPathW returned non-zero\n");
lpFile = xlpFile;
- /* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
+ /* The file was found in the application-supplied default directory (or the system search path) */
+ }
+ else if (lpPath && SearchPathW(NULL, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL))
+ {
+ TRACE("SearchPathW returned non-zero\n");
+ lpFile = xlpFile;
+ /* The file was found in one of the directories in the system-wide search path */
}
attribs = GetFileAttributesW(lpFile);
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 1c5fe7f..8e200aa 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -1307,6 +1307,7 @@
static void test_find_executable(void)
{
+ char notepad_path[MAX_PATH];
char filename[MAX_PATH];
char command[MAX_PATH];
const filename_tests_t* test;
@@ -1329,6 +1330,21 @@
ok(strcmp(command, "your word") != 0, "FindExecutable(NULL) returned command=[%s]\n", command);
}
+ GetSystemDirectoryA( notepad_path, MAX_PATH );
+ strcat( notepad_path, "\\notepad.exe" );
+
+ /* Search for something that should be in the system-wide search path (no default directory) */
+ strcpy(command, "your word");
+ rc=(INT_PTR)FindExecutableA("notepad.exe", NULL, command);
+ ok(rc > 32, "FindExecutable(%s) returned %ld\n", "notepad.exe", rc);
+ ok(strcasecmp(command, notepad_path) == 0, "FindExecutable(%s) returned command=[%s]\n", "notepad.exe", command);
+
+ /* Search for something that should be in the system-wide search path (with default directory) */
+ strcpy(command, "your word");
+ rc=(INT_PTR)FindExecutableA("notepad.exe", tmpdir, command);
+ ok(rc > 32, "FindExecutable(%s) returned %ld\n", "notepad.exe", rc);
+ ok(strcasecmp(command, notepad_path) == 0, "FindExecutable(%s) returned command=[%s]\n", "notepad.exe", command);
+
strcpy(command, "your word");
rc=(INT_PTR)FindExecutableA(tmpdir, NULL, command);
ok(rc == SE_ERR_NOASSOC /* >= win2000 */ || rc > 32 /* win98, nt4 */, "FindExecutable(NULL) returned %ld\n", rc);