Fix the return value of SHELL_ArgifyW()

Francois Gouget fgouget at codeweavers.com
Wed Aug 10 10:53:54 CDT 2005


A long time ago SHELL_ArgifyW() was supposed to return true if it 
substituted a '%1' or equivalent placeholder and false otherwise. This 
way the caller could append the filename itself in the latter case if 
appropriate.

But when support was added for environment variable substitution, the 
'done' variable that was used for this purpose got used in an entirely 
new way and the SHELL_ArgifyW() return value became completely useless 
and wrong.

This patch fixes that by adding a new 'found_p1' variable which is set 
to true whenever we substitute a %1 or equivalent string.


Changelog:

  * dlls/shell32/shlexec.c

    Francois Gouget <fgouget at codeweavers.com>
    Fix the return value of SHELL_Argify() so it once again returns true 
if a '%1' or equivalent placeholder was found.
    This fixes ShellExecuteEx(lpFile="foo.txt", lpClass="txtfile").


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/shell32/shlexec.c
===================================================================
RCS file: /var/cvs/wine/dlls/shell32/shlexec.c,v
retrieving revision 1.66
diff -u -p -r1.66 shlexec.c
--- dlls/shell32/shlexec.c	11 Jul 2005 10:59:41 -0000	1.66
+++ dlls/shell32/shlexec.c	10 Aug 2005 11:11:41 -0000
@@ -80,6 +80,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, in
 {
     WCHAR   xlpFile[1024];
     BOOL    done = FALSE;
+    BOOL    found_p1 = FALSE;
     PWSTR   res = out;
     PCWSTR  cmd;
     LPVOID  pv;
@@ -153,6 +154,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, in
                         res += strlenW(cmd);
                     }
                 }
+                found_p1=1;
                 break;
 
             /*
@@ -166,6 +168,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, in
 		    strcpyW(res, lpFile);
 		    res += strlenW(lpFile);
 		}
+                found_p1=1;
                 break;
 
             case 'i':
@@ -176,6 +179,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, in
 		    res += sprintfW(res, wszILPtr, pv);
 		    SHUnlockShared(pv);
 		}
+                found_p1=1;
                 break;
 
 	    default:
@@ -219,7 +223,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, in
 
     *res = '\0';
 
-    return done;
+    return found_p1;
 }
 
 HRESULT SHELL_GetPathFromIDListForExecuteA(LPCITEMIDLIST pidl, LPSTR pszPath, UINT uOutSize)


More information about the wine-patches mailing list