2 * Shell Library Functions
4 * Copyright 1998 Marcus Meissner
5 * Copyright 2002 Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 WINE_DEFAULT_DEBUG_CHANNEL(exec
);
27 static const WCHAR wszOpen
[] = {'o','p','e','n',0};
28 static const WCHAR wszExe
[] = {'.','e','x','e',0};
29 static const WCHAR wszILPtr
[] = {':','%','p',0};
30 static const WCHAR wszShell
[] = {'\\','s','h','e','l','l','\\',0};
31 static const WCHAR wszFolder
[] = {'F','o','l','d','e','r',0};
32 static const WCHAR wszEmpty
[] = {0};
34 #define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY)
36 static void ParseNoTildeEffect(PWSTR
&res
, LPCWSTR
&args
, DWORD
&len
, DWORD
&used
, int argNum
)
38 bool firstCharQuote
= false;
39 bool quotes_opened
= false;
40 bool backslash_encountered
= false;
42 for (int curArg
=0; curArg
<=argNum
&& *args
; ++curArg
)
44 firstCharQuote
= false;
48 firstCharQuote
= true;
56 // if we found a backslash then flip the variable
57 backslash_encountered
= !backslash_encountered
;
59 else if (*args
== '"')
65 quotes_opened
= false;
79 backslash_encountered
= false;
83 backslash_encountered
= false;
84 if (*args
== ' ' && !firstCharQuote
)
103 static void ParseTildeEffect(PWSTR
&res
, LPCWSTR
&args
, DWORD
&len
, DWORD
&used
, int argNum
)
105 bool quotes_opened
= false;
106 bool backslash_encountered
= false;
108 for (int curArg
=0; curArg
<=argNum
&& *args
; ++curArg
)
114 // if we found a backslash then flip the variable
115 backslash_encountered
= !backslash_encountered
;
117 else if (*args
== '"')
121 if (*(args
+1) != '"')
123 quotes_opened
= false;
132 quotes_opened
= true;
135 backslash_encountered
= false;
139 backslash_encountered
= false;
140 if (*args
== ' ' && !quotes_opened
&& curArg
!=argNum
)
144 if (curArg
== argNum
)
156 /***********************************************************************
157 * SHELL_ArgifyW [Internal]
159 * this function is supposed to expand the escape sequences found in the registry
160 * some diving reported that the following were used:
161 * + %1, %2... seem to report to parameter of index N in ShellExecute pmts
166 * %I address of a global item ID (explorer switch /idlist)
167 * %L seems to be %1 as long filename followed by the 8+3 variation
169 * %* all following parameters (see batfile)
171 * The way we parse the command line arguments was determined through extensive
172 * testing and can be summed up by the following rules"
175 * - if first letter is " break on first non literal " and include any white spaces
176 * - if first letter is NOT " break on first " or white space
177 * - if " is opened any pair of consecutive " results in ONE literal "
180 * - use rules from here http://www.autohotkey.net/~deleyd/parameters/parameters.htm
183 static BOOL
SHELL_ArgifyW(WCHAR
* out
, DWORD len
, const WCHAR
* fmt
, const WCHAR
* lpFile
, LPITEMIDLIST pidl
, LPCWSTR args
, DWORD
* out_len
)
187 BOOL found_p1
= FALSE
;
191 bool tildeEffect
= false;
193 TRACE("Before parsing: %p, %d, %s, %s, %p, %p\n", out
, len
, debugstr_w(fmt
),
194 debugstr_w(lpFile
), pidl
, args
);
253 ParseTildeEffect(res
, args
, len
, used
, *fmt
- '2');
258 ParseNoTildeEffect(res
, args
, len
, used
, *fmt
- '2');
264 if (!done
|| (*fmt
== '1'))
266 /*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */
267 if (SearchPathW(NULL
, lpFile
, wszExe
, sizeof(xlpFile
)/sizeof(WCHAR
), xlpFile
, NULL
))
283 * IE uses this a lot for activating things such as windows media
284 * player. This is not verified to be fully correct but it appears
291 used
+= wcslen(lpFile
);
295 res
+= wcslen(lpFile
);
306 /* %p should not exceed 8, maybe 16 when looking forward to 64bit.
307 * allowing a buffer of 100 should more than exceed all needs */
310 HGLOBAL hmem
= SHAllocShared(pidl
, ILGetSize(pidl
), 0);
311 pv
= SHLockShared(hmem
, 0);
312 chars
= swprintf(buf
, wszILPtr
, pv
);
314 if (chars
>= sizeof(buf
)/sizeof(WCHAR
))
315 ERR("pidl format buffer too small!\n");
331 * Check if this is an env-variable here...
334 /* Make sure that we have at least one more %.*/
335 if (strchrW(fmt
, '%'))
337 WCHAR tmpBuffer
[1024];
338 PWSTR tmpB
= tmpBuffer
;
339 WCHAR tmpEnvBuff
[MAX_PATH
];
346 TRACE("Checking %s to be an env-var\n", debugstr_w(tmpBuffer
));
348 envRet
= GetEnvironmentVariableW(tmpBuffer
, tmpEnvBuff
, MAX_PATH
);
349 if (envRet
== 0 || envRet
> MAX_PATH
)
351 used
+= wcslen(tmpBuffer
);
354 wcscpy( res
, tmpBuffer
);
355 res
+= wcslen(tmpBuffer
);
360 used
+= wcslen(tmpEnvBuff
);
363 wcscpy( res
, tmpEnvBuff
);
364 res
+= wcslen(tmpEnvBuff
);
371 /* Don't skip past terminator (catch a single '%' at the end) */
388 TRACE("used %i of %i space\n",used
,len
);
392 TRACE("After parsing: %p, %d, %s, %s, %p, %p\n", out
, len
, debugstr_w(fmt
),
393 debugstr_w(lpFile
), pidl
, args
);
398 static HRESULT
SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl
, LPWSTR pszPath
, UINT uOutSize
)
401 IShellFolder
* desktop
;
403 HRESULT hr
= SHGetDesktopFolder(&desktop
);
407 hr
= desktop
->GetDisplayNameOf(pidl
, SHGDN_FORPARSING
, &strret
);
410 StrRetToStrNW(pszPath
, uOutSize
, &strret
, pidl
);
418 /*************************************************************************
419 * SHELL_ExecuteW [Internal]
422 static UINT_PTR
SHELL_ExecuteW(const WCHAR
*lpCmd
, WCHAR
*env
, BOOL shWait
,
423 const SHELLEXECUTEINFOW
*psei
, LPSHELLEXECUTEINFOW psei_out
)
425 STARTUPINFOW startup
;
426 PROCESS_INFORMATION info
;
427 UINT_PTR retval
= SE_ERR_NOASSOC
;
429 WCHAR curdir
[MAX_PATH
];
430 DWORD dwCreationFlags
;
431 const WCHAR
*lpDirectory
= NULL
;
433 TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd
), debugstr_w(psei
->lpDirectory
));
435 /* make sure we don't fail the CreateProcess if the calling app passes in
436 * a bad working directory */
437 if (psei
->lpDirectory
&& psei
->lpDirectory
[0])
439 DWORD attr
= GetFileAttributesW(psei
->lpDirectory
);
440 if (attr
!= INVALID_FILE_ATTRIBUTES
&& attr
& FILE_ATTRIBUTE_DIRECTORY
)
441 lpDirectory
= psei
->lpDirectory
;
444 /* ShellExecute specifies the command from psei->lpDirectory
445 * if present. Not from the current dir as CreateProcess does */
447 if ( ( gcdret
= GetCurrentDirectoryW( MAX_PATH
, curdir
)))
448 if ( !SetCurrentDirectoryW( lpDirectory
))
449 ERR("cannot set directory %s\n", debugstr_w(lpDirectory
));
451 ZeroMemory(&startup
,sizeof(STARTUPINFOW
));
452 startup
.cb
= sizeof(STARTUPINFOW
);
453 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
454 startup
.wShowWindow
= psei
->nShow
;
455 dwCreationFlags
= CREATE_UNICODE_ENVIRONMENT
;
457 if (psei
->fMask
& SEE_MASK_NO_CONSOLE
)
458 dwCreationFlags
|= CREATE_NEW_CONSOLE
;
460 if (CreateProcessW(NULL
, (LPWSTR
)lpCmd
, NULL
, NULL
, FALSE
, dwCreationFlags
, env
,
461 lpDirectory
, &startup
, &info
))
463 /* Give 30 seconds to the app to come up, if desired. Probably only needed
464 when starting app immediately before making a DDE connection. */
466 if (WaitForInputIdle( info
.hProcess
, 30000 ) == WAIT_FAILED
)
467 WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
470 if (psei
->fMask
& SEE_MASK_NOCLOSEPROCESS
)
471 psei_out
->hProcess
= info
.hProcess
;
473 CloseHandle( info
.hProcess
);
474 CloseHandle( info
.hThread
);
476 else if ((retval
= GetLastError()) >= 32)
478 WARN("CreateProcess returned error %ld\n", retval
);
479 retval
= ERROR_BAD_FORMAT
;
482 TRACE("returning %lu\n", retval
);
484 psei_out
->hInstApp
= (HINSTANCE
)retval
;
487 if( !SetCurrentDirectoryW( curdir
))
488 ERR("cannot return to directory %s\n", debugstr_w(curdir
));
494 /***********************************************************************
495 * SHELL_BuildEnvW [Internal]
497 * Build the environment for the new process, adding the specified
498 * path to the PATH variable. Returned pointer must be freed by caller.
500 static LPWSTR
SHELL_BuildEnvW( const WCHAR
*path
)
502 static const WCHAR wPath
[] = {'P','A','T','H','=',0};
503 WCHAR
*strings
, *new_env
;
505 int total
= wcslen(path
) + 1;
506 BOOL got_path
= FALSE
;
508 if (!(strings
= GetEnvironmentStringsW())) return NULL
;
512 int len
= wcslen(p
) + 1;
513 if (!_wcsnicmp( p
, wPath
, 5 )) got_path
= TRUE
;
517 if (!got_path
) total
+= 5; /* we need to create PATH */
518 total
++; /* terminating null */
520 if (!(new_env
= (LPWSTR
)HeapAlloc( GetProcessHeap(), 0, total
* sizeof(WCHAR
) )))
522 FreeEnvironmentStringsW( strings
);
529 int len
= wcslen(p
) + 1;
530 memcpy( p2
, p
, len
* sizeof(WCHAR
) );
531 if (!_wcsnicmp( p
, wPath
, 5 ))
534 wcscpy( p2
+ len
, path
);
535 p2
+= wcslen(path
) + 1;
544 p2
+= wcslen(p2
) + 1;
547 FreeEnvironmentStringsW( strings
);
552 /***********************************************************************
553 * SHELL_TryAppPathW [Internal]
555 * Helper function for SHELL_FindExecutable
556 * @param lpResult - pointer to a buffer of size MAX_PATH
557 * On entry: szName is a filename (probably without path separators).
558 * On exit: if szName found in "App Path", place full path in lpResult, and return true
560 static BOOL
SHELL_TryAppPathW( LPCWSTR szName
, LPWSTR lpResult
, WCHAR
**env
)
562 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',
563 '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p',' ','P','a','t','h','s','\\',0};
564 static const WCHAR wPath
[] = {'P','a','t','h',0};
571 if (env
) *env
= NULL
;
572 wcscpy(buffer
, wszKeyAppPaths
);
573 wcscat(buffer
, szName
);
574 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, buffer
, 0, KEY_READ
, &hkApp
);
577 len
= MAX_PATH
*sizeof(WCHAR
);
578 res
= RegQueryValueW(hkApp
, NULL
, lpResult
, &len
);
584 DWORD count
= sizeof(buffer
);
585 if (!RegQueryValueExW(hkApp
, wPath
, NULL
, NULL
, (LPBYTE
)buffer
, &count
) && buffer
[0])
586 *env
= SHELL_BuildEnvW( buffer
);
590 if (hkApp
) RegCloseKey(hkApp
);
594 static UINT
SHELL_FindExecutableByOperation(LPCWSTR lpOperation
, LPWSTR key
, LPWSTR filetype
, LPWSTR command
, LONG commandlen
)
596 static const WCHAR wCommand
[] = {'\\','c','o','m','m','a','n','d',0};
598 WCHAR verb
[MAX_PATH
];
600 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, filetype
, 0, 0x02000000, &hkeyClass
))
601 return SE_ERR_NOASSOC
;
602 if (!HCR_GetDefaultVerbW(hkeyClass
, lpOperation
, verb
, sizeof(verb
)/sizeof(verb
[0])))
603 return SE_ERR_NOASSOC
;
604 RegCloseKey(hkeyClass
);
606 /* Looking for ...buffer\shell\<verb>\command */
607 wcscat(filetype
, wszShell
);
608 wcscat(filetype
, verb
);
609 wcscat(filetype
, wCommand
);
611 if (RegQueryValueW(HKEY_CLASSES_ROOT
, filetype
, command
,
612 &commandlen
) == ERROR_SUCCESS
)
614 commandlen
/= sizeof(WCHAR
);
615 if (key
) wcscpy(key
, filetype
);
619 LONG paramlen
= sizeof(param
);
620 static const WCHAR wSpace
[] = {' ',0};
622 /* FIXME: it seems all Windows version don't behave the same here.
623 * the doc states that this ddeexec information can be found after
625 * on Win98, it doesn't appear, but I think it does on Win2k
627 /* Get the parameters needed by the application
628 from the associated ddeexec key */
629 tmp
= strstrW(filetype
, wCommand
);
631 wcscat(filetype
, wDdeexec
);
632 if (RegQueryValueW(HKEY_CLASSES_ROOT
, filetype
, param
,
633 ¶mlen
) == ERROR_SUCCESS
)
635 paramlen
/= sizeof(WCHAR
);
636 wcscat(command
, wSpace
);
637 wcscat(command
, param
);
638 commandlen
+= paramlen
;
642 command
[commandlen
] = '\0';
644 return 33; /* FIXME see SHELL_FindExecutable() */
647 return SE_ERR_NOASSOC
;
650 /*************************************************************************
651 * SHELL_FindExecutable [Internal]
653 * Utility for code sharing between FindExecutable and ShellExecute
655 * lpFile the name of a file
656 * lpOperation the operation on it (open)
658 * lpResult a buffer, big enough :-(, to store the command to do the
659 * operation on the file
660 * key a buffer, big enough, to get the key name to do actually the
661 * command (it'll be used afterwards for more information
664 static UINT
SHELL_FindExecutable(LPCWSTR lpPath
, LPCWSTR lpFile
, LPCWSTR lpOperation
,
665 LPWSTR lpResult
, DWORD resultLen
, LPWSTR key
, WCHAR
**env
,LPITEMIDLIST pidl
, LPCWSTR args
)
667 static const WCHAR wWindows
[] = {'w','i','n','d','o','w','s',0};
668 static const WCHAR wPrograms
[] = {'p','r','o','g','r','a','m','s',0};
669 static const WCHAR wExtensions
[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
670 WCHAR
*extension
= NULL
; /* pointer to file extension */
671 WCHAR filetype
[256]; /* registry name for this filetype */
672 LONG filetypelen
= sizeof(filetype
); /* length of above */
673 WCHAR command
[1024]; /* command from registry */
674 WCHAR wBuffer
[256]; /* Used to GetProfileString */
675 UINT retval
= SE_ERR_NOASSOC
;
676 WCHAR
*tok
; /* token pointer */
677 WCHAR xlpFile
[256]; /* result of SearchPath */
678 DWORD attribs
; /* file attributes */
680 TRACE("%s\n", debugstr_w(lpFile
));
683 return ERROR_INVALID_PARAMETER
;
686 lpResult
[0] = '\0'; /* Start off with an empty return string */
687 if (key
) *key
= '\0';
689 /* trap NULL parameters on entry */
692 WARN("(lpFile=%s,lpResult=%s): NULL parameter\n",
693 debugstr_w(lpFile
), debugstr_w(lpResult
));
694 return ERROR_FILE_NOT_FOUND
; /* File not found. Close enough, I guess. */
697 if (SHELL_TryAppPathW( lpFile
, lpResult
, env
))
699 TRACE("found %s via App Paths\n", debugstr_w(lpResult
));
703 if (SearchPathW(lpPath
, lpFile
, wszExe
, sizeof(xlpFile
)/sizeof(WCHAR
), xlpFile
, NULL
))
705 TRACE("SearchPathW returned non-zero\n");
707 /* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
710 attribs
= GetFileAttributesW(lpFile
);
711 if (attribs
!=INVALID_FILE_ATTRIBUTES
&& (attribs
&FILE_ATTRIBUTE_DIRECTORY
))
713 wcscpy(filetype
, wszFolder
);
714 filetypelen
= 6; /* strlen("Folder") */
718 /* Did we get something? Anything? */
721 TRACE("Returning SE_ERR_FNF\n");
724 /* First thing we need is the file's extension */
725 extension
= wcsrchr(xlpFile
, '.'); /* Assume last "." is the one; */
726 /* File->Run in progman uses */
728 TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile
), debugstr_w(extension
));
730 if (extension
== NULL
|| extension
[1]==0)
732 WARN("Returning SE_ERR_NOASSOC\n");
733 return SE_ERR_NOASSOC
;
736 /* Three places to check: */
737 /* 1. win.ini, [windows], programs (NB no leading '.') */
738 /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
739 /* 3. win.ini, [extensions], extension (NB no leading '.' */
740 /* All I know of the order is that registry is checked before */
741 /* extensions; however, it'd make sense to check the programs */
742 /* section first, so that's what happens here. */
744 /* See if it's a program - if GetProfileString fails, we skip this
745 * section. Actually, if GetProfileString fails, we've probably
746 * got a lot more to worry about than running a program... */
747 if (GetProfileStringW(wWindows
, wPrograms
, wExtensions
, wBuffer
, sizeof(wBuffer
)/sizeof(WCHAR
)) > 0)
754 while (*p
&& *p
!= ' ' && *p
!= '\t') p
++;
758 while (*p
== ' ' || *p
== '\t') p
++;
761 if (wcsicmp(tok
, &extension
[1]) == 0) /* have to skip the leading "." */
763 wcscpy(lpResult
, xlpFile
);
764 /* Need to perhaps check that the file has a path
766 TRACE("found %s\n", debugstr_w(lpResult
));
768 /* Greater than 32 to indicate success */
775 if (RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, filetype
,
776 &filetypelen
) == ERROR_SUCCESS
)
778 filetypelen
/= sizeof(WCHAR
);
779 if (filetypelen
== sizeof(filetype
)/sizeof(WCHAR
))
782 filetype
[filetypelen
] = '\0';
783 TRACE("File type: %s\n", debugstr_w(filetype
));
794 /* pass the operation string to SHELL_FindExecutableByOperation() */
795 filetype
[filetypelen
] = '\0';
796 retval
= SHELL_FindExecutableByOperation(lpOperation
, key
, filetype
, command
, sizeof(command
));
801 SHELL_ArgifyW(lpResult
, resultLen
, command
, xlpFile
, pidl
, args
, &finishedLen
);
802 if (finishedLen
> resultLen
)
803 ERR("Argify buffer not large enough.. truncated\n");
804 /* Remove double quotation marks and command line arguments */
805 if (*lpResult
== '"')
808 while (*(p
+ 1) != '"')
817 /* Truncate on first space */
819 while (*p
!= ' ' && *p
!= '\0')
825 else /* Check win.ini */
827 static const WCHAR wExtensions
[] = {'e','x','t','e','n','s','i','o','n','s',0};
829 /* Toss the leading dot */
831 if (GetProfileStringW(wExtensions
, extension
, wszEmpty
, command
, sizeof(command
)/sizeof(WCHAR
)) > 0)
833 if (wcslen(command
) != 0)
835 wcscpy(lpResult
, command
);
836 tok
= wcschr(lpResult
, '^'); /* should be ^.extension? */
840 wcscat(lpResult
, xlpFile
); /* what if no dir in xlpFile? */
841 tok
= wcschr(command
, '^'); /* see above */
842 if ((tok
!= NULL
) && (wcslen(tok
)>5))
844 wcscat(lpResult
, &tok
[5]);
847 retval
= 33; /* FIXME - see above */
852 TRACE("returning %s\n", debugstr_w(lpResult
));
856 /******************************************************************
859 * callback for the DDE connection. not really useful
861 static HDDEDATA CALLBACK
dde_cb(UINT uType
, UINT uFmt
, HCONV hConv
,
862 HSZ hsz1
, HSZ hsz2
, HDDEDATA hData
,
863 ULONG_PTR dwData1
, ULONG_PTR dwData2
)
865 TRACE("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n",
866 uType
, uFmt
, hConv
, hsz1
, hsz2
, hData
, dwData1
, dwData2
);
870 /******************************************************************
873 * ShellExecute helper. Used to do an operation with a DDE connection
875 * Handles both the direct connection (try #1), and if it fails,
876 * launching an application and trying (#2) to connect to it
879 static unsigned dde_connect(const WCHAR
* key
, const WCHAR
* start
, WCHAR
* ddeexec
,
880 const WCHAR
* lpFile
, WCHAR
*env
,
881 LPCWSTR szCommandline
, LPITEMIDLIST pidl
, SHELL_ExecuteW32 execfunc
,
882 const SHELLEXECUTEINFOW
*psei
, LPSHELLEXECUTEINFOW psei_out
)
884 static const WCHAR wApplication
[] = {'\\','a','p','p','l','i','c','a','t','i','o','n',0};
885 static const WCHAR wTopic
[] = {'\\','t','o','p','i','c',0};
887 WCHAR
* endkey
= regkey
+ wcslen(key
);
888 WCHAR app
[256], topic
[256], ifexec
[256], res
[256];
889 LONG applen
, topiclen
, ifexeclen
;
894 HSZ hszApp
, hszTopic
;
897 unsigned ret
= SE_ERR_NOASSOC
;
898 BOOL unicode
= !(GetVersion() & 0x80000000);
901 wcscpy(endkey
, wApplication
);
902 applen
= sizeof(app
);
903 if (RegQueryValueW(HKEY_CLASSES_ROOT
, regkey
, app
, &applen
) != ERROR_SUCCESS
)
905 WCHAR command
[1024], fullpath
[MAX_PATH
];
906 static const WCHAR wSo
[] = { '.','s','o',0 };
907 DWORD sizeSo
= sizeof(wSo
)/sizeof(WCHAR
);
911 /* Get application command from start string and find filename of application */
914 wcscpy(command
, start
+1);
915 if ((ptr
= wcschr(command
, '"')))
917 ret
= SearchPathW(NULL
, command
, wszExe
, sizeof(fullpath
)/sizeof(WCHAR
), fullpath
, &ptr
);
922 for (p
=(LPWSTR
)start
; (space
= const_cast<LPWSTR
>(strchrW(p
, ' '))); p
=space
+1)
924 int idx
= space
-start
;
925 memcpy(command
, start
, idx
*sizeof(WCHAR
));
927 if ((ret
= SearchPathW(NULL
, command
, wszExe
, sizeof(fullpath
)/sizeof(WCHAR
), fullpath
, &ptr
)))
931 ret
= SearchPathW(NULL
, start
, wszExe
, sizeof(fullpath
)/sizeof(WCHAR
), fullpath
, &ptr
);
936 ERR("Unable to find application path for command %s\n", debugstr_w(start
));
937 return ERROR_ACCESS_DENIED
;
941 /* Remove extensions (including .so) */
942 ptr
= app
+ wcslen(app
) - (sizeSo
-1);
943 if (wcslen(app
) >= sizeSo
&&
947 ptr
= const_cast<LPWSTR
>(strrchrW(app
, '.'));
952 wcscpy(endkey
, wTopic
);
953 topiclen
= sizeof(topic
);
954 if (RegQueryValueW(HKEY_CLASSES_ROOT
, regkey
, topic
, &topiclen
) != ERROR_SUCCESS
)
956 static const WCHAR wSystem
[] = {'S','y','s','t','e','m',0};
957 wcscpy(topic
, wSystem
);
962 if (DdeInitializeW(&ddeInst
, dde_cb
, APPCMD_CLIENTONLY
, 0L) != DMLERR_NO_ERROR
)
967 if (DdeInitializeA(&ddeInst
, dde_cb
, APPCMD_CLIENTONLY
, 0L) != DMLERR_NO_ERROR
)
971 hszApp
= DdeCreateStringHandleW(ddeInst
, app
, CP_WINUNICODE
);
972 hszTopic
= DdeCreateStringHandleW(ddeInst
, topic
, CP_WINUNICODE
);
974 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
978 static const WCHAR wIfexec
[] = {'\\','i','f','e','x','e','c',0};
979 TRACE("Launching %s\n", debugstr_w(start
));
980 ret
= execfunc(start
, env
, TRUE
, psei
, psei_out
);
983 TRACE("Couldn't launch\n");
986 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
989 TRACE("Couldn't connect. ret=%d\n", ret
);
990 DdeUninitialize(ddeInst
);
991 SetLastError(ERROR_DDE_FAIL
);
992 return 30; /* whatever */
994 strcpyW(endkey
, wIfexec
);
995 ifexeclen
= sizeof(ifexec
);
996 if (RegQueryValueW(HKEY_CLASSES_ROOT
, regkey
, ifexec
, &ifexeclen
) == ERROR_SUCCESS
)
1002 SHELL_ArgifyW(res
, sizeof(res
)/sizeof(WCHAR
), exec
, lpFile
, pidl
, szCommandline
, &resultLen
);
1003 if (resultLen
> sizeof(res
)/sizeof(WCHAR
))
1004 ERR("Argify buffer not large enough, truncated\n");
1005 TRACE("%s %s => %s\n", debugstr_w(exec
), debugstr_w(lpFile
), debugstr_w(res
));
1007 /* It's documented in the KB 330337 that IE has a bug and returns
1008 * error DMLERR_NOTPROCESSED on XTYP_EXECUTE request.
1011 hDdeData
= DdeClientTransaction((LPBYTE
)res
, (strlenW(res
) + 1) * sizeof(WCHAR
), hConv
, 0L, 0, XTYP_EXECUTE
, 30000, &tid
);
1014 DWORD lenA
= WideCharToMultiByte(CP_ACP
, 0, res
, -1, NULL
, 0, NULL
, NULL
);
1015 char *resA
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, lenA
);
1016 WideCharToMultiByte(CP_ACP
, 0, res
, -1, resA
, lenA
, NULL
, NULL
);
1017 hDdeData
= DdeClientTransaction( (LPBYTE
)resA
, lenA
, hConv
, 0L, 0,
1018 XTYP_EXECUTE
, 10000, &tid
);
1019 HeapFree(GetProcessHeap(), 0, resA
);
1022 DdeFreeDataHandle(hDdeData
);
1024 WARN("DdeClientTransaction failed with error %04x\n", DdeGetLastError(ddeInst
));
1027 DdeDisconnect(hConv
);
1030 DdeUninitialize(ddeInst
);
1035 /*************************************************************************
1036 * execute_from_key [Internal]
1038 static UINT_PTR
execute_from_key(LPCWSTR key
, LPCWSTR lpFile
, WCHAR
*env
,
1039 LPCWSTR szCommandline
, LPCWSTR executable_name
,
1040 SHELL_ExecuteW32 execfunc
,
1041 LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
)
1043 static const WCHAR wCommand
[] = {'c','o','m','m','a','n','d',0};
1044 static const WCHAR wDdeexec
[] = {'d','d','e','e','x','e','c',0};
1045 WCHAR cmd
[256], param
[1024], ddeexec
[256];
1046 DWORD cmdlen
= sizeof(cmd
), ddeexeclen
= sizeof(ddeexec
);
1047 UINT_PTR retval
= SE_ERR_NOASSOC
;
1051 TRACE("%s %s %s %s %s\n", debugstr_w(key
), debugstr_w(lpFile
), debugstr_w(env
),
1052 debugstr_w(szCommandline
), debugstr_w(executable_name
));
1057 /* Get the application from the registry */
1058 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, cmd
, (LONG
*)&cmdlen
) == ERROR_SUCCESS
)
1060 TRACE("got cmd: %s\n", debugstr_w(cmd
));
1062 /* Is there a replace() function anywhere? */
1063 cmdlen
/= sizeof(WCHAR
);
1064 if (cmdlen
>= sizeof(cmd
)/sizeof(WCHAR
))
1065 cmdlen
= sizeof(cmd
)/sizeof(WCHAR
)-1;
1067 SHELL_ArgifyW(param
, sizeof(param
)/sizeof(WCHAR
), cmd
, lpFile
, (LPITEMIDLIST
)psei
->lpIDList
, szCommandline
, &resultLen
);
1068 if (resultLen
> sizeof(param
)/sizeof(WCHAR
))
1069 ERR("Argify buffer not large enough, truncating\n");
1072 /* Get the parameters needed by the application
1073 from the associated ddeexec key */
1074 tmp
= const_cast<LPWSTR
>(strstrW(key
, wCommand
));
1076 wcscpy(tmp
, wDdeexec
);
1078 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, ddeexec
, (LONG
*)&ddeexeclen
) == ERROR_SUCCESS
)
1080 TRACE("Got ddeexec %s => %s\n", debugstr_w(key
), debugstr_w(ddeexec
));
1081 if (!param
[0]) strcpyW(param
, executable_name
);
1082 retval
= dde_connect(key
, param
, ddeexec
, lpFile
, env
, szCommandline
, (LPITEMIDLIST
)psei
->lpIDList
, execfunc
, psei
, psei_out
);
1086 TRACE("executing: %s\n", debugstr_w(param
));
1087 retval
= execfunc(param
, env
, FALSE
, psei
, psei_out
);
1090 WARN("Nothing appropriate found for %s\n", debugstr_w(key
));
1095 /*************************************************************************
1096 * FindExecutableA [SHELL32.@]
1098 HINSTANCE WINAPI
FindExecutableA(LPCSTR lpFile
, LPCSTR lpDirectory
, LPSTR lpResult
)
1101 WCHAR
*wFile
= NULL
, *wDirectory
= NULL
;
1102 WCHAR wResult
[MAX_PATH
];
1104 if (lpFile
) __SHCloneStrAtoW(&wFile
, lpFile
);
1105 if (lpDirectory
) __SHCloneStrAtoW(&wDirectory
, lpDirectory
);
1107 retval
= FindExecutableW(wFile
, wDirectory
, wResult
);
1108 WideCharToMultiByte(CP_ACP
, 0, wResult
, -1, lpResult
, MAX_PATH
, NULL
, NULL
);
1110 SHFree( wDirectory
);
1112 TRACE("returning %s\n", lpResult
);
1116 /*************************************************************************
1117 * FindExecutableW [SHELL32.@]
1119 * This function returns the executable associated with the specified file
1120 * for the default verb.
1123 * lpFile [I] The file to find the association for. This must refer to
1124 * an existing file otherwise FindExecutable fails and returns
1126 * lpResult [O] Points to a buffer into which the executable path is
1127 * copied. This parameter must not be NULL otherwise
1128 * FindExecutable() segfaults. The buffer must be of size at
1129 * least MAX_PATH characters.
1132 * A value greater than 32 on success, less than or equal to 32 otherwise.
1133 * See the SE_ERR_* constants.
1136 * On Windows XP and 2003, FindExecutable() seems to first convert the
1137 * filename into 8.3 format, thus taking into account only the first three
1138 * characters of the extension, and expects to find an association for those.
1139 * However other Windows versions behave sanely.
1141 HINSTANCE WINAPI
FindExecutableW(LPCWSTR lpFile
, LPCWSTR lpDirectory
, LPWSTR lpResult
)
1143 UINT_PTR retval
= SE_ERR_NOASSOC
;
1144 WCHAR old_dir
[1024];
1146 TRACE("File %s, Dir %s\n", debugstr_w(lpFile
), debugstr_w(lpDirectory
));
1148 lpResult
[0] = '\0'; /* Start off with an empty return string */
1150 return (HINSTANCE
)SE_ERR_FNF
;
1154 GetCurrentDirectoryW(sizeof(old_dir
)/sizeof(WCHAR
), old_dir
);
1155 SetCurrentDirectoryW(lpDirectory
);
1158 retval
= SHELL_FindExecutable(lpDirectory
, lpFile
, wszOpen
, lpResult
, MAX_PATH
, NULL
, NULL
, NULL
, NULL
);
1160 TRACE("returning %s\n", debugstr_w(lpResult
));
1162 SetCurrentDirectoryW(old_dir
);
1163 return (HINSTANCE
)retval
;
1166 /* FIXME: is this already implemented somewhere else? */
1167 static HKEY
ShellExecute_GetClassKey( const SHELLEXECUTEINFOW
*sei
)
1169 LPCWSTR ext
= NULL
, lpClass
= NULL
;
1171 DWORD type
= 0, sz
= 0;
1175 if (sei
->fMask
& SEE_MASK_CLASSALL
)
1176 return sei
->hkeyClass
;
1178 if (sei
->fMask
& SEE_MASK_CLASSNAME
)
1179 lpClass
= sei
->lpClass
;
1182 ext
= PathFindExtensionW( sei
->lpFile
);
1183 TRACE("ext = %s\n", debugstr_w( ext
) );
1187 r
= RegOpenKeyW( HKEY_CLASSES_ROOT
, ext
, &hkey
);
1188 if (r
!= ERROR_SUCCESS
)
1191 r
= RegQueryValueExW( hkey
, NULL
, 0, &type
, NULL
, &sz
);
1192 if ( r
== ERROR_SUCCESS
&& type
== REG_SZ
)
1194 sz
+= sizeof (WCHAR
);
1195 cls
= (LPWSTR
)HeapAlloc( GetProcessHeap(), 0, sz
);
1197 RegQueryValueExW( hkey
, NULL
, 0, &type
, (LPBYTE
) cls
, &sz
);
1200 RegCloseKey( hkey
);
1204 TRACE("class = %s\n", debugstr_w(lpClass
) );
1208 RegOpenKeyW( HKEY_CLASSES_ROOT
, lpClass
, &hkey
);
1210 HeapFree( GetProcessHeap(), 0, cls
);
1215 static IDataObject
*shellex_get_dataobj( LPSHELLEXECUTEINFOW sei
)
1217 LPCITEMIDLIST pidllast
= NULL
;
1218 IDataObject
*dataobj
= NULL
;
1219 IShellFolder
*shf
= NULL
;
1220 LPITEMIDLIST pidl
= NULL
;
1223 if (sei
->fMask
& SEE_MASK_CLASSALL
)
1224 pidl
= (LPITEMIDLIST
)sei
->lpIDList
;
1227 WCHAR fullpath
[MAX_PATH
];
1231 ret
= GetFullPathNameW( sei
->lpFile
, MAX_PATH
, fullpath
, NULL
);
1235 pidl
= ILCreateFromPathW( fullpath
);
1238 r
= SHBindToParent( pidl
, IID_IShellFolder
, (LPVOID
*)&shf
, &pidllast
);
1242 shf
->GetUIObjectOf(NULL
, 1, &pidllast
,
1243 IID_IDataObject
, NULL
, (LPVOID
*) &dataobj
);
1246 if ( pidl
!= sei
->lpIDList
)
1253 static HRESULT
shellex_run_context_menu_default( IShellExtInit
*obj
,
1254 LPSHELLEXECUTEINFOW sei
)
1256 IContextMenu
*cm
= NULL
;
1257 CMINVOKECOMMANDINFOEX ici
;
1264 TRACE("%p %p\n", obj
, sei
);
1266 r
= obj
->QueryInterface(IID_IContextMenu
, (LPVOID
*) &cm
);
1270 hmenu
= CreateMenu();
1274 /* the number of the last menu added is returned in r */
1275 r
= cm
->QueryContextMenu(hmenu
, 0, 0x20, 0x7fff, CMF_DEFAULTONLY
);
1279 n
= GetMenuItemCount( hmenu
);
1280 for ( i
= 0; i
< n
; i
++ )
1282 memset( &info
, 0, sizeof info
);
1283 info
.cbSize
= sizeof info
;
1284 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_DATA
| MIIM_ID
;
1285 info
.dwTypeData
= string
;
1286 info
.cch
= sizeof string
;
1288 GetMenuItemInfoW( hmenu
, i
, TRUE
, &info
);
1290 TRACE("menu %d %s %08x %08lx %08x %08x\n", i
, debugstr_w(string
),
1291 info
.fState
, info
.dwItemData
, info
.fType
, info
.wID
);
1292 if ( ( !sei
->lpVerb
&& (info
.fState
& MFS_DEFAULT
) ) ||
1293 ( sei
->lpVerb
&& !lstrcmpiW( sei
->lpVerb
, string
) ) )
1304 memset( &ici
, 0, sizeof ici
);
1305 ici
.cbSize
= sizeof ici
;
1306 ici
.fMask
= CMIC_MASK_UNICODE
| (sei
->fMask
& (SEE_MASK_NOASYNC
|SEE_MASK_ASYNCOK
|SEE_MASK_FLAG_NO_UI
));
1307 ici
.nShow
= sei
->nShow
;
1308 ici
.lpVerb
= MAKEINTRESOURCEA( def
);
1309 ici
.hwnd
= sei
->hwnd
;
1310 ici
.lpParametersW
= sei
->lpParameters
;
1312 r
= cm
->InvokeCommand((LPCMINVOKECOMMANDINFO
) &ici
);
1314 TRACE("invoke command returned %08x\n", r
);
1318 DestroyMenu( hmenu
);
1324 static HRESULT
shellex_load_object_and_run( HKEY hkey
, LPCGUID guid
, LPSHELLEXECUTEINFOW sei
)
1326 IDataObject
*dataobj
= NULL
;
1327 IObjectWithSite
*ows
= NULL
;
1328 IShellExtInit
*obj
= NULL
;
1331 TRACE("%p %s %p\n", hkey
, debugstr_guid( guid
), sei
);
1333 r
= CoInitialize( NULL
);
1337 r
= CoCreateInstance(*guid
, NULL
, CLSCTX_INPROC_SERVER
,
1338 IID_IShellExtInit
, (LPVOID
*)&obj
);
1341 ERR("failed %08x\n", r
);
1345 dataobj
= shellex_get_dataobj( sei
);
1348 ERR("failed to get data object\n");
1352 r
= obj
->Initialize(NULL
, dataobj
, hkey
);
1356 r
= obj
->QueryInterface(IID_IObjectWithSite
, (LPVOID
*) &ows
);
1360 ows
->SetSite(NULL
);
1362 r
= shellex_run_context_menu_default( obj
, sei
);
1376 /*************************************************************************
1377 * ShellExecute_FromContextMenu [Internal]
1379 static LONG
ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei
)
1381 static const WCHAR szcm
[] = { 's','h','e','l','l','e','x','\\',
1382 'C','o','n','t','e','x','t','M','e','n','u','H','a','n','d','l','e','r','s',0 };
1383 HKEY hkey
, hkeycm
= 0;
1390 TRACE("%s\n", debugstr_w(sei
->lpFile
) );
1392 hkey
= ShellExecute_GetClassKey( sei
);
1394 return ERROR_FUNCTION_FAILED
;
1396 r
= RegOpenKeyW( hkey
, szcm
, &hkeycm
);
1397 if ( r
== ERROR_SUCCESS
)
1402 r
= RegEnumKeyW( hkeycm
, i
++, szguid
, sizeof(szguid
)/sizeof(szguid
[0]) );
1403 if ( r
!= ERROR_SUCCESS
)
1406 hr
= CLSIDFromString( szguid
, &guid
);
1409 /* stop at the first one that succeeds in running */
1410 hr
= shellex_load_object_and_run( hkey
, &guid
, sei
);
1411 if ( SUCCEEDED( hr
) )
1415 RegCloseKey( hkeycm
);
1418 if ( hkey
!= sei
->hkeyClass
)
1419 RegCloseKey( hkey
);
1423 static UINT_PTR
SHELL_execute_class( LPCWSTR wszApplicationName
, LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
, SHELL_ExecuteW32 execfunc
)
1425 static const WCHAR wSpace
[] = {' ',0};
1426 WCHAR execCmd
[1024], wcmd
[1024];
1427 /* launch a document by fileclass like 'WordPad.Document.1' */
1428 /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
1429 /* FIXME: wcmd should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */
1430 ULONG cmask
=(psei
->fMask
& SEE_MASK_CLASSALL
);
1434 HCR_GetExecuteCommandW((cmask
== SEE_MASK_CLASSKEY
) ? psei
->hkeyClass
: NULL
,
1435 (cmask
== SEE_MASK_CLASSNAME
) ? psei
->lpClass
: NULL
,
1437 execCmd
, sizeof(execCmd
));
1439 /* FIXME: get the extension of lpFile, check if it fits to the lpClass */
1440 TRACE("SEE_MASK_CLASSNAME->%s, doc->%s\n", debugstr_w(execCmd
), debugstr_w(wszApplicationName
));
1443 done
= SHELL_ArgifyW(wcmd
, sizeof(wcmd
)/sizeof(WCHAR
), execCmd
, wszApplicationName
, (LPITEMIDLIST
)psei
->lpIDList
, NULL
, &resultLen
);
1444 if (!done
&& wszApplicationName
[0])
1446 strcatW(wcmd
, wSpace
);
1447 strcatW(wcmd
, wszApplicationName
);
1449 if (resultLen
> sizeof(wcmd
)/sizeof(WCHAR
))
1450 ERR("Argify buffer not large enough... truncating\n");
1451 return execfunc(wcmd
, NULL
, FALSE
, psei
, psei_out
);
1454 static BOOL
SHELL_translate_idlist( LPSHELLEXECUTEINFOW sei
, LPWSTR wszParameters
, DWORD parametersLen
, LPWSTR wszApplicationName
, DWORD dwApplicationNameLen
)
1456 static const WCHAR wExplorer
[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0};
1457 WCHAR buffer
[MAX_PATH
];
1458 BOOL appKnownSingular
= FALSE
;
1460 /* last chance to translate IDList: now also allow CLSID paths */
1461 if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW((LPCITEMIDLIST
)sei
->lpIDList
, buffer
, sizeof(buffer
)))) {
1462 if (buffer
[0]==':' && buffer
[1]==':') {
1463 /* open shell folder for the specified class GUID */
1464 if (strlenW(buffer
) + 1 > parametersLen
)
1465 ERR("parameters len exceeds buffer size (%i > %i), truncating\n",
1466 lstrlenW(buffer
) + 1, parametersLen
);
1467 lstrcpynW(wszParameters
, buffer
, parametersLen
);
1468 if (strlenW(wExplorer
) > dwApplicationNameLen
)
1469 ERR("application len exceeds buffer size (%i > %i), truncating\n",
1470 lstrlenW(wExplorer
) + 1, dwApplicationNameLen
);
1471 lstrcpynW(wszApplicationName
, wExplorer
, dwApplicationNameLen
);
1472 appKnownSingular
= TRUE
;
1474 sei
->fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1476 WCHAR target
[MAX_PATH
];
1479 /* Check if we're executing a directory and if so use the
1480 handler for the Folder class */
1481 strcpyW(target
, buffer
);
1482 attribs
= GetFileAttributesW(buffer
);
1483 if (attribs
!= INVALID_FILE_ATTRIBUTES
&&
1484 (attribs
& FILE_ATTRIBUTE_DIRECTORY
) &&
1485 HCR_GetExecuteCommandW(0, wszFolder
,
1487 buffer
, sizeof(buffer
))) {
1488 SHELL_ArgifyW(wszApplicationName
, dwApplicationNameLen
,
1489 buffer
, target
, (LPITEMIDLIST
)sei
->lpIDList
, NULL
, &resultLen
);
1490 if (resultLen
> dwApplicationNameLen
)
1491 ERR("Argify buffer not large enough... truncating\n");
1492 appKnownSingular
= FALSE
;
1494 sei
->fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1497 return appKnownSingular
;
1500 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
)
1502 static const WCHAR wQuote
[] = {'"',0};
1503 static const WCHAR wSpace
[] = {' ',0};
1506 WCHAR
*wszQuotedCmd
;
1508 /* Length of quotes plus length of command plus NULL terminator */
1509 len
= 2 + lstrlenW(wcmd
) + 1;
1510 if (wszParameters
[0])
1512 /* Length of space plus length of parameters */
1513 len
+= 1 + lstrlenW(wszParameters
);
1515 wszQuotedCmd
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1516 /* Must quote to handle case where cmd contains spaces,
1517 * else security hole if malicious user creates executable file "C:\\Program"
1519 strcpyW(wszQuotedCmd
, wQuote
);
1520 strcatW(wszQuotedCmd
, wcmd
);
1521 strcatW(wszQuotedCmd
, wQuote
);
1522 if (wszParameters
[0])
1524 strcatW(wszQuotedCmd
, wSpace
);
1525 strcatW(wszQuotedCmd
, wszParameters
);
1528 TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName
), debugstr_w(psei
->lpVerb
), debugstr_w(wszQuotedCmd
), debugstr_w(lpstrProtocol
));
1531 retval
= execute_from_key(lpstrProtocol
, wszApplicationName
, env
, psei
->lpParameters
, wcmd
, execfunc
, psei
, psei_out
);
1533 retval
= execfunc(wszQuotedCmd
, env
, FALSE
, psei
, psei_out
);
1534 HeapFree(GetProcessHeap(), 0, wszQuotedCmd
);
1538 static UINT_PTR
SHELL_execute_url( LPCWSTR lpFile
, LPCWSTR wFile
, LPCWSTR wcmd
, LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
, SHELL_ExecuteW32 execfunc
)
1540 static const WCHAR wShell
[] = {'\\','s','h','e','l','l','\\',0};
1541 static const WCHAR wCommand
[] = {'\\','c','o','m','m','a','n','d',0};
1543 WCHAR
*lpstrProtocol
;
1548 lpstrRes
= strchrW(lpFile
, ':');
1550 iSize
= lpstrRes
- lpFile
;
1552 iSize
= strlenW(lpFile
);
1554 TRACE("Got URL: %s\n", debugstr_w(lpFile
));
1555 /* Looking for ...protocol\shell\lpOperation\command */
1556 len
= iSize
+ lstrlenW(wShell
) + lstrlenW(wCommand
) + 1;
1558 len
+= lstrlenW(psei
->lpVerb
);
1560 len
+= lstrlenW(wszOpen
);
1561 lpstrProtocol
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1562 memcpy(lpstrProtocol
, lpFile
, iSize
*sizeof(WCHAR
));
1563 lpstrProtocol
[iSize
] = '\0';
1564 strcatW(lpstrProtocol
, wShell
);
1565 strcatW(lpstrProtocol
, psei
->lpVerb
? psei
->lpVerb
: wszOpen
);
1566 strcatW(lpstrProtocol
, wCommand
);
1568 /* Remove File Protocol from lpFile */
1569 /* In the case file://path/file */
1570 if (!strncmpiW(lpFile
, wFile
, iSize
))
1573 while (*lpFile
== ':') lpFile
++;
1575 retval
= execute_from_key(lpstrProtocol
, lpFile
, NULL
, psei
->lpParameters
,
1576 wcmd
, execfunc
, psei
, psei_out
);
1577 HeapFree(GetProcessHeap(), 0, lpstrProtocol
);
1581 void do_error_dialog( UINT_PTR retval
, HWND hwnd
, WCHAR
* filename
)
1584 DWORD_PTR msgArguments
[3] = { (DWORD_PTR
)filename
, 0, 0 };
1587 error_code
= GetLastError();
1589 if (retval
== SE_ERR_NOASSOC
)
1590 LoadStringW(shell32_hInstance
, IDS_SHLEXEC_NOASSOC
, msg
, sizeof(msg
)/sizeof(WCHAR
));
1592 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ARGUMENT_ARRAY
,
1597 sizeof(msg
)/sizeof(WCHAR
),
1598 (va_list*)msgArguments
);
1600 MessageBoxW(hwnd
, msg
, NULL
, MB_ICONERROR
);
1603 /*************************************************************************
1604 * SHELL_execute [Internal]
1606 BOOL
SHELL_execute( LPSHELLEXECUTEINFOW sei
, SHELL_ExecuteW32 execfunc
)
1608 static const WCHAR wSpace
[] = {' ',0};
1609 static const WCHAR wWww
[] = {'w','w','w',0};
1610 static const WCHAR wFile
[] = {'f','i','l','e',0};
1611 static const WCHAR wHttp
[] = {'h','t','t','p',':','/','/',0};
1612 static const DWORD unsupportedFlags
=
1613 SEE_MASK_INVOKEIDLIST
| SEE_MASK_ICON
| SEE_MASK_HOTKEY
|
1614 SEE_MASK_CONNECTNETDRV
| SEE_MASK_FLAG_DDEWAIT
|
1615 SEE_MASK_UNICODE
| SEE_MASK_ASYNCOK
| SEE_MASK_HMONITOR
;
1617 WCHAR parametersBuffer
[1024], dirBuffer
[MAX_PATH
], wcmdBuffer
[1024];
1618 WCHAR
*wszApplicationName
, *wszParameters
, *wszDir
, *wcmd
;
1619 DWORD dwApplicationNameLen
= MAX_PATH
+2;
1620 DWORD parametersLen
= sizeof(parametersBuffer
) / sizeof(WCHAR
);
1621 DWORD dirLen
= sizeof(dirBuffer
) / sizeof(WCHAR
);
1622 DWORD wcmdLen
= sizeof(wcmdBuffer
) / sizeof(WCHAR
);
1624 SHELLEXECUTEINFOW sei_tmp
; /* modifiable copy of SHELLEXECUTEINFO struct */
1625 WCHAR wfileName
[MAX_PATH
];
1627 WCHAR lpstrProtocol
[256];
1629 UINT_PTR retval
= SE_ERR_NOASSOC
;
1630 BOOL appKnownSingular
= FALSE
;
1632 /* make a local copy of the LPSHELLEXECUTEINFO structure and work with this from now on */
1635 TRACE("mask=0x%08x hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
1636 sei_tmp
.fMask
, sei_tmp
.hwnd
, debugstr_w(sei_tmp
.lpVerb
),
1637 debugstr_w(sei_tmp
.lpFile
), debugstr_w(sei_tmp
.lpParameters
),
1638 debugstr_w(sei_tmp
.lpDirectory
), sei_tmp
.nShow
,
1639 ((sei_tmp
.fMask
& SEE_MASK_CLASSALL
) == SEE_MASK_CLASSNAME
) ?
1640 debugstr_w(sei_tmp
.lpClass
) : "not used");
1642 sei
->hProcess
= NULL
;
1644 /* make copies of all path/command strings */
1645 if (!sei_tmp
.lpFile
)
1647 wszApplicationName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
*sizeof(WCHAR
));
1648 *wszApplicationName
= '\0';
1650 else if (*sei_tmp
.lpFile
== '\"')
1652 DWORD l
= strlenW(sei_tmp
.lpFile
+1);
1653 if(l
>= dwApplicationNameLen
)
1654 dwApplicationNameLen
= l
+1;
1656 wszApplicationName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
*sizeof(WCHAR
));
1657 memcpy(wszApplicationName
, sei_tmp
.lpFile
+1, (l
+1)*sizeof(WCHAR
));
1659 if (wszApplicationName
[l
-1] == '\"')
1660 wszApplicationName
[l
-1] = '\0';
1661 appKnownSingular
= TRUE
;
1663 TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName
));
1667 DWORD l
= strlenW(sei_tmp
.lpFile
)+1;
1668 if(l
> dwApplicationNameLen
) dwApplicationNameLen
= l
+1;
1669 wszApplicationName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
*sizeof(WCHAR
));
1670 memcpy(wszApplicationName
, sei_tmp
.lpFile
, l
*sizeof(WCHAR
));
1673 wszParameters
= parametersBuffer
;
1674 if (sei_tmp
.lpParameters
)
1676 len
= lstrlenW(sei_tmp
.lpParameters
) + 1;
1677 if (len
> parametersLen
)
1679 wszParameters
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1680 parametersLen
= len
;
1682 strcpyW(wszParameters
, sei_tmp
.lpParameters
);
1685 *wszParameters
= '\0';
1688 if (sei_tmp
.lpDirectory
)
1690 len
= lstrlenW(sei_tmp
.lpDirectory
) + 1;
1693 wszDir
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1696 strcpyW(wszDir
, sei_tmp
.lpDirectory
);
1701 /* adjust string pointers to point to the new buffers */
1702 sei_tmp
.lpFile
= wszApplicationName
;
1703 sei_tmp
.lpParameters
= wszParameters
;
1704 sei_tmp
.lpDirectory
= wszDir
;
1706 if (sei_tmp
.fMask
& unsupportedFlags
)
1708 FIXME("flags ignored: 0x%08x\n", sei_tmp
.fMask
& unsupportedFlags
);
1711 /* process the IDList */
1712 if (sei_tmp
.fMask
& SEE_MASK_IDLIST
)
1714 IShellExecuteHookW
* pSEH
;
1716 HRESULT hr
= SHBindToParent((LPCITEMIDLIST
)sei_tmp
.lpIDList
, IID_IShellExecuteHookW
, (LPVOID
*)&pSEH
, NULL
);
1720 hr
= pSEH
->Execute(&sei_tmp
);
1726 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1727 if (wszParameters
!= parametersBuffer
)
1728 HeapFree(GetProcessHeap(), 0, wszParameters
);
1729 if (wszDir
!= dirBuffer
)
1730 HeapFree(GetProcessHeap(), 0, wszDir
);
1735 SHGetPathFromIDListW((LPCITEMIDLIST
)sei_tmp
.lpIDList
, wszApplicationName
);
1736 appKnownSingular
= TRUE
;
1737 TRACE("-- idlist=%p (%s)\n", sei_tmp
.lpIDList
, debugstr_w(wszApplicationName
));
1740 if ( ERROR_SUCCESS
== ShellExecute_FromContextMenu( &sei_tmp
) )
1742 sei
->hInstApp
= (HINSTANCE
) 33;
1743 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1744 if (wszParameters
!= parametersBuffer
)
1745 HeapFree(GetProcessHeap(), 0, wszParameters
);
1746 if (wszDir
!= dirBuffer
)
1747 HeapFree(GetProcessHeap(), 0, wszDir
);
1751 if (sei_tmp
.fMask
& SEE_MASK_CLASSALL
)
1753 retval
= SHELL_execute_class( wszApplicationName
, &sei_tmp
, sei
,
1755 if (retval
<= 32 && !(sei_tmp
.fMask
& SEE_MASK_FLAG_NO_UI
))
1762 Info
.pcszFile
= wszApplicationName
;
1763 Info
.pcszClass
= NULL
;
1764 Info
.oaifInFlags
= OAIF_ALLOW_REGISTRATION
| OAIF_EXEC
;
1766 //if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK)
1767 do_error_dialog(retval
, sei_tmp
.hwnd
, wszApplicationName
);
1769 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1770 if (wszParameters
!= parametersBuffer
)
1771 HeapFree(GetProcessHeap(), 0, wszParameters
);
1772 if (wszDir
!= dirBuffer
)
1773 HeapFree(GetProcessHeap(), 0, wszDir
);
1777 /* Has the IDList not yet been translated? */
1778 if (sei_tmp
.fMask
& SEE_MASK_IDLIST
)
1780 appKnownSingular
= SHELL_translate_idlist( &sei_tmp
, wszParameters
,
1783 dwApplicationNameLen
);
1786 /* expand environment strings */
1787 len
= ExpandEnvironmentStringsW(sei_tmp
.lpFile
, NULL
, 0);
1791 buf
= (LPWSTR
)HeapAlloc(GetProcessHeap(),0,(len
+1)*sizeof(WCHAR
));
1793 ExpandEnvironmentStringsW(sei_tmp
.lpFile
, buf
, len
+1);
1794 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1795 dwApplicationNameLen
= len
+1;
1796 wszApplicationName
= buf
;
1797 /* appKnownSingular unmodified */
1799 sei_tmp
.lpFile
= wszApplicationName
;
1802 if (*sei_tmp
.lpParameters
)
1804 len
= ExpandEnvironmentStringsW(sei_tmp
.lpParameters
, NULL
, 0);
1809 buf
= (LPWSTR
)HeapAlloc(GetProcessHeap(),0,len
*sizeof(WCHAR
));
1810 ExpandEnvironmentStringsW(sei_tmp
.lpParameters
, buf
, len
);
1811 if (wszParameters
!= parametersBuffer
)
1812 HeapFree(GetProcessHeap(), 0, wszParameters
);
1813 wszParameters
= buf
;
1814 parametersLen
= len
;
1815 sei_tmp
.lpParameters
= wszParameters
;
1819 if (*sei_tmp
.lpDirectory
)
1821 len
= ExpandEnvironmentStringsW(sei_tmp
.lpDirectory
, NULL
, 0);
1826 buf
= (LPWSTR
)HeapAlloc(GetProcessHeap(),0,len
*sizeof(WCHAR
));
1827 ExpandEnvironmentStringsW(sei_tmp
.lpDirectory
, buf
, len
);
1828 if (wszDir
!= dirBuffer
)
1829 HeapFree(GetProcessHeap(), 0, wszDir
);
1831 sei_tmp
.lpDirectory
= wszDir
;
1835 /* Else, try to execute the filename */
1836 TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName
), debugstr_w(wszParameters
), debugstr_w(wszDir
));
1838 /* separate out command line arguments from executable file name */
1839 if (!*sei_tmp
.lpParameters
&& !appKnownSingular
)
1841 /* If the executable path is quoted, handle the rest of the command line as parameters. */
1842 if (sei_tmp
.lpFile
[0] == '"')
1844 LPWSTR src
= wszApplicationName
/*sei_tmp.lpFile*/ + 1;
1845 LPWSTR dst
= wfileName
;
1848 /* copy the unquoted executable path to 'wfileName' */
1849 while(*src
&& *src
!='"')
1858 while(isspace(*src
))
1864 /* copy the parameter string to 'wszParameters' */
1865 strcpyW(wszParameters
, src
);
1867 /* terminate previous command string after the quote character */
1872 /* If the executable name is not quoted, we have to use this search loop here,
1873 that in CreateProcess() is not sufficient because it does not handle shell links. */
1874 WCHAR buffer
[MAX_PATH
], xlpFile
[MAX_PATH
];
1877 LPWSTR beg
= wszApplicationName
/*sei_tmp.lpFile*/;
1878 for(s
=beg
; (space
= const_cast<LPWSTR
>(strchrW(s
, ' '))); s
=space
+1)
1880 int idx
= space
-sei_tmp
.lpFile
;
1881 memcpy(buffer
, sei_tmp
.lpFile
, idx
* sizeof(WCHAR
));
1884 /*FIXME This finds directory paths if the targeted file name contains spaces. */
1885 if (SearchPathW(*sei_tmp
.lpDirectory
? sei_tmp
.lpDirectory
: NULL
, buffer
, wszExe
, sizeof(xlpFile
)/sizeof(xlpFile
[0]), xlpFile
, NULL
))
1887 /* separate out command from parameter string */
1888 LPCWSTR p
= space
+ 1;
1893 strcpyW(wszParameters
, p
);
1900 lstrcpynW(wfileName
, sei_tmp
.lpFile
,sizeof(wfileName
)/sizeof(WCHAR
));
1904 lstrcpynW(wfileName
, sei_tmp
.lpFile
,sizeof(wfileName
)/sizeof(WCHAR
));
1909 len
= lstrlenW(wszApplicationName
) + 3;
1910 if (sei_tmp
.lpParameters
[0])
1911 len
+= 1 + lstrlenW(wszParameters
);
1914 wcmd
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1917 swprintf(wcmd
, L
"\"%s\"", wszApplicationName
);
1918 if (sei_tmp
.lpParameters
[0])
1920 strcatW(wcmd
, wSpace
);
1921 strcatW(wcmd
, wszParameters
);
1924 retval
= execfunc(wcmd
, NULL
, FALSE
, &sei_tmp
, sei
);
1927 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1928 if (wszParameters
!= parametersBuffer
)
1929 HeapFree(GetProcessHeap(), 0, wszParameters
);
1930 if (wszDir
!= dirBuffer
)
1931 HeapFree(GetProcessHeap(), 0, wszDir
);
1932 if (wcmd
!= wcmdBuffer
)
1933 HeapFree(GetProcessHeap(), 0, wcmd
);
1937 /* Else, try to find the executable */
1939 retval
= SHELL_FindExecutable(sei_tmp
.lpDirectory
, lpFile
, sei_tmp
.lpVerb
, wcmd
, wcmdLen
, lpstrProtocol
, &env
, (LPITEMIDLIST
)sei_tmp
.lpIDList
, sei_tmp
.lpParameters
);
1940 if (retval
> 32) /* Found */
1942 retval
= SHELL_quote_and_execute( wcmd
, wszParameters
, lpstrProtocol
,
1943 wszApplicationName
, env
, &sei_tmp
,
1945 HeapFree( GetProcessHeap(), 0, env
);
1947 else if (PathIsDirectoryW(lpFile
))
1949 static const WCHAR wExplorer
[] = {'e','x','p','l','o','r','e','r',0};
1950 static const WCHAR wQuote
[] = {'"',0};
1951 WCHAR wExec
[MAX_PATH
];
1952 WCHAR
* lpQuotedFile
= (LPWSTR
)HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR
) * (strlenW(lpFile
) + 3) );
1956 retval
= SHELL_FindExecutable( sei_tmp
.lpDirectory
, wExplorer
,
1957 wszOpen
, wExec
, MAX_PATH
,
1958 NULL
, &env
, NULL
, NULL
);
1961 strcpyW(lpQuotedFile
, wQuote
);
1962 strcatW(lpQuotedFile
, lpFile
);
1963 strcatW(lpQuotedFile
, wQuote
);
1964 retval
= SHELL_quote_and_execute( wExec
, lpQuotedFile
,
1966 wszApplicationName
, env
,
1967 &sei_tmp
, sei
, execfunc
);
1968 HeapFree( GetProcessHeap(), 0, env
);
1970 HeapFree( GetProcessHeap(), 0, lpQuotedFile
);
1973 retval
= 0; /* Out of memory */
1975 else if (PathIsURLW(lpFile
)) /* File not found, check for URL */
1977 retval
= SHELL_execute_url( lpFile
, wFile
, wcmd
, &sei_tmp
, sei
, execfunc
);
1979 /* Check if file specified is in the form www.??????.*** */
1980 else if (!strncmpiW(lpFile
, wWww
, 3))
1982 /* if so, append lpFile http:// and call ShellExecute */
1983 WCHAR lpstrTmpFile
[256];
1984 strcpyW(lpstrTmpFile
, wHttp
);
1985 strcatW(lpstrTmpFile
, lpFile
);
1986 retval
= (UINT_PTR
)ShellExecuteW(sei_tmp
.hwnd
, sei_tmp
.lpVerb
, lpstrTmpFile
, NULL
, NULL
, 0);
1989 TRACE("retval %lu\n", retval
);
1991 if (retval
<= 32 && !(sei_tmp
.fMask
& SEE_MASK_FLAG_NO_UI
))
1998 Info
.pcszFile
= wszApplicationName
;
1999 Info
.pcszClass
= NULL
;
2000 Info
.oaifInFlags
= OAIF_ALLOW_REGISTRATION
| OAIF_EXEC
;
2002 //if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK)
2003 do_error_dialog(retval
, sei_tmp
.hwnd
, wszApplicationName
);
2006 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
2007 if (wszParameters
!= parametersBuffer
)
2008 HeapFree(GetProcessHeap(), 0, wszParameters
);
2009 if (wszDir
!= dirBuffer
)
2010 HeapFree(GetProcessHeap(), 0, wszDir
);
2011 if (wcmd
!= wcmdBuffer
)
2012 HeapFree(GetProcessHeap(), 0, wcmd
);
2014 sei
->hInstApp
= (HINSTANCE
)(retval
> 32 ? 33 : retval
);
2019 /*************************************************************************
2020 * ShellExecuteA [SHELL32.290]
2022 HINSTANCE WINAPI
ShellExecuteA(HWND hWnd
, LPCSTR lpOperation
,LPCSTR lpFile
,
2023 LPCSTR lpParameters
,LPCSTR lpDirectory
, INT iShowCmd
)
2025 SHELLEXECUTEINFOA sei
;
2027 TRACE("%p,%s,%s,%s,%s,%d\n",
2028 hWnd
, debugstr_a(lpOperation
), debugstr_a(lpFile
),
2029 debugstr_a(lpParameters
), debugstr_a(lpDirectory
), iShowCmd
);
2031 sei
.cbSize
= sizeof(sei
);
2032 sei
.fMask
= SEE_MASK_FLAG_NO_UI
;
2034 sei
.lpVerb
= lpOperation
;
2035 sei
.lpFile
= lpFile
;
2036 sei
.lpParameters
= lpParameters
;
2037 sei
.lpDirectory
= lpDirectory
;
2038 sei
.nShow
= iShowCmd
;
2045 ShellExecuteExA (&sei
);
2046 return sei
.hInstApp
;
2049 /*************************************************************************
2050 * ShellExecuteExA [SHELL32.292]
2053 BOOL WINAPI
ShellExecuteExA (LPSHELLEXECUTEINFOA sei
)
2055 SHELLEXECUTEINFOW seiW
;
2057 WCHAR
*wVerb
= NULL
, *wFile
= NULL
, *wParameters
= NULL
, *wDirectory
= NULL
, *wClass
= NULL
;
2061 memcpy(&seiW
, sei
, sizeof(SHELLEXECUTEINFOW
));
2064 seiW
.lpVerb
= __SHCloneStrAtoW(&wVerb
, sei
->lpVerb
);
2067 seiW
.lpFile
= __SHCloneStrAtoW(&wFile
, sei
->lpFile
);
2069 if (sei
->lpParameters
)
2070 seiW
.lpParameters
= __SHCloneStrAtoW(&wParameters
, sei
->lpParameters
);
2072 if (sei
->lpDirectory
)
2073 seiW
.lpDirectory
= __SHCloneStrAtoW(&wDirectory
, sei
->lpDirectory
);
2075 if ((sei
->fMask
& SEE_MASK_CLASSALL
) == SEE_MASK_CLASSNAME
&& sei
->lpClass
)
2076 seiW
.lpClass
= __SHCloneStrAtoW(&wClass
, sei
->lpClass
);
2078 seiW
.lpClass
= NULL
;
2080 ret
= SHELL_execute( &seiW
, SHELL_ExecuteW
);
2082 sei
->hInstApp
= seiW
.hInstApp
;
2084 if (sei
->fMask
& SEE_MASK_NOCLOSEPROCESS
)
2085 sei
->hProcess
= seiW
.hProcess
;
2089 SHFree(wParameters
);
2096 /*************************************************************************
2097 * ShellExecuteExW [SHELL32.293]
2100 BOOL WINAPI
ShellExecuteExW (LPSHELLEXECUTEINFOW sei
)
2102 return SHELL_execute( sei
, SHELL_ExecuteW
);
2105 /*************************************************************************
2106 * ShellExecuteW [SHELL32.294]
2108 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
2109 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
2111 HINSTANCE WINAPI
ShellExecuteW(HWND hwnd
, LPCWSTR lpOperation
, LPCWSTR lpFile
,
2112 LPCWSTR lpParameters
, LPCWSTR lpDirectory
, INT nShowCmd
)
2114 SHELLEXECUTEINFOW sei
;
2117 sei
.cbSize
= sizeof(sei
);
2118 sei
.fMask
= SEE_MASK_FLAG_NO_UI
;
2120 sei
.lpVerb
= lpOperation
;
2121 sei
.lpFile
= lpFile
;
2122 sei
.lpParameters
= lpParameters
;
2123 sei
.lpDirectory
= lpDirectory
;
2124 sei
.nShow
= nShowCmd
;
2131 SHELL_execute( &sei
, SHELL_ExecuteW
);
2132 return sei
.hInstApp
;
2135 /*************************************************************************
2136 * WOWShellExecute [SHELL32.@]
2138 * FIXME: the callback function most likely doesn't work the same way on Windows.
2140 EXTERN_C HINSTANCE WINAPI
WOWShellExecute(HWND hWnd
, LPCSTR lpOperation
,LPCSTR lpFile
,
2141 LPCSTR lpParameters
,LPCSTR lpDirectory
, INT iShowCmd
, void *callback
)
2143 SHELLEXECUTEINFOW seiW
;
2144 WCHAR
*wVerb
= NULL
, *wFile
= NULL
, *wParameters
= NULL
, *wDirectory
= NULL
;
2145 HANDLE hProcess
= 0;
2147 seiW
.lpVerb
= lpOperation
? __SHCloneStrAtoW(&wVerb
, lpOperation
) : NULL
;
2148 seiW
.lpFile
= lpFile
? __SHCloneStrAtoW(&wFile
, lpFile
) : NULL
;
2149 seiW
.lpParameters
= lpParameters
? __SHCloneStrAtoW(&wParameters
, lpParameters
) : NULL
;
2150 seiW
.lpDirectory
= lpDirectory
? __SHCloneStrAtoW(&wDirectory
, lpDirectory
) : NULL
;
2152 seiW
.cbSize
= sizeof(seiW
);
2155 seiW
.nShow
= iShowCmd
;
2160 seiW
.hProcess
= hProcess
;
2162 SHELL_execute( &seiW
, (SHELL_ExecuteW32
)callback
);
2166 SHFree(wParameters
);
2168 return seiW
.hInstApp
;
2171 /*************************************************************************
2172 * OpenAs_RunDLLA [SHELL32.@]
2174 EXTERN_C
void WINAPI
OpenAs_RunDLLA(HWND hwnd
, HINSTANCE hinst
, LPCSTR cmdline
, int cmdshow
)
2176 FIXME("%p, %p, %s, %d\n", hwnd
, hinst
, debugstr_a(cmdline
), cmdshow
);
2179 /*************************************************************************
2180 * OpenAs_RunDLLW [SHELL32.@]
2182 EXTERN_C
void WINAPI
OpenAs_RunDLLW(HWND hwnd
, HINSTANCE hinst
, LPCWSTR cmdline
, int cmdshow
)
2184 FIXME("%p, %p, %s, %d\n", hwnd
, hinst
, debugstr_w(cmdline
), cmdshow
);