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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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>
|
|
|
|
|
|
|
|
#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"
|
2002-10-17 18:43:42 +02:00
|
|
|
#include "wownt32.h"
|
2002-02-27 02:22:15 +01:00
|
|
|
#include "shellapi.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2002-02-27 02:22:15 +01:00
|
|
|
#include "shlobj.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "ddeml.h"
|
|
|
|
|
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "shell32_main.h"
|
2002-07-24 20:59:38 +02:00
|
|
|
#include "undocshell.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-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
|
|
|
*
|
|
|
|
* FIXME: use 'len'
|
2002-02-27 02:22:15 +01:00
|
|
|
*/
|
2004-03-26 03:29:12 +01:00
|
|
|
static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lpFile, LPITEMIDLIST pidl, LPCWSTR args)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-03-26 03:29:12 +01:00
|
|
|
WCHAR xlpFile[1024];
|
|
|
|
BOOL done = FALSE;
|
|
|
|
PWSTR res = out;
|
|
|
|
PCWSTR cmd;
|
|
|
|
LPVOID pv;
|
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 '%':
|
|
|
|
*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 == '*')
|
|
|
|
{
|
|
|
|
*res++ = '"';
|
|
|
|
while(*args)
|
|
|
|
*res++ = *args++;
|
|
|
|
*res++ = '"';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while(*args && !isspace(*args))
|
|
|
|
*res++ = *args++;
|
|
|
|
|
|
|
|
while(isspace(*args))
|
|
|
|
++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. */
|
2004-01-15 07:13:57 +01:00
|
|
|
if (SearchPathW(NULL, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL))
|
2004-03-26 03:29:12 +01:00
|
|
|
cmd = xlpFile;
|
|
|
|
else
|
|
|
|
cmd = lpFile;
|
|
|
|
|
|
|
|
/* Add double quotation marks unless we already have them (e.g.: "%1" %* for exefile) */
|
|
|
|
if (res==out || res[-1]!='"')
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2004-03-26 03:29:12 +01:00
|
|
|
*res++ = '"';
|
|
|
|
strcpyW(res, cmd);
|
|
|
|
res += strlenW(cmd);
|
|
|
|
*res++ = '"';
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-03-26 03:29:12 +01:00
|
|
|
strcpyW(res, cmd);
|
|
|
|
res += strlenW(cmd);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
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
|
|
|
/*
|
|
|
|
* IE uses this alot for activating things such as windows media
|
|
|
|
* 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) {
|
|
|
|
strcpyW(res, lpFile);
|
|
|
|
res += strlenW(lpFile);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'i':
|
|
|
|
case 'I':
|
|
|
|
if (pidl) {
|
|
|
|
HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0);
|
|
|
|
pv = SHLockShared(hmem, 0);
|
|
|
|
res += sprintfW(res, wszILPtr, pv);
|
|
|
|
SHUnlockShared(pv);
|
|
|
|
}
|
2003-05-19 20:55:26 +02:00
|
|
|
break;
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
default: FIXME("Unknown escape sequence %%%c\n", *fmt);
|
|
|
|
}
|
|
|
|
fmt++;
|
2002-07-24 20:59:38 +02:00
|
|
|
done = TRUE;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
*res++ = *fmt++;
|
|
|
|
}
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
*res = '\0';
|
2004-03-26 03:29:12 +01:00
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
return done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2004-01-15 07:13:57 +01:00
|
|
|
* SHELL_ExecuteW [Internal]
|
2002-07-25 02:18:23 +02:00
|
|
|
*
|
|
|
|
*/
|
2004-03-18 05:04:29 +01:00
|
|
|
static UINT SHELL_ExecuteW(const WCHAR *lpCmd, void *env, BOOL shWait,
|
|
|
|
LPSHELLEXECUTEINFOW 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;
|
2002-11-22 00:56:42 +01:00
|
|
|
UINT retval = 31;
|
2004-03-19 02:52:30 +01:00
|
|
|
UINT gcdret = 0;
|
|
|
|
WCHAR curdir[MAX_PATH];
|
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));
|
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 */
|
|
|
|
if( psei->lpDirectory && psei->lpDirectory[0] )
|
|
|
|
if( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir)))
|
|
|
|
if( !SetCurrentDirectoryW( psei->lpDirectory))
|
|
|
|
ERR("cannot set directory %s\n", debugstr_w(psei->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;
|
|
|
|
if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, 0,
|
|
|
|
env, *psei->lpDirectory? psei->lpDirectory: NULL, &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)
|
2002-10-29 22:30:01 +01:00
|
|
|
WARN("WaitForInputIdle failed: Error %ld\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
|
|
|
{
|
|
|
|
FIXME("Strange error set by CreateProcess: %d\n", retval);
|
2002-11-22 00:56:42 +01:00
|
|
|
retval = ERROR_BAD_FORMAT;
|
2002-07-25 02:18:23 +02:00
|
|
|
}
|
|
|
|
|
2004-02-12 21:04:09 +01:00
|
|
|
TRACE("returning %u\n", retval);
|
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
psei_out->hInstApp = (HINSTANCE)retval;
|
2004-03-19 02:52:30 +01:00
|
|
|
if( gcdret )
|
|
|
|
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 */
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if (!(new_env = HeapAlloc( GetProcessHeap(), 0, 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-01-15 07:13:57 +01:00
|
|
|
static BOOL SHELL_TryAppPathW( LPCWSTR szName, LPWSTR lpResult, void**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;
|
|
|
|
}
|
|
|
|
|
2004-03-04 21:34:38 +01:00
|
|
|
static UINT SHELL_FindExecutableByOperation(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation, LPWSTR key, LPWSTR filetype, LPWSTR command, LONG commandlen)
|
|
|
|
{
|
|
|
|
static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0};
|
|
|
|
|
|
|
|
/* Looking for ...buffer\shell\<verb>\command */
|
|
|
|
strcatW(filetype, wszShell);
|
|
|
|
strcatW(filetype, lpOperation);
|
|
|
|
strcatW(filetype, wCommand);
|
|
|
|
|
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, filetype, command,
|
|
|
|
&commandlen) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
commandlen /= sizeof(WCHAR);
|
|
|
|
if (key) strcpyW(key, filetype);
|
|
|
|
#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 */
|
|
|
|
tmp = strstrW(filetype, wCommand);
|
|
|
|
tmp[0] = '\0';
|
|
|
|
strcatW(filetype, wDdeexec);
|
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, filetype, param,
|
|
|
|
¶mlen) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
paramlen /= sizeof(WCHAR);
|
|
|
|
strcatW(command, wSpace);
|
|
|
|
strcatW(command, param);
|
|
|
|
commandlen += paramlen;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
command[commandlen] = '\0';
|
|
|
|
|
|
|
|
return 33; /* FIXME see SHELL_FindExecutable() */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 31; /* default - 'No association was found' */
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
* lpOperation the operation on it (open)
|
|
|
|
* 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)
|
|
|
|
*/
|
2004-03-26 03:29:12 +01:00
|
|
|
UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
|
|
|
|
LPWSTR lpResult, int resultLen, LPWSTR key, void **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 */
|
|
|
|
WCHAR wtmpext[5]; /* local copy to mung as we please */
|
|
|
|
WCHAR filetype[256]; /* registry name for this filetype */
|
2004-03-03 06:26:30 +01:00
|
|
|
LONG filetypelen = sizeof(filetype); /* length of above */
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR command[256]; /* command from registry */
|
|
|
|
WCHAR wBuffer[256]; /* Used to GetProfileString */
|
|
|
|
UINT retval = 31; /* default - 'No association was found' */
|
|
|
|
WCHAR *tok; /* token pointer */
|
2004-04-05 23:06:16 +02:00
|
|
|
WCHAR xlpFile[256]; /* result of SearchPath */
|
2004-01-15 07:13:57 +01:00
|
|
|
|
|
|
|
TRACE("%s\n", (lpFile != NULL) ? debugstr_w(lpFile) : "-");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
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 */
|
|
|
|
if ((lpFile == NULL) || (lpResult == NULL) || (lpOperation == NULL))
|
|
|
|
{
|
|
|
|
WARN("(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
|
2004-01-15 07:13:57 +01:00
|
|
|
debugstr_w(lpFile), debugstr_w(lpOperation), debugstr_w(lpResult));
|
2002-02-27 02:22:15 +01:00
|
|
|
return 2; /* File not found. Close enough, I guess. */
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if (SearchPathW(lpPath, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), 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;
|
2003-01-03 04:03:36 +01:00
|
|
|
/* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* First thing we need is the file's extension */
|
2004-01-15 07:13:57 +01:00
|
|
|
extension = strrchrW(xlpFile, '.'); /* Assume last "." is the one; */
|
2002-02-27 02:22:15 +01:00
|
|
|
/* File->Run in progman uses */
|
|
|
|
/* .\FILE.EXE :( */
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if ((extension == NULL) || (extension == &xlpFile[strlenW(xlpFile)]))
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
|
|
|
WARN("Returning 31 - No association\n");
|
|
|
|
return 31; /* no association */
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Make local copy & lowercase it for reg & 'programs=' lookup */
|
2004-01-15 07:13:57 +01:00
|
|
|
lstrcpynW(wtmpext, extension, 5);
|
|
|
|
CharLowerW(wtmpext);
|
|
|
|
TRACE("%s file\n", debugstr_w(wtmpext));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Three places to check: */
|
|
|
|
/* 1. win.ini, [windows], programs (NB no leading '.') */
|
|
|
|
/* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
|
|
|
|
/* 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. */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* 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... */
|
2004-01-15 07:13:57 +01:00
|
|
|
if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, sizeof(wBuffer)/sizeof(WCHAR)) > 0)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
CharLowerW(wBuffer);
|
|
|
|
tok = wBuffer;
|
|
|
|
while (*tok)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR *p = tok;
|
|
|
|
while (*p && *p != ' ' && *p != '\t') p++;
|
|
|
|
if (*p)
|
|
|
|
{
|
|
|
|
*p++ = 0;
|
|
|
|
while (*p == ' ' || *p == '\t') p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmpW(tok, &wtmpext[1]) == 0) /* have to skip the leading "." */
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(lpResult, xlpFile);
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Need to perhaps check that the file has a path
|
|
|
|
* attached */
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("found %s\n", debugstr_w(lpResult));
|
2002-02-27 02:22:15 +01:00
|
|
|
return 33;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Greater than 32 to indicate success FIXME According to the
|
|
|
|
* docs, I should be returning a handle for the
|
|
|
|
* executable. Does this mean I'm supposed to open the
|
|
|
|
* executable file or something? More RTFM, I guess... */
|
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
tok = p;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Check registry */
|
2004-01-15 07:13:57 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, wtmpext, filetype,
|
|
|
|
&filetypelen) == ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-03-03 06:26:30 +01:00
|
|
|
filetypelen /= sizeof(WCHAR);
|
2002-02-27 02:22:15 +01:00
|
|
|
filetype[filetypelen] = '\0';
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("File type: %s\n", debugstr_w(filetype));
|
2004-03-04 21:34:38 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-03-04 21:34:38 +01:00
|
|
|
if (*filetype)
|
|
|
|
{
|
|
|
|
if (lpOperation)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-03-04 21:34:38 +01:00
|
|
|
/* pass the operation string to SHELL_FindExecutableByOperation() */
|
|
|
|
filetype[filetypelen] = '\0';
|
|
|
|
retval = SHELL_FindExecutableByOperation(lpPath, lpFile, lpOperation, key, filetype, command, sizeof(command));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR operation[MAX_PATH];
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
/* Looking for ...buffer\shell\<operation>\command */
|
|
|
|
strcatW(filetype, wszShell);
|
|
|
|
|
|
|
|
/* enumerate the operation subkeys in the registry and search for one with an associated command */
|
|
|
|
if (RegOpenKeyW(HKEY_CLASSES_ROOT, filetype, &hkey) == ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-03-04 21:34:38 +01:00
|
|
|
int idx = 0;
|
|
|
|
for(;; ++idx)
|
|
|
|
{
|
|
|
|
if (RegEnumKeyW(hkey, idx, operation, MAX_PATH) != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
filetype[filetypelen] = '\0';
|
|
|
|
retval = SHELL_FindExecutableByOperation(lpPath, lpFile, operation, key, filetype, command, sizeof(command));
|
|
|
|
|
|
|
|
if (retval > 32)
|
|
|
|
break;
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2004-03-04 21:34:38 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retval > 32)
|
2004-03-26 03:29:12 +01:00
|
|
|
{
|
|
|
|
SHELL_ArgifyW(lpResult, resultLen, command, xlpFile, pidl, args);
|
|
|
|
|
|
|
|
/* Remove double quotation marks and command line arguments */
|
|
|
|
if (*lpResult == '"')
|
|
|
|
{
|
|
|
|
WCHAR *p = lpResult;
|
|
|
|
while (*(p + 1) != '"')
|
|
|
|
{
|
|
|
|
*p = *(p + 1);
|
|
|
|
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};
|
|
|
|
static const WCHAR wEmpty[] = {0};
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Toss the leading dot */
|
|
|
|
extension++;
|
2004-01-15 07:13:57 +01:00
|
|
|
if (GetProfileStringW(wExtensions, extension, wEmpty, command, sizeof(command)/sizeof(WCHAR)) > 0)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
if (strlenW(command) != 0)
|
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
|
|
|
|
*
|
|
|
|
* callback for the DDE connection. not really usefull
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static HDDEDATA CALLBACK dde_cb(UINT uType, UINT uFmt, HCONV hConv,
|
2002-02-27 02:22:15 +01:00
|
|
|
HSZ hsz1, HSZ hsz2,
|
|
|
|
HDDEDATA hData, DWORD dwData1, DWORD 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
|
|
|
|
*
|
|
|
|
*/
|
2004-01-15 07:13:57 +01:00
|
|
|
static unsigned dde_connect(WCHAR* key, WCHAR* start, WCHAR* ddeexec,
|
|
|
|
const WCHAR* lpFile, void *env,
|
2004-03-26 03:29:12 +01:00
|
|
|
LPCWSTR szCommandline, LPITEMIDLIST pidl, SHELL_ExecuteW32 execfunc,
|
2004-03-18 05:04:29 +01:00
|
|
|
LPSHELLEXECUTEINFOW 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};
|
|
|
|
WCHAR * endkey = key + strlenW(key);
|
|
|
|
WCHAR app[256], topic[256], ifexec[256], res[256];
|
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;
|
|
|
|
HSZ hszApp, hszTopic;
|
|
|
|
HCONV hConv;
|
|
|
|
unsigned ret = 31;
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(endkey, wApplication);
|
2004-03-03 06:26:30 +01:00
|
|
|
applen = sizeof(app);
|
2004-01-15 07:13:57 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, app, &applen) != ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
FIXME("default app name NIY %s\n", debugstr_w(key));
|
2002-02-27 02:22:15 +01:00
|
|
|
return 2;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(endkey, wTopic);
|
2004-03-03 06:26:30 +01:00
|
|
|
topiclen = sizeof(topic);
|
2004-01-15 07:13:57 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, 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
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if (DdeInitializeW(&ddeInst, dde_cb, APPCMD_CLIENTONLY, 0L) != DMLERR_NO_ERROR)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
hszApp = DdeCreateStringHandleW(ddeInst, app, CP_WINANSI);
|
|
|
|
hszTopic = DdeCreateStringHandleW(ddeInst, topic, CP_WINANSI);
|
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};
|
|
|
|
TRACE("Launching '%s'\n", debugstr_w(start));
|
2004-03-18 05:04:29 +01:00
|
|
|
ret = execfunc(start, env, TRUE, psei, psei_out);
|
2002-02-27 02:22:15 +01:00
|
|
|
if (ret < 32)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(endkey, wIfexec);
|
2004-03-03 06:26:30 +01:00
|
|
|
ifexeclen = sizeof(ifexec);
|
2004-01-15 07:13:57 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, ifexec, &ifexeclen) == ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
|
|
|
exec = ifexec;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-03-26 03:29:12 +01:00
|
|
|
SHELL_ArgifyW(res, sizeof(res)/sizeof(WCHAR), exec, lpFile, pidl, szCommandline);
|
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-01-15 07:13:57 +01:00
|
|
|
ret = (DdeClientTransaction((LPBYTE)res, (strlenW(res) + 1) * sizeof(WCHAR), hConv, 0L, 0,
|
2002-09-16 21:27:51 +02:00
|
|
|
XTYP_EXECUTE, 10000, &tid) != DMLERR_NO_ERROR) ? 31 : 33;
|
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]
|
|
|
|
*/
|
2004-03-26 03:29:12 +01:00
|
|
|
static UINT execute_from_key(LPWSTR key, LPCWSTR lpFile, void *env, LPCWSTR szCommandline,
|
2004-03-18 05:04:29 +01:00
|
|
|
SHELL_ExecuteW32 execfunc,
|
|
|
|
LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-04-05 23:06:16 +02:00
|
|
|
WCHAR cmd[1024];
|
2004-03-03 06:26:30 +01:00
|
|
|
LONG cmdlen = sizeof(cmd);
|
2002-11-22 00:56:42 +01:00
|
|
|
UINT retval = 31;
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2004-04-05 23:06:16 +02:00
|
|
|
cmd[0] = '\0';
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/* Get the application for the registry */
|
2004-01-15 07:13:57 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, cmd, &cmdlen) == ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01: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};
|
|
|
|
LPWSTR tmp;
|
2004-04-05 23:06:16 +02:00
|
|
|
WCHAR param[256];
|
2004-03-03 06:26:30 +01:00
|
|
|
LONG paramlen = sizeof(param);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-04-05 23:06:16 +02:00
|
|
|
param[0] = '\0';
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Get the parameters needed by the application
|
|
|
|
from the associated ddeexec key */
|
2004-01-15 07:13:57 +01:00
|
|
|
tmp = strstrW(key, wCommand);
|
2002-02-27 02:22:15 +01:00
|
|
|
assert(tmp);
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(tmp, wDdeexec);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, key, param, ¶mlen) == ERROR_SUCCESS)
|
2002-02-27 02:22:15 +01:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("Got ddeexec %s => %s\n", debugstr_w(key), debugstr_w(param));
|
2004-03-26 03:29:12 +01:00
|
|
|
retval = dde_connect(key, cmd, param, lpFile, env, szCommandline, psei->lpIDList, execfunc, psei, psei_out);
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Is there a replace() function anywhere? */
|
2004-03-03 06:26:30 +01:00
|
|
|
cmdlen /= sizeof(WCHAR);
|
2002-02-27 02:22:15 +01:00
|
|
|
cmd[cmdlen] = '\0';
|
2004-03-26 03:29:12 +01:00
|
|
|
SHELL_ArgifyW(param, sizeof(param)/sizeof(WCHAR), cmd, lpFile, psei->lpIDList, szCommandline);
|
2004-03-18 05:04:29 +01:00
|
|
|
retval = execfunc(param, env, FALSE, psei, psei_out);
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else TRACE("ooch\n");
|
|
|
|
|
|
|
|
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);
|
|
|
|
if (wFile) SHFree( wFile );
|
|
|
|
if (wDirectory) SHFree( wDirectory );
|
|
|
|
|
|
|
|
TRACE("returning %s\n", lpResult);
|
|
|
|
return (HINSTANCE)retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* FindExecutableW [SHELL32.@]
|
|
|
|
*/
|
|
|
|
HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
UINT retval = 31; /* default - 'No association was found' */
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR old_dir[1024];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
TRACE("File %s, Dir %s\n",
|
2004-01-15 07:13:57 +01:00
|
|
|
(lpFile != NULL ? debugstr_w(lpFile) : "-"), (lpDirectory != NULL ? debugstr_w(lpDirectory) : "-"));
|
2002-02-27 02:22:15 +01:00
|
|
|
|
|
|
|
lpResult[0] = '\0'; /* Start off with an empty return string */
|
|
|
|
|
|
|
|
/* trap NULL parameters on entry */
|
|
|
|
if ((lpFile == NULL) || (lpResult == NULL))
|
|
|
|
{
|
|
|
|
/* FIXME - should throw a warning, perhaps! */
|
2002-11-22 00:56:42 +01:00
|
|
|
return (HINSTANCE)2; /* File not found. Close enough, I guess. */
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDirectory)
|
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
GetCurrentDirectoryW(sizeof(old_dir)/sizeof(WCHAR), old_dir);
|
|
|
|
SetCurrentDirectoryW(lpDirectory);
|
2002-02-27 02:22:15 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-03-26 03:29:12 +01:00
|
|
|
retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, lpResult, MAX_PATH, NULL, NULL, NULL, NULL);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2004-01-15 07:13:57 +01:00
|
|
|
* ShellExecuteExW32 [Internal]
|
2002-07-24 20:59:38 +02:00
|
|
|
*/
|
2004-01-15 07:13:57 +01:00
|
|
|
BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wQuote[] = {'"',0};
|
|
|
|
static const WCHAR wSpace[] = {' ',0};
|
|
|
|
static const WCHAR wWww[] = {'w','w','w',0};
|
|
|
|
static const WCHAR wFile[] = {'f','i','l','e',0};
|
|
|
|
static const WCHAR wHttp[] = {'h','t','t','p',':','/','/',0};
|
2004-03-18 05:04:29 +01:00
|
|
|
|
|
|
|
WCHAR wszApplicationName[MAX_PATH+2], wszCommandline[1024], wszDir[MAX_PATH];
|
|
|
|
SHELLEXECUTEINFOW sei_tmp; /* modifyable copy of SHELLEXECUTEINFO struct */
|
2004-03-26 03:29:12 +01:00
|
|
|
WCHAR wfileName[MAX_PATH];
|
2003-09-26 06:35:01 +02:00
|
|
|
void *env;
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR lpstrProtocol[256];
|
2004-03-04 21:34:38 +01:00
|
|
|
LPCWSTR lpFile;
|
2002-11-22 00:56:42 +01:00
|
|
|
UINT retval = 31;
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR wcmd[1024];
|
2004-03-18 05:04:29 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2002-07-25 02:18:23 +02:00
|
|
|
BOOL done;
|
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 */
|
|
|
|
memcpy(&sei_tmp, sei, sizeof(sei_tmp));
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("mask=0x%08lx 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,
|
|
|
|
(sei_tmp.fMask & 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 */
|
|
|
|
if (sei_tmp.lpFile)
|
|
|
|
strcpyW(wszApplicationName, sei_tmp.lpFile);
|
|
|
|
else
|
|
|
|
*wszApplicationName = '\0';
|
|
|
|
|
|
|
|
if (sei_tmp.lpParameters)
|
|
|
|
strcpyW(wszCommandline, sei_tmp.lpParameters);
|
|
|
|
else
|
|
|
|
*wszCommandline = '\0';
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
if (sei_tmp.lpDirectory)
|
|
|
|
strcpyW(wszDir, sei_tmp.lpDirectory);
|
|
|
|
else
|
|
|
|
*wszDir = '\0';
|
|
|
|
|
|
|
|
/* adjust string pointers to point to the new buffers */
|
|
|
|
sei_tmp.lpFile = wszApplicationName;
|
|
|
|
sei_tmp.lpParameters = wszCommandline;
|
|
|
|
sei_tmp.lpDirectory = wszDir;
|
|
|
|
|
|
|
|
if (sei_tmp.fMask & (SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
|
2002-07-24 20:59:38 +02:00
|
|
|
SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
|
|
|
|
SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE |
|
|
|
|
SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR ))
|
|
|
|
{
|
2004-03-18 05:04:29 +01:00
|
|
|
FIXME("flags ignored: 0x%08lx\n", sei_tmp.fMask);
|
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))
|
|
|
|
{
|
|
|
|
hr = IShellExecuteHookW_Execute(pSEH, sei);
|
|
|
|
|
|
|
|
IShellExecuteHookW_Release(pSEH);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
wszApplicationName[0] = '"';
|
2004-03-18 05:04:29 +01:00
|
|
|
SHGetPathFromIDListW(sei_tmp.lpIDList, wszApplicationName+1);
|
2004-01-15 07:13:57 +01:00
|
|
|
strcatW(wszApplicationName, wQuote);
|
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
|
|
|
}
|
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
if (sei_tmp.fMask & (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY))
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2002-07-25 02:18:23 +02:00
|
|
|
/* launch a document by fileclass like 'WordPad.Document.1' */
|
|
|
|
/* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
|
2004-01-15 07:13:57 +01:00
|
|
|
/* FIXME: szCommandline should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */
|
2004-03-18 05:04:29 +01:00
|
|
|
HCR_GetExecuteCommandW((sei_tmp.fMask & SEE_MASK_CLASSKEY) ? sei_tmp.hkeyClass : NULL,
|
|
|
|
(sei_tmp.fMask & SEE_MASK_CLASSNAME) ? sei_tmp.lpClass: NULL,
|
|
|
|
(sei_tmp.lpVerb) ? sei_tmp.lpVerb : wszOpen,
|
2004-01-17 00:06:25 +01:00
|
|
|
wszCommandline, sizeof(wszCommandline)/sizeof(WCHAR));
|
2003-05-20 01:07:49 +02:00
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
/* FIXME: get the extension of lpFile, check if it fits to the lpClass */
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("SEE_MASK_CLASSNAME->'%s', doc->'%s'\n", debugstr_w(wszCommandline), debugstr_w(wszApplicationName));
|
2002-07-25 02:18:23 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
wcmd[0] = '\0';
|
2004-03-26 03:29:12 +01:00
|
|
|
done = SHELL_ArgifyW(wcmd, sizeof(wcmd)/sizeof(WCHAR), wszCommandline, wszApplicationName, sei_tmp.lpIDList, NULL);
|
2004-01-15 07:13:57 +01:00
|
|
|
if (!done && wszApplicationName[0])
|
2002-07-25 02:18:23 +02:00
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
strcatW(wcmd, wSpace);
|
|
|
|
strcatW(wcmd, wszApplicationName);
|
2002-07-25 02:18:23 +02:00
|
|
|
}
|
2004-03-18 05:04:29 +01:00
|
|
|
retval = execfunc(wcmd, NULL, FALSE, &sei_tmp, sei);
|
2002-07-25 02:18:23 +02:00
|
|
|
if (retval > 32)
|
|
|
|
return TRUE;
|
2002-07-24 20:59:38 +02:00
|
|
|
else
|
2002-07-25 02:18:23 +02:00
|
|
|
return FALSE;
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
/* expand environment strings */
|
|
|
|
if (ExpandEnvironmentStringsW(sei_tmp.lpFile, buffer, MAX_PATH))
|
|
|
|
lstrcpyW(wszApplicationName, buffer);
|
|
|
|
|
|
|
|
if (*sei_tmp.lpParameters)
|
|
|
|
if (ExpandEnvironmentStringsW(sei_tmp.lpParameters, buffer, MAX_PATH))
|
|
|
|
lstrcpyW(wszCommandline, buffer);
|
|
|
|
|
|
|
|
if (*sei_tmp.lpDirectory)
|
|
|
|
if (ExpandEnvironmentStringsW(sei_tmp.lpDirectory, buffer, MAX_PATH))
|
|
|
|
lstrcpyW(wszDir, buffer);
|
|
|
|
|
2002-07-25 02:18:23 +02:00
|
|
|
/* Else, try to execute the filename */
|
2004-03-18 05:04:29 +01:00
|
|
|
TRACE("execute:'%s','%s','%s'\n", debugstr_w(wszApplicationName), debugstr_w(wszCommandline), debugstr_w(wszDir));
|
2002-07-25 02:18:23 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(wfileName, wszApplicationName);
|
|
|
|
lpFile = wfileName;
|
|
|
|
if (wszCommandline[0]) {
|
|
|
|
strcatW(wszApplicationName, wSpace);
|
|
|
|
strcatW(wszApplicationName, wszCommandline);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2004-03-18 05:04:29 +01:00
|
|
|
retval = execfunc(wszApplicationName, NULL, FALSE, &sei_tmp, sei);
|
2002-07-25 02:18:23 +02:00
|
|
|
if (retval > 32)
|
|
|
|
return TRUE;
|
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';
|
2004-03-26 03:29:12 +01:00
|
|
|
retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, 1024, lpstrProtocol, &env, sei_tmp.lpIDList, sei_tmp.lpParameters);
|
2002-07-24 20:59:38 +02:00
|
|
|
if (retval > 32) /* Found */
|
|
|
|
{
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR wszQuotedCmd[MAX_PATH+2];
|
2003-01-03 04:03:36 +01:00
|
|
|
/* Must quote to handle case where cmd contains spaces,
|
|
|
|
* else security hole if malicious user creates executable file "C:\\Program"
|
|
|
|
*/
|
2004-01-15 07:13:57 +01:00
|
|
|
strcpyW(wszQuotedCmd, wQuote);
|
|
|
|
strcatW(wszQuotedCmd, wcmd);
|
|
|
|
strcatW(wszQuotedCmd, wQuote);
|
|
|
|
if (wszCommandline[0]) {
|
|
|
|
strcatW(wszQuotedCmd, wSpace);
|
|
|
|
strcatW(wszQuotedCmd, wszCommandline);
|
|
|
|
}
|
2004-03-18 05:04:29 +01:00
|
|
|
TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName), debugstr_w(sei_tmp.lpVerb), debugstr_w(wszQuotedCmd), debugstr_w(lpstrProtocol));
|
2002-07-24 20:59:38 +02:00
|
|
|
if (*lpstrProtocol)
|
2004-03-26 03:29:12 +01:00
|
|
|
retval = execute_from_key(lpstrProtocol, wszApplicationName, env, sei_tmp.lpParameters, execfunc, &sei_tmp, sei);
|
2002-07-24 20:59:38 +02:00
|
|
|
else
|
2004-03-18 05:04:29 +01:00
|
|
|
retval = execfunc(wszQuotedCmd, env, FALSE, &sei_tmp, sei);
|
2003-09-26 06:35:01 +02:00
|
|
|
if (env) HeapFree( GetProcessHeap(), 0, env );
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
2004-01-15 07:13:57 +01:00
|
|
|
else if (PathIsURLW((LPWSTR)lpFile)) /* File not found, check for URL */
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
2004-03-02 00:11:53 +01:00
|
|
|
static const WCHAR wShell[] = {'\\','s','h','e','l','l','\\',0};
|
2004-01-15 07:13:57 +01:00
|
|
|
static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0};
|
|
|
|
LPWSTR lpstrRes;
|
2002-07-24 20:59:38 +02:00
|
|
|
INT iSize;
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
lpstrRes = strchrW(lpFile, ':');
|
2002-07-24 20:59:38 +02:00
|
|
|
if (lpstrRes)
|
|
|
|
iSize = lpstrRes - lpFile;
|
|
|
|
else
|
2004-01-15 07:13:57 +01:00
|
|
|
iSize = strlenW(lpFile);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
TRACE("Got URL: %s\n", debugstr_w(lpFile));
|
2002-07-24 20:59:38 +02:00
|
|
|
/* Looking for ...protocol\shell\lpOperation\command */
|
2004-01-15 07:13:57 +01:00
|
|
|
strncpyW(lpstrProtocol, lpFile, iSize);
|
2002-07-24 20:59:38 +02:00
|
|
|
lpstrProtocol[iSize] = '\0';
|
2004-01-15 07:13:57 +01:00
|
|
|
strcatW(lpstrProtocol, wShell);
|
2004-03-18 05:04:29 +01:00
|
|
|
strcatW(lpstrProtocol, sei_tmp.lpVerb? sei_tmp.lpVerb: wszOpen);
|
2004-01-15 07:13:57 +01:00
|
|
|
strcatW(lpstrProtocol, wCommand);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
|
|
|
/* Remove File Protocol from lpFile */
|
|
|
|
/* In the case file://path/file */
|
2004-01-15 07:13:57 +01:00
|
|
|
if (!strncmpiW(lpFile, wFile, iSize))
|
2002-07-24 20:59:38 +02:00
|
|
|
{
|
|
|
|
lpFile += iSize;
|
|
|
|
while (*lpFile == ':') lpFile++;
|
|
|
|
}
|
2004-03-26 03:29:12 +01:00
|
|
|
retval = execute_from_key(lpstrProtocol, lpFile, NULL, sei_tmp.lpParameters, execfunc, &sei_tmp, sei);
|
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
|
|
|
{
|
|
|
|
/* if so, append lpFile http:// and call ShellExecute */
|
2004-01-15 07:13:57 +01:00
|
|
|
WCHAR lpstrTmpFile[256];
|
|
|
|
strcpyW(lpstrTmpFile, wHttp);
|
|
|
|
strcatW(lpstrTmpFile, lpFile);
|
2004-03-18 05:04:29 +01:00
|
|
|
retval = (UINT)ShellExecuteW(sei_tmp.hwnd, sei_tmp.lpVerb, lpstrTmpFile, NULL, NULL, 0);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
2004-02-12 21:04:09 +01:00
|
|
|
TRACE("retval %u\n", retval);
|
|
|
|
|
2002-07-24 20:59:38 +02:00
|
|
|
if (retval <= 32)
|
|
|
|
{
|
2002-11-22 00:56:42 +01:00
|
|
|
sei->hInstApp = (HINSTANCE)retval;
|
2002-07-24 20:59:38 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
sei->hInstApp = (HINSTANCE)33;
|
2002-07-24 20:59:38 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteA [SHELL32.290]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpOperation,LPCSTR lpFile,
|
2002-02-27 02:22:15 +01:00
|
|
|
LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd)
|
|
|
|
{
|
2002-07-24 20:59:38 +02:00
|
|
|
SHELLEXECUTEINFOA sei;
|
|
|
|
HANDLE hProcess = 0;
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
TRACE("\n");
|
2002-07-24 20:59:38 +02:00
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
|
sei.fMask = 0;
|
|
|
|
sei.hwnd = hWnd;
|
|
|
|
sei.lpVerb = lpOperation;
|
|
|
|
sei.lpFile = lpFile;
|
|
|
|
sei.lpParameters = lpParameters;
|
|
|
|
sei.lpDirectory = lpDirectory;
|
|
|
|
sei.nShow = iShowCmd;
|
|
|
|
sei.lpIDList = 0;
|
|
|
|
sei.lpClass = 0;
|
|
|
|
sei.hkeyClass = 0;
|
|
|
|
sei.dwHotKey = 0;
|
|
|
|
sei.hProcess = hProcess;
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
ShellExecuteExA (&sei);
|
2002-07-24 20:59:38 +02:00
|
|
|
return sei.hInstApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteEx [SHELL32.291]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ShellExecuteExAW (LPVOID sei)
|
|
|
|
{
|
|
|
|
if (SHELL_OsIsUnicode())
|
2004-01-15 07:13:57 +01:00
|
|
|
return ShellExecuteExW32 (sei, SHELL_ExecuteW);
|
|
|
|
return ShellExecuteExA (sei);
|
2002-07-24 20:59:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteExA [SHELL32.292]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
if ((sei->fMask & 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
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
ret = ShellExecuteExW32 (&seiW, SHELL_ExecuteW);
|
2002-07-24 20:59:38 +02:00
|
|
|
|
2004-02-12 21:04:09 +01:00
|
|
|
sei->hInstApp = seiW.hInstApp;
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
if (wVerb) SHFree(wVerb);
|
|
|
|
if (wFile) SHFree(wFile);
|
|
|
|
if (wParameters) SHFree(wParameters);
|
|
|
|
if (wDirectory) SHFree(wDirectory);
|
|
|
|
if (wClass) 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]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei)
|
|
|
|
{
|
|
|
|
return ShellExecuteExW32 (sei, SHELL_ExecuteW);
|
|
|
|
}
|
|
|
|
|
2002-02-27 02:22:15 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* ShellExecuteW [SHELL32.294]
|
|
|
|
* from shellapi.h
|
2002-06-01 01:06:46 +02:00
|
|
|
* WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
|
|
|
|
* LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
|
2002-02-27 02:22:15 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, 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;
|
|
|
|
HANDLE hProcess = 0;
|
2002-02-27 02:22:15 +01:00
|
|
|
|
2002-07-24 20:59:38 +02:00
|
|
|
TRACE("\n");
|
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
|
sei.fMask = 0;
|
|
|
|
sei.hwnd = hwnd;
|
|
|
|
sei.lpVerb = lpOperation;
|
|
|
|
sei.lpFile = lpFile;
|
|
|
|
sei.lpParameters = lpParameters;
|
|
|
|
sei.lpDirectory = lpDirectory;
|
|
|
|
sei.nShow = nShowCmd;
|
|
|
|
sei.lpIDList = 0;
|
|
|
|
sei.lpClass = 0;
|
|
|
|
sei.hkeyClass = 0;
|
|
|
|
sei.dwHotKey = 0;
|
|
|
|
sei.hProcess = hProcess;
|
|
|
|
|
2004-01-15 07:13:57 +01:00
|
|
|
ShellExecuteExW32 (&sei, SHELL_ExecuteW);
|
2002-07-24 20:59:38 +02:00
|
|
|
return sei.hInstApp;
|
|
|
|
}
|