Index: reactos/dll/win32/shell32/shlexec.cpp =================================================================== --- reactos/dll/win32/shell32/shlexec.cpp (revision 74931) +++ reactos/dll/win32/shell32/shlexec.cpp (working copy) @@ -1209,6 +1209,7 @@ { UINT_PTR retval = SE_ERR_NOASSOC; WCHAR old_dir[1024]; + WCHAR res[MAX_PATH]; TRACE("File %s, Dir %s\n", debugstr_w(lpFile), debugstr_w(lpDirectory)); @@ -1222,7 +1223,9 @@ SetCurrentDirectoryW(lpDirectory); } - retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, lpResult, MAX_PATH, NULL, NULL, NULL, NULL); + retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, res, MAX_PATH, NULL, NULL, NULL, NULL); + if (retval > 32) + strcpyW(lpResult, res); TRACE("returning %s\n", debugstr_w(lpResult)); if (lpDirectory) @@ -1409,6 +1412,7 @@ if (!dataobj) { ERR("failed to get data object\n"); + r = E_FAIL; goto end; } @@ -1663,7 +1667,6 @@ DWORD error_code; error_code = GetLastError(); - if (retval == SE_ERR_NOASSOC) LoadStringW(shell32_hInstance, IDS_SHLEXEC_NOASSOC, msg, sizeof(msg) / sizeof(WCHAR)); else @@ -1721,17 +1724,16 @@ wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen * sizeof(WCHAR)); *wszApplicationName = '\0'; } - else if (*sei_tmp.lpFile == '\"') + else if (*sei_tmp.lpFile == '\"' && sei_tmp.lpFile[(len = strlenW(sei_tmp.lpFile))-1] == '\"') { - DWORD l = strlenW(sei_tmp.lpFile + 1); - if(l >= dwApplicationNameLen) - dwApplicationNameLen = l + 1; + if(len-1 >= dwApplicationNameLen) + dwApplicationNameLen = len; wszApplicationName = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen * sizeof(WCHAR)); - memcpy(wszApplicationName, sei_tmp.lpFile + 1, (l + 1)*sizeof(WCHAR)); + memcpy(wszApplicationName, sei_tmp.lpFile + 1, len * sizeof(WCHAR)); - if (wszApplicationName[l-1] == L'\"') - wszApplicationName[l-1] = L'\0'; + if(len > 2) + wszApplicationName[len-2] = '\0'; appKnownSingular = TRUE; TRACE("wszApplicationName=%s\n", debugstr_w(wszApplicationName)); @@ -1809,6 +1811,23 @@ TRACE("-- idlist=%p (%s)\n", sei_tmp.lpIDList, debugstr_w(wszApplicationName)); } + if (sei_tmp.fMask & SEE_MASK_DOENVSUBST) + { + len = ExpandEnvironmentStringsW(sei_tmp.lpFile, NULL, 0); + if (len > 0) + { + LPWSTR buf; + buf = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + + ExpandEnvironmentStringsW(sei_tmp.lpFile, buf, len + 1); + HeapFree(GetProcessHeap(), 0, wszApplicationName); + wszApplicationName = buf; + /* appKnownSingular unmodified */ + + sei_tmp.lpFile = wszApplicationName; + } + } + if (ERROR_SUCCESS == ShellExecute_FromContextMenu(&sei_tmp)) { sei->hInstApp = (HINSTANCE) 33; @@ -1870,7 +1889,6 @@ } HeapFree(GetProcessHeap(), 0, wszApplicationName); - dwApplicationNameLen = lstrlenW(buf) + 1; wszApplicationName = buf; sei_tmp.lpFile = wszApplicationName; } @@ -1884,7 +1902,6 @@ ExpandEnvironmentStringsW(sei_tmp.lpFile, buf, len + 1); HeapFree(GetProcessHeap(), 0, wszApplicationName); - dwApplicationNameLen = len + 1; wszApplicationName = buf; /* appKnownSingular unmodified */ @@ -1931,7 +1948,7 @@ { end = ++src; - while(isspace(*src)) + while(isspaceW(*src)) ++src; } else