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
24 WINE_DEFAULT_DEBUG_CHANNEL(exec
);
26 static const WCHAR wszOpen
[] = {'o','p','e','n',0};
27 static const WCHAR wszExe
[] = {'.','e','x','e',0};
28 static const WCHAR wszILPtr
[] = {':','%','p',0};
29 static const WCHAR wszShell
[] = {'\\','s','h','e','l','l','\\',0};
30 static const WCHAR wszFolder
[] = {'F','o','l','d','e','r',0};
31 static const WCHAR wszEmpty
[] = {0};
33 #define SEE_MASK_CLASSALL (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY)
35 static void ParseNoTildeEffect(PWSTR
&res
, LPCWSTR
&args
, DWORD
&len
, DWORD
&used
, int argNum
)
37 bool firstCharQuote
= false;
38 bool quotes_opened
= false;
39 bool backslash_encountered
= false;
41 for (int curArg
=0; curArg
<=argNum
&& *args
; ++curArg
)
43 firstCharQuote
= false;
47 firstCharQuote
= true;
55 // if we found a backslash then flip the variable
56 backslash_encountered
= !backslash_encountered
;
58 else if (*args
== '"')
64 quotes_opened
= false;
78 backslash_encountered
= false;
82 backslash_encountered
= false;
83 if (*args
== ' ' && !firstCharQuote
)
102 static void ParseTildeEffect(PWSTR
&res
, LPCWSTR
&args
, DWORD
&len
, DWORD
&used
, int argNum
)
104 bool quotes_opened
= false;
105 bool backslash_encountered
= false;
107 for (int curArg
=0; curArg
<=argNum
&& *args
; ++curArg
)
113 // if we found a backslash then flip the variable
114 backslash_encountered
= !backslash_encountered
;
116 else if (*args
== '"')
120 if (*(args
+1) != '"')
122 quotes_opened
= false;
131 quotes_opened
= true;
134 backslash_encountered
= false;
138 backslash_encountered
= false;
139 if (*args
== ' ' && !quotes_opened
&& curArg
!=argNum
)
143 if (curArg
== argNum
)
155 /***********************************************************************
156 * SHELL_ArgifyW [Internal]
158 * this function is supposed to expand the escape sequences found in the registry
159 * some diving reported that the following were used:
160 * + %1, %2... seem to report to parameter of index N in ShellExecute pmts
165 * %I address of a global item ID (explorer switch /idlist)
166 * %L seems to be %1 as long filename followed by the 8+3 variation
168 * %* all following parameters (see batfile)
170 * The way we parse the command line arguments was determined through extensive
171 * testing and can be summed up by the following rules"
174 * - if first letter is " break on first non literal " and include any white spaces
175 * - if first letter is NOT " break on first " or white space
176 * - if " is opened any pair of consecutive " results in ONE literal "
179 * - use rules from here http://www.autohotkey.net/~deleyd/parameters/parameters.htm
182 static BOOL
SHELL_ArgifyW(WCHAR
* out
, DWORD len
, const WCHAR
* fmt
, const WCHAR
* lpFile
, LPITEMIDLIST pidl
, LPCWSTR args
, DWORD
* out_len
)
186 BOOL found_p1
= FALSE
;
190 bool tildeEffect
= false;
192 TRACE("Before parsing: %p, %d, %s, %s, %p, %p\n", out
, len
, debugstr_w(fmt
),
193 debugstr_w(lpFile
), pidl
, args
);
252 ParseTildeEffect(res
, args
, len
, used
, *fmt
- '2');
257 ParseNoTildeEffect(res
, args
, len
, used
, *fmt
- '2');
263 if (!done
|| (*fmt
== '1'))
265 /*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */
266 if (SearchPathW(NULL
, lpFile
, wszExe
, sizeof(xlpFile
)/sizeof(WCHAR
), xlpFile
, NULL
))
282 * IE uses this a lot for activating things such as windows media
283 * player. This is not verified to be fully correct but it appears
290 used
+= wcslen(lpFile
);
294 res
+= wcslen(lpFile
);
305 /* %p should not exceed 8, maybe 16 when looking forward to 64bit.
306 * allowing a buffer of 100 should more than exceed all needs */
309 HGLOBAL hmem
= SHAllocShared(pidl
, ILGetSize(pidl
), 0);
310 pv
= SHLockShared(hmem
, 0);
311 chars
= swprintf(buf
, wszILPtr
, pv
);
313 if (chars
>= sizeof(buf
)/sizeof(WCHAR
))
314 ERR("pidl format buffer too small!\n");
330 * Check if this is an env-variable here...
333 /* Make sure that we have at least one more %.*/
334 if (strchrW(fmt
, '%'))
336 WCHAR tmpBuffer
[1024];
337 PWSTR tmpB
= tmpBuffer
;
338 WCHAR tmpEnvBuff
[MAX_PATH
];
345 TRACE("Checking %s to be an env-var\n", debugstr_w(tmpBuffer
));
347 envRet
= GetEnvironmentVariableW(tmpBuffer
, tmpEnvBuff
, MAX_PATH
);
348 if (envRet
== 0 || envRet
> MAX_PATH
)
350 used
+= wcslen(tmpBuffer
);
353 wcscpy( res
, tmpBuffer
);
354 res
+= wcslen(tmpBuffer
);
359 used
+= wcslen(tmpEnvBuff
);
362 wcscpy( res
, tmpEnvBuff
);
363 res
+= wcslen(tmpEnvBuff
);
370 /* Don't skip past terminator (catch a single '%' at the end) */
387 TRACE("used %i of %i space\n",used
,len
);
391 TRACE("After parsing: %p, %d, %s, %s, %p, %p\n", out
, len
, debugstr_w(fmt
),
392 debugstr_w(lpFile
), pidl
, args
);
397 static HRESULT
SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl
, LPWSTR pszPath
, UINT uOutSize
)
400 IShellFolder
* desktop
;
402 HRESULT hr
= SHGetDesktopFolder(&desktop
);
406 hr
= desktop
->GetDisplayNameOf(pidl
, SHGDN_FORPARSING
, &strret
);
409 StrRetToStrNW(pszPath
, uOutSize
, &strret
, pidl
);
417 /*************************************************************************
418 * SHELL_ExecuteW [Internal]
421 static UINT_PTR
SHELL_ExecuteW(const WCHAR
*lpCmd
, WCHAR
*env
, BOOL shWait
,
422 const SHELLEXECUTEINFOW
*psei
, LPSHELLEXECUTEINFOW psei_out
)
424 STARTUPINFOW startup
;
425 PROCESS_INFORMATION info
;
426 UINT_PTR retval
= SE_ERR_NOASSOC
;
428 WCHAR curdir
[MAX_PATH
];
429 DWORD dwCreationFlags
;
430 const WCHAR
*lpDirectory
= NULL
;
432 TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd
), debugstr_w(psei
->lpDirectory
));
434 /* make sure we don't fail the CreateProcess if the calling app passes in
435 * a bad working directory */
436 if (psei
->lpDirectory
&& psei
->lpDirectory
[0])
438 DWORD attr
= GetFileAttributesW(psei
->lpDirectory
);
439 if (attr
!= INVALID_FILE_ATTRIBUTES
&& attr
& FILE_ATTRIBUTE_DIRECTORY
)
440 lpDirectory
= psei
->lpDirectory
;
443 /* ShellExecute specifies the command from psei->lpDirectory
444 * if present. Not from the current dir as CreateProcess does */
446 if ( ( gcdret
= GetCurrentDirectoryW( MAX_PATH
, curdir
)))
447 if ( !SetCurrentDirectoryW( lpDirectory
))
448 ERR("cannot set directory %s\n", debugstr_w(lpDirectory
));
450 ZeroMemory(&startup
,sizeof(STARTUPINFOW
));
451 startup
.cb
= sizeof(STARTUPINFOW
);
452 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
453 startup
.wShowWindow
= psei
->nShow
;
454 dwCreationFlags
= CREATE_UNICODE_ENVIRONMENT
;
456 if (psei
->fMask
& SEE_MASK_NO_CONSOLE
)
457 dwCreationFlags
|= CREATE_NEW_CONSOLE
;
459 //DbgPrint("[shell32, SHELL_ExecuteW] CreateProcessW cmd = %ws\n", (LPWSTR)lpCmd);
462 if (CreateProcessW(NULL
, (LPWSTR
)lpCmd
, NULL
, NULL
, FALSE
, dwCreationFlags
, env
,
463 lpDirectory
, &startup
, &info
))
465 /* Give 30 seconds to the app to come up, if desired. Probably only needed
466 when starting app immediately before making a DDE connection. */
468 if (WaitForInputIdle( info
.hProcess
, 30000 ) == WAIT_FAILED
)
469 WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
472 if (psei
->fMask
& SEE_MASK_NOCLOSEPROCESS
)
473 psei_out
->hProcess
= info
.hProcess
;
475 CloseHandle( info
.hProcess
);
476 CloseHandle( info
.hThread
);
478 else if ((retval
= GetLastError()) >= 32)
480 TRACE("CreateProcess returned error %ld\n", retval
);
481 retval
= ERROR_BAD_FORMAT
;
484 TRACE("returning %lu\n", retval
);
486 psei_out
->hInstApp
= (HINSTANCE
)retval
;
489 if( !SetCurrentDirectoryW( curdir
))
490 ERR("cannot return to directory %s\n", debugstr_w(curdir
));
496 /***********************************************************************
497 * SHELL_BuildEnvW [Internal]
499 * Build the environment for the new process, adding the specified
500 * path to the PATH variable. Returned pointer must be freed by caller.
502 static LPWSTR
SHELL_BuildEnvW( const WCHAR
*path
)
504 static const WCHAR wPath
[] = {'P','A','T','H','=',0};
505 WCHAR
*strings
, *new_env
;
507 int total
= wcslen(path
) + 1;
508 BOOL got_path
= FALSE
;
510 if (!(strings
= GetEnvironmentStringsW())) return NULL
;
514 int len
= wcslen(p
) + 1;
515 if (!_wcsnicmp( p
, wPath
, 5 )) got_path
= TRUE
;
519 if (!got_path
) total
+= 5; /* we need to create PATH */
520 total
++; /* terminating null */
522 if (!(new_env
= (LPWSTR
)HeapAlloc( GetProcessHeap(), 0, total
* sizeof(WCHAR
) )))
524 FreeEnvironmentStringsW( strings
);
531 int len
= wcslen(p
) + 1;
532 memcpy( p2
, p
, len
* sizeof(WCHAR
) );
533 if (!_wcsnicmp( p
, wPath
, 5 ))
536 wcscpy( p2
+ len
, path
);
537 p2
+= wcslen(path
) + 1;
546 p2
+= wcslen(p2
) + 1;
549 FreeEnvironmentStringsW( strings
);
554 /***********************************************************************
555 * SHELL_TryAppPathW [Internal]
557 * Helper function for SHELL_FindExecutable
558 * @param lpResult - pointer to a buffer of size MAX_PATH
559 * On entry: szName is a filename (probably without path separators).
560 * On exit: if szName found in "App Path", place full path in lpResult, and return true
562 static BOOL
SHELL_TryAppPathW( LPCWSTR szName
, LPWSTR lpResult
, WCHAR
**env
)
564 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',
565 '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p',' ','P','a','t','h','s','\\',0};
566 static const WCHAR wPath
[] = {'P','a','t','h',0};
573 if (env
) *env
= NULL
;
574 wcscpy(buffer
, wszKeyAppPaths
);
575 wcscat(buffer
, szName
);
576 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, buffer
, 0, KEY_READ
, &hkApp
);
579 len
= MAX_PATH
*sizeof(WCHAR
);
580 res
= RegQueryValueW(hkApp
, NULL
, lpResult
, &len
);
586 DWORD count
= sizeof(buffer
);
587 if (!RegQueryValueExW(hkApp
, wPath
, NULL
, NULL
, (LPBYTE
)buffer
, &count
) && buffer
[0])
588 *env
= SHELL_BuildEnvW( buffer
);
592 if (hkApp
) RegCloseKey(hkApp
);
596 static UINT
SHELL_FindExecutableByOperation(LPCWSTR lpOperation
, LPWSTR key
, LPWSTR filetype
, LPWSTR command
, LONG commandlen
)
598 static const WCHAR wCommand
[] = {'\\','c','o','m','m','a','n','d',0};
600 WCHAR verb
[MAX_PATH
];
602 if (RegOpenKeyExW(HKEY_CLASSES_ROOT
, filetype
, 0, 0x02000000, &hkeyClass
))
603 return SE_ERR_NOASSOC
;
604 if (!HCR_GetDefaultVerbW(hkeyClass
, lpOperation
, verb
, sizeof(verb
)/sizeof(verb
[0])))
605 return SE_ERR_NOASSOC
;
606 RegCloseKey(hkeyClass
);
608 /* Looking for ...buffer\shell\<verb>\command */
609 wcscat(filetype
, wszShell
);
610 wcscat(filetype
, verb
);
611 wcscat(filetype
, wCommand
);
613 if (RegQueryValueW(HKEY_CLASSES_ROOT
, filetype
, command
,
614 &commandlen
) == ERROR_SUCCESS
)
616 commandlen
/= sizeof(WCHAR
);
617 if (key
) wcscpy(key
, filetype
);
621 LONG paramlen
= sizeof(param
);
622 static const WCHAR wSpace
[] = {' ',0};
624 /* FIXME: it seems all Windows version don't behave the same here.
625 * the doc states that this ddeexec information can be found after
627 * on Win98, it doesn't appear, but I think it does on Win2k
629 /* Get the parameters needed by the application
630 from the associated ddeexec key */
631 tmp
= strstrW(filetype
, wCommand
);
633 wcscat(filetype
, wDdeexec
);
634 if (RegQueryValueW(HKEY_CLASSES_ROOT
, filetype
, param
,
635 ¶mlen
) == ERROR_SUCCESS
)
637 paramlen
/= sizeof(WCHAR
);
638 wcscat(command
, wSpace
);
639 wcscat(command
, param
);
640 commandlen
+= paramlen
;
644 command
[commandlen
] = '\0';
646 return 33; /* FIXME see SHELL_FindExecutable() */
649 return SE_ERR_NOASSOC
;
652 /*************************************************************************
653 * SHELL_FindExecutable [Internal]
655 * Utility for code sharing between FindExecutable and ShellExecute
657 * lpFile the name of a file
658 * lpOperation the operation on it (open)
660 * lpResult a buffer, big enough :-(, to store the command to do the
661 * operation on the file
662 * key a buffer, big enough, to get the key name to do actually the
663 * command (it'll be used afterwards for more information
666 static UINT
SHELL_FindExecutable(LPCWSTR lpPath
, LPCWSTR lpFile
, LPCWSTR lpOperation
,
667 LPWSTR lpResult
, DWORD resultLen
, LPWSTR key
, WCHAR
**env
, LPITEMIDLIST pidl
, LPCWSTR args
)
669 static const WCHAR wWindows
[] = {'w','i','n','d','o','w','s',0};
670 static const WCHAR wPrograms
[] = {'p','r','o','g','r','a','m','s',0};
671 static const WCHAR wExtensions
[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
672 WCHAR
*extension
= NULL
; /* pointer to file extension */
673 WCHAR filetype
[256]; /* registry name for this filetype */
674 LONG filetypelen
= sizeof(filetype
); /* length of above */
675 WCHAR command
[1024]; /* command from registry */
676 WCHAR wBuffer
[256]; /* Used to GetProfileString */
677 UINT retval
= SE_ERR_NOASSOC
;
678 WCHAR
*tok
; /* token pointer */
679 WCHAR xlpFile
[256]; /* result of SearchPath */
680 DWORD attribs
; /* file attributes */
682 TRACE("%s\n", debugstr_w(lpFile
));
685 return ERROR_INVALID_PARAMETER
;
688 lpResult
[0] = '\0'; /* Start off with an empty return string */
689 if (key
) *key
= '\0';
691 /* trap NULL parameters on entry */
694 WARN("(lpFile=%s,lpResult=%s): NULL parameter\n",
695 debugstr_w(lpFile
), debugstr_w(lpResult
));
696 return ERROR_FILE_NOT_FOUND
; /* File not found. Close enough, I guess. */
699 if (SHELL_TryAppPathW( lpFile
, lpResult
, env
))
701 TRACE("found %s via App Paths\n", debugstr_w(lpResult
));
705 if (SearchPathW(lpPath
, lpFile
, wszExe
, sizeof(xlpFile
)/sizeof(WCHAR
), xlpFile
, NULL
))
707 TRACE("SearchPathW returned non-zero\n");
709 /* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
712 attribs
= GetFileAttributesW(lpFile
);
713 if (attribs
!=INVALID_FILE_ATTRIBUTES
&& (attribs
&FILE_ATTRIBUTE_DIRECTORY
))
715 wcscpy(filetype
, wszFolder
);
716 filetypelen
= 6; /* strlen("Folder") */
720 /* Did we get something? Anything? */
723 TRACE("Returning SE_ERR_FNF\n");
726 /* First thing we need is the file's extension */
727 extension
= wcsrchr(xlpFile
, '.'); /* Assume last "." is the one; */
728 /* File->Run in progman uses */
730 TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile
), debugstr_w(extension
));
732 if (extension
== NULL
|| extension
[1]==0)
734 WARN("Returning SE_ERR_NOASSOC\n");
735 return SE_ERR_NOASSOC
;
738 /* Three places to check: */
739 /* 1. win.ini, [windows], programs (NB no leading '.') */
740 /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
741 /* 3. win.ini, [extensions], extension (NB no leading '.' */
742 /* All I know of the order is that registry is checked before */
743 /* extensions; however, it'd make sense to check the programs */
744 /* section first, so that's what happens here. */
746 /* See if it's a program - if GetProfileString fails, we skip this
747 * section. Actually, if GetProfileString fails, we've probably
748 * got a lot more to worry about than running a program... */
749 if (GetProfileStringW(wWindows
, wPrograms
, wExtensions
, wBuffer
, sizeof(wBuffer
)/sizeof(WCHAR
)) > 0)
756 while (*p
&& *p
!= ' ' && *p
!= '\t') p
++;
760 while (*p
== ' ' || *p
== '\t') p
++;
763 if (wcsicmp(tok
, &extension
[1]) == 0) /* have to skip the leading "." */
765 wcscpy(lpResult
, xlpFile
);
766 /* Need to perhaps check that the file has a path
768 TRACE("found %s\n", debugstr_w(lpResult
));
770 /* Greater than 32 to indicate success */
777 if (RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, filetype
,
778 &filetypelen
) == ERROR_SUCCESS
)
780 filetypelen
/= sizeof(WCHAR
);
781 if (filetypelen
== sizeof(filetype
)/sizeof(WCHAR
))
784 filetype
[filetypelen
] = '\0';
785 TRACE("File type: %s\n", debugstr_w(filetype
));
796 /* pass the operation string to SHELL_FindExecutableByOperation() */
797 filetype
[filetypelen
] = '\0';
798 retval
= SHELL_FindExecutableByOperation(lpOperation
, key
, filetype
, command
, sizeof(command
));
803 SHELL_ArgifyW(lpResult
, resultLen
, command
, xlpFile
, pidl
, args
, &finishedLen
);
804 if (finishedLen
> resultLen
)
805 ERR("Argify buffer not large enough.. truncated\n");
806 DbgPrint("[shell32, SHELL_FindExecutable] Remove double quotation marks and command line arguments\n");
807 /* Remove double quotation marks and command line arguments */
808 if (*lpResult
== '"')
811 while (*(p
+ 1) != '"')
820 /* Truncate on first space */
822 while (*p
!= ' ' && *p
!= '\0')
828 else /* Check win.ini */
830 static const WCHAR wExtensions
[] = {'e','x','t','e','n','s','i','o','n','s',0};
832 /* Toss the leading dot */
834 if (GetProfileStringW(wExtensions
, extension
, wszEmpty
, command
, sizeof(command
)/sizeof(WCHAR
)) > 0)
836 if (wcslen(command
) != 0)
838 wcscpy(lpResult
, command
);
839 tok
= wcschr(lpResult
, '^'); /* should be ^.extension? */
843 wcscat(lpResult
, xlpFile
); /* what if no dir in xlpFile? */
844 tok
= wcschr(command
, '^'); /* see above */
845 if ((tok
!= NULL
) && (wcslen(tok
)>5))
847 wcscat(lpResult
, &tok
[5]);
850 retval
= 33; /* FIXME - see above */
855 TRACE("returning %s\n", debugstr_w(lpResult
));
859 /******************************************************************
862 * callback for the DDE connection. not really useful
864 static HDDEDATA CALLBACK
dde_cb(UINT uType
, UINT uFmt
, HCONV hConv
,
865 HSZ hsz1
, HSZ hsz2
, HDDEDATA hData
,
866 ULONG_PTR dwData1
, ULONG_PTR dwData2
)
868 TRACE("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n",
869 uType
, uFmt
, hConv
, hsz1
, hsz2
, hData
, dwData1
, dwData2
);
873 /******************************************************************
876 * ShellExecute helper. Used to do an operation with a DDE connection
878 * Handles both the direct connection (try #1), and if it fails,
879 * launching an application and trying (#2) to connect to it
882 static unsigned dde_connect(const WCHAR
* key
, const WCHAR
* start
, WCHAR
* ddeexec
,
883 const WCHAR
* lpFile
, WCHAR
*env
,
884 LPCWSTR szCommandline
, LPITEMIDLIST pidl
, SHELL_ExecuteW32 execfunc
,
885 const SHELLEXECUTEINFOW
*psei
, LPSHELLEXECUTEINFOW psei_out
)
887 static const WCHAR wApplication
[] = {'\\','a','p','p','l','i','c','a','t','i','o','n',0};
888 static const WCHAR wTopic
[] = {'\\','t','o','p','i','c',0};
890 WCHAR
* endkey
= regkey
+ wcslen(key
);
891 WCHAR app
[256], topic
[256], ifexec
[256], res
[256];
892 LONG applen
, topiclen
, ifexeclen
;
897 HSZ hszApp
, hszTopic
;
900 unsigned ret
= SE_ERR_NOASSOC
;
901 BOOL unicode
= !(GetVersion() & 0x80000000);
904 wcscpy(endkey
, wApplication
);
905 applen
= sizeof(app
);
906 if (RegQueryValueW(HKEY_CLASSES_ROOT
, regkey
, app
, &applen
) != ERROR_SUCCESS
)
908 WCHAR command
[1024], fullpath
[MAX_PATH
];
909 static const WCHAR wSo
[] = { '.','s','o',0 };
910 DWORD sizeSo
= sizeof(wSo
)/sizeof(WCHAR
);
914 /* Get application command from start string and find filename of application */
917 wcscpy(command
, start
+1);
918 if ((ptr
= wcschr(command
, '"')))
920 ret
= SearchPathW(NULL
, command
, wszExe
, sizeof(fullpath
)/sizeof(WCHAR
), fullpath
, &ptr
);
925 for (p
=(LPWSTR
)start
; (space
= const_cast<LPWSTR
>(strchrW(p
, ' '))); p
=space
+1)
927 int idx
= space
-start
;
928 memcpy(command
, start
, idx
*sizeof(WCHAR
));
930 if ((ret
= SearchPathW(NULL
, command
, wszExe
, sizeof(fullpath
)/sizeof(WCHAR
), fullpath
, &ptr
)))
934 ret
= SearchPathW(NULL
, start
, wszExe
, sizeof(fullpath
)/sizeof(WCHAR
), fullpath
, &ptr
);
939 ERR("Unable to find application path for command %s\n", debugstr_w(start
));
940 return ERROR_ACCESS_DENIED
;
944 /* Remove extensions (including .so) */
945 ptr
= app
+ wcslen(app
) - (sizeSo
-1);
946 if (wcslen(app
) >= sizeSo
&&
950 ptr
= const_cast<LPWSTR
>(strrchrW(app
, '.'));
955 wcscpy(endkey
, wTopic
);
956 topiclen
= sizeof(topic
);
957 if (RegQueryValueW(HKEY_CLASSES_ROOT
, regkey
, topic
, &topiclen
) != ERROR_SUCCESS
)
959 static const WCHAR wSystem
[] = {'S','y','s','t','e','m',0};
960 wcscpy(topic
, wSystem
);
965 if (DdeInitializeW(&ddeInst
, dde_cb
, APPCMD_CLIENTONLY
, 0L) != DMLERR_NO_ERROR
)
970 if (DdeInitializeA(&ddeInst
, dde_cb
, APPCMD_CLIENTONLY
, 0L) != DMLERR_NO_ERROR
)
974 hszApp
= DdeCreateStringHandleW(ddeInst
, app
, CP_WINUNICODE
);
975 hszTopic
= DdeCreateStringHandleW(ddeInst
, topic
, CP_WINUNICODE
);
977 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
981 static const WCHAR wIfexec
[] = {'\\','i','f','e','x','e','c',0};
982 TRACE("Launching %s\n", debugstr_w(start
));
983 ret
= execfunc(start
, env
, TRUE
, psei
, psei_out
);
986 TRACE("Couldn't launch\n");
989 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
992 TRACE("Couldn't connect. ret=%d\n", ret
);
993 DdeUninitialize(ddeInst
);
994 SetLastError(ERROR_DDE_FAIL
);
995 return 30; /* whatever */
997 strcpyW(endkey
, wIfexec
);
998 ifexeclen
= sizeof(ifexec
);
999 if (RegQueryValueW(HKEY_CLASSES_ROOT
, regkey
, ifexec
, &ifexeclen
) == ERROR_SUCCESS
)
1005 SHELL_ArgifyW(res
, sizeof(res
)/sizeof(WCHAR
), exec
, lpFile
, pidl
, szCommandline
, &resultLen
);
1006 if (resultLen
> sizeof(res
)/sizeof(WCHAR
))
1007 ERR("Argify buffer not large enough, truncated\n");
1008 TRACE("%s %s => %s\n", debugstr_w(exec
), debugstr_w(lpFile
), debugstr_w(res
));
1010 /* It's documented in the KB 330337 that IE has a bug and returns
1011 * error DMLERR_NOTPROCESSED on XTYP_EXECUTE request.
1014 hDdeData
= DdeClientTransaction((LPBYTE
)res
, (strlenW(res
) + 1) * sizeof(WCHAR
), hConv
, 0L, 0,
1015 XTYP_EXECUTE
, 30000, &tid
);
1018 DWORD lenA
= WideCharToMultiByte(CP_ACP
, 0, res
, -1, NULL
, 0, NULL
, NULL
);
1019 char *resA
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, lenA
);
1020 WideCharToMultiByte(CP_ACP
, 0, res
, -1, resA
, lenA
, NULL
, NULL
);
1021 hDdeData
= DdeClientTransaction( (LPBYTE
)resA
, lenA
, hConv
, 0L, 0,
1022 XTYP_EXECUTE
, 10000, &tid
);
1023 HeapFree(GetProcessHeap(), 0, resA
);
1026 DdeFreeDataHandle(hDdeData
);
1028 WARN("DdeClientTransaction failed with error %04x\n", DdeGetLastError(ddeInst
));
1031 DdeDisconnect(hConv
);
1034 DdeUninitialize(ddeInst
);
1039 /*************************************************************************
1040 * execute_from_key [Internal]
1042 static UINT_PTR
execute_from_key(LPCWSTR key
, LPCWSTR lpFile
, WCHAR
*env
, LPCWSTR szCommandline
,
1043 LPCWSTR executable_name
,
1044 SHELL_ExecuteW32 execfunc
,
1045 LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
)
1047 static const WCHAR wCommand
[] = {'c','o','m','m','a','n','d',0};
1048 static const WCHAR wDdeexec
[] = {'d','d','e','e','x','e','c',0};
1049 WCHAR cmd
[256], param
[1024], ddeexec
[256];
1050 DWORD cmdlen
= sizeof(cmd
), ddeexeclen
= sizeof(ddeexec
);
1051 UINT_PTR retval
= SE_ERR_NOASSOC
;
1055 TRACE("%s %s %s %s %s\n", debugstr_w(key
), debugstr_w(lpFile
), debugstr_w(env
),
1056 debugstr_w(szCommandline
), debugstr_w(executable_name
));
1061 /* Get the application from the registry */
1062 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, cmd
, (LONG
*)&cmdlen
) == ERROR_SUCCESS
)
1064 TRACE("got cmd: %s\n", debugstr_w(cmd
));
1066 /* Is there a replace() function anywhere? */
1067 cmdlen
/= sizeof(WCHAR
);
1068 if (cmdlen
>= sizeof(cmd
)/sizeof(WCHAR
))
1069 cmdlen
= sizeof(cmd
)/sizeof(WCHAR
)-1;
1071 SHELL_ArgifyW(param
, sizeof(param
)/sizeof(WCHAR
), cmd
, lpFile
, (LPITEMIDLIST
)psei
->lpIDList
, szCommandline
, &resultLen
);
1072 if (resultLen
> sizeof(param
)/sizeof(WCHAR
))
1073 ERR("Argify buffer not large enough, truncating\n");
1076 /* Get the parameters needed by the application
1077 from the associated ddeexec key */
1078 tmp
= const_cast<LPWSTR
>(strstrW(key
, wCommand
));
1080 wcscpy(tmp
, wDdeexec
);
1082 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, ddeexec
, (LONG
*)&ddeexeclen
) == ERROR_SUCCESS
)
1084 TRACE("Got ddeexec %s => %s\n", debugstr_w(key
), debugstr_w(ddeexec
));
1085 if (!param
[0]) strcpyW(param
, executable_name
);
1086 retval
= dde_connect(key
, param
, ddeexec
, lpFile
, env
, szCommandline
, (LPITEMIDLIST
)psei
->lpIDList
, execfunc
, psei
, psei_out
);
1090 TRACE("executing: %s\n", debugstr_w(param
));
1091 retval
= execfunc(param
, env
, FALSE
, psei
, psei_out
);
1094 WARN("Nothing appropriate found for %s\n", debugstr_w(key
));
1099 /*************************************************************************
1100 * FindExecutableA [SHELL32.@]
1102 HINSTANCE WINAPI
FindExecutableA(LPCSTR lpFile
, LPCSTR lpDirectory
, LPSTR lpResult
)
1105 WCHAR
*wFile
= NULL
, *wDirectory
= NULL
;
1106 WCHAR wResult
[MAX_PATH
];
1108 if (lpFile
) __SHCloneStrAtoW(&wFile
, lpFile
);
1109 if (lpDirectory
) __SHCloneStrAtoW(&wDirectory
, lpDirectory
);
1111 retval
= FindExecutableW(wFile
, wDirectory
, wResult
);
1112 WideCharToMultiByte(CP_ACP
, 0, wResult
, -1, lpResult
, MAX_PATH
, NULL
, NULL
);
1114 SHFree( wDirectory
);
1116 TRACE("returning %s\n", lpResult
);
1120 /*************************************************************************
1121 * FindExecutableW [SHELL32.@]
1123 * This function returns the executable associated with the specified file
1124 * for the default verb.
1127 * lpFile [I] The file to find the association for. This must refer to
1128 * an existing file otherwise FindExecutable fails and returns
1130 * lpResult [O] Points to a buffer into which the executable path is
1131 * copied. This parameter must not be NULL otherwise
1132 * FindExecutable() segfaults. The buffer must be of size at
1133 * least MAX_PATH characters.
1136 * A value greater than 32 on success, less than or equal to 32 otherwise.
1137 * See the SE_ERR_* constants.
1140 * On Windows XP and 2003, FindExecutable() seems to first convert the
1141 * filename into 8.3 format, thus taking into account only the first three
1142 * characters of the extension, and expects to find an association for those.
1143 * However other Windows versions behave sanely.
1145 HINSTANCE WINAPI
FindExecutableW(LPCWSTR lpFile
, LPCWSTR lpDirectory
, LPWSTR lpResult
)
1147 UINT_PTR retval
= SE_ERR_NOASSOC
;
1148 WCHAR old_dir
[1024];
1150 TRACE("File %s, Dir %s\n", debugstr_w(lpFile
), debugstr_w(lpDirectory
));
1152 lpResult
[0] = '\0'; /* Start off with an empty return string */
1154 return (HINSTANCE
)SE_ERR_FNF
;
1158 GetCurrentDirectoryW(sizeof(old_dir
)/sizeof(WCHAR
), old_dir
);
1159 SetCurrentDirectoryW(lpDirectory
);
1162 retval
= SHELL_FindExecutable(lpDirectory
, lpFile
, wszOpen
, lpResult
, MAX_PATH
, NULL
, NULL
, NULL
, NULL
);
1164 TRACE("returning %s\n", debugstr_w(lpResult
));
1166 SetCurrentDirectoryW(old_dir
);
1167 return (HINSTANCE
)retval
;
1170 /* FIXME: is this already implemented somewhere else? */
1171 static HKEY
ShellExecute_GetClassKey( const SHELLEXECUTEINFOW
*sei
)
1173 LPCWSTR ext
= NULL
, lpClass
= NULL
;
1175 DWORD type
= 0, sz
= 0;
1179 if (sei
->fMask
& SEE_MASK_CLASSALL
)
1180 return sei
->hkeyClass
;
1182 if (sei
->fMask
& SEE_MASK_CLASSNAME
)
1183 lpClass
= sei
->lpClass
;
1186 ext
= PathFindExtensionW( sei
->lpFile
);
1187 TRACE("ext = %s\n", debugstr_w( ext
) );
1191 r
= RegOpenKeyW( HKEY_CLASSES_ROOT
, ext
, &hkey
);
1192 if (r
!= ERROR_SUCCESS
)
1195 r
= RegQueryValueExW( hkey
, NULL
, 0, &type
, NULL
, &sz
);
1196 if ( r
== ERROR_SUCCESS
&& type
== REG_SZ
)
1198 sz
+= sizeof (WCHAR
);
1199 cls
= (LPWSTR
)HeapAlloc( GetProcessHeap(), 0, sz
);
1201 RegQueryValueExW( hkey
, NULL
, 0, &type
, (LPBYTE
) cls
, &sz
);
1204 RegCloseKey( hkey
);
1208 TRACE("class = %s\n", debugstr_w(lpClass
) );
1212 RegOpenKeyW( HKEY_CLASSES_ROOT
, lpClass
, &hkey
);
1214 HeapFree( GetProcessHeap(), 0, cls
);
1219 static IDataObject
*shellex_get_dataobj( LPSHELLEXECUTEINFOW sei
)
1221 LPCITEMIDLIST pidllast
= NULL
;
1222 IDataObject
*dataobj
= NULL
;
1223 IShellFolder
*shf
= NULL
;
1224 LPITEMIDLIST pidl
= NULL
;
1227 if (sei
->fMask
& SEE_MASK_CLASSALL
)
1228 pidl
= (LPITEMIDLIST
)sei
->lpIDList
;
1231 WCHAR fullpath
[MAX_PATH
];
1235 ret
= GetFullPathNameW( sei
->lpFile
, MAX_PATH
, fullpath
, NULL
);
1239 pidl
= ILCreateFromPathW( fullpath
);
1242 r
= SHBindToParent( pidl
, IID_IShellFolder
, (LPVOID
*)&shf
, &pidllast
);
1246 shf
->GetUIObjectOf(NULL
, 1, &pidllast
,
1247 IID_IDataObject
, NULL
, (LPVOID
*) &dataobj
);
1250 if ( pidl
!= sei
->lpIDList
)
1257 static HRESULT
shellex_run_context_menu_default( IShellExtInit
*obj
,
1258 LPSHELLEXECUTEINFOW sei
)
1260 IContextMenu
*cm
= NULL
;
1261 CMINVOKECOMMANDINFOEX ici
;
1268 TRACE("%p %p\n", obj
, sei
);
1270 r
= obj
->QueryInterface(IID_IContextMenu
, (LPVOID
*) &cm
);
1274 hmenu
= CreateMenu();
1278 /* the number of the last menu added is returned in r */
1279 r
= cm
->QueryContextMenu(hmenu
, 0, 0x20, 0x7fff, CMF_DEFAULTONLY
);
1283 n
= GetMenuItemCount( hmenu
);
1284 for ( i
= 0; i
< n
; i
++ )
1286 memset( &info
, 0, sizeof info
);
1287 info
.cbSize
= sizeof info
;
1288 info
.fMask
= MIIM_FTYPE
| MIIM_STRING
| MIIM_STATE
| MIIM_DATA
| MIIM_ID
;
1289 info
.dwTypeData
= string
;
1290 info
.cch
= sizeof string
;
1292 GetMenuItemInfoW( hmenu
, i
, TRUE
, &info
);
1294 TRACE("menu %d %s %08x %08lx %08x %08x\n", i
, debugstr_w(string
),
1295 info
.fState
, info
.dwItemData
, info
.fType
, info
.wID
);
1296 if ( ( !sei
->lpVerb
&& (info
.fState
& MFS_DEFAULT
) ) ||
1297 ( sei
->lpVerb
&& !lstrcmpiW( sei
->lpVerb
, string
) ) )
1308 memset( &ici
, 0, sizeof ici
);
1309 ici
.cbSize
= sizeof ici
;
1310 ici
.fMask
= CMIC_MASK_UNICODE
| (sei
->fMask
& (SEE_MASK_NOASYNC
|SEE_MASK_ASYNCOK
|SEE_MASK_FLAG_NO_UI
));
1311 ici
.nShow
= sei
->nShow
;
1312 ici
.lpVerb
= MAKEINTRESOURCEA( def
);
1313 ici
.hwnd
= sei
->hwnd
;
1314 ici
.lpParametersW
= sei
->lpParameters
;
1316 r
= cm
->InvokeCommand((LPCMINVOKECOMMANDINFO
) &ici
);
1318 TRACE("invoke command returned %08x\n", r
);
1322 DestroyMenu( hmenu
);
1328 static HRESULT
shellex_load_object_and_run( HKEY hkey
, LPCGUID guid
, LPSHELLEXECUTEINFOW sei
)
1330 IDataObject
*dataobj
= NULL
;
1331 IObjectWithSite
*ows
= NULL
;
1332 IShellExtInit
*obj
= NULL
;
1335 TRACE("%p %s %p\n", hkey
, debugstr_guid( guid
), sei
);
1337 r
= CoInitialize( NULL
);
1341 r
= CoCreateInstance(*guid
, NULL
, CLSCTX_INPROC_SERVER
,
1342 IID_IShellExtInit
, (LPVOID
*)&obj
);
1345 ERR("failed %08x\n", r
);
1349 dataobj
= shellex_get_dataobj( sei
);
1352 ERR("failed to get data object\n");
1356 r
= obj
->Initialize(NULL
, dataobj
, hkey
);
1360 r
= obj
->QueryInterface(IID_IObjectWithSite
, (LPVOID
*) &ows
);
1364 ows
->SetSite(NULL
);
1366 r
= shellex_run_context_menu_default( obj
, sei
);
1380 /*************************************************************************
1381 * ShellExecute_FromContextMenu [Internal]
1383 static LONG
ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei
)
1385 static const WCHAR szcm
[] = { 's','h','e','l','l','e','x','\\',
1386 'C','o','n','t','e','x','t','M','e','n','u','H','a','n','d','l','e','r','s',0 };
1387 HKEY hkey
, hkeycm
= 0;
1394 TRACE("%s\n", debugstr_w(sei
->lpFile
) );
1396 hkey
= ShellExecute_GetClassKey( sei
);
1398 return ERROR_FUNCTION_FAILED
;
1400 r
= RegOpenKeyW( hkey
, szcm
, &hkeycm
);
1401 if ( r
== ERROR_SUCCESS
)
1406 r
= RegEnumKeyW( hkeycm
, i
++, szguid
, sizeof(szguid
)/sizeof(szguid
[0]) );
1407 if ( r
!= ERROR_SUCCESS
)
1410 hr
= CLSIDFromString( szguid
, &guid
);
1413 /* stop at the first one that succeeds in running */
1414 hr
= shellex_load_object_and_run( hkey
, &guid
, sei
);
1415 if ( SUCCEEDED( hr
) )
1419 RegCloseKey( hkeycm
);
1422 if ( hkey
!= sei
->hkeyClass
)
1423 RegCloseKey( hkey
);
1427 static UINT_PTR
SHELL_execute_class( LPCWSTR wszApplicationName
, LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
, SHELL_ExecuteW32 execfunc
)
1429 static const WCHAR wSpace
[] = {' ',0};
1430 WCHAR execCmd
[1024], wcmd
[1024];
1431 /* launch a document by fileclass like 'WordPad.Document.1' */
1432 /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
1433 /* FIXME: wcmd should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */
1434 ULONG cmask
=(psei
->fMask
& SEE_MASK_CLASSALL
);
1438 HCR_GetExecuteCommandW((cmask
== SEE_MASK_CLASSKEY
) ? psei
->hkeyClass
: NULL
,
1439 (cmask
== SEE_MASK_CLASSNAME
) ? psei
->lpClass
: NULL
,
1441 execCmd
, sizeof(execCmd
));
1443 /* FIXME: get the extension of lpFile, check if it fits to the lpClass */
1444 TRACE("SEE_MASK_CLASSNAME->%s, doc->%s\n", debugstr_w(execCmd
), debugstr_w(wszApplicationName
));
1447 done
= SHELL_ArgifyW(wcmd
, sizeof(wcmd
)/sizeof(WCHAR
), execCmd
, wszApplicationName
, (LPITEMIDLIST
)psei
->lpIDList
, NULL
, &resultLen
);
1448 if (!done
&& wszApplicationName
[0])
1450 strcatW(wcmd
, wSpace
);
1451 strcatW(wcmd
, wszApplicationName
);
1453 if (resultLen
> sizeof(wcmd
)/sizeof(WCHAR
))
1454 ERR("Argify buffer not large enough... truncating\n");
1455 return execfunc(wcmd
, NULL
, FALSE
, psei
, psei_out
);
1458 static BOOL
SHELL_translate_idlist( LPSHELLEXECUTEINFOW sei
, LPWSTR wszParameters
, DWORD parametersLen
, LPWSTR wszApplicationName
, DWORD dwApplicationNameLen
)
1460 static const WCHAR wExplorer
[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0};
1461 WCHAR buffer
[MAX_PATH
];
1462 BOOL appKnownSingular
= FALSE
;
1464 /* last chance to translate IDList: now also allow CLSID paths */
1465 if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW((LPCITEMIDLIST
)sei
->lpIDList
, buffer
, sizeof(buffer
)))) {
1466 if (buffer
[0]==':' && buffer
[1]==':') {
1467 /* open shell folder for the specified class GUID */
1468 if (strlenW(buffer
) + 1 > parametersLen
)
1469 ERR("parameters len exceeds buffer size (%i > %i), truncating\n",
1470 lstrlenW(buffer
) + 1, parametersLen
);
1471 lstrcpynW(wszParameters
, buffer
, parametersLen
);
1472 if (strlenW(wExplorer
) > dwApplicationNameLen
)
1473 ERR("application len exceeds buffer size (%i > %i), truncating\n",
1474 lstrlenW(wExplorer
) + 1, dwApplicationNameLen
);
1475 lstrcpynW(wszApplicationName
, wExplorer
, dwApplicationNameLen
);
1476 appKnownSingular
= TRUE
;
1478 sei
->fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1480 WCHAR target
[MAX_PATH
];
1483 /* Check if we're executing a directory and if so use the
1484 handler for the Folder class */
1485 strcpyW(target
, buffer
);
1486 attribs
= GetFileAttributesW(buffer
);
1487 if (attribs
!= INVALID_FILE_ATTRIBUTES
&&
1488 (attribs
& FILE_ATTRIBUTE_DIRECTORY
) &&
1489 HCR_GetExecuteCommandW(0, wszFolder
,
1491 buffer
, sizeof(buffer
))) {
1492 SHELL_ArgifyW(wszApplicationName
, dwApplicationNameLen
,
1493 buffer
, target
, (LPITEMIDLIST
)sei
->lpIDList
, NULL
, &resultLen
);
1494 if (resultLen
> dwApplicationNameLen
)
1495 ERR("Argify buffer not large enough... truncating\n");
1496 appKnownSingular
= FALSE
;
1498 sei
->fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1501 return appKnownSingular
;
1504 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
)
1506 static const WCHAR wQuote
[] = {'"',0};
1507 static const WCHAR wSpace
[] = {' ',0};
1510 WCHAR
*wszQuotedCmd
;
1512 /* Length of quotes plus length of command plus NULL terminator */
1513 len
= 2 + lstrlenW(wcmd
) + 1;
1514 if (wszParameters
[0])
1516 /* Length of space plus length of parameters */
1517 len
+= 1 + lstrlenW(wszParameters
);
1519 wszQuotedCmd
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1520 /* Must quote to handle case where cmd contains spaces,
1521 * else security hole if malicious user creates executable file "C:\\Program"
1523 strcpyW(wszQuotedCmd
, wQuote
);
1524 strcatW(wszQuotedCmd
, wcmd
);
1525 strcatW(wszQuotedCmd
, wQuote
);
1526 if (wszParameters
[0])
1528 strcatW(wszQuotedCmd
, wSpace
);
1529 strcatW(wszQuotedCmd
, wszParameters
);
1532 TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName
), debugstr_w(psei
->lpVerb
), debugstr_w(wszQuotedCmd
), debugstr_w(lpstrProtocol
));
1535 retval
= execute_from_key(lpstrProtocol
, wszApplicationName
, env
, psei
->lpParameters
, wcmd
, execfunc
, psei
, psei_out
);
1537 retval
= execfunc(wszQuotedCmd
, env
, FALSE
, psei
, psei_out
);
1538 HeapFree(GetProcessHeap(), 0, wszQuotedCmd
);
1542 static UINT_PTR
SHELL_execute_url( LPCWSTR lpFile
, LPCWSTR wFile
, LPCWSTR wcmd
, LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
, SHELL_ExecuteW32 execfunc
)
1544 static const WCHAR wShell
[] = {'\\','s','h','e','l','l','\\',0};
1545 static const WCHAR wCommand
[] = {'\\','c','o','m','m','a','n','d',0};
1547 WCHAR
*lpstrProtocol
;
1552 lpstrRes
= strchrW(lpFile
, ':');
1554 iSize
= lpstrRes
- lpFile
;
1556 iSize
= strlenW(lpFile
);
1558 TRACE("Got URL: %s\n", debugstr_w(lpFile
));
1559 /* Looking for ...protocol\shell\lpOperation\command */
1560 len
= iSize
+ lstrlenW(wShell
) + lstrlenW(wCommand
) + 1;
1562 len
+= lstrlenW(psei
->lpVerb
);
1564 len
+= lstrlenW(wszOpen
);
1565 lpstrProtocol
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1566 memcpy(lpstrProtocol
, lpFile
, iSize
*sizeof(WCHAR
));
1567 lpstrProtocol
[iSize
] = '\0';
1568 strcatW(lpstrProtocol
, wShell
);
1569 strcatW(lpstrProtocol
, psei
->lpVerb
? psei
->lpVerb
: wszOpen
);
1570 strcatW(lpstrProtocol
, wCommand
);
1572 /* Remove File Protocol from lpFile */
1573 /* In the case file://path/file */
1574 if (!strncmpiW(lpFile
, wFile
, iSize
))
1577 while (*lpFile
== ':') lpFile
++;
1579 retval
= execute_from_key(lpstrProtocol
, lpFile
, NULL
, psei
->lpParameters
,
1580 wcmd
, execfunc
, psei
, psei_out
);
1581 HeapFree(GetProcessHeap(), 0, lpstrProtocol
);
1585 void do_error_dialog( UINT_PTR retval
, HWND hwnd
, WCHAR
* filename
)
1588 DWORD_PTR msgArguments
[3] = { (DWORD_PTR
)filename
, 0, 0 };
1591 error_code
= GetLastError();
1593 if (retval
== SE_ERR_NOASSOC
)
1594 LoadStringW(shell32_hInstance
, IDS_SHLEXEC_NOASSOC
, msg
, sizeof(msg
)/sizeof(WCHAR
));
1596 FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ARGUMENT_ARRAY
,
1601 sizeof(msg
)/sizeof(WCHAR
),
1602 (va_list*)msgArguments
);
1604 MessageBoxW(hwnd
, msg
, NULL
, MB_ICONERROR
);
1607 /*************************************************************************
1608 * SHELL_execute [Internal]
1610 BOOL
SHELL_execute( LPSHELLEXECUTEINFOW sei
, SHELL_ExecuteW32 execfunc
)
1612 static const WCHAR wSpace
[] = {' ',0};
1613 static const WCHAR wWww
[] = {'w','w','w',0};
1614 static const WCHAR wFile
[] = {'f','i','l','e',0};
1615 static const WCHAR wHttp
[] = {'h','t','t','p',':','/','/',0};
1616 static const DWORD unsupportedFlags
=
1617 SEE_MASK_INVOKEIDLIST
| SEE_MASK_ICON
| SEE_MASK_HOTKEY
|
1618 SEE_MASK_CONNECTNETDRV
| SEE_MASK_FLAG_DDEWAIT
|
1619 SEE_MASK_UNICODE
| SEE_MASK_ASYNCOK
| SEE_MASK_HMONITOR
;
1621 WCHAR parametersBuffer
[1024], dirBuffer
[MAX_PATH
], wcmdBuffer
[1024];
1622 WCHAR
*wszApplicationName
, *wszParameters
, *wszDir
, *wcmd
;
1623 DWORD dwApplicationNameLen
= MAX_PATH
+2;
1624 DWORD parametersLen
= sizeof(parametersBuffer
) / sizeof(WCHAR
);
1625 DWORD dirLen
= sizeof(dirBuffer
) / sizeof(WCHAR
);
1626 DWORD wcmdLen
= sizeof(wcmdBuffer
) / sizeof(WCHAR
);
1628 SHELLEXECUTEINFOW sei_tmp
; /* modifiable copy of SHELLEXECUTEINFO struct */
1629 WCHAR wfileName
[MAX_PATH
];
1631 WCHAR lpstrProtocol
[256];
1633 UINT_PTR retval
= SE_ERR_NOASSOC
;
1634 BOOL appKnownSingular
= FALSE
;
1636 /* make a local copy of the LPSHELLEXECUTEINFO structure and work with this from now on */
1639 TRACE("mask=0x%08x hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
1640 sei_tmp
.fMask
, sei_tmp
.hwnd
, debugstr_w(sei_tmp
.lpVerb
),
1641 debugstr_w(sei_tmp
.lpFile
), debugstr_w(sei_tmp
.lpParameters
),
1642 debugstr_w(sei_tmp
.lpDirectory
), sei_tmp
.nShow
,
1643 ((sei_tmp
.fMask
& SEE_MASK_CLASSALL
) == SEE_MASK_CLASSNAME
) ?
1644 debugstr_w(sei_tmp
.lpClass
) : "not used");
1646 sei
->hProcess
= NULL
;
1648 /* make copies of all path/command strings */
1649 if (!sei_tmp
.lpFile
)
1651 wszApplicationName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
*sizeof(WCHAR
));
1652 *wszApplicationName
= '\0';
1654 else if (*sei_tmp
.lpFile
== '\"')
1656 DWORD l
= strlenW(sei_tmp
.lpFile
+1);
1657 if(l
>= dwApplicationNameLen
)
1658 dwApplicationNameLen
= l
+1;
1660 wszApplicationName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
*sizeof(WCHAR
));
1661 memcpy(wszApplicationName
, sei_tmp
.lpFile
+1, (l
+1)*sizeof(WCHAR
));
1663 if (wszApplicationName
[l
-1] == '\"')
1664 wszApplicationName
[l
-1] = '\0';
1665 appKnownSingular
= TRUE
;
1667 TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName
));
1671 DWORD l
= strlenW(sei_tmp
.lpFile
)+1;
1672 if(l
> dwApplicationNameLen
) dwApplicationNameLen
= l
+1;
1673 wszApplicationName
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen
*sizeof(WCHAR
));
1674 memcpy(wszApplicationName
, sei_tmp
.lpFile
, l
*sizeof(WCHAR
));
1677 wszParameters
= parametersBuffer
;
1678 if (sei_tmp
.lpParameters
)
1680 len
= lstrlenW(sei_tmp
.lpParameters
) + 1;
1681 if (len
> parametersLen
)
1683 wszParameters
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1684 parametersLen
= len
;
1686 strcpyW(wszParameters
, sei_tmp
.lpParameters
);
1689 *wszParameters
= '\0';
1692 if (sei_tmp
.lpDirectory
)
1694 len
= lstrlenW(sei_tmp
.lpDirectory
) + 1;
1697 wszDir
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1700 strcpyW(wszDir
, sei_tmp
.lpDirectory
);
1705 /* adjust string pointers to point to the new buffers */
1706 sei_tmp
.lpFile
= wszApplicationName
;
1707 sei_tmp
.lpParameters
= wszParameters
;
1708 sei_tmp
.lpDirectory
= wszDir
;
1710 if (sei_tmp
.fMask
& unsupportedFlags
)
1712 FIXME("flags ignored: 0x%08x\n", sei_tmp
.fMask
& unsupportedFlags
);
1715 /* process the IDList */
1716 if (sei_tmp
.fMask
& SEE_MASK_IDLIST
)
1718 IShellExecuteHookW
* pSEH
;
1720 HRESULT hr
= SHBindToParent((LPCITEMIDLIST
)sei_tmp
.lpIDList
, IID_IShellExecuteHookW
, (LPVOID
*)&pSEH
, NULL
);
1724 hr
= pSEH
->Execute(&sei_tmp
);
1730 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1731 if (wszParameters
!= parametersBuffer
)
1732 HeapFree(GetProcessHeap(), 0, wszParameters
);
1733 if (wszDir
!= dirBuffer
)
1734 HeapFree(GetProcessHeap(), 0, wszDir
);
1739 SHGetPathFromIDListW((LPCITEMIDLIST
)sei_tmp
.lpIDList
, wszApplicationName
);
1740 appKnownSingular
= TRUE
;
1741 TRACE("-- idlist=%p (%s)\n", sei_tmp
.lpIDList
, debugstr_w(wszApplicationName
));
1744 if ( ERROR_SUCCESS
== ShellExecute_FromContextMenu( &sei_tmp
) )
1746 sei
->hInstApp
= (HINSTANCE
) 33;
1747 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1748 if (wszParameters
!= parametersBuffer
)
1749 HeapFree(GetProcessHeap(), 0, wszParameters
);
1750 if (wszDir
!= dirBuffer
)
1751 HeapFree(GetProcessHeap(), 0, wszDir
);
1755 if (sei_tmp
.fMask
& SEE_MASK_CLASSALL
)
1757 retval
= SHELL_execute_class( wszApplicationName
, &sei_tmp
, sei
,
1759 if (retval
<= 32 && !(sei_tmp
.fMask
& SEE_MASK_FLAG_NO_UI
))
1766 Info
.pcszFile
= wszApplicationName
;
1767 Info
.pcszClass
= NULL
;
1768 Info
.oaifInFlags
= OAIF_ALLOW_REGISTRATION
| OAIF_EXEC
;
1770 //if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK)
1771 do_error_dialog(retval
, sei_tmp
.hwnd
, wszApplicationName
);
1773 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1774 if (wszParameters
!= parametersBuffer
)
1775 HeapFree(GetProcessHeap(), 0, wszParameters
);
1776 if (wszDir
!= dirBuffer
)
1777 HeapFree(GetProcessHeap(), 0, wszDir
);
1781 /* Has the IDList not yet been translated? */
1782 if (sei_tmp
.fMask
& SEE_MASK_IDLIST
)
1784 appKnownSingular
= SHELL_translate_idlist( &sei_tmp
, wszParameters
,
1787 dwApplicationNameLen
);
1790 /* expand environment strings */
1791 len
= ExpandEnvironmentStringsW(sei_tmp
.lpFile
, NULL
, 0);
1795 buf
= (LPWSTR
)HeapAlloc(GetProcessHeap(),0,(len
+1)*sizeof(WCHAR
));
1797 ExpandEnvironmentStringsW(sei_tmp
.lpFile
, buf
, len
+1);
1798 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1799 dwApplicationNameLen
= len
+1;
1800 wszApplicationName
= buf
;
1801 /* appKnownSingular unmodified */
1803 sei_tmp
.lpFile
= wszApplicationName
;
1806 if (*sei_tmp
.lpParameters
)
1808 len
= ExpandEnvironmentStringsW(sei_tmp
.lpParameters
, NULL
, 0);
1813 buf
= (LPWSTR
)HeapAlloc(GetProcessHeap(),0,len
*sizeof(WCHAR
));
1814 ExpandEnvironmentStringsW(sei_tmp
.lpParameters
, buf
, len
);
1815 if (wszParameters
!= parametersBuffer
)
1816 HeapFree(GetProcessHeap(), 0, wszParameters
);
1817 wszParameters
= buf
;
1818 parametersLen
= len
;
1819 sei_tmp
.lpParameters
= wszParameters
;
1823 if (*sei_tmp
.lpDirectory
)
1825 len
= ExpandEnvironmentStringsW(sei_tmp
.lpDirectory
, NULL
, 0);
1830 buf
= (LPWSTR
)HeapAlloc(GetProcessHeap(),0,len
*sizeof(WCHAR
));
1831 ExpandEnvironmentStringsW(sei_tmp
.lpDirectory
, buf
, len
);
1832 if (wszDir
!= dirBuffer
)
1833 HeapFree(GetProcessHeap(), 0, wszDir
);
1835 sei_tmp
.lpDirectory
= wszDir
;
1839 /* Else, try to execute the filename */
1840 TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName
), debugstr_w(wszParameters
), debugstr_w(wszDir
));
1842 /* separate out command line arguments from executable file name */
1843 if (!*sei_tmp
.lpParameters
&& !appKnownSingular
)
1845 /* If the executable path is quoted, handle the rest of the command line as parameters. */
1846 if (sei_tmp
.lpFile
[0] == '"')
1848 LPWSTR src
= wszApplicationName
/*sei_tmp.lpFile*/ + 1;
1849 LPWSTR dst
= wfileName
;
1852 /* copy the unquoted executable path to 'wfileName' */
1853 while(*src
&& *src
!='"')
1862 while(isspace(*src
))
1868 /* copy the parameter string to 'wszParameters' */
1869 strcpyW(wszParameters
, src
);
1871 /* terminate previous command string after the quote character */
1876 /* If the executable name is not quoted, we have to use this search loop here,
1877 that in CreateProcess() is not sufficient because it does not handle shell links. */
1878 WCHAR buffer
[MAX_PATH
], xlpFile
[MAX_PATH
];
1881 LPWSTR beg
= wszApplicationName
/*sei_tmp.lpFile*/;
1882 for(s
=beg
; (space
= const_cast<LPWSTR
>(strchrW(s
, ' '))); s
=space
+1)
1884 int idx
= space
-sei_tmp
.lpFile
;
1885 memcpy(buffer
, sei_tmp
.lpFile
, idx
* sizeof(WCHAR
));
1888 /*FIXME This finds directory paths if the targeted file name contains spaces. */
1889 if (SearchPathW(*sei_tmp
.lpDirectory
? sei_tmp
.lpDirectory
: NULL
, buffer
, wszExe
, sizeof(xlpFile
)/sizeof(xlpFile
[0]), xlpFile
, NULL
))
1891 /* separate out command from parameter string */
1892 LPCWSTR p
= space
+ 1;
1897 strcpyW(wszParameters
, p
);
1904 lstrcpynW(wfileName
, sei_tmp
.lpFile
,sizeof(wfileName
)/sizeof(WCHAR
));
1908 lstrcpynW(wfileName
, sei_tmp
.lpFile
,sizeof(wfileName
)/sizeof(WCHAR
));
1913 len
= lstrlenW(wszApplicationName
) + 1;
1914 if (sei_tmp
.lpParameters
[0])
1915 len
+= 1 + lstrlenW(wszParameters
);
1918 wcmd
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
1921 strcpyW(wcmd
, wszApplicationName
);
1922 if (sei_tmp
.lpParameters
[0])
1924 strcatW(wcmd
, wSpace
);
1925 strcatW(wcmd
, wszParameters
);
1928 retval
= execfunc(wcmd
, NULL
, FALSE
, &sei_tmp
, sei
);
1931 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
1932 if (wszParameters
!= parametersBuffer
)
1933 HeapFree(GetProcessHeap(), 0, wszParameters
);
1934 if (wszDir
!= dirBuffer
)
1935 HeapFree(GetProcessHeap(), 0, wszDir
);
1936 if (wcmd
!= wcmdBuffer
)
1937 HeapFree(GetProcessHeap(), 0, wcmd
);
1941 /* Else, try to find the executable */
1943 retval
= SHELL_FindExecutable(sei_tmp
.lpDirectory
, lpFile
, sei_tmp
.lpVerb
, wcmd
, wcmdLen
, lpstrProtocol
, &env
, (LPITEMIDLIST
)sei_tmp
.lpIDList
, sei_tmp
.lpParameters
);
1944 if (retval
> 32) /* Found */
1946 retval
= SHELL_quote_and_execute( wcmd
, wszParameters
, lpstrProtocol
,
1947 wszApplicationName
, env
, &sei_tmp
,
1949 HeapFree( GetProcessHeap(), 0, env
);
1951 else if (PathIsDirectoryW(lpFile
))
1953 static const WCHAR wExplorer
[] = {'e','x','p','l','o','r','e','r',0};
1954 static const WCHAR wQuote
[] = {'"',0};
1955 WCHAR wExec
[MAX_PATH
];
1956 WCHAR
* lpQuotedFile
= (LPWSTR
)HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR
) * (strlenW(lpFile
) + 3) );
1960 retval
= SHELL_FindExecutable( sei_tmp
.lpDirectory
, wExplorer
,
1961 wszOpen
, wExec
, MAX_PATH
,
1962 NULL
, &env
, NULL
, NULL
);
1965 strcpyW(lpQuotedFile
, wQuote
);
1966 strcatW(lpQuotedFile
, lpFile
);
1967 strcatW(lpQuotedFile
, wQuote
);
1968 retval
= SHELL_quote_and_execute( wExec
, lpQuotedFile
,
1970 wszApplicationName
, env
,
1971 &sei_tmp
, sei
, execfunc
);
1972 HeapFree( GetProcessHeap(), 0, env
);
1974 HeapFree( GetProcessHeap(), 0, lpQuotedFile
);
1977 retval
= 0; /* Out of memory */
1979 else if (PathIsURLW(lpFile
)) /* File not found, check for URL */
1981 retval
= SHELL_execute_url( lpFile
, wFile
, wcmd
, &sei_tmp
, sei
, execfunc
);
1983 /* Check if file specified is in the form www.??????.*** */
1984 else if (!strncmpiW(lpFile
, wWww
, 3))
1986 /* if so, append lpFile http:// and call ShellExecute */
1987 WCHAR lpstrTmpFile
[256];
1988 strcpyW(lpstrTmpFile
, wHttp
);
1989 strcatW(lpstrTmpFile
, lpFile
);
1990 retval
= (UINT_PTR
)ShellExecuteW(sei_tmp
.hwnd
, sei_tmp
.lpVerb
, lpstrTmpFile
, NULL
, NULL
, 0);
1993 TRACE("retval %lu\n", retval
);
1995 if (retval
<= 32 && !(sei_tmp
.fMask
& SEE_MASK_FLAG_NO_UI
))
2002 Info
.pcszFile
= wszApplicationName
;
2003 Info
.pcszClass
= NULL
;
2004 Info
.oaifInFlags
= OAIF_ALLOW_REGISTRATION
| OAIF_EXEC
;
2006 //if (SHOpenWithDialog(sei_tmp.hwnd, &Info) != S_OK)
2007 do_error_dialog(retval
, sei_tmp
.hwnd
, wszApplicationName
);
2010 HeapFree(GetProcessHeap(), 0, wszApplicationName
);
2011 if (wszParameters
!= parametersBuffer
)
2012 HeapFree(GetProcessHeap(), 0, wszParameters
);
2013 if (wszDir
!= dirBuffer
)
2014 HeapFree(GetProcessHeap(), 0, wszDir
);
2015 if (wcmd
!= wcmdBuffer
)
2016 HeapFree(GetProcessHeap(), 0, wcmd
);
2018 sei
->hInstApp
= (HINSTANCE
)(retval
> 32 ? 33 : retval
);
2023 /*************************************************************************
2024 * ShellExecuteA [SHELL32.290]
2026 HINSTANCE WINAPI
ShellExecuteA(HWND hWnd
, LPCSTR lpOperation
,LPCSTR lpFile
,
2027 LPCSTR lpParameters
,LPCSTR lpDirectory
, INT iShowCmd
)
2029 SHELLEXECUTEINFOA sei
;
2031 TRACE("%p,%s,%s,%s,%s,%d\n",
2032 hWnd
, debugstr_a(lpOperation
), debugstr_a(lpFile
),
2033 debugstr_a(lpParameters
), debugstr_a(lpDirectory
), iShowCmd
);
2035 sei
.cbSize
= sizeof(sei
);
2036 sei
.fMask
= SEE_MASK_FLAG_NO_UI
;
2038 sei
.lpVerb
= lpOperation
;
2039 sei
.lpFile
= lpFile
;
2040 sei
.lpParameters
= lpParameters
;
2041 sei
.lpDirectory
= lpDirectory
;
2042 sei
.nShow
= iShowCmd
;
2049 ShellExecuteExA (&sei
);
2050 return sei
.hInstApp
;
2053 /*************************************************************************
2054 * ShellExecuteExA [SHELL32.292]
2057 BOOL WINAPI
ShellExecuteExA (LPSHELLEXECUTEINFOA sei
)
2059 SHELLEXECUTEINFOW seiW
;
2061 WCHAR
*wVerb
= NULL
, *wFile
= NULL
, *wParameters
= NULL
, *wDirectory
= NULL
, *wClass
= NULL
;
2065 memcpy(&seiW
, sei
, sizeof(SHELLEXECUTEINFOW
));
2068 seiW
.lpVerb
= __SHCloneStrAtoW(&wVerb
, sei
->lpVerb
);
2071 seiW
.lpFile
= __SHCloneStrAtoW(&wFile
, sei
->lpFile
);
2073 if (sei
->lpParameters
)
2074 seiW
.lpParameters
= __SHCloneStrAtoW(&wParameters
, sei
->lpParameters
);
2076 if (sei
->lpDirectory
)
2077 seiW
.lpDirectory
= __SHCloneStrAtoW(&wDirectory
, sei
->lpDirectory
);
2079 if ((sei
->fMask
& SEE_MASK_CLASSALL
) == SEE_MASK_CLASSNAME
&& sei
->lpClass
)
2080 seiW
.lpClass
= __SHCloneStrAtoW(&wClass
, sei
->lpClass
);
2082 seiW
.lpClass
= NULL
;
2084 ret
= SHELL_execute( &seiW
, SHELL_ExecuteW
);
2086 sei
->hInstApp
= seiW
.hInstApp
;
2088 if (sei
->fMask
& SEE_MASK_NOCLOSEPROCESS
)
2089 sei
->hProcess
= seiW
.hProcess
;
2093 SHFree(wParameters
);
2100 /*************************************************************************
2101 * ShellExecuteExW [SHELL32.293]
2104 BOOL WINAPI
ShellExecuteExW (LPSHELLEXECUTEINFOW sei
)
2106 return SHELL_execute( sei
, SHELL_ExecuteW
);
2109 /*************************************************************************
2110 * ShellExecuteW [SHELL32.294]
2112 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
2113 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
2115 HINSTANCE WINAPI
ShellExecuteW(HWND hwnd
, LPCWSTR lpOperation
, LPCWSTR lpFile
,
2116 LPCWSTR lpParameters
, LPCWSTR lpDirectory
, INT nShowCmd
)
2118 SHELLEXECUTEINFOW sei
;
2121 sei
.cbSize
= sizeof(sei
);
2122 sei
.fMask
= SEE_MASK_FLAG_NO_UI
;
2124 sei
.lpVerb
= lpOperation
;
2125 sei
.lpFile
= lpFile
;
2126 sei
.lpParameters
= lpParameters
;
2127 sei
.lpDirectory
= lpDirectory
;
2128 sei
.nShow
= nShowCmd
;
2135 SHELL_execute( &sei
, SHELL_ExecuteW
);
2136 return sei
.hInstApp
;
2139 /*************************************************************************
2140 * WOWShellExecute [SHELL32.@]
2142 * FIXME: the callback function most likely doesn't work the same way on Windows.
2144 EXTERN_C HINSTANCE WINAPI
WOWShellExecute(HWND hWnd
, LPCSTR lpOperation
,LPCSTR lpFile
,
2145 LPCSTR lpParameters
,LPCSTR lpDirectory
, INT iShowCmd
, void *callback
)
2147 SHELLEXECUTEINFOW seiW
;
2148 WCHAR
*wVerb
= NULL
, *wFile
= NULL
, *wParameters
= NULL
, *wDirectory
= NULL
;
2149 HANDLE hProcess
= 0;
2151 seiW
.lpVerb
= lpOperation
? __SHCloneStrAtoW(&wVerb
, lpOperation
) : NULL
;
2152 seiW
.lpFile
= lpFile
? __SHCloneStrAtoW(&wFile
, lpFile
) : NULL
;
2153 seiW
.lpParameters
= lpParameters
? __SHCloneStrAtoW(&wParameters
, lpParameters
) : NULL
;
2154 seiW
.lpDirectory
= lpDirectory
? __SHCloneStrAtoW(&wDirectory
, lpDirectory
) : NULL
;
2156 seiW
.cbSize
= sizeof(seiW
);
2159 seiW
.nShow
= iShowCmd
;
2164 seiW
.hProcess
= hProcess
;
2166 SHELL_execute( &seiW
, (SHELL_ExecuteW32
)callback
);
2170 SHFree(wParameters
);
2172 return seiW
.hInstApp
;
2175 /*************************************************************************
2176 * OpenAs_RunDLLA [SHELL32.@]
2178 EXTERN_C
void WINAPI
OpenAs_RunDLLA(HWND hwnd
, HINSTANCE hinst
, LPCSTR cmdline
, int cmdshow
)
2180 FIXME("%p, %p, %s, %d\n", hwnd
, hinst
, debugstr_a(cmdline
), cmdshow
);
2183 /*************************************************************************
2184 * OpenAs_RunDLLW [SHELL32.@]
2186 EXTERN_C
void WINAPI
OpenAs_RunDLLW(HWND hwnd
, HINSTANCE hinst
, LPCWSTR cmdline
, int cmdshow
)
2188 FIXME("%p, %p, %s, %d\n", hwnd
, hinst
, debugstr_w(cmdline
), cmdshow
);