2002-02-27 02:22:15 +01:00
|
|
|
/*
|
|
|
|
* Shell Library Functions
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 2002 Eric Pouech
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-02-27 02:22:15 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-12-16 23:40:34 +01:00
|
|
|
#include "wine/port.h"
|
2002-02-27 02:22:15 +01:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-07-24 20:59:38 +02:00
|
|
|
#include <stdio.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2002-02-27 02:22:15 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2002-02-27 02:22:15 +01:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winuser.h"
|
2002-02-27 02:22:15 +01:00
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "ddeml.h"
|
|
|
|
|
|
|
|
#include "shell32_main.h"
|
2004-04-07 05:49:51 +02:00
|
|
|
#include "pidl.h"
|
2009-02-26 02:14:30 +01:00
|
|
|
#include "shresdef.h"
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(exec);
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wszOpen[] = {'o','p','e','n',0};
|
|
|
|
static const WCHAR wszExe[] = {'.','e','x','e',0};
|
2004-03-26 03:29:12 +01:00
|
|
|
static const WCHAR wszILPtr[] = {':','%','p',0};
|
2004-03-04 21:34:38 +01:00
|
|
|
static const WCHAR wszShell[] = {'\\','s','h','e','l','l','\\',0};
|
2004-04-07 05:49:51 +02:00
|
|
|
static const WCHAR wszFolder[] = {'F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR wszEmpty[] = {0};
|
2004-01-15 07:13:57 +01:00
|
|
|
|
2005-08-11 12:29:44 +02:00
|
|
|
#define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY)
|
|
|
|
|
2009-05-15 02:15:17 +02:00
|
|
|
typedef UINT_PTR (*SHELL_ExecuteW32)(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
|
|
|
const SHELLEXECUTEINFOW *sei, LPSHELLEXECUTEINFOW sei_out);
|
|
|
|
|
2017-05-17 14:35:42 +02:00
|
|
|
static inline BOOL isSpace(WCHAR c)
|
|
|
|
{
|
|
|
|
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
|
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
|
2002-09-16 21:27:51 +02:00
|
|
|
/***********************************************************************
|
2004-01-15 07:13:57 +01:00
|
|
|
* SHELL_ArgifyW [Internal]
|
|
|
|
*
|
2002-09-16 21:27:51 +02:00
|
|
|
* this function is supposed to expand the escape sequences found in the registry
|
2002-02-27 02:22:15 +01:00
|
|
|
* some diving reported that the following were used:
|
2002-06-01 01:06:46 +02:00
|
|
|
* + %1, %2... seem to report to parameter of index N in ShellExecute pmts
|
2002-07-24 20:59:38 +02:00
|
|
|
* %1 file
|
|
|
|
* %2 printer
|
|
|
|
* %3 driver
|
|
|
|
* %4 port
|
2003-06-18 05:30:39 +02:00
|
|
|
* %I address of a global item ID (explorer switch /idlist)
|
2002-07-24 20:59:38 +02:00
|
|
|
* %L seems to be %1 as long filename followed by the 8+3 variation
|
|
|
|
* %S ???
|
|
|
|
* %* all following parameters (see batfile)
|
2004-03-26 03:29:12 +01:00
|
|
|
*
|
2002-02-27 02:22:15 +01:00
|
|
|
*/
|
2006-11-03 17:24:19 +01:00
|
|
|
static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lpFile, LPITEMIDLIST pidl, LPCWSTR args, DWORD* out_len)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-03-26 03:29:12 +01:00
|
|
|
WCHAR xlpFile[1024];
|
|
|
|
BOOL done = FALSE;
|
2005-08-11 19:04:31 +02:00
|
|
|
BOOL found_p1 = FALSE;
|
2004-03-26 03:29:12 +01:00
|
|
|
PWSTR res = out;
|
|
|
|
PCWSTR cmd;
|
2006-11-03 17:24:19 +01:00
|
|
|
DWORD used = 0;
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2004-06-14 19:54:24 +02:00
|
|
|
TRACE("%p, %d, %s, %s, %p, %p\n", out, len, debugstr_w(fmt),
|
|
|
|
debugstr_w(lpFile), pidl, args);
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
while (*fmt)
|
|
|
|
{
|
|
|
|
if (*fmt == '%')
|
|
|
|
{
|
|
|
|
switch (*++fmt)
|
|
|
|
{
|
|
|
|
case '\0':
|
2002-06-01 01:06:46 +02:00
|
|
|
case '%':
|
2006-11-03 17:24:19 +01:00
|
|
|
used++;
|
|
|
|
if (used < len)
|
|
|
|
*res++ = '%';
|
2002-02-27 02:22:15 +01:00
|
|
|
break;
|
2004-03-26 03:29:12 +01:00
|
|
|
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
|
|
|
case '0':
|
2002-07-24 20:59:38 +02:00
|
|
|
case '*':
|
2004-03-26 03:29:12 +01:00
|
|
|
if (args)
|
|
|
|
{
|
|
|
|
if (*fmt == '*')
|
|
|
|
{
|
2006-11-03 17:24:19 +01:00
|
|
|
used++;
|
|
|
|
if (used < len)
|
|
|
|
*res++ = '"';
|
2004-03-26 03:29:12 +01:00
|
|
|
while(*args)
|
2006-11-03 17:24:19 +01:00
|
|
|
{
|
|
|
|
used++;
|
|
|
|
if (used < len)
|
|
|
|
*res++ = *args++;
|
|
|
|
else
|
|
|
|
args++;
|
|
|
|
}
|
|
|
|
used++;
|
|
|
|
if (used < len)
|
|
|
|
*res++ = '"';
|
2004-03-26 03:29:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-17 14:35:42 +02:00
|
|
|
while(*args && !isSpace(*args))
|
2006-11-03 17:24:19 +01:00
|
|
|
{
|
|
|
|
used++;
|
|
|
|
if (used < len)
|
|
|
|
*res++ = *args++;
|
|
|
|
else
|
|
|
|
args++;
|
|
|
|
}
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2017-05-17 14:35:42 +02:00
|
|
|
while(isSpace(*args))
|
2004-03-26 03:29:12 +01:00
|
|
|
++args;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* else fall through */
|
|
|
|
case '1':
|
2002-07-24 20:59:38 +02:00
|
|
|
if (!done || (*fmt == '1'))
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-03-26 03:29:12 +01:00
|
|
|
/*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */
|
2018-03-19 08:11:27 +01:00
|
|
|
if (SearchPathW(NULL, lpFile, wszExe, ARRAY_SIZE(xlpFile), xlpFile, NULL))
|
2004-03-26 03:29:12 +01:00
|
|
|
cmd = xlpFile;
|
|
|
|
else
|
|
|
|
cmd = lpFile;
|
|
|
|
|
2007-06-16 23:00:08 +02:00
|
|
|
used += strlenW(cmd);
|
|
|
|
if (used < len)
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2007-06-16 23:00:08 +02:00
|
|
|
strcpyW(res, cmd);
|
|
|
|
res += strlenW(cmd);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2005-08-11 19:04:31 +02:00
|
|
|
found_p1 = TRUE;
|
2002-02-27 02:22:15 +01:00
|
|
|
break;
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2003-05-19 20:55:26 +02:00
|
|
|
/*
|
2004-04-13 00:08:23 +02:00
|
|
|
* IE uses this a lot for activating things such as windows media
|
2003-05-19 20:55:26 +02:00
|
|
|
* player. This is not verified to be fully correct but it appears
|
|
|
|
* to work just fine.
|
|
|
|
*/
|
2004-03-26 03:29:12 +01:00
|
|
|
case 'l':
|
2003-05-19 20:55:26 +02:00
|
|
|
case 'L':
|
2004-03-26 03:29:12 +01:00
|
|
|
if (lpFile) {
|
2006-11-03 17:24:19 +01:00
|
|
|
used += strlenW(lpFile);
|
|
|
|
if (used < len)
|
|
|
|
{
|
|
|
|
strcpyW(res, lpFile);
|
|
|
|
res += strlenW(lpFile);
|
|
|
|
}
|
2004-03-26 03:29:12 +01:00
|
|
|
}
|
2006-11-03 17:24:19 +01:00
|
|
|
found_p1 = TRUE;
|
2004-03-26 03:29:12 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'i':
|
|
|
|
case 'I':
|
|
|
|
if (pidl) {
|
2006-11-03 17:24:19 +01:00
|
|
|
INT chars = 0;
|
2008-01-16 12:20:50 +01:00
|
|
|
/* %p should not exceed 8, maybe 16 when looking forward to 64bit.
|
2006-11-03 17:24:19 +01:00
|
|
|
* allowing a buffer of 100 should more than exceed all needs */
|
|
|
|
WCHAR buf[100];
|
|
|
|
LPVOID pv;
|
2004-03-26 03:29:12 +01:00
|
|
|
HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0);
|
|
|
|
pv = SHLockShared(hmem, 0);
|
2006-11-03 17:24:19 +01:00
|
|
|
chars = sprintfW(buf, wszILPtr, pv);
|
2018-03-19 08:11:27 +01:00
|
|
|
if (chars >= ARRAY_SIZE(buf))
|
2006-11-08 00:54:49 +01:00
|
|
|
ERR("pidl format buffer too small!\n");
|
2006-11-03 17:24:19 +01:00
|
|
|
used += chars;
|
|
|
|
if (used < len)
|
|
|
|
{
|
|
|
|
strcpyW(res,buf);
|
|
|
|
res += chars;
|
|
|
|
}
|
2004-03-26 03:29:12 +01:00
|
|
|
SHUnlockShared(pv);
|
|
|
|
}
|
2005-08-11 19:04:31 +02:00
|
|
|
found_p1 = TRUE;
|
2003-05-19 20:55:26 +02:00
|
|
|
break;
|
|
|
|
|
2004-09-14 22:14:09 +02:00
|
|
|
default:
|
|
|
|
/*
|
2005-03-23 14:15:18 +01:00
|
|
|
* Check if this is an env-variable here...
|
2004-09-14 22:14:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Make sure that we have at least one more %.*/
|
|
|
|
if (strchrW(fmt, '%'))
|
|
|
|
{
|
|
|
|
WCHAR tmpBuffer[1024];
|
|
|
|
PWSTR tmpB = tmpBuffer;
|
|
|
|
WCHAR tmpEnvBuff[MAX_PATH];
|
|
|
|
DWORD envRet;
|
|
|
|
|
|
|
|
while (*fmt != '%')
|
|
|
|
*tmpB++ = *fmt++;
|
|
|
|
*tmpB++ = 0;
|
|
|
|
|
2005-03-23 14:15:18 +01:00
|
|
|
TRACE("Checking %s to be an env-var\n", debugstr_w(tmpBuffer));
|
2004-09-14 22:14:09 +02:00
|
|
|
|
|
|
|
envRet = GetEnvironmentVariableW(tmpBuffer, tmpEnvBuff, MAX_PATH);
|
|
|
|
if (envRet == 0 || envRet > MAX_PATH)
|
2006-11-03 17:24:19 +01:00
|
|
|
{
|
|
|
|
used += strlenW(tmpBuffer);
|
|
|
|
if (used < len)
|
|
|
|
{
|
|
|
|
strcpyW( res, tmpBuffer );
|
|
|
|
res += strlenW(tmpBuffer);
|
|
|
|
}
|
|
|
|
}
|
2004-09-14 22:14:09 +02:00
|
|
|
else
|
2006-11-03 17:24:19 +01:00
|
|
|
{
|
|
|
|
used += strlenW(tmpEnvBuff);
|
|
|
|
if (used < len)
|
|
|
|
{
|
|
|
|
strcpyW( res, tmpEnvBuff );
|
|
|
|
res += strlenW(tmpEnvBuff);
|
|
|
|
}
|
|
|
|
}
|
2004-09-14 22:14:09 +02:00
|
|
|
}
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2004-10-21 22:59:25 +02:00
|
|
|
/* Don't skip past terminator (catch a single '%' at the end) */
|
|
|
|
if (*fmt != '\0')
|
|
|
|
{
|
|
|
|
fmt++;
|
|
|
|
}
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
else
|
2006-11-03 17:24:19 +01:00
|
|
|
{
|
|
|
|
used ++;
|
|
|
|
if (used < len)
|
|
|
|
*res++ = *fmt++;
|
|
|
|
else
|
|
|
|
fmt++;
|
|
|
|
}
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2011-07-19 20:22:07 +02:00
|
|
|
used ++;
|
|
|
|
if (res - out < len)
|
|
|
|
*res = '\0';
|
|
|
|
else
|
|
|
|
out[len-1] = '\0';
|
|
|
|
|
2006-11-03 17:24:19 +01:00
|
|
|
TRACE("used %i of %i space\n",used,len);
|
|
|
|
if (out_len)
|
|
|
|
*out_len = used;
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2005-08-11 19:04:31 +02:00
|
|
|
return found_p1;
|
2002-07-25 02:18:23 +02:00
|
|
|
}
|
|
|
|
|
2007-02-06 23:05:44 +01:00
|
|
|
static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR pszPath, UINT uOutSize)
|
2004-04-07 05:49:51 +02:00
|
|
|
{
|
|
|
|
STRRET strret;
|
|
|
|
IShellFolder* desktop;
|
|
|
|
|
|
|
|
HRESULT hr = SHGetDesktopFolder(&desktop);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(desktop, pidl, SHGDN_FORPARSING, &strret);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
StrRetToStrNW(pszPath, uOutSize, &strret, pidl);
|
|
|
|
|
|
|
|
IShellFolder_Release(desktop);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
/*************************************************************************
|
2004-01-15 07:13:57 +01:00
|
|
|
* SHELL_ExecuteW [Internal]
|
2002-07-25 02:18:23 +02:00
|
|
|
*
|
|
|
|
*/
|
2005-09-02 13:32:17 +02:00
|
|
|
static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
2007-10-31 00:07:38 +01:00
|
|
|
const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out)
|
2002-07-25 02:18:23 +02:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
STARTUPINFOW startup;
|
2002-07-25 02:18:23 +02:00
|
|
|
PROCESS_INFORMATION info;
|
2006-12-14 18:00:12 +01:00
|
|
|
UINT_PTR retval = SE_ERR_NOASSOC;
|
2004-03-19 02:52:30 +01:00
|
|
|
UINT gcdret = 0;
|
|
|
|
WCHAR curdir[MAX_PATH];
|
2007-07-16 17:14:07 +02:00
|
|
|
DWORD dwCreationFlags;
|
2007-08-31 16:41:36 +02:00
|
|
|
const WCHAR *lpDirectory = NULL;
|
2002-07-25 02:18:23 +02:00
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory));
|
2007-08-31 16:41:36 +02:00
|
|
|
|
|
|
|
/* make sure we don't fail the CreateProcess if the calling app passes in
|
|
|
|
* a bad working directory */
|
|
|
|
if (psei->lpDirectory && psei->lpDirectory[0])
|
|
|
|
{
|
|
|
|
DWORD attr = GetFileAttributesW(psei->lpDirectory);
|
|
|
|
if (attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
lpDirectory = psei->lpDirectory;
|
|
|
|
}
|
|
|
|
|
2004-03-19 02:52:30 +01:00
|
|
|
/* ShellExecute specifies the command from psei->lpDirectory
|
|
|
|
* if present. Not from the current dir as CreateProcess does */
|
2007-08-31 16:41:36 +02:00
|
|
|
if( lpDirectory )
|
2004-03-19 02:52:30 +01:00
|
|
|
if( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir)))
|
2007-08-31 16:41:36 +02:00
|
|
|
if( !SetCurrentDirectoryW( lpDirectory))
|
|
|
|
ERR("cannot set directory %s\n", debugstr_w(lpDirectory));
|
2004-01-15 07:13:57 +01:00
|
|
|
ZeroMemory(&startup,sizeof(STARTUPINFOW));
|
|
|
|
startup.cb = sizeof(STARTUPINFOW);
|
2002-07-25 02:18:23 +02:00
|
|
|
startup.dwFlags = STARTF_USESHOWWINDOW;
|
2004-03-18 05:04:29 +01:00
|
|
|
startup.wShowWindow = psei->nShow;
|
2007-07-16 17:14:07 +02:00
|
|
|
dwCreationFlags = CREATE_UNICODE_ENVIRONMENT;
|
2014-04-16 22:50:37 +02:00
|
|
|
if (!(psei->fMask & SEE_MASK_NO_CONSOLE))
|
2007-07-16 17:14:07 +02:00
|
|
|
dwCreationFlags |= CREATE_NEW_CONSOLE;
|
|
|
|
if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env,
|
2007-08-31 16:41:36 +02:00
|
|
|
lpDirectory, &startup, &info))
|
2002-07-25 02:18:23 +02:00
|
|
|
{
|
2002-10-29 22:30:01 +01:00
|
|
|
/* Give 30 seconds to the app to come up, if desired. Probably only needed
|
|
|
|
when starting app immediately before making a DDE connection. */
|
|
|
|
if (shWait)
|
2004-04-01 23:00:23 +02:00
|
|
|
if (WaitForInputIdle( info.hProcess, 30000 ) == WAIT_FAILED)
|
2006-10-07 20:18:14 +02:00
|
|
|
WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
|
2002-11-22 00:56:42 +01:00
|
|
|
retval = 33;
|
2004-03-18 05:04:29 +01:00
|
|
|
if (psei->fMask & SEE_MASK_NOCLOSEPROCESS)
|
|
|
|
psei_out->hProcess = info.hProcess;
|
2002-10-29 22:30:01 +01:00
|
|
|
else
|
|
|
|
CloseHandle( info.hProcess );
|
|
|
|
CloseHandle( info.hThread );
|
|
|
|
}
|
2002-11-22 00:56:42 +01:00
|
|
|
else if ((retval = GetLastError()) >= 32)
|
2002-10-29 22:30:01 +01:00
|
|
|
{
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("CreateProcess returned error %ld\n", retval);
|
2002-11-22 00:56:42 +01:00
|
|
|
retval = ERROR_BAD_FORMAT;
|
2002-07-25 02:18:23 +02:00
|
|
|
}
|
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("returning %lu\n", retval);
|
2004-02-12 21:04:09 +01:00
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
psei_out->hInstApp = (HINSTANCE)retval;
|
2004-09-14 22:14:09 +02:00
|
|
|
if( gcdret )
|
2004-03-19 02:52:30 +01:00
|
|
|
if( !SetCurrentDirectoryW( curdir))
|
|
|
|
ERR("cannot return to directory %s\n", debugstr_w(curdir));
|
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
return retval;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
|
2003-09-26 06:35:01 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2004-01-15 07:13:57 +01:00
|
|
|
* SHELL_BuildEnvW [Internal]
|
2003-09-26 06:35:01 +02:00
|
|
|
*
|
|
|
|
* Build the environment for the new process, adding the specified
|
|
|
|
* path to the PATH variable. Returned pointer must be freed by caller.
|
|
|
|
*/
|
2004-01-15 07:13:57 +01:00
|
|
|
static void *SHELL_BuildEnvW( const WCHAR *path )
|
2003-09-26 06:35:01 +02:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wPath[] = {'P','A','T','H','=',0};
|
|
|
|
WCHAR *strings, *new_env;
|
|
|
|
WCHAR *p, *p2;
|
|
|
|
int total = strlenW(path) + 1;
|
2003-09-26 06:35:01 +02:00
|
|
|
BOOL got_path = FALSE;
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if (!(strings = GetEnvironmentStringsW())) return NULL;
|
2003-09-26 06:35:01 +02:00
|
|
|
p = strings;
|
|
|
|
while (*p)
|
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
int len = strlenW(p) + 1;
|
|
|
|
if (!strncmpiW( p, wPath, 5 )) got_path = TRUE;
|
2003-09-26 06:35:01 +02:00
|
|
|
total += len;
|
|
|
|
p += len;
|
|
|
|
}
|
|
|
|
if (!got_path) total += 5; /* we need to create PATH */
|
|
|
|
total++; /* terminating null */
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
if (!(new_env = heap_alloc( total * sizeof(WCHAR) )))
|
2003-09-26 06:35:01 +02:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
FreeEnvironmentStringsW( strings );
|
2003-09-26 06:35:01 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
p = strings;
|
|
|
|
p2 = new_env;
|
|
|
|
while (*p)
|
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
int len = strlenW(p) + 1;
|
|
|
|
memcpy( p2, p, len * sizeof(WCHAR) );
|
|
|
|
if (!strncmpiW( p, wPath, 5 ))
|
2003-09-26 06:35:01 +02:00
|
|
|
{
|
|
|
|
p2[len - 1] = ';';
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW( p2 + len, path );
|
|
|
|
p2 += strlenW(path) + 1;
|
2003-09-26 06:35:01 +02:00
|
|
|
}
|
|
|
|
p += len;
|
|
|
|
p2 += len;
|
|
|
|
}
|
|
|
|
if (!got_path)
|
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW( p2, wPath );
|
|
|
|
strcatW( p2, path );
|
|
|
|
p2 += strlenW(p2) + 1;
|
2003-09-26 06:35:01 +02:00
|
|
|
}
|
|
|
|
*p2 = 0;
|
2004-01-15 07:13:57 +01:00
|
|
|
FreeEnvironmentStringsW( strings );
|
2003-09-26 06:35:01 +02:00
|
|
|
return new_env;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-03 04:03:36 +01:00
|
|
|
/***********************************************************************
|
2004-01-15 07:13:57 +01:00
|
|
|
* SHELL_TryAppPathW [Internal]
|
2003-01-03 04:03:36 +01:00
|
|
|
*
|
|
|
|
* Helper function for SHELL_FindExecutable
|
|
|
|
* @param lpResult - pointer to a buffer of size MAX_PATH
|
|
|
|
* On entry: szName is a filename (probably without path separators).
|
|
|
|
* On exit: if szName found in "App Path", place full path in lpResult, and return true
|
|
|
|
*/
|
2004-06-15 20:27:50 +02:00
|
|
|
static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, WCHAR **env)
|
2003-01-03 04:03:36 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wszKeyAppPaths[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',
|
|
|
|
'\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p',' ','P','a','t','h','s','\\',0};
|
|
|
|
static const WCHAR wPath[] = {'P','a','t','h',0};
|
2003-01-03 04:03:36 +01:00
|
|
|
HKEY hkApp = 0;
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR buffer[1024];
|
2003-01-03 04:03:36 +01:00
|
|
|
LONG len;
|
2003-09-26 06:35:01 +02:00
|
|
|
LONG res;
|
2003-01-03 04:03:36 +01:00
|
|
|
BOOL found = FALSE;
|
|
|
|
|
2003-09-26 06:35:01 +02:00
|
|
|
if (env) *env = NULL;
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(buffer, wszKeyAppPaths);
|
|
|
|
strcatW(buffer, szName);
|
|
|
|
res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buffer, 0, KEY_READ, &hkApp);
|
2003-09-26 06:35:01 +02:00
|
|
|
if (res) goto end;
|
2003-01-03 04:03:36 +01:00
|
|
|
|
2004-03-03 06:26:30 +01:00
|
|
|
len = MAX_PATH*sizeof(WCHAR);
|
2004-01-15 07:13:57 +01:00
|
|
|
res = RegQueryValueW(hkApp, NULL, lpResult, &len);
|
2003-09-26 06:35:01 +02:00
|
|
|
if (res) goto end;
|
2003-01-03 04:03:36 +01:00
|
|
|
found = TRUE;
|
|
|
|
|
2003-09-26 06:35:01 +02:00
|
|
|
if (env)
|
|
|
|
{
|
|
|
|
DWORD count = sizeof(buffer);
|
2004-01-15 07:13:57 +01:00
|
|
|
if (!RegQueryValueExW(hkApp, wPath, NULL, NULL, (LPBYTE)buffer, &count) && buffer[0])
|
|
|
|
*env = SHELL_BuildEnvW( buffer );
|
2003-09-26 06:35:01 +02:00
|
|
|
}
|
|
|
|
|
2003-01-03 04:03:36 +01:00
|
|
|
end:
|
|
|
|
if (hkApp) RegCloseKey(hkApp);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2010-03-24 19:05:21 +01:00
|
|
|
/*************************************************************************
|
2012-10-17 23:25:56 +02:00
|
|
|
* SHELL_FindExecutableByVerb [Internal]
|
2010-03-24 19:05:21 +01:00
|
|
|
*
|
|
|
|
* called from SHELL_FindExecutable or SHELL_execute_class
|
|
|
|
* in/out:
|
2012-10-17 23:25:56 +02:00
|
|
|
* classname a buffer, big enough, to get the key name to do actually the
|
2010-03-24 19:05:21 +01:00
|
|
|
* command "WordPad.Document.1\\shell\\open\\command"
|
|
|
|
* passed as "WordPad.Document.1"
|
|
|
|
* in:
|
2012-10-17 23:25:56 +02:00
|
|
|
* lpVerb the operation on it (open)
|
2010-03-24 19:05:21 +01:00
|
|
|
* commandlen the size of command buffer (in bytes)
|
|
|
|
* out:
|
|
|
|
* command a buffer, to store the command to do the
|
|
|
|
* operation on the file
|
|
|
|
* key a buffer, big enough, to get the key name to do actually the
|
|
|
|
* command "WordPad.Document.1\\shell\\open\\command"
|
|
|
|
* Can be NULL
|
|
|
|
*/
|
2012-10-17 23:25:56 +02:00
|
|
|
static UINT SHELL_FindExecutableByVerb(LPCWSTR lpVerb, LPWSTR key, LPWSTR classname, LPWSTR command, LONG commandlen)
|
2004-03-04 21:34:38 +01:00
|
|
|
{
|
|
|
|
static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0};
|
2006-06-23 18:32:38 +02:00
|
|
|
HKEY hkeyClass;
|
|
|
|
WCHAR verb[MAX_PATH];
|
|
|
|
|
2012-10-17 23:25:56 +02:00
|
|
|
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, classname, 0, 0x02000000, &hkeyClass))
|
2006-12-14 18:00:12 +01:00
|
|
|
return SE_ERR_NOASSOC;
|
2018-03-19 08:11:27 +01:00
|
|
|
if (!HCR_GetDefaultVerbW(hkeyClass, lpVerb, verb, ARRAY_SIZE(verb)))
|
2006-12-14 18:00:12 +01:00
|
|
|
return SE_ERR_NOASSOC;
|
2006-06-23 18:32:38 +02:00
|
|
|
RegCloseKey(hkeyClass);
|
2004-03-04 21:34:38 +01:00
|
|
|
|
|
|
|
/* Looking for ...buffer\shell\<verb>\command */
|
2012-10-17 23:25:56 +02:00
|
|
|
strcatW(classname, wszShell);
|
|
|
|
strcatW(classname, verb);
|
|
|
|
strcatW(classname, wCommand);
|
2004-03-04 21:34:38 +01:00
|
|
|
|
2012-10-17 23:25:56 +02:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, classname, command,
|
2004-03-04 21:34:38 +01:00
|
|
|
&commandlen) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
commandlen /= sizeof(WCHAR);
|
2012-10-17 23:25:56 +02:00
|
|
|
if (key) strcpyW(key, classname);
|
2004-03-04 21:34:38 +01:00
|
|
|
#if 0
|
|
|
|
LPWSTR tmp;
|
|
|
|
WCHAR param[256];
|
|
|
|
LONG paramlen = sizeof(param);
|
|
|
|
static const WCHAR wSpace[] = {' ',0};
|
|
|
|
|
|
|
|
/* FIXME: it seems all Windows version don't behave the same here.
|
|
|
|
* the doc states that this ddeexec information can be found after
|
|
|
|
* the exec names.
|
|
|
|
* on Win98, it doesn't appear, but I think it does on Win2k
|
|
|
|
*/
|
|
|
|
/* Get the parameters needed by the application
|
|
|
|
from the associated ddeexec key */
|
2012-10-17 23:25:56 +02:00
|
|
|
tmp = strstrW(classname, wCommand);
|
2004-03-04 21:34:38 +01:00
|
|
|
tmp[0] = '\0';
|
2012-10-17 23:25:56 +02:00
|
|
|
strcatW(classname, wDdeexec);
|
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, classname, param,
|
2004-03-04 21:34:38 +01:00
|
|
|
¶mlen) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
paramlen /= sizeof(WCHAR);
|
|
|
|
strcatW(command, wSpace);
|
|
|
|
strcatW(command, param);
|
|
|
|
commandlen += paramlen;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
command[commandlen] = '\0';
|
|
|
|
|
|
|
|
return 33; /* FIXME see SHELL_FindExecutable() */
|
|
|
|
}
|
|
|
|
|
2006-12-14 18:00:12 +01:00
|
|
|
return SE_ERR_NOASSOC;
|
2004-03-04 21:34:38 +01:00
|
|
|
}
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* SHELL_FindExecutable [Internal]
|
|
|
|
*
|
|
|
|
* Utility for code sharing between FindExecutable and ShellExecute
|
2002-06-01 01:06:46 +02:00
|
|
|
* in:
|
2002-02-27 02:22:15 +01:00
|
|
|
* lpFile the name of a file
|
2012-10-17 23:25:56 +02:00
|
|
|
* lpVerb the operation on it (open)
|
2002-02-27 02:22:15 +01:00
|
|
|
* out:
|
|
|
|
* lpResult a buffer, big enough :-(, to store the command to do the
|
|
|
|
* operation on the file
|
|
|
|
* key a buffer, big enough, to get the key name to do actually the
|
|
|
|
* command (it'll be used afterwards for more information
|
|
|
|
* on the operation)
|
|
|
|
*/
|
2012-10-17 23:25:56 +02:00
|
|
|
static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
|
2004-06-15 20:27:50 +02:00
|
|
|
LPWSTR lpResult, int resultLen, LPWSTR key, WCHAR **env, LPITEMIDLIST pidl, LPCWSTR args)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wWindows[] = {'w','i','n','d','o','w','s',0};
|
|
|
|
static const WCHAR wPrograms[] = {'p','r','o','g','r','a','m','s',0};
|
|
|
|
static const WCHAR wExtensions[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
|
|
|
|
WCHAR *extension = NULL; /* pointer to file extension */
|
2012-10-17 23:25:56 +02:00
|
|
|
WCHAR classname[256]; /* registry name for this file type */
|
|
|
|
LONG classnamelen = sizeof(classname); /* length of above */
|
2004-04-09 21:04:03 +02:00
|
|
|
WCHAR command[1024]; /* command from registry */
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR wBuffer[256]; /* Used to GetProfileString */
|
2006-12-14 18:00:12 +01:00
|
|
|
UINT retval = SE_ERR_NOASSOC;
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR *tok; /* token pointer */
|
2004-04-05 23:06:16 +02:00
|
|
|
WCHAR xlpFile[256]; /* result of SearchPath */
|
2004-04-13 02:18:45 +02:00
|
|
|
DWORD attribs; /* file attributes */
|
2004-01-15 07:13:57 +01:00
|
|
|
|
2007-01-18 11:38:19 +01:00
|
|
|
TRACE("%s\n", debugstr_w(lpFile));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-12-01 23:30:13 +01:00
|
|
|
if (!lpResult)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2004-04-05 23:06:16 +02:00
|
|
|
xlpFile[0] = '\0';
|
2002-02-27 02:22:15 +01:00
|
|
|
lpResult[0] = '\0'; /* Start off with an empty return string */
|
2003-01-03 04:03:36 +01:00
|
|
|
if (key) *key = '\0';
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* trap NULL parameters on entry */
|
2006-12-01 23:30:13 +01:00
|
|
|
if (!lpFile)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2006-06-23 18:32:38 +02:00
|
|
|
WARN("(lpFile=%s,lpResult=%s): NULL parameter\n",
|
|
|
|
debugstr_w(lpFile), debugstr_w(lpResult));
|
2006-12-01 23:30:13 +01:00
|
|
|
return ERROR_FILE_NOT_FOUND; /* File not found. Close enough, I guess. */
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if (SHELL_TryAppPathW( lpFile, lpResult, env ))
|
2003-01-03 04:03:36 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("found %s via App Paths\n", debugstr_w(lpResult));
|
2003-01-03 04:03:36 +01:00
|
|
|
return 33;
|
|
|
|
}
|
|
|
|
|
2018-03-19 08:11:27 +01:00
|
|
|
if (SearchPathW(lpPath, lpFile, wszExe, ARRAY_SIZE(xlpFile), xlpFile, NULL))
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("SearchPathW returned non-zero\n");
|
2002-02-27 02:22:15 +01:00
|
|
|
lpFile = xlpFile;
|
2012-07-10 19:59:24 +02:00
|
|
|
/* The file was found in the application-supplied default directory (or the system search path) */
|
|
|
|
}
|
2018-03-19 08:11:27 +01:00
|
|
|
else if (lpPath && SearchPathW(NULL, lpFile, wszExe, ARRAY_SIZE(xlpFile), xlpFile, NULL))
|
2012-07-10 19:59:24 +02:00
|
|
|
{
|
|
|
|
TRACE("SearchPathW returned non-zero\n");
|
|
|
|
lpFile = xlpFile;
|
|
|
|
/* The file was found in one of the directories in the system-wide search path */
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-04-13 02:18:45 +02:00
|
|
|
attribs = GetFileAttributesW(lpFile);
|
|
|
|
if (attribs!=INVALID_FILE_ATTRIBUTES && (attribs&FILE_ATTRIBUTE_DIRECTORY))
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2012-10-17 23:25:56 +02:00
|
|
|
strcpyW(classname, wszFolder);
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2004-04-13 02:18:45 +02:00
|
|
|
else
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2008-12-08 20:06:12 +01:00
|
|
|
/* Did we get something? Anything? */
|
|
|
|
if (xlpFile[0]==0)
|
|
|
|
{
|
|
|
|
TRACE("Returning SE_ERR_FNF\n");
|
|
|
|
return SE_ERR_FNF;
|
|
|
|
}
|
2004-04-13 02:18:45 +02:00
|
|
|
/* First thing we need is the file's extension */
|
|
|
|
extension = strrchrW(xlpFile, '.'); /* Assume last "." is the one; */
|
|
|
|
/* File->Run in progman uses */
|
|
|
|
/* .\FILE.EXE :( */
|
|
|
|
TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
|
|
|
|
|
|
|
|
if (extension == NULL || extension[1]==0)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2006-12-14 18:00:12 +01:00
|
|
|
WARN("Returning SE_ERR_NOASSOC\n");
|
|
|
|
return SE_ERR_NOASSOC;
|
2004-04-13 02:18:45 +02:00
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
|
2004-04-13 02:18:45 +02:00
|
|
|
/* Three places to check: */
|
|
|
|
/* 1. win.ini, [windows], programs (NB no leading '.') */
|
2012-10-17 23:25:56 +02:00
|
|
|
/* 2. Registry, HKEY_CLASS_ROOT\<classname>\shell\open\command */
|
2004-04-13 02:18:45 +02:00
|
|
|
/* 3. win.ini, [extensions], extension (NB no leading '.' */
|
|
|
|
/* All I know of the order is that registry is checked before */
|
|
|
|
/* extensions; however, it'd make sense to check the programs */
|
|
|
|
/* section first, so that's what happens here. */
|
|
|
|
|
|
|
|
/* See if it's a program - if GetProfileString fails, we skip this
|
|
|
|
* section. Actually, if GetProfileString fails, we've probably
|
|
|
|
* got a lot more to worry about than running a program... */
|
2018-03-19 08:11:27 +01:00
|
|
|
if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, ARRAY_SIZE(wBuffer)) > 0)
|
2004-04-13 02:18:45 +02:00
|
|
|
{
|
|
|
|
CharLowerW(wBuffer);
|
|
|
|
tok = wBuffer;
|
|
|
|
while (*tok)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-04-13 02:18:45 +02:00
|
|
|
WCHAR *p = tok;
|
|
|
|
while (*p && *p != ' ' && *p != '\t') p++;
|
|
|
|
if (*p)
|
|
|
|
{
|
|
|
|
*p++ = 0;
|
|
|
|
while (*p == ' ' || *p == '\t') p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmpiW(tok, &extension[1]) == 0) /* have to skip the leading "." */
|
|
|
|
{
|
|
|
|
strcpyW(lpResult, xlpFile);
|
|
|
|
/* Need to perhaps check that the file has a path
|
|
|
|
* attached */
|
|
|
|
TRACE("found %s\n", debugstr_w(lpResult));
|
|
|
|
return 33;
|
2007-11-16 23:11:49 +01:00
|
|
|
/* Greater than 32 to indicate success */
|
2004-04-13 02:18:45 +02:00
|
|
|
}
|
|
|
|
tok = p;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-04-13 02:18:45 +02:00
|
|
|
/* Check registry */
|
2012-10-17 23:25:56 +02:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, extension, classname,
|
|
|
|
&classnamelen) == ERROR_SUCCESS)
|
2004-04-13 02:18:45 +02:00
|
|
|
{
|
2012-10-17 23:25:56 +02:00
|
|
|
classnamelen /= sizeof(WCHAR);
|
2018-03-19 08:11:27 +01:00
|
|
|
if (classnamelen == ARRAY_SIZE(classname))
|
2012-10-17 23:25:56 +02:00
|
|
|
classnamelen--;
|
|
|
|
classname[classnamelen] = '\0';
|
|
|
|
TRACE("File type: %s\n", debugstr_w(classname));
|
2004-04-13 02:18:45 +02:00
|
|
|
}
|
2006-02-22 12:04:02 +01:00
|
|
|
else
|
|
|
|
{
|
2012-10-17 23:25:56 +02:00
|
|
|
*classname = '\0';
|
2006-02-22 12:04:02 +01:00
|
|
|
}
|
2004-03-04 21:34:38 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2012-10-17 23:25:56 +02:00
|
|
|
if (*classname)
|
2004-03-04 21:34:38 +01:00
|
|
|
{
|
2012-10-17 23:25:56 +02:00
|
|
|
/* pass the verb string to SHELL_FindExecutableByVerb() */
|
|
|
|
retval = SHELL_FindExecutableByVerb(lpVerb, key, classname, command, sizeof(command));
|
2004-03-04 21:34:38 +01:00
|
|
|
|
|
|
|
if (retval > 32)
|
2004-03-26 03:29:12 +01:00
|
|
|
{
|
2006-11-03 17:24:19 +01:00
|
|
|
DWORD finishedLen;
|
|
|
|
SHELL_ArgifyW(lpResult, resultLen, command, xlpFile, pidl, args, &finishedLen);
|
|
|
|
if (finishedLen > resultLen)
|
|
|
|
ERR("Argify buffer not large enough.. truncated\n");
|
2004-03-26 03:29:12 +01:00
|
|
|
|
|
|
|
/* Remove double quotation marks and command line arguments */
|
|
|
|
if (*lpResult == '"')
|
|
|
|
{
|
|
|
|
WCHAR *p = lpResult;
|
|
|
|
while (*(p + 1) != '"')
|
|
|
|
{
|
|
|
|
*p = *(p + 1);
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
*p = '\0';
|
|
|
|
}
|
2006-12-13 18:06:45 +01:00
|
|
|
else
|
|
|
|
{
|
2008-03-01 05:33:54 +01:00
|
|
|
/* Truncate on first space */
|
2006-12-13 18:06:45 +01:00
|
|
|
WCHAR *p = lpResult;
|
|
|
|
while (*p != ' ' && *p != '\0')
|
|
|
|
p++;
|
|
|
|
*p='\0';
|
|
|
|
}
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Check win.ini */
|
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wExtensions[] = {'e','x','t','e','n','s','i','o','n','s',0};
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Toss the leading dot */
|
|
|
|
extension++;
|
2018-03-19 08:11:27 +01:00
|
|
|
if (GetProfileStringW(wExtensions, extension, wszEmpty, command, ARRAY_SIZE(command)) > 0)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2018-12-09 01:48:14 +01:00
|
|
|
if (*command)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(lpResult, command);
|
|
|
|
tok = strchrW(lpResult, '^'); /* should be ^.extension? */
|
2002-02-27 02:22:15 +01:00
|
|
|
if (tok != NULL)
|
|
|
|
{
|
|
|
|
tok[0] = '\0';
|
2004-01-15 07:13:57 +01:00
|
|
|
strcatW(lpResult, xlpFile); /* what if no dir in xlpFile? */
|
|
|
|
tok = strchrW(command, '^'); /* see above */
|
|
|
|
if ((tok != NULL) && (strlenW(tok)>5))
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
strcatW(lpResult, &tok[5]);
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
retval = 33; /* FIXME - see above */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("returning %s\n", debugstr_w(lpResult));
|
2002-02-27 02:22:15 +01:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* dde_cb
|
|
|
|
*
|
2005-07-11 12:59:41 +02:00
|
|
|
* callback for the DDE connection. not really useful
|
2002-02-27 02:22:15 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HDDEDATA CALLBACK dde_cb(UINT uType, UINT uFmt, HCONV hConv,
|
2004-04-27 01:29:44 +02:00
|
|
|
HSZ hsz1, HSZ hsz2, HDDEDATA hData,
|
|
|
|
ULONG_PTR dwData1, ULONG_PTR dwData2)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-06-15 19:02:46 +02:00
|
|
|
TRACE("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n",
|
2004-06-15 02:44:14 +02:00
|
|
|
uType, uFmt, hConv, hsz1, hsz2, hData, dwData1, dwData2);
|
2002-12-02 19:10:57 +01:00
|
|
|
return NULL;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* dde_connect
|
|
|
|
*
|
|
|
|
* ShellExecute helper. Used to do an operation with a DDE connection
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Handles both the direct connection (try #1), and if it fails,
|
2002-02-27 02:22:15 +01:00
|
|
|
* launching an application and trying (#2) to connect to it
|
|
|
|
*
|
|
|
|
*/
|
2007-11-16 21:40:56 +01:00
|
|
|
static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec,
|
2004-06-15 20:27:50 +02:00
|
|
|
const WCHAR* lpFile, WCHAR *env,
|
2004-03-26 03:29:12 +01:00
|
|
|
LPCWSTR szCommandline, LPITEMIDLIST pidl, SHELL_ExecuteW32 execfunc,
|
2007-10-31 00:07:38 +01:00
|
|
|
const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wApplication[] = {'\\','a','p','p','l','i','c','a','t','i','o','n',0};
|
|
|
|
static const WCHAR wTopic[] = {'\\','t','o','p','i','c',0};
|
2007-11-16 21:40:56 +01:00
|
|
|
WCHAR regkey[256];
|
|
|
|
WCHAR * endkey = regkey + strlenW(key);
|
2011-07-19 19:47:29 +02:00
|
|
|
WCHAR app[256], topic[256], ifexec[256], static_res[256];
|
|
|
|
WCHAR * dynamic_res=NULL;
|
|
|
|
WCHAR * res;
|
2002-02-27 02:22:15 +01:00
|
|
|
LONG applen, topiclen, ifexeclen;
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR * exec;
|
2002-02-27 02:22:15 +01:00
|
|
|
DWORD ddeInst = 0;
|
|
|
|
DWORD tid;
|
2011-10-16 22:07:05 +02:00
|
|
|
DWORD resultLen, endkeyLen;
|
2002-02-27 02:22:15 +01:00
|
|
|
HSZ hszApp, hszTopic;
|
|
|
|
HCONV hConv;
|
2004-06-14 21:32:32 +02:00
|
|
|
HDDEDATA hDdeData;
|
2006-12-14 18:00:12 +01:00
|
|
|
unsigned ret = SE_ERR_NOASSOC;
|
2005-11-11 11:54:07 +01:00
|
|
|
BOOL unicode = !(GetVersion() & 0x80000000);
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2018-03-29 17:14:11 +02:00
|
|
|
if (strlenW(key) + 1 > ARRAY_SIZE(regkey))
|
2011-10-16 22:07:05 +02:00
|
|
|
{
|
|
|
|
FIXME("input parameter %s larger than buffer\n", debugstr_w(key));
|
|
|
|
return 2;
|
|
|
|
}
|
2007-11-16 21:40:56 +01:00
|
|
|
strcpyW(regkey, key);
|
2018-03-29 17:14:11 +02:00
|
|
|
endkeyLen = ARRAY_SIZE(regkey) - (endkey - regkey);
|
2011-10-16 22:07:05 +02:00
|
|
|
if (strlenW(wApplication) + 1 > endkeyLen)
|
|
|
|
{
|
|
|
|
FIXME("endkey %s overruns buffer\n", debugstr_w(wApplication));
|
|
|
|
return 2;
|
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(endkey, wApplication);
|
2004-03-03 06:26:30 +01:00
|
|
|
applen = sizeof(app);
|
2007-11-16 21:40:56 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, app, &applen) != ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2007-05-28 03:01:10 +02:00
|
|
|
WCHAR command[1024], fullpath[MAX_PATH];
|
|
|
|
static const WCHAR wSo[] = { '.','s','o',0 };
|
2018-11-15 20:42:19 +01:00
|
|
|
int sizeSo = ARRAY_SIZE(wSo);
|
2007-05-28 03:01:10 +02:00
|
|
|
LPWSTR ptr = NULL;
|
|
|
|
DWORD ret = 0;
|
|
|
|
|
|
|
|
/* Get application command from start string and find filename of application */
|
|
|
|
if (*start == '"')
|
|
|
|
{
|
2018-03-29 17:14:11 +02:00
|
|
|
if (strlenW(start + 1) + 1 > ARRAY_SIZE(command))
|
2011-10-16 22:07:05 +02:00
|
|
|
{
|
|
|
|
FIXME("size of input parameter %s larger than buffer\n",
|
|
|
|
debugstr_w(start + 1));
|
|
|
|
return 2;
|
|
|
|
}
|
2007-05-28 03:01:10 +02:00
|
|
|
strcpyW(command, start+1);
|
|
|
|
if ((ptr = strchrW(command, '"')))
|
|
|
|
*ptr = 0;
|
2018-03-29 17:14:11 +02:00
|
|
|
ret = SearchPathW(NULL, command, wszExe, ARRAY_SIZE(fullpath), fullpath, &ptr);
|
2007-05-28 03:01:10 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-28 09:57:39 +02:00
|
|
|
LPCWSTR p;
|
|
|
|
LPWSTR space;
|
|
|
|
for (p=start; (space=strchrW(p, ' ')); p=space+1)
|
2007-05-28 03:01:10 +02:00
|
|
|
{
|
|
|
|
int idx = space-start;
|
|
|
|
memcpy(command, start, idx*sizeof(WCHAR));
|
|
|
|
command[idx] = '\0';
|
2018-03-29 17:14:11 +02:00
|
|
|
if ((ret = SearchPathW(NULL, command, wszExe, ARRAY_SIZE(fullpath), fullpath, &ptr)))
|
2007-05-28 03:01:10 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!ret)
|
2018-03-29 17:14:11 +02:00
|
|
|
ret = SearchPathW(NULL, start, wszExe, ARRAY_SIZE(fullpath), fullpath, &ptr);
|
2007-05-28 03:01:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
ERR("Unable to find application path for command %s\n", debugstr_w(start));
|
|
|
|
return ERROR_ACCESS_DENIED;
|
|
|
|
}
|
2018-03-29 17:14:11 +02:00
|
|
|
if (strlenW(ptr) + 1 > ARRAY_SIZE(app))
|
2011-10-16 22:07:05 +02:00
|
|
|
{
|
|
|
|
FIXME("size of found path %s larger than buffer\n", debugstr_w(ptr));
|
|
|
|
return 2;
|
|
|
|
}
|
2007-05-28 03:01:10 +02:00
|
|
|
strcpyW(app, ptr);
|
|
|
|
|
|
|
|
/* Remove extensions (including .so) */
|
|
|
|
ptr = app + strlenW(app) - (sizeSo-1);
|
|
|
|
if (strlenW(app) >= sizeSo &&
|
|
|
|
!strcmpW(ptr, wSo))
|
|
|
|
*ptr = 0;
|
|
|
|
|
|
|
|
ptr = strrchrW(app, '.');
|
|
|
|
assert(ptr);
|
|
|
|
*ptr = 0;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2011-10-16 22:07:05 +02:00
|
|
|
if (strlenW(wTopic) + 1 > endkeyLen)
|
|
|
|
{
|
|
|
|
FIXME("endkey %s overruns buffer\n", debugstr_w(wTopic));
|
|
|
|
return 2;
|
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(endkey, wTopic);
|
2004-03-03 06:26:30 +01:00
|
|
|
topiclen = sizeof(topic);
|
2007-11-16 21:40:56 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, topic, &topiclen) != ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wSystem[] = {'S','y','s','t','e','m',0};
|
|
|
|
strcpyW(topic, wSystem);
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-10-18 16:11:17 +02:00
|
|
|
if (unicode)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2005-10-18 16:11:17 +02:00
|
|
|
if (DdeInitializeW(&ddeInst, dde_cb, APPCMD_CLIENTONLY, 0L) != DMLERR_NO_ERROR)
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (DdeInitializeA(&ddeInst, dde_cb, APPCMD_CLIENTONLY, 0L) != DMLERR_NO_ERROR)
|
|
|
|
return 2;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-04-23 23:32:17 +02:00
|
|
|
hszApp = DdeCreateStringHandleW(ddeInst, app, CP_WINUNICODE);
|
|
|
|
hszTopic = DdeCreateStringHandleW(ddeInst, topic, CP_WINUNICODE);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL);
|
|
|
|
exec = ddeexec;
|
|
|
|
if (!hConv)
|
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wIfexec[] = {'\\','i','f','e','x','e','c',0};
|
2007-01-18 11:38:19 +01:00
|
|
|
TRACE("Launching %s\n", debugstr_w(start));
|
2004-03-18 05:04:29 +01:00
|
|
|
ret = execfunc(start, env, TRUE, psei, psei_out);
|
2006-12-14 18:00:12 +01:00
|
|
|
if (ret <= 32)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
|
|
|
TRACE("Couldn't launch\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL);
|
|
|
|
if (!hConv)
|
|
|
|
{
|
2002-09-16 21:27:51 +02:00
|
|
|
TRACE("Couldn't connect. ret=%d\n", ret);
|
2004-03-01 22:22:25 +01:00
|
|
|
DdeUninitialize(ddeInst);
|
|
|
|
SetLastError(ERROR_DDE_FAIL);
|
|
|
|
return 30; /* whatever */
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2011-10-16 22:07:05 +02:00
|
|
|
if (strlenW(wIfexec) + 1 > endkeyLen)
|
|
|
|
{
|
|
|
|
FIXME("endkey %s overruns buffer\n", debugstr_w(wIfexec));
|
|
|
|
return 2;
|
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(endkey, wIfexec);
|
2004-03-03 06:26:30 +01:00
|
|
|
ifexeclen = sizeof(ifexec);
|
2007-11-16 21:40:56 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, ifexec, &ifexeclen) == ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
|
|
|
exec = ifexec;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2018-03-29 17:14:11 +02:00
|
|
|
SHELL_ArgifyW(static_res, ARRAY_SIZE(static_res), exec, lpFile, pidl, szCommandline, &resultLen);
|
|
|
|
if (resultLen > ARRAY_SIZE(static_res))
|
2011-07-19 19:47:29 +02:00
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
res = dynamic_res = heap_alloc(resultLen * sizeof(WCHAR));
|
2011-07-19 19:47:29 +02:00
|
|
|
SHELL_ArgifyW(dynamic_res, resultLen, exec, lpFile, pidl, szCommandline, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res = static_res;
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("%s %s => %s\n", debugstr_w(exec), debugstr_w(lpFile), debugstr_w(res));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-06-14 21:32:32 +02:00
|
|
|
/* It's documented in the KB 330337 that IE has a bug and returns
|
|
|
|
* error DMLERR_NOTPROCESSED on XTYP_EXECUTE request.
|
|
|
|
*/
|
2005-10-18 16:11:17 +02:00
|
|
|
if (unicode)
|
|
|
|
hDdeData = DdeClientTransaction((LPBYTE)res, (strlenW(res) + 1) * sizeof(WCHAR), hConv, 0L, 0,
|
2006-02-01 12:29:39 +01:00
|
|
|
XTYP_EXECUTE, 30000, &tid);
|
2005-10-18 16:11:17 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD lenA = WideCharToMultiByte(CP_ACP, 0, res, -1, NULL, 0, NULL, NULL);
|
2018-02-22 08:43:28 +01:00
|
|
|
char *resA = heap_alloc(lenA);
|
2005-10-18 16:11:17 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, res, -1, resA, lenA, NULL, NULL);
|
|
|
|
hDdeData = DdeClientTransaction( (LPBYTE)resA, lenA, hConv, 0L, 0,
|
|
|
|
XTYP_EXECUTE, 10000, &tid );
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(resA);
|
2005-10-18 16:11:17 +02:00
|
|
|
}
|
2004-06-14 21:32:32 +02:00
|
|
|
if (hDdeData)
|
|
|
|
DdeFreeDataHandle(hDdeData);
|
|
|
|
else
|
|
|
|
WARN("DdeClientTransaction failed with error %04x\n", DdeGetLastError(ddeInst));
|
|
|
|
ret = 33;
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(dynamic_res);
|
2011-07-19 19:47:29 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
DdeDisconnect(hConv);
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
error:
|
|
|
|
DdeUninitialize(ddeInst);
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* execute_from_key [Internal]
|
|
|
|
*/
|
2007-11-16 21:41:43 +01:00
|
|
|
static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env, LPCWSTR szCommandline,
|
2006-02-01 12:29:39 +01:00
|
|
|
LPCWSTR executable_name,
|
2004-03-18 05:04:29 +01:00
|
|
|
SHELL_ExecuteW32 execfunc,
|
2005-11-11 11:54:07 +01:00
|
|
|
LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2007-05-28 03:01:01 +02:00
|
|
|
static const WCHAR wCommand[] = {'c','o','m','m','a','n','d',0};
|
|
|
|
static const WCHAR wDdeexec[] = {'d','d','e','e','x','e','c',0};
|
|
|
|
WCHAR cmd[256], param[1024], ddeexec[256];
|
|
|
|
LONG cmdlen = sizeof(cmd), ddeexeclen = sizeof(ddeexec);
|
2006-12-14 18:00:12 +01:00
|
|
|
UINT_PTR retval = SE_ERR_NOASSOC;
|
2007-05-28 03:01:01 +02:00
|
|
|
DWORD resultLen;
|
|
|
|
LPWSTR tmp;
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2006-02-01 12:29:39 +01:00
|
|
|
TRACE("%s %s %s %s %s\n", debugstr_w(key), debugstr_w(lpFile), debugstr_w(env),
|
|
|
|
debugstr_w(szCommandline), debugstr_w(executable_name));
|
|
|
|
|
2004-04-05 23:06:16 +02:00
|
|
|
cmd[0] = '\0';
|
2007-05-28 03:01:01 +02:00
|
|
|
param[0] = '\0';
|
2004-04-05 23:06:16 +02:00
|
|
|
|
2006-02-01 12:29:39 +01:00
|
|
|
/* Get the application from the registry */
|
2004-01-15 07:13:57 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, cmd, &cmdlen) == ERROR_SUCCESS)
|
2006-02-01 12:29:39 +01:00
|
|
|
{
|
|
|
|
TRACE("got cmd: %s\n", debugstr_w(cmd));
|
|
|
|
|
|
|
|
/* Is there a replace() function anywhere? */
|
|
|
|
cmdlen /= sizeof(WCHAR);
|
2018-03-29 17:14:11 +02:00
|
|
|
if (cmdlen >= ARRAY_SIZE(cmd))
|
|
|
|
cmdlen = ARRAY_SIZE(cmd) - 1;
|
2006-02-01 12:29:39 +01:00
|
|
|
cmd[cmdlen] = '\0';
|
2018-03-29 17:14:11 +02:00
|
|
|
SHELL_ArgifyW(param, ARRAY_SIZE(param), cmd, lpFile, psei->lpIDList, szCommandline, &resultLen);
|
|
|
|
if (resultLen > ARRAY_SIZE(param))
|
2006-11-03 17:24:19 +01:00
|
|
|
ERR("Argify buffer not large enough, truncating\n");
|
2007-05-28 03:01:01 +02:00
|
|
|
}
|
2006-11-03 17:24:19 +01:00
|
|
|
|
2007-05-28 03:01:01 +02:00
|
|
|
/* Get the parameters needed by the application
|
|
|
|
from the associated ddeexec key */
|
|
|
|
tmp = strstrW(key, wCommand);
|
|
|
|
assert(tmp);
|
|
|
|
strcpyW(tmp, wDdeexec);
|
|
|
|
|
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, ddeexec, &ddeexeclen) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
TRACE("Got ddeexec %s => %s\n", debugstr_w(key), debugstr_w(ddeexec));
|
|
|
|
if (!param[0]) strcpyW(param, executable_name);
|
|
|
|
retval = dde_connect(key, param, ddeexec, lpFile, env, szCommandline, psei->lpIDList, execfunc, psei, psei_out);
|
|
|
|
}
|
|
|
|
else if (param[0])
|
|
|
|
{
|
2006-03-13 06:44:41 +01:00
|
|
|
TRACE("executing: %s\n", debugstr_w(param));
|
2006-02-01 12:29:39 +01:00
|
|
|
retval = execfunc(param, env, FALSE, psei, psei_out);
|
|
|
|
}
|
|
|
|
else
|
2007-05-28 03:01:01 +02:00
|
|
|
WARN("Nothing appropriate found for %s\n", debugstr_w(key));
|
2002-02-27 02:22:15 +01:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FindExecutableA [SHELL32.@]
|
|
|
|
*/
|
|
|
|
HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
|
2004-01-15 07:13:57 +01:00
|
|
|
{
|
|
|
|
HINSTANCE retval;
|
|
|
|
WCHAR *wFile = NULL, *wDirectory = NULL;
|
|
|
|
WCHAR wResult[MAX_PATH];
|
|
|
|
|
|
|
|
if (lpFile) __SHCloneStrAtoW(&wFile, lpFile);
|
|
|
|
if (lpDirectory) __SHCloneStrAtoW(&wDirectory, lpDirectory);
|
|
|
|
|
|
|
|
retval = FindExecutableW(wFile, wDirectory, wResult);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, wResult, -1, lpResult, MAX_PATH, NULL, NULL);
|
2006-10-07 03:06:26 +02:00
|
|
|
SHFree( wFile );
|
|
|
|
SHFree( wDirectory );
|
2004-01-15 07:13:57 +01:00
|
|
|
|
|
|
|
TRACE("returning %s\n", lpResult);
|
2005-09-02 13:32:17 +02:00
|
|
|
return retval;
|
2004-01-15 07:13:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FindExecutableW [SHELL32.@]
|
2006-12-13 18:07:21 +01:00
|
|
|
*
|
|
|
|
* This function returns the executable associated with the specified file
|
|
|
|
* for the default verb.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpFile [I] The file to find the association for. This must refer to
|
|
|
|
* an existing file otherwise FindExecutable fails and returns
|
|
|
|
* SE_ERR_FNF.
|
|
|
|
* lpResult [O] Points to a buffer into which the executable path is
|
|
|
|
* copied. This parameter must not be NULL otherwise
|
|
|
|
* FindExecutable() segfaults. The buffer must be of size at
|
|
|
|
* least MAX_PATH characters.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* A value greater than 32 on success, less than or equal to 32 otherwise.
|
|
|
|
* See the SE_ERR_* constants.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* On Windows XP and 2003, FindExecutable() seems to first convert the
|
|
|
|
* filename into 8.3 format, thus taking into account only the first three
|
|
|
|
* characters of the extension, and expects to find an association for those.
|
|
|
|
* However other Windows versions behave sanely.
|
2004-01-15 07:13:57 +01:00
|
|
|
*/
|
|
|
|
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2006-12-14 18:00:12 +01:00
|
|
|
UINT_PTR retval = SE_ERR_NOASSOC;
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR old_dir[1024];
|
2016-03-23 20:25:12 +01:00
|
|
|
WCHAR res[MAX_PATH];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2007-01-18 11:38:19 +01:00
|
|
|
TRACE("File %s, Dir %s\n", debugstr_w(lpFile), debugstr_w(lpDirectory));
|
2002-02-27 02:22:15 +01:00
|
|
|
|
|
|
|
lpResult[0] = '\0'; /* Start off with an empty return string */
|
2006-12-13 18:07:42 +01:00
|
|
|
if (lpFile == NULL)
|
|
|
|
return (HINSTANCE)SE_ERR_FNF;
|
2002-02-27 02:22:15 +01:00
|
|
|
|
|
|
|
if (lpDirectory)
|
|
|
|
{
|
2018-03-29 17:14:11 +02:00
|
|
|
GetCurrentDirectoryW(ARRAY_SIZE(old_dir), old_dir);
|
2004-01-15 07:13:57 +01:00
|
|
|
SetCurrentDirectoryW(lpDirectory);
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2016-03-23 20:25:12 +01:00
|
|
|
retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, res, MAX_PATH, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (retval > 32)
|
|
|
|
strcpyW(lpResult, res);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("returning %s\n", debugstr_w(lpResult));
|
2002-02-27 02:22:15 +01:00
|
|
|
if (lpDirectory)
|
2004-01-15 07:13:57 +01:00
|
|
|
SetCurrentDirectoryW(old_dir);
|
2002-11-22 00:56:42 +01:00
|
|
|
return (HINSTANCE)retval;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
|
2005-11-03 12:33:57 +01:00
|
|
|
/* FIXME: is this already implemented somewhere else? */
|
2007-10-31 00:07:38 +01:00
|
|
|
static HKEY ShellExecute_GetClassKey( const SHELLEXECUTEINFOW *sei )
|
2005-11-03 12:33:57 +01:00
|
|
|
{
|
|
|
|
LPCWSTR ext = NULL, lpClass = NULL;
|
|
|
|
LPWSTR cls = NULL;
|
|
|
|
DWORD type = 0, sz = 0;
|
|
|
|
HKEY hkey = 0;
|
|
|
|
LONG r;
|
|
|
|
|
|
|
|
if (sei->fMask & SEE_MASK_CLASSALL)
|
|
|
|
return sei->hkeyClass;
|
|
|
|
|
|
|
|
if (sei->fMask & SEE_MASK_CLASSNAME)
|
|
|
|
lpClass = sei->lpClass;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ext = PathFindExtensionW( sei->lpFile );
|
|
|
|
TRACE("ext = %s\n", debugstr_w( ext ) );
|
|
|
|
if (!ext)
|
|
|
|
return hkey;
|
|
|
|
|
|
|
|
r = RegOpenKeyW( HKEY_CLASSES_ROOT, ext, &hkey );
|
|
|
|
if (r != ERROR_SUCCESS )
|
|
|
|
return hkey;
|
|
|
|
|
|
|
|
r = RegQueryValueExW( hkey, NULL, 0, &type, NULL, &sz );
|
|
|
|
if ( r == ERROR_SUCCESS && type == REG_SZ )
|
|
|
|
{
|
|
|
|
sz += sizeof (WCHAR);
|
2018-02-22 08:43:28 +01:00
|
|
|
cls = heap_alloc( sz );
|
2005-11-03 12:33:57 +01:00
|
|
|
cls[0] = 0;
|
|
|
|
RegQueryValueExW( hkey, NULL, 0, &type, (LPBYTE) cls, &sz );
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
lpClass = cls;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("class = %s\n", debugstr_w(lpClass) );
|
|
|
|
|
|
|
|
hkey = 0;
|
|
|
|
if ( lpClass )
|
|
|
|
RegOpenKeyW( HKEY_CLASSES_ROOT, lpClass, &hkey );
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free( cls );
|
2005-11-03 12:33:57 +01:00
|
|
|
|
|
|
|
return hkey;
|
|
|
|
}
|
|
|
|
|
2018-10-16 02:41:38 +02:00
|
|
|
static HRESULT shellex_get_dataobj( LPSHELLEXECUTEINFOW sei, IDataObject **dataobj )
|
2005-11-03 12:33:57 +01:00
|
|
|
{
|
|
|
|
LPCITEMIDLIST pidllast = NULL;
|
|
|
|
IShellFolder *shf = NULL;
|
|
|
|
LPITEMIDLIST pidl = NULL;
|
2018-10-16 02:41:38 +02:00
|
|
|
HRESULT r = SE_ERR_DLLNOTFOUND;
|
2005-11-03 12:33:57 +01:00
|
|
|
|
|
|
|
if (sei->fMask & SEE_MASK_CLASSALL)
|
|
|
|
pidl = sei->lpIDList;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR fullpath[MAX_PATH];
|
2008-08-17 19:32:26 +02:00
|
|
|
BOOL ret;
|
2005-11-03 12:33:57 +01:00
|
|
|
|
|
|
|
fullpath[0] = 0;
|
2008-08-17 19:32:26 +02:00
|
|
|
ret = GetFullPathNameW( sei->lpFile, MAX_PATH, fullpath, NULL );
|
|
|
|
if (!ret)
|
2005-11-03 12:33:57 +01:00
|
|
|
goto end;
|
|
|
|
|
|
|
|
pidl = ILCreateFromPathW( fullpath );
|
|
|
|
}
|
|
|
|
|
|
|
|
r = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&shf, &pidllast );
|
|
|
|
if ( FAILED( r ) )
|
|
|
|
goto end;
|
|
|
|
|
2018-10-16 02:41:38 +02:00
|
|
|
r = IShellFolder_GetUIObjectOf( shf, NULL, 1, &pidllast,
|
|
|
|
&IID_IDataObject, NULL, (void**)dataobj );
|
2005-11-03 12:33:57 +01:00
|
|
|
|
|
|
|
end:
|
|
|
|
if ( pidl != sei->lpIDList )
|
|
|
|
ILFree( pidl );
|
|
|
|
if ( shf )
|
|
|
|
IShellFolder_Release( shf );
|
2018-10-16 02:41:38 +02:00
|
|
|
return r;
|
2005-11-03 12:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT shellex_run_context_menu_default( IShellExtInit *obj,
|
|
|
|
LPSHELLEXECUTEINFOW sei )
|
|
|
|
{
|
|
|
|
IContextMenu *cm = NULL;
|
|
|
|
CMINVOKECOMMANDINFOEX ici;
|
|
|
|
MENUITEMINFOW info;
|
|
|
|
WCHAR string[0x80];
|
|
|
|
INT i, n, def = -1;
|
|
|
|
HMENU hmenu = 0;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", obj, sei );
|
|
|
|
|
|
|
|
r = IShellExtInit_QueryInterface( obj, &IID_IContextMenu, (LPVOID*) &cm );
|
|
|
|
if ( FAILED( r ) )
|
|
|
|
return r;
|
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
if ( !hmenu )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
/* the number of the last menu added is returned in r */
|
|
|
|
r = IContextMenu_QueryContextMenu( cm, hmenu, 0, 0x20, 0x7fff, CMF_DEFAULTONLY );
|
|
|
|
if ( FAILED( r ) )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
n = GetMenuItemCount( hmenu );
|
|
|
|
for ( i = 0; i < n; i++ )
|
|
|
|
{
|
|
|
|
memset( &info, 0, sizeof info );
|
|
|
|
info.cbSize = sizeof info;
|
|
|
|
info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_ID;
|
|
|
|
info.dwTypeData = string;
|
2018-06-29 17:23:26 +02:00
|
|
|
info.cch = ARRAY_SIZE(string);
|
2005-11-03 12:33:57 +01:00
|
|
|
string[0] = 0;
|
|
|
|
GetMenuItemInfoW( hmenu, i, TRUE, &info );
|
|
|
|
|
|
|
|
TRACE("menu %d %s %08x %08lx %08x %08x\n", i, debugstr_w(string),
|
|
|
|
info.fState, info.dwItemData, info.fType, info.wID );
|
|
|
|
if ( ( !sei->lpVerb && (info.fState & MFS_DEFAULT) ) ||
|
|
|
|
( sei->lpVerb && !lstrcmpiW( sei->lpVerb, string ) ) )
|
|
|
|
{
|
|
|
|
def = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r = E_FAIL;
|
|
|
|
if ( def == -1 )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
memset( &ici, 0, sizeof ici );
|
|
|
|
ici.cbSize = sizeof ici;
|
2014-04-18 00:31:53 +02:00
|
|
|
ici.fMask = CMIC_MASK_UNICODE | (sei->fMask & (SEE_MASK_NO_CONSOLE|SEE_MASK_NOASYNC|SEE_MASK_ASYNCOK|SEE_MASK_FLAG_NO_UI));
|
2005-11-03 12:33:57 +01:00
|
|
|
ici.nShow = sei->nShow;
|
|
|
|
ici.lpVerb = MAKEINTRESOURCEA( def );
|
|
|
|
ici.hwnd = sei->hwnd;
|
|
|
|
ici.lpParametersW = sei->lpParameters;
|
|
|
|
|
|
|
|
r = IContextMenu_InvokeCommand( cm, (LPCMINVOKECOMMANDINFO) &ici );
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("invoke command returned %08x\n", r );
|
2005-11-03 12:33:57 +01:00
|
|
|
|
|
|
|
end:
|
|
|
|
if ( hmenu )
|
|
|
|
DestroyMenu( hmenu );
|
|
|
|
if ( cm )
|
|
|
|
IContextMenu_Release( cm );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT shellex_load_object_and_run( HKEY hkey, LPCGUID guid, LPSHELLEXECUTEINFOW sei )
|
|
|
|
{
|
|
|
|
IDataObject *dataobj = NULL;
|
|
|
|
IObjectWithSite *ows = NULL;
|
|
|
|
IShellExtInit *obj = NULL;
|
|
|
|
HRESULT r;
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", hkey, debugstr_guid( guid ), sei );
|
|
|
|
|
|
|
|
r = CoInitialize( NULL );
|
|
|
|
if ( FAILED( r ) )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = CoCreateInstance( guid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellExtInit, (LPVOID*)&obj );
|
|
|
|
if ( FAILED( r ) )
|
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
ERR("failed %08x\n", r );
|
2005-11-03 12:33:57 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2018-10-16 02:41:38 +02:00
|
|
|
r = shellex_get_dataobj( sei, &dataobj );
|
|
|
|
if ( FAILED( r ) )
|
2005-11-03 12:33:57 +01:00
|
|
|
{
|
|
|
|
ERR("failed to get data object\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = IShellExtInit_Initialize( obj, NULL, dataobj, hkey );
|
|
|
|
if ( FAILED( r ) )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
r = IShellExtInit_QueryInterface( obj, &IID_IObjectWithSite, (LPVOID*) &ows );
|
|
|
|
if ( FAILED( r ) )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
IObjectWithSite_SetSite( ows, NULL );
|
|
|
|
|
|
|
|
r = shellex_run_context_menu_default( obj, sei );
|
|
|
|
|
|
|
|
end:
|
|
|
|
if ( ows )
|
|
|
|
IObjectWithSite_Release( ows );
|
|
|
|
if ( dataobj )
|
|
|
|
IDataObject_Release( dataobj );
|
|
|
|
if ( obj )
|
|
|
|
IShellExtInit_Release( obj );
|
|
|
|
CoUninitialize();
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecute_FromContextMenu [Internal]
|
|
|
|
*/
|
|
|
|
static LONG ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei )
|
|
|
|
{
|
|
|
|
static const WCHAR szcm[] = { 's','h','e','l','l','e','x','\\',
|
|
|
|
'C','o','n','t','e','x','t','M','e','n','u','H','a','n','d','l','e','r','s',0 };
|
|
|
|
HKEY hkey, hkeycm = 0;
|
|
|
|
WCHAR szguid[39];
|
|
|
|
HRESULT hr;
|
|
|
|
GUID guid;
|
|
|
|
DWORD i;
|
|
|
|
LONG r;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(sei->lpFile) );
|
|
|
|
|
|
|
|
hkey = ShellExecute_GetClassKey( sei );
|
|
|
|
if ( !hkey )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
r = RegOpenKeyW( hkey, szcm, &hkeycm );
|
|
|
|
if ( r == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
while ( 1 )
|
|
|
|
{
|
2018-03-29 17:14:11 +02:00
|
|
|
r = RegEnumKeyW( hkeycm, i++, szguid, ARRAY_SIZE(szguid));
|
2005-11-03 12:33:57 +01:00
|
|
|
if ( r != ERROR_SUCCESS )
|
|
|
|
break;
|
2005-11-30 18:26:32 +01:00
|
|
|
|
2005-11-03 12:33:57 +01:00
|
|
|
hr = CLSIDFromString( szguid, &guid );
|
2005-11-30 18:26:32 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
/* stop at the first one that succeeds in running */
|
|
|
|
hr = shellex_load_object_and_run( hkey, &guid, sei );
|
|
|
|
if ( SUCCEEDED( hr ) )
|
|
|
|
break;
|
|
|
|
}
|
2005-11-03 12:33:57 +01:00
|
|
|
}
|
|
|
|
RegCloseKey( hkeycm );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( hkey != sei->hkeyClass )
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-03-24 19:05:21 +01:00
|
|
|
static UINT_PTR SHELL_quote_and_execute( LPCWSTR wcmd, LPCWSTR wszParameters, LPCWSTR lpstrProtocol, LPCWSTR wszApplicationName, LPWSTR env, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc );
|
|
|
|
|
2007-11-16 21:36:18 +01:00
|
|
|
static UINT_PTR SHELL_execute_class( LPCWSTR wszApplicationName, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc )
|
|
|
|
{
|
2010-03-24 19:05:21 +01:00
|
|
|
static const WCHAR wQuote[] = {'"',0};
|
2007-11-16 21:36:18 +01:00
|
|
|
static const WCHAR wSpace[] = {' ',0};
|
2012-10-17 23:25:56 +02:00
|
|
|
WCHAR execCmd[1024], classname[1024];
|
2007-11-16 21:36:18 +01:00
|
|
|
/* launch a document by fileclass like 'WordPad.Document.1' */
|
|
|
|
/* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
|
|
|
|
/* FIXME: wcmd should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */
|
|
|
|
ULONG cmask=(psei->fMask & SEE_MASK_CLASSALL);
|
|
|
|
DWORD resultLen;
|
|
|
|
BOOL done;
|
2010-03-24 19:05:21 +01:00
|
|
|
UINT_PTR rslt;
|
2007-11-16 21:36:18 +01:00
|
|
|
|
2010-03-24 19:05:21 +01:00
|
|
|
/* FIXME: remove following block when SHELL_quote_and_execute supports hkeyClass parameter */
|
|
|
|
if (cmask != SEE_MASK_CLASSNAME)
|
|
|
|
{
|
|
|
|
WCHAR wcmd[1024];
|
2007-11-16 21:36:18 +01:00
|
|
|
HCR_GetExecuteCommandW((cmask == SEE_MASK_CLASSKEY) ? psei->hkeyClass : NULL,
|
|
|
|
(cmask == SEE_MASK_CLASSNAME) ? psei->lpClass: NULL,
|
|
|
|
psei->lpVerb,
|
|
|
|
execCmd, sizeof(execCmd));
|
|
|
|
|
|
|
|
/* FIXME: get the extension of lpFile, check if it fits to the lpClass */
|
|
|
|
TRACE("SEE_MASK_CLASSNAME->%s, doc->%s\n", debugstr_w(execCmd), debugstr_w(wszApplicationName));
|
|
|
|
|
|
|
|
wcmd[0] = '\0';
|
2018-03-29 17:14:11 +02:00
|
|
|
done = SHELL_ArgifyW(wcmd, ARRAY_SIZE(wcmd), execCmd, wszApplicationName, psei->lpIDList, NULL, &resultLen);
|
2007-11-16 21:36:18 +01:00
|
|
|
if (!done && wszApplicationName[0])
|
|
|
|
{
|
|
|
|
strcatW(wcmd, wSpace);
|
2010-03-24 19:05:21 +01:00
|
|
|
if (*wszApplicationName != '"')
|
|
|
|
{
|
|
|
|
strcatW(wcmd, wQuote);
|
|
|
|
strcatW(wcmd, wszApplicationName);
|
|
|
|
strcatW(wcmd, wQuote);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcatW(wcmd, wszApplicationName);
|
2007-11-16 21:36:18 +01:00
|
|
|
}
|
2018-03-29 17:14:11 +02:00
|
|
|
if (resultLen > ARRAY_SIZE(wcmd))
|
2007-11-16 21:36:18 +01:00
|
|
|
ERR("Argify buffer not large enough... truncating\n");
|
|
|
|
return execfunc(wcmd, NULL, FALSE, psei, psei_out);
|
2010-03-24 19:05:21 +01:00
|
|
|
}
|
|
|
|
|
2012-10-17 23:25:56 +02:00
|
|
|
strcpyW(classname, psei->lpClass);
|
|
|
|
rslt = SHELL_FindExecutableByVerb(psei->lpVerb, NULL, classname, execCmd, sizeof(execCmd));
|
2010-03-24 19:05:21 +01:00
|
|
|
|
2012-10-17 23:25:56 +02:00
|
|
|
TRACE("SHELL_FindExecutableByVerb returned %u (%s, %s)\n", (unsigned int)rslt, debugstr_w(classname), debugstr_w(execCmd));
|
2010-03-24 19:05:21 +01:00
|
|
|
if (33 > rslt)
|
|
|
|
return rslt;
|
2012-10-17 23:25:56 +02:00
|
|
|
rslt = SHELL_quote_and_execute( execCmd, wszEmpty, classname,
|
2010-03-24 19:05:21 +01:00
|
|
|
wszApplicationName, NULL, psei,
|
|
|
|
psei_out, execfunc );
|
|
|
|
return rslt;
|
2007-11-16 21:36:18 +01:00
|
|
|
}
|
|
|
|
|
2015-07-15 17:33:57 +02:00
|
|
|
static void SHELL_translate_idlist( LPSHELLEXECUTEINFOW sei, LPWSTR wszParameters, DWORD parametersLen, LPWSTR wszApplicationName, DWORD dwApplicationNameLen )
|
2007-11-16 21:37:00 +01:00
|
|
|
{
|
|
|
|
static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0};
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
/* last chance to translate IDList: now also allow CLSID paths */
|
2018-03-29 17:14:11 +02:00
|
|
|
if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW(sei->lpIDList, buffer, ARRAY_SIZE(buffer)))) {
|
2007-11-16 21:37:00 +01:00
|
|
|
if (buffer[0]==':' && buffer[1]==':') {
|
|
|
|
/* open shell folder for the specified class GUID */
|
2008-11-11 23:27:29 +01:00
|
|
|
if (strlenW(buffer) + 1 > parametersLen)
|
2007-11-16 21:37:00 +01:00
|
|
|
ERR("parameters len exceeds buffer size (%i > %i), truncating\n",
|
|
|
|
lstrlenW(buffer) + 1, parametersLen);
|
|
|
|
lstrcpynW(wszParameters, buffer, parametersLen);
|
2008-11-11 23:27:29 +01:00
|
|
|
if (strlenW(wExplorer) > dwApplicationNameLen)
|
2007-11-16 21:37:00 +01:00
|
|
|
ERR("application len exceeds buffer size (%i > %i), truncating\n",
|
|
|
|
lstrlenW(wExplorer) + 1, dwApplicationNameLen);
|
|
|
|
lstrcpynW(wszApplicationName, wExplorer, dwApplicationNameLen);
|
|
|
|
|
|
|
|
sei->fMask &= ~SEE_MASK_INVOKEIDLIST;
|
|
|
|
} else {
|
|
|
|
WCHAR target[MAX_PATH];
|
|
|
|
DWORD attribs;
|
|
|
|
DWORD resultLen;
|
|
|
|
/* Check if we're executing a directory and if so use the
|
|
|
|
handler for the Folder class */
|
|
|
|
strcpyW(target, buffer);
|
|
|
|
attribs = GetFileAttributesW(buffer);
|
|
|
|
if (attribs != INVALID_FILE_ATTRIBUTES &&
|
|
|
|
(attribs & FILE_ATTRIBUTE_DIRECTORY) &&
|
|
|
|
HCR_GetExecuteCommandW(0, wszFolder,
|
|
|
|
sei->lpVerb,
|
|
|
|
buffer, sizeof(buffer))) {
|
|
|
|
SHELL_ArgifyW(wszApplicationName, dwApplicationNameLen,
|
|
|
|
buffer, target, sei->lpIDList, NULL, &resultLen);
|
|
|
|
if (resultLen > dwApplicationNameLen)
|
|
|
|
ERR("Argify buffer not large enough... truncating\n");
|
|
|
|
}
|
|
|
|
sei->fMask &= ~SEE_MASK_INVOKEIDLIST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-17 23:25:56 +02:00
|
|
|
static UINT_PTR SHELL_quote_and_execute( LPCWSTR wcmd, LPCWSTR wszParameters, LPCWSTR wszKeyname, LPCWSTR wszApplicationName, LPWSTR env, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc )
|
2007-11-16 21:39:15 +01:00
|
|
|
{
|
|
|
|
static const WCHAR wQuote[] = {'"',0};
|
|
|
|
static const WCHAR wSpace[] = {' ',0};
|
|
|
|
UINT_PTR retval;
|
2007-11-16 21:40:25 +01:00
|
|
|
DWORD len;
|
|
|
|
WCHAR *wszQuotedCmd;
|
|
|
|
|
|
|
|
/* Length of quotes plus length of command plus NULL terminator */
|
|
|
|
len = 2 + lstrlenW(wcmd) + 1;
|
|
|
|
if (wszParameters[0])
|
|
|
|
{
|
|
|
|
/* Length of space plus length of parameters */
|
|
|
|
len += 1 + lstrlenW(wszParameters);
|
|
|
|
}
|
2018-02-22 08:43:28 +01:00
|
|
|
wszQuotedCmd = heap_alloc(len * sizeof(WCHAR));
|
2007-11-16 21:39:15 +01:00
|
|
|
/* Must quote to handle case where cmd contains spaces,
|
|
|
|
* else security hole if malicious user creates executable file "C:\\Program"
|
|
|
|
*/
|
|
|
|
strcpyW(wszQuotedCmd, wQuote);
|
|
|
|
strcatW(wszQuotedCmd, wcmd);
|
|
|
|
strcatW(wszQuotedCmd, wQuote);
|
|
|
|
if (wszParameters[0]) {
|
|
|
|
strcatW(wszQuotedCmd, wSpace);
|
|
|
|
strcatW(wszQuotedCmd, wszParameters);
|
|
|
|
}
|
2012-10-17 23:25:56 +02:00
|
|
|
TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName), debugstr_w(psei->lpVerb), debugstr_w(wszQuotedCmd), debugstr_w(wszKeyname));
|
|
|
|
if (*wszKeyname)
|
|
|
|
retval = execute_from_key(wszKeyname, wszApplicationName, env, psei->lpParameters, wcmd, execfunc, psei, psei_out);
|
2007-11-16 21:39:15 +01:00
|
|
|
else
|
|
|
|
retval = execfunc(wszQuotedCmd, env, FALSE, psei, psei_out);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszQuotedCmd);
|
2007-11-16 21:39:15 +01:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-10-10 00:54:07 +02:00
|
|
|
static UINT_PTR SHELL_execute_url( LPCWSTR lpFile, LPCWSTR wcmd, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc )
|
2007-11-16 21:43:03 +01:00
|
|
|
{
|
|
|
|
static const WCHAR wShell[] = {'\\','s','h','e','l','l','\\',0};
|
|
|
|
static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0};
|
2007-11-16 21:43:35 +01:00
|
|
|
UINT_PTR retval;
|
|
|
|
WCHAR *lpstrProtocol;
|
2007-11-16 21:43:03 +01:00
|
|
|
LPCWSTR lpstrRes;
|
|
|
|
INT iSize;
|
2007-11-16 21:43:35 +01:00
|
|
|
DWORD len;
|
2007-11-16 21:43:03 +01:00
|
|
|
|
|
|
|
lpstrRes = strchrW(lpFile, ':');
|
|
|
|
if (lpstrRes)
|
|
|
|
iSize = lpstrRes - lpFile;
|
|
|
|
else
|
|
|
|
iSize = strlenW(lpFile);
|
|
|
|
|
|
|
|
TRACE("Got URL: %s\n", debugstr_w(lpFile));
|
2012-10-17 23:25:56 +02:00
|
|
|
/* Looking for ...<protocol>\shell\<lpVerb>\command */
|
2007-11-16 21:43:35 +01:00
|
|
|
len = iSize + lstrlenW(wShell) + lstrlenW(wCommand) + 1;
|
2011-10-18 22:19:17 +02:00
|
|
|
if (psei->lpVerb && *psei->lpVerb)
|
2007-11-16 21:43:35 +01:00
|
|
|
len += lstrlenW(psei->lpVerb);
|
|
|
|
else
|
|
|
|
len += lstrlenW(wszOpen);
|
2018-02-22 08:43:28 +01:00
|
|
|
lpstrProtocol = heap_alloc(len * sizeof(WCHAR));
|
2007-11-16 21:43:03 +01:00
|
|
|
memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR));
|
|
|
|
lpstrProtocol[iSize] = '\0';
|
|
|
|
strcatW(lpstrProtocol, wShell);
|
2011-10-18 22:19:17 +02:00
|
|
|
strcatW(lpstrProtocol, psei->lpVerb && *psei->lpVerb ? psei->lpVerb: wszOpen);
|
2007-11-16 21:43:03 +01:00
|
|
|
strcatW(lpstrProtocol, wCommand);
|
|
|
|
|
2007-11-16 21:43:35 +01:00
|
|
|
retval = execute_from_key(lpstrProtocol, lpFile, NULL, psei->lpParameters,
|
|
|
|
wcmd, execfunc, psei, psei_out);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(lpstrProtocol);
|
2007-11-16 21:43:35 +01:00
|
|
|
return retval;
|
2007-11-16 21:43:03 +01:00
|
|
|
}
|
|
|
|
|
2008-12-15 17:10:07 +01:00
|
|
|
static void do_error_dialog( UINT_PTR retval, HWND hwnd )
|
|
|
|
{
|
|
|
|
WCHAR msg[2048];
|
|
|
|
int error_code=GetLastError();
|
|
|
|
|
2009-02-26 02:14:30 +01:00
|
|
|
if (retval == SE_ERR_NOASSOC)
|
2018-03-29 17:14:11 +02:00
|
|
|
LoadStringW(shell32_hInstance, IDS_SHLEXEC_NOASSOC, msg, ARRAY_SIZE(msg));
|
2009-02-26 02:14:30 +01:00
|
|
|
else
|
2018-03-29 17:14:11 +02:00
|
|
|
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, 0, msg, ARRAY_SIZE(msg), NULL);
|
2008-12-15 17:10:07 +01:00
|
|
|
|
|
|
|
MessageBoxW(hwnd, msg, NULL, MB_ICONERROR);
|
|
|
|
}
|
|
|
|
|
2018-10-16 02:41:36 +02:00
|
|
|
static WCHAR *expand_environment( const WCHAR *str )
|
|
|
|
{
|
|
|
|
WCHAR *buf;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
len = ExpandEnvironmentStringsW(str, NULL, 0);
|
|
|
|
if (!len) return NULL;
|
|
|
|
|
|
|
|
buf = heap_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!buf) return NULL;
|
|
|
|
|
|
|
|
len = ExpandEnvironmentStringsW(str, buf, len);
|
|
|
|
if (!len)
|
|
|
|
{
|
|
|
|
heap_free(buf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/*************************************************************************
|
2005-10-18 16:11:17 +02:00
|
|
|
* SHELL_execute [Internal]
|
2002-07-24 20:59:38 +02:00
|
|
|
*/
|
2009-05-15 02:15:17 +02:00
|
|
|
static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wWww[] = {'w','w','w',0};
|
|
|
|
static const WCHAR wHttp[] = {'h','t','t','p',':','/','/',0};
|
2005-05-14 13:06:54 +02:00
|
|
|
static const DWORD unsupportedFlags =
|
|
|
|
SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
|
2008-12-15 17:10:07 +01:00
|
|
|
SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
|
2007-07-16 17:14:07 +02:00
|
|
|
SEE_MASK_UNICODE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR;
|
2004-03-18 05:04:29 +01:00
|
|
|
|
2007-11-16 21:42:06 +01:00
|
|
|
WCHAR parametersBuffer[1024], dirBuffer[MAX_PATH], wcmdBuffer[1024];
|
2018-10-16 02:41:36 +02:00
|
|
|
WCHAR *wszApplicationName, *wszParameters, *wszDir, *wcmd = NULL;
|
2006-04-12 20:33:31 +02:00
|
|
|
DWORD dwApplicationNameLen = MAX_PATH+2;
|
2018-03-29 17:14:11 +02:00
|
|
|
DWORD parametersLen = ARRAY_SIZE(parametersBuffer);
|
|
|
|
DWORD wcmdLen = ARRAY_SIZE(wcmdBuffer);
|
2006-11-03 16:47:13 +01:00
|
|
|
DWORD len;
|
2004-04-13 00:08:23 +02:00
|
|
|
SHELLEXECUTEINFOW sei_tmp; /* modifiable copy of SHELLEXECUTEINFO struct */
|
2004-06-15 20:27:50 +02:00
|
|
|
WCHAR *env;
|
2012-10-17 23:25:56 +02:00
|
|
|
WCHAR wszKeyname[256];
|
2004-03-04 21:34:38 +01:00
|
|
|
LPCWSTR lpFile;
|
2006-12-14 18:00:12 +01:00
|
|
|
UINT_PTR retval = SE_ERR_NOASSOC;
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
/* make a local copy of the LPSHELLEXECUTEINFO structure and work with this from now on */
|
2008-03-17 22:36:59 +01:00
|
|
|
sei_tmp = *sei;
|
2004-03-18 05:04:29 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("mask=0x%08x hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
|
2004-03-18 05:04:29 +01:00
|
|
|
sei_tmp.fMask, sei_tmp.hwnd, debugstr_w(sei_tmp.lpVerb),
|
|
|
|
debugstr_w(sei_tmp.lpFile), debugstr_w(sei_tmp.lpParameters),
|
|
|
|
debugstr_w(sei_tmp.lpDirectory), sei_tmp.nShow,
|
2005-08-11 12:29:44 +02:00
|
|
|
((sei_tmp.fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME) ?
|
|
|
|
debugstr_w(sei_tmp.lpClass) : "not used");
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2003-01-15 00:43:41 +01:00
|
|
|
sei->hProcess = NULL;
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
/* make copies of all path/command strings */
|
2005-08-17 11:53:30 +02:00
|
|
|
if (!sei_tmp.lpFile)
|
2006-04-12 20:33:31 +02:00
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
wszApplicationName = heap_alloc(dwApplicationNameLen*sizeof(WCHAR));
|
2005-08-17 11:53:30 +02:00
|
|
|
*wszApplicationName = '\0';
|
2006-04-12 20:33:31 +02:00
|
|
|
}
|
2015-07-15 17:34:09 +02:00
|
|
|
else if (*sei_tmp.lpFile == '\"' && sei_tmp.lpFile[(len = strlenW(sei_tmp.lpFile))-1] == '\"')
|
2005-08-17 11:53:30 +02:00
|
|
|
{
|
2015-07-15 17:34:09 +02:00
|
|
|
if(len-1 >= dwApplicationNameLen) dwApplicationNameLen = len;
|
2018-02-22 08:43:28 +01:00
|
|
|
wszApplicationName = heap_alloc(dwApplicationNameLen*sizeof(WCHAR));
|
2015-07-15 17:34:09 +02:00
|
|
|
memcpy(wszApplicationName, sei_tmp.lpFile+1, len*sizeof(WCHAR));
|
|
|
|
if(len > 2)
|
|
|
|
wszApplicationName[len-2] = '\0';
|
2005-08-17 11:53:30 +02:00
|
|
|
TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName));
|
2006-04-12 20:33:31 +02:00
|
|
|
} else {
|
|
|
|
DWORD l = strlenW(sei_tmp.lpFile)+1;
|
|
|
|
if(l > dwApplicationNameLen) dwApplicationNameLen = l+1;
|
2018-02-22 08:43:28 +01:00
|
|
|
wszApplicationName = heap_alloc(dwApplicationNameLen*sizeof(WCHAR));
|
2006-04-12 20:33:31 +02:00
|
|
|
memcpy(wszApplicationName, sei_tmp.lpFile, l*sizeof(WCHAR));
|
2005-08-17 11:53:30 +02:00
|
|
|
}
|
2004-03-18 05:04:29 +01:00
|
|
|
|
2007-11-16 21:33:58 +01:00
|
|
|
wszParameters = parametersBuffer;
|
2004-03-18 05:04:29 +01:00
|
|
|
if (sei_tmp.lpParameters)
|
2007-11-16 21:33:58 +01:00
|
|
|
{
|
|
|
|
len = lstrlenW(sei_tmp.lpParameters) + 1;
|
|
|
|
if (len > parametersLen)
|
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
wszParameters = heap_alloc(len * sizeof(WCHAR));
|
2007-11-16 21:33:58 +01:00
|
|
|
parametersLen = len;
|
|
|
|
}
|
2004-04-13 01:12:51 +02:00
|
|
|
strcpyW(wszParameters, sei_tmp.lpParameters);
|
2007-11-16 21:33:58 +01:00
|
|
|
}
|
2004-03-18 05:04:29 +01:00
|
|
|
else
|
2004-04-13 01:12:51 +02:00
|
|
|
*wszParameters = '\0';
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2007-11-16 21:37:27 +01:00
|
|
|
wszDir = dirBuffer;
|
2004-03-18 05:04:29 +01:00
|
|
|
if (sei_tmp.lpDirectory)
|
2007-11-16 21:37:27 +01:00
|
|
|
{
|
|
|
|
len = lstrlenW(sei_tmp.lpDirectory) + 1;
|
2018-03-29 17:14:11 +02:00
|
|
|
if (len > ARRAY_SIZE(dirBuffer))
|
2018-02-22 08:43:28 +01:00
|
|
|
wszDir = heap_alloc(len * sizeof(WCHAR));
|
2004-03-18 05:04:29 +01:00
|
|
|
strcpyW(wszDir, sei_tmp.lpDirectory);
|
2007-11-16 21:37:27 +01:00
|
|
|
}
|
2004-03-18 05:04:29 +01:00
|
|
|
else
|
|
|
|
*wszDir = '\0';
|
|
|
|
|
|
|
|
/* adjust string pointers to point to the new buffers */
|
|
|
|
sei_tmp.lpFile = wszApplicationName;
|
2004-04-13 01:12:51 +02:00
|
|
|
sei_tmp.lpParameters = wszParameters;
|
2004-03-18 05:04:29 +01:00
|
|
|
sei_tmp.lpDirectory = wszDir;
|
|
|
|
|
2005-05-14 13:06:54 +02:00
|
|
|
if (sei_tmp.fMask & unsupportedFlags)
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("flags ignored: 0x%08x\n", sei_tmp.fMask & unsupportedFlags);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* process the IDList */
|
2004-03-27 21:41:20 +01:00
|
|
|
if (sei_tmp.fMask & SEE_MASK_IDLIST)
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2004-03-27 21:41:20 +01:00
|
|
|
IShellExecuteHookW* pSEH;
|
|
|
|
|
|
|
|
HRESULT hr = SHBindToParent(sei_tmp.lpIDList, &IID_IShellExecuteHookW, (LPVOID*)&pSEH, NULL);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2005-09-08 20:54:52 +02:00
|
|
|
hr = IShellExecuteHookW_Execute(pSEH, &sei_tmp);
|
2004-03-27 21:41:20 +01:00
|
|
|
|
|
|
|
IShellExecuteHookW_Release(pSEH);
|
|
|
|
|
2006-04-12 20:33:31 +02:00
|
|
|
if (hr == S_OK) {
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszApplicationName);
|
2007-11-16 21:33:58 +01:00
|
|
|
if (wszParameters != parametersBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszParameters);
|
2007-11-16 21:37:27 +01:00
|
|
|
if (wszDir != dirBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszDir);
|
2004-03-27 21:41:20 +01:00
|
|
|
return TRUE;
|
2006-04-12 20:33:31 +02:00
|
|
|
}
|
2004-03-27 21:41:20 +01:00
|
|
|
}
|
|
|
|
|
2005-11-28 17:29:58 +01:00
|
|
|
SHGetPathFromIDListW(sei_tmp.lpIDList, wszApplicationName);
|
2004-03-18 05:04:29 +01:00
|
|
|
TRACE("-- idlist=%p (%s)\n", sei_tmp.lpIDList, debugstr_w(wszApplicationName));
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2018-10-16 02:41:36 +02:00
|
|
|
if (sei_tmp.fMask & SEE_MASK_DOENVSUBST)
|
|
|
|
{
|
|
|
|
WCHAR *tmp;
|
|
|
|
|
|
|
|
tmp = expand_environment(sei_tmp.lpFile);
|
|
|
|
if (!tmp)
|
|
|
|
{
|
|
|
|
retval = SE_ERR_OOM;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
heap_free(wszApplicationName);
|
|
|
|
sei_tmp.lpFile = wszApplicationName = tmp;
|
|
|
|
|
|
|
|
tmp = expand_environment(sei_tmp.lpDirectory);
|
|
|
|
if (!tmp)
|
|
|
|
{
|
|
|
|
retval = SE_ERR_OOM;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (wszDir != dirBuffer)
|
|
|
|
heap_free(wszDir);
|
|
|
|
sei_tmp.lpDirectory = wszDir = tmp;
|
|
|
|
}
|
|
|
|
|
2005-11-03 12:33:57 +01:00
|
|
|
if ( ERROR_SUCCESS == ShellExecute_FromContextMenu( &sei_tmp ) )
|
|
|
|
{
|
|
|
|
sei->hInstApp = (HINSTANCE) 33;
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszApplicationName);
|
2007-11-16 21:33:58 +01:00
|
|
|
if (wszParameters != parametersBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszParameters);
|
2007-11-16 21:37:27 +01:00
|
|
|
if (wszDir != dirBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszDir);
|
2005-11-03 12:33:57 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-08-11 12:29:44 +02:00
|
|
|
if (sei_tmp.fMask & SEE_MASK_CLASSALL)
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2007-11-16 21:36:18 +01:00
|
|
|
retval = SHELL_execute_class( wszApplicationName, &sei_tmp, sei,
|
|
|
|
execfunc );
|
2008-12-15 17:10:07 +01:00
|
|
|
if (retval <= 32 && !(sei_tmp.fMask & SEE_MASK_FLAG_NO_UI))
|
|
|
|
do_error_dialog(retval, sei_tmp.hwnd);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszApplicationName);
|
2007-11-16 21:33:58 +01:00
|
|
|
if (wszParameters != parametersBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszParameters);
|
2007-11-16 21:37:27 +01:00
|
|
|
if (wszDir != dirBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszDir);
|
2006-04-12 20:33:31 +02:00
|
|
|
return retval > 32;
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2004-04-07 05:49:51 +02:00
|
|
|
/* Has the IDList not yet been translated? */
|
|
|
|
if (sei_tmp.fMask & SEE_MASK_IDLIST)
|
|
|
|
{
|
2015-07-15 17:33:57 +02:00
|
|
|
SHELL_translate_idlist( &sei_tmp, wszParameters,
|
|
|
|
parametersLen,
|
|
|
|
wszApplicationName,
|
|
|
|
dwApplicationNameLen );
|
2004-04-07 05:49:51 +02:00
|
|
|
}
|
|
|
|
|
2012-10-10 00:54:07 +02:00
|
|
|
/* convert file URLs */
|
|
|
|
if (UrlIsFileUrlW(sei_tmp.lpFile))
|
2006-11-03 16:47:13 +01:00
|
|
|
{
|
|
|
|
LPWSTR buf;
|
2012-10-10 00:54:07 +02:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
2018-02-22 08:43:28 +01:00
|
|
|
buf = heap_alloc(size * sizeof(WCHAR));
|
2012-10-13 17:19:40 +02:00
|
|
|
if (!buf || FAILED(PathCreateFromUrlW(sei_tmp.lpFile, buf, &size, 0))) {
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(buf);
|
2012-10-10 00:54:07 +02:00
|
|
|
return SE_ERR_OOM;
|
2012-10-13 17:19:40 +02:00
|
|
|
}
|
2006-11-03 16:47:13 +01:00
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszApplicationName);
|
2006-11-03 16:47:13 +01:00
|
|
|
wszApplicationName = buf;
|
|
|
|
sei_tmp.lpFile = wszApplicationName;
|
|
|
|
}
|
2012-10-10 00:54:07 +02:00
|
|
|
else /* or expand environment strings (not both!) */
|
|
|
|
{
|
|
|
|
len = ExpandEnvironmentStringsW(sei_tmp.lpFile, NULL, 0);
|
|
|
|
if (len>0)
|
|
|
|
{
|
|
|
|
LPWSTR buf;
|
2018-02-22 08:43:28 +01:00
|
|
|
buf = heap_alloc((len + 1) * sizeof(WCHAR));
|
2012-10-10 00:54:07 +02:00
|
|
|
|
|
|
|
ExpandEnvironmentStringsW(sei_tmp.lpFile, buf, len + 1);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszApplicationName);
|
2012-10-10 00:54:07 +02:00
|
|
|
wszApplicationName = buf;
|
|
|
|
|
|
|
|
sei_tmp.lpFile = wszApplicationName;
|
|
|
|
}
|
|
|
|
}
|
2004-03-18 05:04:29 +01:00
|
|
|
|
|
|
|
if (*sei_tmp.lpDirectory)
|
2006-11-03 16:47:13 +01:00
|
|
|
{
|
|
|
|
len = ExpandEnvironmentStringsW(sei_tmp.lpDirectory, NULL, 0);
|
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
LPWSTR buf;
|
|
|
|
len++;
|
2018-02-22 08:43:28 +01:00
|
|
|
buf = heap_alloc(len * sizeof(WCHAR));
|
2006-11-03 16:47:13 +01:00
|
|
|
ExpandEnvironmentStringsW(sei_tmp.lpDirectory, buf, len);
|
2007-11-16 21:37:27 +01:00
|
|
|
if (wszDir != dirBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszDir);
|
2007-11-16 21:37:27 +01:00
|
|
|
wszDir = buf;
|
|
|
|
sei_tmp.lpDirectory = wszDir;
|
2006-11-03 16:47:13 +01:00
|
|
|
}
|
|
|
|
}
|
2004-03-18 05:04:29 +01:00
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
/* Else, try to execute the filename */
|
2004-06-15 02:44:14 +02:00
|
|
|
TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName), debugstr_w(wszParameters), debugstr_w(wszDir));
|
2015-07-15 17:33:57 +02:00
|
|
|
lpFile = sei_tmp.lpFile;
|
2007-11-16 21:42:06 +01:00
|
|
|
wcmd = wcmdBuffer;
|
2015-07-15 17:34:05 +02:00
|
|
|
len = lstrlenW(wszApplicationName) + 3;
|
2007-11-16 21:42:06 +01:00
|
|
|
if (sei_tmp.lpParameters[0])
|
|
|
|
len += 1 + lstrlenW(wszParameters);
|
|
|
|
if (len > wcmdLen)
|
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
wcmd = heap_alloc(len * sizeof(WCHAR));
|
2007-11-16 21:42:06 +01:00
|
|
|
wcmdLen = len;
|
|
|
|
}
|
2015-07-15 17:34:05 +02:00
|
|
|
wcmd[0] = '\"';
|
|
|
|
len = lstrlenW(wszApplicationName);
|
|
|
|
memcpy(wcmd+1, wszApplicationName, len * sizeof(WCHAR));
|
|
|
|
len++;
|
|
|
|
wcmd[len++] = '\"';
|
2015-07-17 04:54:24 +02:00
|
|
|
wcmd[len] = 0;
|
2004-04-13 01:12:51 +02:00
|
|
|
if (sei_tmp.lpParameters[0]) {
|
2015-07-15 17:34:05 +02:00
|
|
|
wcmd[len++] = ' ';
|
|
|
|
strcpyW(wcmd+len, wszParameters);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2005-09-12 14:10:57 +02:00
|
|
|
retval = execfunc(wcmd, NULL, FALSE, &sei_tmp, sei);
|
2006-04-12 20:33:31 +02:00
|
|
|
if (retval > 32) {
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszApplicationName);
|
2007-11-16 21:33:58 +01:00
|
|
|
if (wszParameters != parametersBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszParameters);
|
2007-11-16 21:37:27 +01:00
|
|
|
if (wszDir != dirBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszDir);
|
2007-11-16 21:42:06 +01:00
|
|
|
if (wcmd != wcmdBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wcmd);
|
2002-07-25 02:18:23 +02:00
|
|
|
return TRUE;
|
2006-04-12 20:33:31 +02:00
|
|
|
}
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
/* Else, try to find the executable */
|
2004-01-15 07:13:57 +01:00
|
|
|
wcmd[0] = '\0';
|
2012-10-17 23:25:56 +02:00
|
|
|
retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, wcmdLen, wszKeyname, &env, sei_tmp.lpIDList, sei_tmp.lpParameters);
|
2002-07-24 20:59:38 +02:00
|
|
|
if (retval > 32) /* Found */
|
|
|
|
{
|
2012-10-17 23:25:56 +02:00
|
|
|
retval = SHELL_quote_and_execute( wcmd, wszParameters, wszKeyname,
|
2007-11-16 21:39:15 +01:00
|
|
|
wszApplicationName, env, &sei_tmp,
|
|
|
|
sei, execfunc );
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free( env );
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
2008-08-07 01:10:52 +02:00
|
|
|
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];
|
2018-02-22 08:43:28 +01:00
|
|
|
WCHAR * lpQuotedFile = heap_alloc( sizeof(WCHAR) * (strlenW(lpFile) + 3) );
|
2008-08-07 01:10:52 +02:00
|
|
|
|
|
|
|
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,
|
2012-10-17 23:25:56 +02:00
|
|
|
wszKeyname,
|
2008-08-07 01:10:52 +02:00
|
|
|
wszApplicationName, env,
|
|
|
|
&sei_tmp, sei, execfunc );
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free( env );
|
2008-08-07 01:10:52 +02:00
|
|
|
}
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free( lpQuotedFile );
|
2008-08-07 01:10:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
retval = 0; /* Out of memory */
|
|
|
|
}
|
2006-09-29 23:13:48 +02:00
|
|
|
else if (PathIsURLW(lpFile)) /* File not found, check for URL */
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2012-10-10 00:54:07 +02:00
|
|
|
retval = SHELL_execute_url( lpFile, wcmd, &sei_tmp, sei, execfunc );
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
/* Check if file specified is in the form www.??????.*** */
|
2004-01-15 07:13:57 +01:00
|
|
|
else if (!strncmpiW(lpFile, wWww, 3))
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2012-09-24 16:30:19 +02:00
|
|
|
/* if so, prefix lpFile with http:// and call ShellExecute */
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR lpstrTmpFile[256];
|
|
|
|
strcpyW(lpstrTmpFile, wHttp);
|
|
|
|
strcatW(lpstrTmpFile, lpFile);
|
2005-09-02 13:32:17 +02:00
|
|
|
retval = (UINT_PTR)ShellExecuteW(sei_tmp.hwnd, sei_tmp.lpVerb, lpstrTmpFile, NULL, NULL, 0);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2018-10-16 02:41:36 +02:00
|
|
|
end:
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("retval %lu\n", retval);
|
2004-02-12 21:04:09 +01:00
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszApplicationName);
|
2007-11-16 21:33:58 +01:00
|
|
|
if (wszParameters != parametersBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszParameters);
|
2007-11-16 21:37:27 +01:00
|
|
|
if (wszDir != dirBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszDir);
|
2007-11-16 21:42:06 +01:00
|
|
|
if (wcmd != wcmdBuffer)
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wcmd);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2006-04-12 20:33:31 +02:00
|
|
|
sei->hInstApp = (HINSTANCE)(retval > 32 ? 33 : retval);
|
2008-12-15 17:10:07 +01:00
|
|
|
|
|
|
|
if (retval <= 32 && !(sei_tmp.fMask & SEE_MASK_FLAG_NO_UI))
|
|
|
|
do_error_dialog(retval, sei_tmp.hwnd);
|
2006-04-12 20:33:31 +02:00
|
|
|
return retval > 32;
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteA [SHELL32.290]
|
|
|
|
*/
|
2012-10-17 23:25:56 +02:00
|
|
|
HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpVerb, LPCSTR lpFile,
|
|
|
|
LPCSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2002-07-24 20:59:38 +02:00
|
|
|
SHELLEXECUTEINFOA sei;
|
|
|
|
|
2004-06-15 02:44:14 +02:00
|
|
|
TRACE("%p,%s,%s,%s,%s,%d\n",
|
2012-10-17 23:25:56 +02:00
|
|
|
hWnd, debugstr_a(lpVerb), debugstr_a(lpFile),
|
2005-08-17 11:53:30 +02:00
|
|
|
debugstr_a(lpParameters), debugstr_a(lpDirectory), iShowCmd);
|
2004-06-15 02:44:14 +02:00
|
|
|
|
2002-07-24 20:59:38 +02:00
|
|
|
sei.cbSize = sizeof(sei);
|
2008-12-18 22:01:58 +01:00
|
|
|
sei.fMask = SEE_MASK_FLAG_NO_UI;
|
2002-07-24 20:59:38 +02:00
|
|
|
sei.hwnd = hWnd;
|
2012-10-17 23:25:56 +02:00
|
|
|
sei.lpVerb = lpVerb;
|
2002-07-24 20:59:38 +02:00
|
|
|
sei.lpFile = lpFile;
|
|
|
|
sei.lpParameters = lpParameters;
|
|
|
|
sei.lpDirectory = lpDirectory;
|
|
|
|
sei.nShow = iShowCmd;
|
|
|
|
sei.lpIDList = 0;
|
|
|
|
sei.lpClass = 0;
|
|
|
|
sei.hkeyClass = 0;
|
|
|
|
sei.dwHotKey = 0;
|
2005-10-03 13:02:47 +02:00
|
|
|
sei.hProcess = 0;
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
ShellExecuteExA (&sei);
|
2002-07-24 20:59:38 +02:00
|
|
|
return sei.hInstApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteExA [SHELL32.292]
|
|
|
|
*
|
|
|
|
*/
|
2009-09-12 14:13:47 +02:00
|
|
|
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExA (LPSHELLEXECUTEINFOA sei)
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
SHELLEXECUTEINFOW seiW;
|
|
|
|
BOOL ret;
|
|
|
|
WCHAR *wVerb = NULL, *wFile = NULL, *wParameters = NULL, *wDirectory = NULL, *wClass = NULL;
|
2002-07-24 20:59:38 +02:00
|
|
|
|
|
|
|
TRACE("%p\n", sei);
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
memcpy(&seiW, sei, sizeof(SHELLEXECUTEINFOW));
|
2002-07-24 20:59:38 +02:00
|
|
|
|
|
|
|
if (sei->lpVerb)
|
2004-01-15 07:13:57 +01:00
|
|
|
seiW.lpVerb = __SHCloneStrAtoW(&wVerb, sei->lpVerb);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
|
|
|
if (sei->lpFile)
|
2004-01-15 07:13:57 +01:00
|
|
|
seiW.lpFile = __SHCloneStrAtoW(&wFile, sei->lpFile);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
|
|
|
if (sei->lpParameters)
|
2004-01-15 07:13:57 +01:00
|
|
|
seiW.lpParameters = __SHCloneStrAtoW(&wParameters, sei->lpParameters);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
|
|
|
if (sei->lpDirectory)
|
2004-01-15 07:13:57 +01:00
|
|
|
seiW.lpDirectory = __SHCloneStrAtoW(&wDirectory, sei->lpDirectory);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2005-08-11 12:29:44 +02:00
|
|
|
if ((sei->fMask & SEE_MASK_CLASSALL) == SEE_MASK_CLASSNAME && sei->lpClass)
|
2004-01-15 07:13:57 +01:00
|
|
|
seiW.lpClass = __SHCloneStrAtoW(&wClass, sei->lpClass);
|
2002-07-24 20:59:38 +02:00
|
|
|
else
|
2004-01-15 07:13:57 +01:00
|
|
|
seiW.lpClass = NULL;
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2005-11-11 11:54:07 +01:00
|
|
|
ret = SHELL_execute( &seiW, SHELL_ExecuteW );
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2004-02-12 21:04:09 +01:00
|
|
|
sei->hInstApp = seiW.hInstApp;
|
|
|
|
|
2005-03-17 21:50:53 +01:00
|
|
|
if (sei->fMask & SEE_MASK_NOCLOSEPROCESS)
|
|
|
|
sei->hProcess = seiW.hProcess;
|
|
|
|
|
2006-10-07 03:06:26 +02:00
|
|
|
SHFree(wVerb);
|
|
|
|
SHFree(wFile);
|
|
|
|
SHFree(wParameters);
|
|
|
|
SHFree(wDirectory);
|
|
|
|
SHFree(wClass);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
|
|
|
return ret;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteExW [SHELL32.293]
|
|
|
|
*
|
|
|
|
*/
|
2009-09-12 14:13:47 +02:00
|
|
|
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW (LPSHELLEXECUTEINFOW sei)
|
2004-01-15 07:13:57 +01:00
|
|
|
{
|
2005-11-11 11:54:07 +01:00
|
|
|
return SHELL_execute( sei, SHELL_ExecuteW );
|
2004-01-15 07:13:57 +01:00
|
|
|
}
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteW [SHELL32.294]
|
|
|
|
* from shellapi.h
|
2012-10-17 23:25:56 +02:00
|
|
|
* WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpVerb,
|
2002-06-01 01:06:46 +02:00
|
|
|
* LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
|
2002-02-27 02:22:15 +01:00
|
|
|
*/
|
2012-10-17 23:25:56 +02:00
|
|
|
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile,
|
2002-02-27 02:22:15 +01:00
|
|
|
LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
|
|
|
|
{
|
2002-07-24 20:59:38 +02:00
|
|
|
SHELLEXECUTEINFOW sei;
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2002-07-24 20:59:38 +02:00
|
|
|
TRACE("\n");
|
|
|
|
sei.cbSize = sizeof(sei);
|
2008-12-18 22:01:58 +01:00
|
|
|
sei.fMask = SEE_MASK_FLAG_NO_UI;
|
2002-07-24 20:59:38 +02:00
|
|
|
sei.hwnd = hwnd;
|
2012-10-17 23:25:56 +02:00
|
|
|
sei.lpVerb = lpVerb;
|
2002-07-24 20:59:38 +02:00
|
|
|
sei.lpFile = lpFile;
|
|
|
|
sei.lpParameters = lpParameters;
|
|
|
|
sei.lpDirectory = lpDirectory;
|
|
|
|
sei.nShow = nShowCmd;
|
|
|
|
sei.lpIDList = 0;
|
|
|
|
sei.lpClass = 0;
|
|
|
|
sei.hkeyClass = 0;
|
|
|
|
sei.dwHotKey = 0;
|
2005-10-03 13:02:47 +02:00
|
|
|
sei.hProcess = 0;
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2005-11-11 11:54:07 +01:00
|
|
|
SHELL_execute( &sei, SHELL_ExecuteW );
|
2002-07-24 20:59:38 +02:00
|
|
|
return sei.hInstApp;
|
|
|
|
}
|
2007-04-18 21:33:13 +02:00
|
|
|
|
2009-04-01 18:19:42 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* WOWShellExecute [SHELL32.@]
|
|
|
|
*
|
|
|
|
* FIXME: the callback function most likely doesn't work the same way on Windows.
|
|
|
|
*/
|
2012-10-17 23:25:56 +02:00
|
|
|
HINSTANCE WINAPI WOWShellExecute(HWND hWnd, LPCSTR lpVerb,LPCSTR lpFile,
|
2009-04-01 18:19:42 +02:00
|
|
|
LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd, void *callback)
|
|
|
|
{
|
|
|
|
SHELLEXECUTEINFOW seiW;
|
|
|
|
WCHAR *wVerb = NULL, *wFile = NULL, *wParameters = NULL, *wDirectory = NULL;
|
|
|
|
HANDLE hProcess = 0;
|
|
|
|
|
2012-10-17 23:25:56 +02:00
|
|
|
seiW.lpVerb = lpVerb ? __SHCloneStrAtoW(&wVerb, lpVerb) : NULL;
|
2009-04-01 18:19:42 +02:00
|
|
|
seiW.lpFile = lpFile ? __SHCloneStrAtoW(&wFile, lpFile) : NULL;
|
|
|
|
seiW.lpParameters = lpParameters ? __SHCloneStrAtoW(&wParameters, lpParameters) : NULL;
|
|
|
|
seiW.lpDirectory = lpDirectory ? __SHCloneStrAtoW(&wDirectory, lpDirectory) : NULL;
|
|
|
|
|
|
|
|
seiW.cbSize = sizeof(seiW);
|
|
|
|
seiW.fMask = 0;
|
|
|
|
seiW.hwnd = hWnd;
|
|
|
|
seiW.nShow = iShowCmd;
|
|
|
|
seiW.lpIDList = 0;
|
|
|
|
seiW.lpClass = 0;
|
|
|
|
seiW.hkeyClass = 0;
|
|
|
|
seiW.dwHotKey = 0;
|
|
|
|
seiW.hProcess = hProcess;
|
|
|
|
|
|
|
|
SHELL_execute( &seiW, callback );
|
|
|
|
|
|
|
|
SHFree(wVerb);
|
|
|
|
SHFree(wFile);
|
|
|
|
SHFree(wParameters);
|
|
|
|
SHFree(wDirectory);
|
|
|
|
return seiW.hInstApp;
|
|
|
|
}
|
|
|
|
|
2017-09-26 06:52:52 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* ShellExec_RunDLLW [SHELL32.@]
|
|
|
|
*/
|
|
|
|
void WINAPI ShellExec_RunDLLW(HWND hwnd, HINSTANCE instance, WCHAR *cmdline, int cmdshow)
|
|
|
|
{
|
|
|
|
BOOL in_single_quotes = FALSE, in_double_quotes = FALSE;
|
|
|
|
WCHAR *args;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %s, %d\n", hwnd, instance, debugstr_w(cmdline), cmdshow);
|
|
|
|
|
|
|
|
/* Replace the first whitespace character in the command line string with a
|
|
|
|
null terminator to separate the program name from the program arguments */
|
|
|
|
for (args = cmdline; *args; args++)
|
|
|
|
{
|
|
|
|
switch (*args)
|
|
|
|
{
|
|
|
|
case '\\':
|
|
|
|
args++; /* skip the next character */
|
|
|
|
break;
|
|
|
|
case '\'':
|
|
|
|
if (!in_double_quotes)
|
|
|
|
in_single_quotes = !in_single_quotes;
|
|
|
|
break;
|
|
|
|
case '"':
|
|
|
|
if (!in_single_quotes)
|
|
|
|
in_double_quotes = !in_double_quotes;
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
if (!in_single_quotes && !in_double_quotes)
|
|
|
|
{
|
|
|
|
*args = 0;
|
|
|
|
args++;
|
|
|
|
goto execute;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
execute:
|
|
|
|
ShellExecuteW(hwnd, NULL, cmdline, args, NULL, cmdshow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ShellExec_RunDLLA [SHELL32.@]
|
|
|
|
*/
|
|
|
|
void WINAPI ShellExec_RunDLLA(HWND hwnd, HINSTANCE instance, CHAR *cmdline, int cmdshow)
|
|
|
|
{
|
|
|
|
WCHAR *cmdlineW;
|
|
|
|
ShellExec_RunDLLW(hwnd, instance, __SHCloneStrAtoW(&cmdlineW, cmdline), cmdshow);
|
|
|
|
SHFree(cmdlineW);
|
|
|
|
}
|
|
|
|
|
2007-04-18 21:33:13 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* OpenAs_RunDLLA [SHELL32.@]
|
|
|
|
*/
|
|
|
|
void WINAPI OpenAs_RunDLLA(HWND hwnd, HINSTANCE hinst, LPCSTR cmdline, int cmdshow)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %s, %d\n", hwnd, hinst, debugstr_a(cmdline), cmdshow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* OpenAs_RunDLLW [SHELL32.@]
|
|
|
|
*/
|
|
|
|
void WINAPI OpenAs_RunDLLW(HWND hwnd, HINSTANCE hinst, LPCWSTR cmdline, int cmdshow)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p, %s, %d\n", hwnd, hinst, debugstr_w(cmdline), cmdshow);
|
|
|
|
}
|
2014-11-12 02:41:03 +01:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* RegenerateUserEnvironment [SHELL32.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI RegenerateUserEnvironment(WCHAR *wunknown, BOOL bunknown)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p, %d\n", wunknown, bunknown);
|
|
|
|
return FALSE;
|
|
|
|
}
|