From 15f8fb63ee4030dba52ca45cac836c0bb702520c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 6 Aug 2008 16:10:52 -0700 Subject: [PATCH] shell32: Handle directories in ShellExecute. --- dlls/shell32/shlexec.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 83a3b00..316ffcd 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -1762,6 +1762,34 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) sei, execfunc ); HeapFree( GetProcessHeap(), 0, env ); } + else if (PathIsDirectoryW(lpFile)) + { + static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r',0}; + static const WCHAR wQuote[] = {'"',0}; + WCHAR wExec[MAX_PATH]; + WCHAR * lpQuotedFile = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR) * (strlenW(lpFile) + 3) ); + + if (lpQuotedFile) + { + retval = SHELL_FindExecutable( sei_tmp.lpDirectory, wExplorer, + wszOpen, wExec, MAX_PATH, + NULL, &env, NULL, NULL ); + if (retval > 32) + { + strcpyW(lpQuotedFile, wQuote); + strcatW(lpQuotedFile, lpFile); + strcatW(lpQuotedFile, wQuote); + retval = SHELL_quote_and_execute( wExec, lpQuotedFile, + lpstrProtocol, + wszApplicationName, env, + &sei_tmp, sei, execfunc ); + HeapFree( GetProcessHeap(), 0, env ); + } + HeapFree( GetProcessHeap(), 0, lpQuotedFile ); + } + else + retval = 0; /* Out of memory */ + } else if (PathIsURLW(lpFile)) /* File not found, check for URL */ { retval = SHELL_execute_url( lpFile, wFile, wcmd, &sei_tmp, sei, execfunc ); -- 1.5.4.5