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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
49 #include "wine/winbase16.h"
50 #include "shell32_main.h"
51 #include "undocshell.h"
54 #include "wine/debug.h"
56 WINE_DEFAULT_DEBUG_CHANNEL(exec
);
58 static const WCHAR wszOpen
[] = {'o','p','e','n',0};
59 static const WCHAR wszExe
[] = {'.','e','x','e',0};
60 static const WCHAR wszILPtr
[] = {':','%','p',0};
61 static const WCHAR wszShell
[] = {'\\','s','h','e','l','l','\\',0};
62 static const WCHAR wszFolder
[] = {'F','o','l','d','e','r',0};
63 static const WCHAR wszEmpty
[] = {0};
66 /***********************************************************************
67 * SHELL_ArgifyW [Internal]
69 * this function is supposed to expand the escape sequences found in the registry
70 * some diving reported that the following were used:
71 * + %1, %2... seem to report to parameter of index N in ShellExecute pmts
76 * %I address of a global item ID (explorer switch /idlist)
77 * %L seems to be %1 as long filename followed by the 8+3 variation
79 * %* all following parameters (see batfile)
82 * FIXME: Careful of going over string boundaries. No checking is done to 'res'...
84 static BOOL
SHELL_ArgifyW(WCHAR
* out
, int len
, const WCHAR
* fmt
, const WCHAR
* lpFile
, LPITEMIDLIST pidl
, LPCWSTR args
)
92 TRACE("%p, %d, %s, %s, %p, %p\n", out
, len
, debugstr_w(fmt
),
93 debugstr_w(lpFile
), pidl
, args
);
127 while(*args
&& !isspace(*args
))
130 while(isspace(*args
))
135 /* else fall through */
137 if (!done
|| (*fmt
== '1'))
139 /*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */
140 if (SearchPathW(NULL
, lpFile
, wszExe
, sizeof(xlpFile
)/sizeof(WCHAR
), xlpFile
, NULL
))
145 /* Add double quotation marks unless we already have them (e.g.: "file://%1" %* for exefile) */
146 if (res
== out
|| *(fmt
+ 1) != '"')
162 * IE uses this a lot for activating things such as windows media
163 * player. This is not verified to be fully correct but it appears
169 strcpyW(res
, lpFile
);
170 res
+= strlenW(lpFile
);
177 HGLOBAL hmem
= SHAllocShared(pidl
, ILGetSize(pidl
), 0);
178 pv
= SHLockShared(hmem
, 0);
179 res
+= sprintfW(res
, wszILPtr
, pv
);
186 * Check if this is a env-variable here...
189 /* Make sure that we have at least one more %.*/
190 if (strchrW(fmt
, '%'))
192 WCHAR tmpBuffer
[1024];
193 PWSTR tmpB
= tmpBuffer
;
194 WCHAR tmpEnvBuff
[MAX_PATH
];
201 TRACE("Checking %s to be a env-var\n", debugstr_w(tmpBuffer
));
203 envRet
= GetEnvironmentVariableW(tmpBuffer
, tmpEnvBuff
, MAX_PATH
);
204 if (envRet
== 0 || envRet
> MAX_PATH
)
205 strcpyW( res
, tmpBuffer
);
207 strcpyW( res
, tmpEnvBuff
);
224 HRESULT
SHELL_GetPathFromIDListForExecuteA(LPCITEMIDLIST pidl
, LPSTR pszPath
, UINT uOutSize
)
227 IShellFolder
* desktop
;
229 HRESULT hr
= SHGetDesktopFolder(&desktop
);
232 hr
= IShellFolder_GetDisplayNameOf(desktop
, pidl
, SHGDN_FORPARSING
, &strret
);
235 StrRetToStrNA(pszPath
, uOutSize
, &strret
, pidl
);
237 IShellFolder_Release(desktop
);
243 HRESULT
SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl
, LPWSTR pszPath
, UINT uOutSize
)
246 IShellFolder
* desktop
;
248 HRESULT hr
= SHGetDesktopFolder(&desktop
);
251 hr
= IShellFolder_GetDisplayNameOf(desktop
, pidl
, SHGDN_FORPARSING
, &strret
);
254 StrRetToStrNW(pszPath
, uOutSize
, &strret
, pidl
);
256 IShellFolder_Release(desktop
);
262 /*************************************************************************
263 * SHELL_ResolveShortCutW [Internal]
264 * read shortcut file at 'wcmd'
266 static HRESULT
SHELL_ResolveShortCutW(LPWSTR wcmd
, LPWSTR wargs
, LPWSTR wdir
, HWND hwnd
, LPCWSTR lpVerb
, int* pshowcmd
, LPITEMIDLIST
* ppidl
)
270 HRESULT hr
= SHGetDesktopFolder(&psf
);
278 hr
= IShellFolder_ParseDisplayName(psf
, 0, 0, wcmd
, &l
, &pidl
, 0);
283 hr
= IShellFolder_GetUIObjectOf(psf
, NULL
, 1, (LPCITEMIDLIST
*)&pidl
, &IID_IShellLinkW
, NULL
, (LPVOID
*)&psl
);
286 hr
= IShellLinkW_Resolve(psl
, hwnd
, 0);
289 hr
= IShellLinkW_GetPath(psl
, wcmd
, MAX_PATH
, NULL
, SLGP_UNCPRIORITY
);
293 /* We could not translate the PIDL in the shell link into a valid file system path - so return the PIDL instead. */
294 hr
= IShellLinkW_GetIDList(psl
, ppidl
);
296 if (SUCCEEDED(hr
) && *ppidl
) {
297 /* We got a PIDL instead of a file system path - try to translate it. */
298 if (SUCCEEDED(SHELL_GetPathFromIDListW(*ppidl
, wcmd
, MAX_PATH
))) {
306 /* get command line arguments, working directory and display mode if available */
307 IShellLinkW_GetWorkingDirectory(psl
, wdir
, MAX_PATH
);
308 IShellLinkW_GetArguments(psl
, wargs
, MAX_PATH
);
309 IShellLinkW_GetShowCmd(psl
, pshowcmd
);
314 IShellLinkW_Release(psl
);
320 IShellFolder_Release(psf
);
326 /*************************************************************************
327 * SHELL_ExecuteW [Internal]
330 static UINT
SHELL_ExecuteW(const WCHAR
*lpCmd
, WCHAR
*env
, BOOL shWait
,
331 LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
)
333 STARTUPINFOW startup
;
334 PROCESS_INFORMATION info
;
337 WCHAR curdir
[MAX_PATH
];
339 TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd
), debugstr_w(psei
->lpDirectory
));
340 /* ShellExecute specifies the command from psei->lpDirectory
341 * if present. Not from the current dir as CreateProcess does */
342 if( psei
->lpDirectory
&& psei
->lpDirectory
[0] )
343 if( ( gcdret
= GetCurrentDirectoryW( MAX_PATH
, curdir
)))
344 if( !SetCurrentDirectoryW( psei
->lpDirectory
))
345 ERR("cannot set directory %s\n", debugstr_w(psei
->lpDirectory
));
346 ZeroMemory(&startup
,sizeof(STARTUPINFOW
));
347 startup
.cb
= sizeof(STARTUPINFOW
);
348 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
349 startup
.wShowWindow
= psei
->nShow
;
350 if (CreateProcessW(NULL
, (LPWSTR
)lpCmd
, NULL
, NULL
, FALSE
, CREATE_UNICODE_ENVIRONMENT
,
351 env
, *psei
->lpDirectory
? psei
->lpDirectory
: NULL
, &startup
, &info
))
353 /* Give 30 seconds to the app to come up, if desired. Probably only needed
354 when starting app immediately before making a DDE connection. */
356 if (WaitForInputIdle( info
.hProcess
, 30000 ) == WAIT_FAILED
)
357 WARN("WaitForInputIdle failed: Error %ld\n", GetLastError() );
359 if (psei
->fMask
& SEE_MASK_NOCLOSEPROCESS
)
360 psei_out
->hProcess
= info
.hProcess
;
362 CloseHandle( info
.hProcess
);
363 CloseHandle( info
.hThread
);
365 else if ((retval
= GetLastError()) >= 32)
367 FIXME("Strange error set by CreateProcess: %d\n", retval
);
368 retval
= ERROR_BAD_FORMAT
;
371 TRACE("returning %u\n", retval
);
373 psei_out
->hInstApp
= (HINSTANCE
)retval
;
375 if( !SetCurrentDirectoryW( curdir
))
376 ERR("cannot return to directory %s\n", debugstr_w(curdir
));
382 /***********************************************************************
383 * SHELL_BuildEnvW [Internal]
385 * Build the environment for the new process, adding the specified
386 * path to the PATH variable. Returned pointer must be freed by caller.
388 static void *SHELL_BuildEnvW( const WCHAR
*path
)
390 static const WCHAR wPath
[] = {'P','A','T','H','=',0};
391 WCHAR
*strings
, *new_env
;
393 int total
= strlenW(path
) + 1;
394 BOOL got_path
= FALSE
;
396 if (!(strings
= GetEnvironmentStringsW())) return NULL
;
400 int len
= strlenW(p
) + 1;
401 if (!strncmpiW( p
, wPath
, 5 )) got_path
= TRUE
;
405 if (!got_path
) total
+= 5; /* we need to create PATH */
406 total
++; /* terminating null */
408 if (!(new_env
= HeapAlloc( GetProcessHeap(), 0, total
* sizeof(WCHAR
) )))
410 FreeEnvironmentStringsW( strings
);
417 int len
= strlenW(p
) + 1;
418 memcpy( p2
, p
, len
* sizeof(WCHAR
) );
419 if (!strncmpiW( p
, wPath
, 5 ))
422 strcpyW( p2
+ len
, path
);
423 p2
+= strlenW(path
) + 1;
430 strcpyW( p2
, wPath
);
432 p2
+= strlenW(p2
) + 1;
435 FreeEnvironmentStringsW( strings
);
440 /***********************************************************************
441 * SHELL_TryAppPathW [Internal]
443 * Helper function for SHELL_FindExecutable
444 * @param lpResult - pointer to a buffer of size MAX_PATH
445 * On entry: szName is a filename (probably without path separators).
446 * On exit: if szName found in "App Path", place full path in lpResult, and return true
448 static BOOL
SHELL_TryAppPathW( LPCWSTR szName
, LPWSTR lpResult
, WCHAR
**env
)
450 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',
451 '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','A','p','p',' ','P','a','t','h','s','\\',0};
452 static const WCHAR wPath
[] = {'P','a','t','h',0};
459 if (env
) *env
= NULL
;
460 strcpyW(buffer
, wszKeyAppPaths
);
461 strcatW(buffer
, szName
);
462 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, buffer
, 0, KEY_READ
, &hkApp
);
465 len
= MAX_PATH
*sizeof(WCHAR
);
466 res
= RegQueryValueW(hkApp
, NULL
, lpResult
, &len
);
472 DWORD count
= sizeof(buffer
);
473 if (!RegQueryValueExW(hkApp
, wPath
, NULL
, NULL
, (LPBYTE
)buffer
, &count
) && buffer
[0])
474 *env
= SHELL_BuildEnvW( buffer
);
478 if (hkApp
) RegCloseKey(hkApp
);
482 static UINT
SHELL_FindExecutableByOperation(LPCWSTR lpPath
, LPCWSTR lpFile
, LPCWSTR lpOperation
, LPWSTR key
, LPWSTR filetype
, LPWSTR command
, LONG commandlen
)
484 static const WCHAR wCommand
[] = {'\\','c','o','m','m','a','n','d',0};
486 /* Looking for ...buffer\shell\<verb>\command */
487 strcatW(filetype
, wszShell
);
488 strcatW(filetype
, lpOperation
);
489 strcatW(filetype
, wCommand
);
491 if (RegQueryValueW(HKEY_CLASSES_ROOT
, filetype
, command
,
492 &commandlen
) == ERROR_SUCCESS
)
494 commandlen
/= sizeof(WCHAR
);
495 if (key
) strcpyW(key
, filetype
);
499 LONG paramlen
= sizeof(param
);
500 static const WCHAR wSpace
[] = {' ',0};
502 /* FIXME: it seems all Windows version don't behave the same here.
503 * the doc states that this ddeexec information can be found after
505 * on Win98, it doesn't appear, but I think it does on Win2k
507 /* Get the parameters needed by the application
508 from the associated ddeexec key */
509 tmp
= strstrW(filetype
, wCommand
);
511 strcatW(filetype
, wDdeexec
);
512 if (RegQueryValueW(HKEY_CLASSES_ROOT
, filetype
, param
,
513 ¶mlen
) == ERROR_SUCCESS
)
515 paramlen
/= sizeof(WCHAR
);
516 strcatW(command
, wSpace
);
517 strcatW(command
, param
);
518 commandlen
+= paramlen
;
522 command
[commandlen
] = '\0';
524 return 33; /* FIXME see SHELL_FindExecutable() */
527 return 31; /* default - 'No association was found' */
530 /*************************************************************************
531 * SHELL_FindExecutable [Internal]
533 * Utility for code sharing between FindExecutable and ShellExecute
535 * lpFile the name of a file
536 * lpOperation the operation on it (open)
538 * lpResult a buffer, big enough :-(, to store the command to do the
539 * operation on the file
540 * key a buffer, big enough, to get the key name to do actually the
541 * command (it'll be used afterwards for more information
544 UINT
SHELL_FindExecutable(LPCWSTR lpPath
, LPCWSTR lpFile
, LPCWSTR lpOperation
,
545 LPWSTR lpResult
, int resultLen
, LPWSTR key
, WCHAR
**env
, LPITEMIDLIST pidl
, LPCWSTR args
)
547 static const WCHAR wWindows
[] = {'w','i','n','d','o','w','s',0};
548 static const WCHAR wPrograms
[] = {'p','r','o','g','r','a','m','s',0};
549 static const WCHAR wExtensions
[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
550 WCHAR
*extension
= NULL
; /* pointer to file extension */
551 WCHAR filetype
[256]; /* registry name for this filetype */
552 LONG filetypelen
= sizeof(filetype
); /* length of above */
553 WCHAR command
[1024]; /* command from registry */
554 WCHAR wBuffer
[256]; /* Used to GetProfileString */
555 UINT retval
= 31; /* default - 'No association was found' */
556 WCHAR
*tok
; /* token pointer */
557 WCHAR xlpFile
[256]; /* result of SearchPath */
558 DWORD attribs
; /* file attributes */
560 TRACE("%s\n", (lpFile
!= NULL
) ? debugstr_w(lpFile
) : "-");
563 lpResult
[0] = '\0'; /* Start off with an empty return string */
564 if (key
) *key
= '\0';
566 /* trap NULL parameters on entry */
567 if ((lpFile
== NULL
) || (lpResult
== NULL
) || (lpOperation
== NULL
))
569 WARN("(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
570 debugstr_w(lpFile
), debugstr_w(lpOperation
), debugstr_w(lpResult
));
571 return 2; /* File not found. Close enough, I guess. */
574 if (SHELL_TryAppPathW( lpFile
, lpResult
, env
))
576 TRACE("found %s via App Paths\n", debugstr_w(lpResult
));
580 if (SearchPathW(lpPath
, lpFile
, wszExe
, sizeof(xlpFile
)/sizeof(WCHAR
), xlpFile
, NULL
))
582 TRACE("SearchPathW returned non-zero\n");
584 /* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
587 attribs
= GetFileAttributesW(lpFile
);
588 if (attribs
!=INVALID_FILE_ATTRIBUTES
&& (attribs
&FILE_ATTRIBUTE_DIRECTORY
))
590 strcpyW(filetype
, wszFolder
);
591 filetypelen
= 6; /* strlen("Folder") */
595 /* First thing we need is the file's extension */
596 extension
= strrchrW(xlpFile
, '.'); /* Assume last "." is the one; */
597 /* File->Run in progman uses */
599 TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile
), debugstr_w(extension
));
601 if (extension
== NULL
|| extension
[1]==0)
603 WARN("Returning 31 - No association\n");
604 return 31; /* no association */
607 /* Three places to check: */
608 /* 1. win.ini, [windows], programs (NB no leading '.') */
609 /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
610 /* 3. win.ini, [extensions], extension (NB no leading '.' */
611 /* All I know of the order is that registry is checked before */
612 /* extensions; however, it'd make sense to check the programs */
613 /* section first, so that's what happens here. */
615 /* See if it's a program - if GetProfileString fails, we skip this
616 * section. Actually, if GetProfileString fails, we've probably
617 * got a lot more to worry about than running a program... */
618 if (GetProfileStringW(wWindows
, wPrograms
, wExtensions
, wBuffer
, sizeof(wBuffer
)/sizeof(WCHAR
)) > 0)
625 while (*p
&& *p
!= ' ' && *p
!= '\t') p
++;
629 while (*p
== ' ' || *p
== '\t') p
++;
632 if (strcmpiW(tok
, &extension
[1]) == 0) /* have to skip the leading "." */
634 strcpyW(lpResult
, xlpFile
);
635 /* Need to perhaps check that the file has a path
637 TRACE("found %s\n", debugstr_w(lpResult
));
640 /* Greater than 32 to indicate success FIXME According to the
641 * docs, I should be returning a handle for the
642 * executable. Does this mean I'm supposed to open the
643 * executable file or something? More RTFM, I guess... */
650 if (RegQueryValueW(HKEY_CLASSES_ROOT
, extension
, filetype
,
651 &filetypelen
) == ERROR_SUCCESS
)
653 filetypelen
/= sizeof(WCHAR
);
654 filetype
[filetypelen
] = '\0';
655 TRACE("File type: %s\n", debugstr_w(filetype
));
663 /* pass the operation string to SHELL_FindExecutableByOperation() */
664 filetype
[filetypelen
] = '\0';
665 retval
= SHELL_FindExecutableByOperation(lpPath
, lpFile
, lpOperation
, key
, filetype
, command
, sizeof(command
));
669 WCHAR operation
[MAX_PATH
];
672 /* Looking for ...buffer\shell\<operation>\command */
673 strcatW(filetype
, wszShell
);
675 /* enumerate the operation subkeys in the registry and search for one with an associated command */
676 if (RegOpenKeyW(HKEY_CLASSES_ROOT
, filetype
, &hkey
) == ERROR_SUCCESS
)
681 if (RegEnumKeyW(hkey
, idx
, operation
, MAX_PATH
) != ERROR_SUCCESS
)
684 filetype
[filetypelen
] = '\0';
685 retval
= SHELL_FindExecutableByOperation(lpPath
, lpFile
, operation
, key
, filetype
, command
, sizeof(command
));
696 SHELL_ArgifyW(lpResult
, resultLen
, command
, xlpFile
, pidl
, args
);
698 /* Remove double quotation marks and command line arguments */
699 if (*lpResult
== '"')
702 while (*(p
+ 1) != '"')
711 else /* Check win.ini */
713 static const WCHAR wExtensions
[] = {'e','x','t','e','n','s','i','o','n','s',0};
715 /* Toss the leading dot */
717 if (GetProfileStringW(wExtensions
, extension
, wszEmpty
, command
, sizeof(command
)/sizeof(WCHAR
)) > 0)
719 if (strlenW(command
) != 0)
721 strcpyW(lpResult
, command
);
722 tok
= strchrW(lpResult
, '^'); /* should be ^.extension? */
726 strcatW(lpResult
, xlpFile
); /* what if no dir in xlpFile? */
727 tok
= strchrW(command
, '^'); /* see above */
728 if ((tok
!= NULL
) && (strlenW(tok
)>5))
730 strcatW(lpResult
, &tok
[5]);
733 retval
= 33; /* FIXME - see above */
738 TRACE("returning %s\n", debugstr_w(lpResult
));
742 /******************************************************************
745 * callback for the DDE connection. not really usefull
747 static HDDEDATA CALLBACK
dde_cb(UINT uType
, UINT uFmt
, HCONV hConv
,
748 HSZ hsz1
, HSZ hsz2
, HDDEDATA hData
,
749 ULONG_PTR dwData1
, ULONG_PTR dwData2
)
751 TRACE("dde_cb: %04x, %04x, %p, %p, %p, %p, %08lx, %08lx\n",
752 uType
, uFmt
, hConv
, hsz1
, hsz2
, hData
, dwData1
, dwData2
);
756 /******************************************************************
759 * ShellExecute helper. Used to do an operation with a DDE connection
761 * Handles both the direct connection (try #1), and if it fails,
762 * launching an application and trying (#2) to connect to it
765 static unsigned dde_connect(WCHAR
* key
, WCHAR
* start
, WCHAR
* ddeexec
,
766 const WCHAR
* lpFile
, WCHAR
*env
,
767 LPCWSTR szCommandline
, LPITEMIDLIST pidl
, SHELL_ExecuteW32 execfunc
,
768 LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
)
770 static const WCHAR wApplication
[] = {'\\','a','p','p','l','i','c','a','t','i','o','n',0};
771 static const WCHAR wTopic
[] = {'\\','t','o','p','i','c',0};
772 WCHAR
* endkey
= key
+ strlenW(key
);
773 WCHAR app
[256], topic
[256], ifexec
[256], res
[256];
774 LONG applen
, topiclen
, ifexeclen
;
778 HSZ hszApp
, hszTopic
;
783 strcpyW(endkey
, wApplication
);
784 applen
= sizeof(app
);
785 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, app
, &applen
) != ERROR_SUCCESS
)
787 FIXME("default app name NIY %s\n", debugstr_w(key
));
791 strcpyW(endkey
, wTopic
);
792 topiclen
= sizeof(topic
);
793 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, topic
, &topiclen
) != ERROR_SUCCESS
)
795 static const WCHAR wSystem
[] = {'S','y','s','t','e','m',0};
796 strcpyW(topic
, wSystem
);
799 if (DdeInitializeW(&ddeInst
, dde_cb
, APPCMD_CLIENTONLY
, 0L) != DMLERR_NO_ERROR
)
804 hszApp
= DdeCreateStringHandleW(ddeInst
, app
, CP_WINUNICODE
);
805 hszTopic
= DdeCreateStringHandleW(ddeInst
, topic
, CP_WINUNICODE
);
807 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
811 static const WCHAR wIfexec
[] = {'\\','i','f','e','x','e','c',0};
812 TRACE("Launching '%s'\n", debugstr_w(start
));
813 ret
= execfunc(start
, env
, TRUE
, psei
, psei_out
);
816 TRACE("Couldn't launch\n");
819 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
822 TRACE("Couldn't connect. ret=%d\n", ret
);
823 DdeUninitialize(ddeInst
);
824 SetLastError(ERROR_DDE_FAIL
);
825 return 30; /* whatever */
827 strcpyW(endkey
, wIfexec
);
828 ifexeclen
= sizeof(ifexec
);
829 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, ifexec
, &ifexeclen
) == ERROR_SUCCESS
)
835 SHELL_ArgifyW(res
, sizeof(res
)/sizeof(WCHAR
), exec
, lpFile
, pidl
, szCommandline
);
836 TRACE("%s %s => %s\n", debugstr_w(exec
), debugstr_w(lpFile
), debugstr_w(res
));
838 /* It's documented in the KB 330337 that IE has a bug and returns
839 * error DMLERR_NOTPROCESSED on XTYP_EXECUTE request.
841 hDdeData
= DdeClientTransaction((LPBYTE
)res
, (strlenW(res
) + 1) * sizeof(WCHAR
), hConv
, 0L, 0,
842 XTYP_EXECUTE
, 10000, &tid
);
844 DdeFreeDataHandle(hDdeData
);
846 WARN("DdeClientTransaction failed with error %04x\n", DdeGetLastError(ddeInst
));
849 DdeDisconnect(hConv
);
852 DdeUninitialize(ddeInst
);
857 /*************************************************************************
858 * execute_from_key [Internal]
860 static UINT
execute_from_key(LPWSTR key
, LPCWSTR lpFile
, WCHAR
*env
, LPCWSTR szCommandline
,
861 SHELL_ExecuteW32 execfunc
,
862 LPSHELLEXECUTEINFOW psei
, LPSHELLEXECUTEINFOW psei_out
)
865 LONG cmdlen
= sizeof(cmd
);
870 /* Get the application for the registry */
871 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, cmd
, &cmdlen
) == ERROR_SUCCESS
)
873 static const WCHAR wCommand
[] = {'c','o','m','m','a','n','d',0};
874 static const WCHAR wDdeexec
[] = {'d','d','e','e','x','e','c',0};
877 LONG paramlen
= sizeof(param
);
881 /* Get the parameters needed by the application
882 from the associated ddeexec key */
883 tmp
= strstrW(key
, wCommand
);
885 strcpyW(tmp
, wDdeexec
);
887 if (RegQueryValueW(HKEY_CLASSES_ROOT
, key
, param
, ¶mlen
) == ERROR_SUCCESS
)
889 TRACE("Got ddeexec %s => %s\n", debugstr_w(key
), debugstr_w(param
));
890 retval
= dde_connect(key
, cmd
, param
, lpFile
, env
, szCommandline
, psei
->lpIDList
, execfunc
, psei
, psei_out
);
894 /* Is there a replace() function anywhere? */
895 cmdlen
/= sizeof(WCHAR
);
897 SHELL_ArgifyW(param
, sizeof(param
)/sizeof(WCHAR
), cmd
, lpFile
, psei
->lpIDList
, szCommandline
);
898 retval
= execfunc(param
, env
, FALSE
, psei
, psei_out
);
901 else TRACE("ooch\n");
906 /*************************************************************************
907 * FindExecutableA [SHELL32.@]
909 HINSTANCE WINAPI
FindExecutableA(LPCSTR lpFile
, LPCSTR lpDirectory
, LPSTR lpResult
)
912 WCHAR
*wFile
= NULL
, *wDirectory
= NULL
;
913 WCHAR wResult
[MAX_PATH
];
915 if (lpFile
) __SHCloneStrAtoW(&wFile
, lpFile
);
916 if (lpDirectory
) __SHCloneStrAtoW(&wDirectory
, lpDirectory
);
918 retval
= FindExecutableW(wFile
, wDirectory
, wResult
);
919 WideCharToMultiByte(CP_ACP
, 0, wResult
, -1, lpResult
, MAX_PATH
, NULL
, NULL
);
920 if (wFile
) SHFree( wFile
);
921 if (wDirectory
) SHFree( wDirectory
);
923 TRACE("returning %s\n", lpResult
);
924 return (HINSTANCE
)retval
;
927 /*************************************************************************
928 * FindExecutableW [SHELL32.@]
930 HINSTANCE WINAPI
FindExecutableW(LPCWSTR lpFile
, LPCWSTR lpDirectory
, LPWSTR lpResult
)
932 UINT retval
= 31; /* default - 'No association was found' */
935 TRACE("File %s, Dir %s\n",
936 (lpFile
!= NULL
? debugstr_w(lpFile
) : "-"), (lpDirectory
!= NULL
? debugstr_w(lpDirectory
) : "-"));
938 lpResult
[0] = '\0'; /* Start off with an empty return string */
940 /* trap NULL parameters on entry */
941 if ((lpFile
== NULL
) || (lpResult
== NULL
))
943 /* FIXME - should throw a warning, perhaps! */
944 return (HINSTANCE
)2; /* File not found. Close enough, I guess. */
949 GetCurrentDirectoryW(sizeof(old_dir
)/sizeof(WCHAR
), old_dir
);
950 SetCurrentDirectoryW(lpDirectory
);
953 retval
= SHELL_FindExecutable(lpDirectory
, lpFile
, wszOpen
, lpResult
, MAX_PATH
, NULL
, NULL
, NULL
, NULL
);
955 TRACE("returning %s\n", debugstr_w(lpResult
));
957 SetCurrentDirectoryW(old_dir
);
958 return (HINSTANCE
)retval
;
961 /*************************************************************************
962 * ShellExecuteExW32 [Internal]
964 BOOL WINAPI
ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei
, SHELL_ExecuteW32 execfunc
)
966 static const WCHAR wQuote
[] = {'"',0};
967 static const WCHAR wSpace
[] = {' ',0};
968 static const WCHAR wWww
[] = {'w','w','w',0};
969 static const WCHAR wFile
[] = {'f','i','l','e',0};
970 static const WCHAR wHttp
[] = {'h','t','t','p',':','/','/',0};
971 static const WCHAR wExtLnk
[] = {'.','l','n','k',0};
972 static const WCHAR wExplorer
[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0};
974 WCHAR wszApplicationName
[MAX_PATH
+2], wszParameters
[1024], wszDir
[MAX_PATH
];
975 SHELLEXECUTEINFOW sei_tmp
; /* modifiable copy of SHELLEXECUTEINFO struct */
976 WCHAR wfileName
[MAX_PATH
];
978 WCHAR lpstrProtocol
[256];
982 WCHAR buffer
[MAX_PATH
];
986 /* make a local copy of the LPSHELLEXECUTEINFO structure and work with this from now on */
987 memcpy(&sei_tmp
, sei
, sizeof(sei_tmp
));
989 TRACE("mask=0x%08lx hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
990 sei_tmp
.fMask
, sei_tmp
.hwnd
, debugstr_w(sei_tmp
.lpVerb
),
991 debugstr_w(sei_tmp
.lpFile
), debugstr_w(sei_tmp
.lpParameters
),
992 debugstr_w(sei_tmp
.lpDirectory
), sei_tmp
.nShow
,
993 (sei_tmp
.fMask
& SEE_MASK_CLASSNAME
) ? debugstr_w(sei_tmp
.lpClass
) : "not used");
995 sei
->hProcess
= NULL
;
997 /* make copies of all path/command strings */
999 strcpyW(wszApplicationName
, sei_tmp
.lpFile
);
1001 *wszApplicationName
= '\0';
1003 if (sei_tmp
.lpParameters
)
1004 strcpyW(wszParameters
, sei_tmp
.lpParameters
);
1006 *wszParameters
= '\0';
1008 if (sei_tmp
.lpDirectory
)
1009 strcpyW(wszDir
, sei_tmp
.lpDirectory
);
1013 /* adjust string pointers to point to the new buffers */
1014 sei_tmp
.lpFile
= wszApplicationName
;
1015 sei_tmp
.lpParameters
= wszParameters
;
1016 sei_tmp
.lpDirectory
= wszDir
;
1018 if (sei_tmp
.fMask
& (SEE_MASK_INVOKEIDLIST
| SEE_MASK_ICON
| SEE_MASK_HOTKEY
|
1019 SEE_MASK_CONNECTNETDRV
| SEE_MASK_FLAG_DDEWAIT
|
1020 SEE_MASK_DOENVSUBST
| SEE_MASK_FLAG_NO_UI
| SEE_MASK_UNICODE
|
1021 SEE_MASK_NO_CONSOLE
| SEE_MASK_ASYNCOK
| SEE_MASK_HMONITOR
))
1023 FIXME("flags ignored: 0x%08lx\n", sei_tmp
.fMask
);
1026 /* process the IDList */
1027 if (sei_tmp
.fMask
& SEE_MASK_IDLIST
)
1029 IShellExecuteHookW
* pSEH
;
1031 HRESULT hr
= SHBindToParent(sei_tmp
.lpIDList
, &IID_IShellExecuteHookW
, (LPVOID
*)&pSEH
, NULL
);
1035 hr
= IShellExecuteHookW_Execute(pSEH
, sei
);
1037 IShellExecuteHookW_Release(pSEH
);
1043 wszApplicationName
[0] = '"';
1044 SHGetPathFromIDListW(sei_tmp
.lpIDList
, wszApplicationName
+1);
1045 strcatW(wszApplicationName
, wQuote
);
1046 TRACE("-- idlist=%p (%s)\n", sei_tmp
.lpIDList
, debugstr_w(wszApplicationName
));
1049 if (sei_tmp
.fMask
& (SEE_MASK_CLASSNAME
| SEE_MASK_CLASSKEY
))
1051 /* launch a document by fileclass like 'WordPad.Document.1' */
1052 /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
1053 /* FIXME: szCommandline should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */
1054 HCR_GetExecuteCommandW((sei_tmp
.fMask
& SEE_MASK_CLASSKEY
) ? sei_tmp
.hkeyClass
: NULL
,
1055 (sei_tmp
.fMask
& SEE_MASK_CLASSNAME
) ? sei_tmp
.lpClass
: NULL
,
1056 (sei_tmp
.lpVerb
) ? sei_tmp
.lpVerb
: wszOpen
,
1057 wszParameters
, sizeof(wszParameters
)/sizeof(WCHAR
));
1059 /* FIXME: get the extension of lpFile, check if it fits to the lpClass */
1060 TRACE("SEE_MASK_CLASSNAME->'%s', doc->'%s'\n", debugstr_w(wszParameters
), debugstr_w(wszApplicationName
));
1063 done
= SHELL_ArgifyW(wcmd
, sizeof(wcmd
)/sizeof(WCHAR
), wszParameters
, wszApplicationName
, sei_tmp
.lpIDList
, NULL
);
1064 if (!done
&& wszApplicationName
[0])
1066 strcatW(wcmd
, wSpace
);
1067 strcatW(wcmd
, wszApplicationName
);
1069 retval
= execfunc(wcmd
, NULL
, FALSE
, &sei_tmp
, sei
);
1077 /* resolve shell shortcuts */
1078 ext
= PathFindExtensionW(sei_tmp
.lpFile
);
1080 if (ext
&& !strncmpiW(ext
, wExtLnk
, sizeof(wExtLnk
) / sizeof(WCHAR
) - 1) &&
1081 (ext
[sizeof(wExtLnk
) / sizeof(WCHAR
) - 1] == '\0' ||
1082 (sei_tmp
.lpFile
[0] == '"' && ext
[sizeof(wExtLnk
) / sizeof(WCHAR
) - 1] == '"'))) /* or check for: shell_attribs & SFGAO_LINK */
1087 if (wszApplicationName
[0] == '"')
1089 if (wszApplicationName
[strlenW(wszApplicationName
) - 1] == '"')
1091 wszApplicationName
[strlenW(wszApplicationName
) - 1] = '\0';
1103 /* expand paths before reading shell link */
1104 if (ExpandEnvironmentStringsW(Quoted
? sei_tmp
.lpFile
+ 1 : sei_tmp
.lpFile
, buffer
, MAX_PATH
))
1105 lstrcpyW(Quoted
? wszApplicationName
+ 1 : wszApplicationName
/*sei_tmp.lpFile*/, buffer
);
1107 if (*sei_tmp
.lpParameters
)
1108 if (ExpandEnvironmentStringsW(sei_tmp
.lpParameters
, buffer
, MAX_PATH
))
1109 lstrcpyW(wszParameters
/*sei_tmp.lpParameters*/, buffer
);
1111 hr
= SHELL_ResolveShortCutW((LPWSTR
)(Quoted
? sei_tmp
.lpFile
+ 1 : sei_tmp
.lpFile
),
1112 (LPWSTR
)sei_tmp
.lpParameters
, (LPWSTR
)sei_tmp
.lpDirectory
,
1113 sei_tmp
.hwnd
, sei_tmp
.lpVerb
?sei_tmp
.lpVerb
:wszEmpty
, &sei_tmp
.nShow
, (LPITEMIDLIST
*)&sei_tmp
.lpIDList
);
1116 wszApplicationName
[strlenW(wszApplicationName
) + 1] = '\0';
1117 wszApplicationName
[strlenW(wszApplicationName
)] = '"';
1121 sei
->fMask
|= SEE_MASK_IDLIST
;
1125 /* repeat IDList processing if needed */
1126 if (sei_tmp
.fMask
& SEE_MASK_IDLIST
)
1128 IShellExecuteHookW
* pSEH
;
1130 HRESULT hr
= SHBindToParent(sei_tmp
.lpIDList
, &IID_IShellExecuteHookW
, (LPVOID
*)&pSEH
, NULL
);
1134 hr
= IShellExecuteHookW_Execute(pSEH
, sei
);
1136 IShellExecuteHookW_Release(pSEH
);
1142 TRACE("-- idlist=%p (%s)\n", debugstr_w(sei_tmp
.lpIDList
), debugstr_w(sei_tmp
.lpFile
));
1148 /* Has the IDList not yet been translated? */
1149 if (sei_tmp
.fMask
& SEE_MASK_IDLIST
)
1151 /* last chance to translate IDList: now also allow CLSID paths */
1152 if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW(sei_tmp
.lpIDList
, buffer
, sizeof(buffer
)))) {
1153 if (buffer
[0]==':' && buffer
[1]==':') {
1154 /* open shell folder for the specified class GUID */
1155 strcpyW(wszParameters
, buffer
);
1156 strcpyW(wszApplicationName
, wExplorer
);
1158 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1159 } else if (HCR_GetExecuteCommandW(0, wszFolder
, sei_tmp
.lpVerb
?sei_tmp
.lpVerb
:wszOpen
, buffer
, sizeof(buffer
))) {
1160 SHELL_ArgifyW(wszApplicationName
, sizeof(wszApplicationName
)/sizeof(WCHAR
), buffer
, NULL
, sei_tmp
.lpIDList
, NULL
);
1162 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1167 /* expand environment strings */
1168 if (ExpandEnvironmentStringsW(sei_tmp
.lpFile
, buffer
, MAX_PATH
))
1169 lstrcpyW(wszApplicationName
, buffer
);
1171 if (*sei_tmp
.lpParameters
)
1172 if (ExpandEnvironmentStringsW(sei_tmp
.lpParameters
, buffer
, MAX_PATH
))
1173 lstrcpyW(wszParameters
, buffer
);
1175 if (*sei_tmp
.lpDirectory
)
1176 if (ExpandEnvironmentStringsW(sei_tmp
.lpDirectory
, buffer
, MAX_PATH
))
1177 lstrcpyW(wszDir
, buffer
);
1179 /* Else, try to execute the filename */
1180 TRACE("execute:%s,%s,%s\n", debugstr_w(wszApplicationName
), debugstr_w(wszParameters
), debugstr_w(wszDir
));
1182 /* separate out command line arguments from executable file name */
1183 if (!*sei_tmp
.lpParameters
) {
1184 /* If the executable path is quoted, handle the rest of the command line as parameters. */
1185 if (sei_tmp
.lpFile
[0] == '"') {
1186 LPWSTR src
= wszApplicationName
/*sei_tmp.lpFile*/ + 1;
1187 LPWSTR dst
= wfileName
;
1190 /* copy the unquoted executable path to 'wfileName' */
1191 while(*src
&& *src
!='"')
1199 while(isspace(*src
))
1204 /* copy the parameter string to 'wszParameters' */
1205 strcpyW(wszParameters
, src
);
1207 /* terminate previous command string after the quote character */
1212 /* If the executable name is not quoted, we have to use this search loop here,
1213 that in CreateProcess() is not sufficient because it does not handle shell links. */
1214 WCHAR buffer
[MAX_PATH
], xlpFile
[MAX_PATH
];
1217 LPWSTR beg
= wszApplicationName
/*sei_tmp.lpFile*/;
1218 for(s
=beg
; (space
=strchrW(s
, ' ')); s
=space
+1) {
1219 int idx
= space
-sei_tmp
.lpFile
;
1220 strncpyW(buffer
, sei_tmp
.lpFile
, idx
);
1223 /*FIXME This finds directory paths if the targeted file name contains spaces. */
1224 if (SearchPathW(*sei_tmp
.lpDirectory
? sei_tmp
.lpDirectory
: NULL
, buffer
, wszExe
, sizeof(xlpFile
), xlpFile
, NULL
))
1226 /* separate out command from parameter string */
1227 LPCWSTR p
= space
+ 1;
1232 strcpyW(wszParameters
, p
);
1239 strcpyW(wfileName
, sei_tmp
.lpFile
);
1242 strcpyW(wfileName
, sei_tmp
.lpFile
);
1246 if (sei_tmp
.lpParameters
[0]) {
1247 strcatW(wszApplicationName
, wSpace
);
1248 strcatW(wszApplicationName
, wszParameters
);
1251 /* We set the default to open, and that should generally work.
1252 But that is not really the way the MS docs say to do it. */
1253 if (!sei_tmp
.lpVerb
)
1254 sei_tmp
.lpVerb
= wszOpen
;
1256 retval
= execfunc(wszApplicationName
, NULL
, FALSE
, &sei_tmp
, sei
);
1260 /* Else, try to find the executable */
1262 retval
= SHELL_FindExecutable(sei_tmp
.lpDirectory
, lpFile
, sei_tmp
.lpVerb
, wcmd
, 1024, lpstrProtocol
, &env
, sei_tmp
.lpIDList
, sei_tmp
.lpParameters
);
1263 if (retval
> 32) /* Found */
1265 WCHAR wszQuotedCmd
[MAX_PATH
+2];
1266 /* Must quote to handle case where cmd contains spaces,
1267 * else security hole if malicious user creates executable file "C:\\Program"
1269 strcpyW(wszQuotedCmd
, wQuote
);
1270 strcatW(wszQuotedCmd
, wcmd
);
1271 strcatW(wszQuotedCmd
, wQuote
);
1272 if (wszParameters
[0]) {
1273 strcatW(wszQuotedCmd
, wSpace
);
1274 strcatW(wszQuotedCmd
, wszParameters
);
1276 TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName
), debugstr_w(sei_tmp
.lpVerb
), debugstr_w(wszQuotedCmd
), debugstr_w(lpstrProtocol
));
1278 retval
= execute_from_key(lpstrProtocol
, wszApplicationName
, env
, sei_tmp
.lpParameters
, execfunc
, &sei_tmp
, sei
);
1280 retval
= execfunc(wszQuotedCmd
, env
, FALSE
, &sei_tmp
, sei
);
1281 if (env
) HeapFree( GetProcessHeap(), 0, env
);
1283 else if (PathIsURLW((LPWSTR
)lpFile
)) /* File not found, check for URL */
1285 static const WCHAR wShell
[] = {'\\','s','h','e','l','l','\\',0};
1286 static const WCHAR wCommand
[] = {'\\','c','o','m','m','a','n','d',0};
1290 lpstrRes
= strchrW(lpFile
, ':');
1292 iSize
= lpstrRes
- lpFile
;
1294 iSize
= strlenW(lpFile
);
1296 TRACE("Got URL: %s\n", debugstr_w(lpFile
));
1297 /* Looking for ...protocol\shell\lpOperation\command */
1298 strncpyW(lpstrProtocol
, lpFile
, iSize
);
1299 lpstrProtocol
[iSize
] = '\0';
1300 strcatW(lpstrProtocol
, wShell
);
1301 strcatW(lpstrProtocol
, sei_tmp
.lpVerb
? sei_tmp
.lpVerb
: wszOpen
);
1302 strcatW(lpstrProtocol
, wCommand
);
1304 /* Remove File Protocol from lpFile */
1305 /* In the case file://path/file */
1306 if (!strncmpiW(lpFile
, wFile
, iSize
))
1309 while (*lpFile
== ':') lpFile
++;
1311 retval
= execute_from_key(lpstrProtocol
, lpFile
, NULL
, sei_tmp
.lpParameters
, execfunc
, &sei_tmp
, sei
);
1313 /* Check if file specified is in the form www.??????.*** */
1314 else if (!strncmpiW(lpFile
, wWww
, 3))
1316 /* if so, append lpFile http:// and call ShellExecute */
1317 WCHAR lpstrTmpFile
[256];
1318 strcpyW(lpstrTmpFile
, wHttp
);
1319 strcatW(lpstrTmpFile
, lpFile
);
1320 retval
= (UINT
)ShellExecuteW(sei_tmp
.hwnd
, sei_tmp
.lpVerb
, lpstrTmpFile
, NULL
, NULL
, 0);
1323 TRACE("retval %u\n", retval
);
1327 sei
->hInstApp
= (HINSTANCE
)retval
;
1331 sei
->hInstApp
= (HINSTANCE
)33;
1335 /*************************************************************************
1336 * ShellExecuteA [SHELL32.290]
1338 HINSTANCE WINAPI
ShellExecuteA(HWND hWnd
, LPCSTR lpOperation
,LPCSTR lpFile
,
1339 LPCSTR lpParameters
,LPCSTR lpDirectory
, INT iShowCmd
)
1341 SHELLEXECUTEINFOA sei
;
1342 HANDLE hProcess
= 0;
1344 TRACE("%p,%s,%s,%s,%s,%d\n",
1345 hWnd
, lpOperation
, lpFile
, lpParameters
, lpDirectory
, iShowCmd
);
1347 sei
.cbSize
= sizeof(sei
);
1350 sei
.lpVerb
= lpOperation
;
1351 sei
.lpFile
= lpFile
;
1352 sei
.lpParameters
= lpParameters
;
1353 sei
.lpDirectory
= lpDirectory
;
1354 sei
.nShow
= iShowCmd
;
1359 sei
.hProcess
= hProcess
;
1361 ShellExecuteExA (&sei
);
1362 return sei
.hInstApp
;
1365 /*************************************************************************
1366 * ShellExecuteEx [SHELL32.291]
1369 BOOL WINAPI
ShellExecuteExAW (LPVOID sei
)
1371 if (SHELL_OsIsUnicode())
1372 return ShellExecuteExW32 (sei
, SHELL_ExecuteW
);
1373 return ShellExecuteExA (sei
);
1376 /*************************************************************************
1377 * ShellExecuteExA [SHELL32.292]
1380 BOOL WINAPI
ShellExecuteExA (LPSHELLEXECUTEINFOA sei
)
1382 SHELLEXECUTEINFOW seiW
;
1384 WCHAR
*wVerb
= NULL
, *wFile
= NULL
, *wParameters
= NULL
, *wDirectory
= NULL
, *wClass
= NULL
;
1388 memcpy(&seiW
, sei
, sizeof(SHELLEXECUTEINFOW
));
1391 seiW
.lpVerb
= __SHCloneStrAtoW(&wVerb
, sei
->lpVerb
);
1394 seiW
.lpFile
= __SHCloneStrAtoW(&wFile
, sei
->lpFile
);
1396 if (sei
->lpParameters
)
1397 seiW
.lpParameters
= __SHCloneStrAtoW(&wParameters
, sei
->lpParameters
);
1399 if (sei
->lpDirectory
)
1400 seiW
.lpDirectory
= __SHCloneStrAtoW(&wDirectory
, sei
->lpDirectory
);
1402 if ((sei
->fMask
& SEE_MASK_CLASSNAME
) && sei
->lpClass
)
1403 seiW
.lpClass
= __SHCloneStrAtoW(&wClass
, sei
->lpClass
);
1405 seiW
.lpClass
= NULL
;
1407 ret
= ShellExecuteExW32 (&seiW
, SHELL_ExecuteW
);
1409 sei
->hInstApp
= seiW
.hInstApp
;
1411 if (wVerb
) SHFree(wVerb
);
1412 if (wFile
) SHFree(wFile
);
1413 if (wParameters
) SHFree(wParameters
);
1414 if (wDirectory
) SHFree(wDirectory
);
1415 if (wClass
) SHFree(wClass
);
1420 /*************************************************************************
1421 * ShellExecuteExW [SHELL32.293]
1424 BOOL WINAPI
ShellExecuteExW (LPSHELLEXECUTEINFOW sei
)
1426 return ShellExecuteExW32 (sei
, SHELL_ExecuteW
);
1429 /*************************************************************************
1430 * ShellExecuteW [SHELL32.294]
1432 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
1433 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
1435 HINSTANCE WINAPI
ShellExecuteW(HWND hwnd
, LPCWSTR lpOperation
, LPCWSTR lpFile
,
1436 LPCWSTR lpParameters
, LPCWSTR lpDirectory
, INT nShowCmd
)
1438 SHELLEXECUTEINFOW sei
;
1439 HANDLE hProcess
= 0;
1442 sei
.cbSize
= sizeof(sei
);
1445 sei
.lpVerb
= lpOperation
;
1446 sei
.lpFile
= lpFile
;
1447 sei
.lpParameters
= lpParameters
;
1448 sei
.lpDirectory
= lpDirectory
;
1449 sei
.nShow
= nShowCmd
;
1454 sei
.hProcess
= hProcess
;
1456 ShellExecuteExW32 (&sei
, SHELL_ExecuteW
);
1457 return sei
.hInstApp
;