Erich Hoover : shell32: Fix FindExecutable search path when a default directory is supplied.

Alexandre Julliard julliard at winehq.org
Thu Jul 12 18:00:34 CDT 2012


Module: wine
Branch: master
Commit: 6a1d2f80b87de75cd4ed2d1280ab8e885b691857
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6a1d2f80b87de75cd4ed2d1280ab8e885b691857

Author: Erich Hoover <ehoover at mines.edu>
Date:   Tue Jul 10 11:59:24 2012 -0600

shell32: Fix FindExecutable search path when a default directory is supplied.

---

 dlls/shell32/shlexec.c       |    8 +++++++-
 dlls/shell32/tests/shlexec.c |   16 ++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)

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 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOpera
     {
         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_filename(void)
 
 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 @@ static void test_find_executable(void)
     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);




More information about the wine-cvs mailing list