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"
48 #include "wine/winbase16.h"
49 #include "shell32_main.h"
50 #include "undocshell.h"
52 #include "wine/debug.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(exec);
56 /***********************************************************************
57 * this function is supposed to expand the escape sequences found in the registry
58 * some diving reported that the following were used:
59 * + %1, %2... seem to report to parameter of index N in ShellExecute pmts
64 * %I address of a global item ID (explorer switch /idlist)
65 * %L seems to be %1 as long filename followed by the 8+3 variation
67 * %* all following parameters (see batfile)
69 static BOOL argify(char* res, int len, const char* fmt, const char* lpFile)
86 if (!done || (*fmt == '1'))
88 if (SearchPathA(NULL, lpFile, ".exe", sizeof(xlpFile), xlpFile, NULL))
91 res += strlen(xlpFile);
96 res += strlen(lpFile);
101 * IE uses this alot for activating things such as windows media
102 * player. This is not verified to be fully correct but it appears
107 res += strlen(lpFile);
110 default: FIXME("Unknown escape sequence %%%c\n", *fmt);
122 /*************************************************************************
123 * SHELL_ExecuteA [Internal]
126 static UINT SHELL_ExecuteA(char *lpCmd, void *env, LPSHELLEXECUTEINFOA sei, BOOL shWait)
128 STARTUPINFOA startup;
129 PROCESS_INFORMATION info;
132 TRACE("Execute %s from directory %s\n", lpCmd, sei->lpDirectory);
133 ZeroMemory(&startup,sizeof(STARTUPINFOA));
134 startup.cb = sizeof(STARTUPINFOA);
135 startup.dwFlags = STARTF_USESHOWWINDOW;
136 startup.wShowWindow = sei->nShow;
137 if (CreateProcessA(NULL, lpCmd, NULL, NULL, FALSE, 0,
138 env, sei->lpDirectory, &startup, &info))
140 /* Give 30 seconds to the app to come up, if desired. Probably only needed
141 when starting app immediately before making a DDE connection. */
143 if (WaitForInputIdle( info.hProcess, 30000 ) == -1)
144 WARN("WaitForInputIdle failed: Error %ld\n", GetLastError() );
146 if(sei->fMask & SEE_MASK_NOCLOSEPROCESS)
147 sei->hProcess = info.hProcess;
149 CloseHandle( info.hProcess );
150 CloseHandle( info.hThread );
152 else if ((retval = GetLastError()) >= 32)
154 FIXME("Strange error set by CreateProcess: %d\n", retval);
155 retval = ERROR_BAD_FORMAT;
158 sei->hInstApp = (HINSTANCE)retval;
163 /***********************************************************************
166 * Build the environment for the new process, adding the specified
167 * path to the PATH variable. Returned pointer must be freed by caller.
169 static void *build_env( const char *path )
171 char *strings, *new_env;
173 int total = strlen(path) + 1;
174 BOOL got_path = FALSE;
176 if (!(strings = GetEnvironmentStringsA())) return NULL;
180 int len = strlen(p) + 1;
181 if (!strncasecmp( p, "PATH=", 5 )) got_path = TRUE;
185 if (!got_path) total += 5; /* we need to create PATH */
186 total++; /* terminating null */
188 if (!(new_env = HeapAlloc( GetProcessHeap(), 0, total )))
190 FreeEnvironmentStringsA( strings );
197 int len = strlen(p) + 1;
198 memcpy( p2, p, len );
199 if (!strncasecmp( p, "PATH=", 5 ))
202 strcpy( p2 + len, path );
203 p2 += strlen(path) + 1;
210 strcpy( p2, "PATH=" );
212 p2 += strlen(p2) + 1;
215 FreeEnvironmentStringsA( strings );
220 /***********************************************************************
223 * Helper function for SHELL_FindExecutable
224 * @param lpResult - pointer to a buffer of size MAX_PATH
225 * On entry: szName is a filename (probably without path separators).
226 * On exit: if szName found in "App Path", place full path in lpResult, and return true
228 static BOOL SHELL_TryAppPath( LPCSTR szName, LPSTR lpResult, void**env)
236 if (env) *env = NULL;
237 sprintf(buffer, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s", szName);
238 res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, buffer, 0, KEY_READ, &hkApp);
242 res = RegQueryValueA(hkApp, NULL, lpResult, &len);
248 DWORD count = sizeof(buffer);
249 if (!RegQueryValueExA(hkApp, "Path", NULL, NULL, buffer, &count) && buffer[0])
250 *env = build_env( buffer );
254 if (hkApp) RegCloseKey(hkApp);
258 /*************************************************************************
259 * SHELL_FindExecutable [Internal]
261 * Utility for code sharing between FindExecutable and ShellExecute
263 * lpFile the name of a file
264 * lpOperation the operation on it (open)
266 * lpResult a buffer, big enough :-(, to store the command to do the
267 * operation on the file
268 * key a buffer, big enough, to get the key name to do actually the
269 * command (it'll be used afterwards for more information
272 static UINT SHELL_FindExecutable(LPCSTR lpPath, LPCSTR lpFile, LPCSTR lpOperation,
273 LPSTR lpResult, LPSTR key, void **env)
275 char *extension = NULL; /* pointer to file extension */
276 char tmpext[5]; /* local copy to mung as we please */
277 char filetype[256]; /* registry name for this filetype */
278 LONG filetypelen = 256; /* length of above */
279 char command[256]; /* command from registry */
280 LONG commandlen = 256; /* This is the most DOS can handle :) */
281 char buffer[256]; /* Used to GetProfileString */
282 UINT retval = 31; /* default - 'No association was found' */
283 char *tok; /* token pointer */
284 char xlpFile[256] = ""; /* result of SearchPath */
286 TRACE("%s\n", (lpFile != NULL) ? lpFile : "-");
288 lpResult[0] = '\0'; /* Start off with an empty return string */
289 if (key) *key = '\0';
291 /* trap NULL parameters on entry */
292 if ((lpFile == NULL) || (lpResult == NULL) || (lpOperation == NULL))
294 WARN("(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
295 lpFile, lpOperation, lpResult);
296 return 2; /* File not found. Close enough, I guess. */
299 if (SHELL_TryAppPath( lpFile, lpResult, env ))
301 TRACE("found %s via App Paths\n", lpResult);
305 if (SearchPathA(lpPath, lpFile, ".exe", sizeof(xlpFile), xlpFile, NULL))
307 TRACE("SearchPathA returned non-zero\n");
309 /* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
312 /* First thing we need is the file's extension */
313 extension = strrchr(xlpFile, '.'); /* Assume last "." is the one; */
314 /* File->Run in progman uses */
316 TRACE("xlpFile=%s,extension=%s\n", xlpFile, extension);
318 if ((extension == NULL) || (extension == &xlpFile[strlen(xlpFile)]))
320 WARN("Returning 31 - No association\n");
321 return 31; /* no association */
324 /* Make local copy & lowercase it for reg & 'programs=' lookup */
325 lstrcpynA(tmpext, extension, 5);
327 TRACE("%s file\n", tmpext);
329 /* Three places to check: */
330 /* 1. win.ini, [windows], programs (NB no leading '.') */
331 /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
332 /* 3. win.ini, [extensions], extension (NB no leading '.' */
333 /* All I know of the order is that registry is checked before */
334 /* extensions; however, it'd make sense to check the programs */
335 /* section first, so that's what happens here. */
337 /* See if it's a program - if GetProfileString fails, we skip this
338 * section. Actually, if GetProfileString fails, we've probably
339 * got a lot more to worry about than running a program... */
340 if (GetProfileStringA("windows", "programs", "exe pif bat cmd com",
341 buffer, sizeof(buffer)) > 0)
345 for (i = 0;i<strlen(buffer); i++) buffer[i] = tolower(buffer[i]);
347 tok = strtok(buffer, " \t"); /* ? */
350 if (strcmp(tok, &tmpext[1]) == 0) /* have to skip the leading "." */
352 strcpy(lpResult, xlpFile);
353 /* Need to perhaps check that the file has a path
355 TRACE("found %s\n", lpResult);
358 /* Greater than 32 to indicate success FIXME According to the
359 * docs, I should be returning a handle for the
360 * executable. Does this mean I'm supposed to open the
361 * executable file or something? More RTFM, I guess... */
363 tok = strtok(NULL, " \t");
368 if (RegQueryValueA(HKEY_CLASSES_ROOT, tmpext, filetype,
369 &filetypelen) == ERROR_SUCCESS)
371 filetype[filetypelen] = '\0';
372 TRACE("File type: %s\n", filetype);
374 /* Looking for ...buffer\shell\lpOperation\command */
375 strcat(filetype, "\\shell\\");
376 strcat(filetype, lpOperation);
377 strcat(filetype, "\\command");
379 if (RegQueryValueA(HKEY_CLASSES_ROOT, filetype, command,
380 &commandlen) == ERROR_SUCCESS)
382 if (key) strcpy(key, filetype);
388 /* FIXME: it seems all Windows version don't behave the same here.
389 * the doc states that this ddeexec information can be found after
391 * on Win98, it doesn't appear, but I think it does on Win2k
393 /* Get the parameters needed by the application
394 from the associated ddeexec key */
395 tmp = strstr(filetype, "command");
397 strcat(filetype, "ddeexec");
399 if (RegQueryValueA(HKEY_CLASSES_ROOT, filetype, param, ¶mlen) == ERROR_SUCCESS)
401 strcat(command, " ");
402 strcat(command, param);
403 commandlen += paramlen;
406 command[commandlen] = '\0';
407 argify(lpResult, sizeof(lpResult), command, xlpFile);
408 retval = 33; /* FIXME see above */
411 else /* Check win.ini */
413 /* Toss the leading dot */
415 if (GetProfileStringA("extensions", extension, "", command,
416 sizeof(command)) > 0)
418 if (strlen(command) != 0)
420 strcpy(lpResult, command);
421 tok = strstr(lpResult, "^"); /* should be ^.extension? */
425 strcat(lpResult, xlpFile); /* what if no dir in xlpFile? */
426 tok = strstr(command, "^"); /* see above */
427 if ((tok != NULL) && (strlen(tok)>5))
429 strcat(lpResult, &tok[5]);
432 retval = 33; /* FIXME - see above */
437 TRACE("returning %s\n", lpResult);
441 /******************************************************************
444 * callback for the DDE connection. not really usefull
446 static HDDEDATA CALLBACK dde_cb(UINT uType, UINT uFmt, HCONV hConv,
448 HDDEDATA hData, DWORD dwData1, DWORD dwData2)
453 /******************************************************************
456 * ShellExecute helper. Used to do an operation with a DDE connection
458 * Handles both the direct connection (try #1), and if it fails,
459 * launching an application and trying (#2) to connect to it
462 static unsigned dde_connect(char* key, char* start, char* ddeexec,
463 const char* lpFile, void *env,
464 LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc)
466 char* endkey = key + strlen(key);
467 char app[256], topic[256], ifexec[256], res[256];
468 LONG applen, topiclen, ifexeclen;
472 HSZ hszApp, hszTopic;
476 strcpy(endkey, "\\application");
477 applen = sizeof(app);
478 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, app, &applen) != ERROR_SUCCESS)
480 FIXME("default app name NIY %s\n", key);
484 strcpy(endkey, "\\topic");
485 topiclen = sizeof(topic);
486 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, topic, &topiclen) != ERROR_SUCCESS)
488 strcpy(topic, "System");
491 if (DdeInitializeA(&ddeInst, dde_cb, APPCMD_CLIENTONLY, 0L) != DMLERR_NO_ERROR)
496 hszApp = DdeCreateStringHandleA(ddeInst, app, CP_WINANSI);
497 hszTopic = DdeCreateStringHandleA(ddeInst, topic, CP_WINANSI);
499 hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL);
503 TRACE("Launching '%s'\n", start);
504 ret = execfunc(start, env, sei, TRUE);
507 TRACE("Couldn't launch\n");
510 hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL);
513 TRACE("Couldn't connect. ret=%d\n", ret);
514 ret = 30; /* whatever */
517 strcpy(endkey, "\\ifexec");
518 ifexeclen = sizeof(ifexec);
519 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, ifexec, &ifexeclen) == ERROR_SUCCESS)
525 argify(res, sizeof(res), exec, lpFile);
526 TRACE("%s %s => %s\n", exec, lpFile, res);
528 ret = (DdeClientTransaction(res, strlen(res) + 1, hConv, 0L, 0,
529 XTYP_EXECUTE, 10000, &tid) != DMLERR_NO_ERROR) ? 31 : 33;
530 DdeDisconnect(hConv);
532 DdeUninitialize(ddeInst);
536 /*************************************************************************
537 * execute_from_key [Internal]
539 static UINT execute_from_key(LPSTR key, LPCSTR lpFile, void *env,
540 LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc)
543 LONG cmdlen = sizeof(cmd);
546 /* Get the application for the registry */
547 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, cmd, &cmdlen) == ERROR_SUCCESS)
550 char param[256] = "";
553 /* Get the parameters needed by the application
554 from the associated ddeexec key */
555 tmp = strstr(key, "command");
557 strcpy(tmp, "ddeexec");
559 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, param, ¶mlen) == ERROR_SUCCESS)
561 TRACE("Got ddeexec %s => %s\n", key, param);
562 retval = dde_connect(key, cmd, param, lpFile, env, sei, execfunc);
566 /* Is there a replace() function anywhere? */
568 argify(param, sizeof(param), cmd, lpFile);
569 retval = execfunc(param, env, sei, FALSE);
572 else TRACE("ooch\n");
577 /*************************************************************************
578 * FindExecutableA [SHELL32.@]
580 HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
582 UINT retval = 31; /* default - 'No association was found' */
585 TRACE("File %s, Dir %s\n",
586 (lpFile != NULL ? lpFile : "-"), (lpDirectory != NULL ? lpDirectory : "-"));
588 lpResult[0] = '\0'; /* Start off with an empty return string */
590 /* trap NULL parameters on entry */
591 if ((lpFile == NULL) || (lpResult == NULL))
593 /* FIXME - should throw a warning, perhaps! */
594 return (HINSTANCE)2; /* File not found. Close enough, I guess. */
599 GetCurrentDirectoryA(sizeof(old_dir), old_dir);
600 SetCurrentDirectoryA(lpDirectory);
603 retval = SHELL_FindExecutable(lpDirectory, lpFile, "open", lpResult, NULL, NULL);
605 TRACE("returning %s\n", lpResult);
607 SetCurrentDirectoryA(old_dir);
608 return (HINSTANCE)retval;
611 /*************************************************************************
612 * FindExecutableW [SHELL32.@]
614 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
616 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
617 return (HINSTANCE)31; /* default - 'No association was found' */
620 /*************************************************************************
621 * ShellExecuteExA32 [Internal]
623 BOOL WINAPI ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc)
625 CHAR szApplicationName[MAX_PATH + 2],szCommandline[MAX_PATH],szPidl[20],fileName[MAX_PATH];
629 char lpstrProtocol[256];
630 LPCSTR lpFile,lpOperation;
635 TRACE("mask=0x%08lx hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
636 sei->fMask, sei->hwnd, debugstr_a(sei->lpVerb),
637 debugstr_a(sei->lpFile), debugstr_a(sei->lpParameters),
638 debugstr_a(sei->lpDirectory), sei->nShow,
639 (sei->fMask & SEE_MASK_CLASSNAME) ? debugstr_a(sei->lpClass) : "not used");
641 sei->hProcess = NULL;
642 ZeroMemory(szApplicationName,MAX_PATH);
644 strcpy(szApplicationName, sei->lpFile);
646 ZeroMemory(szCommandline,MAX_PATH);
647 if (sei->lpParameters)
648 strcpy(szCommandline, sei->lpParameters);
650 if (sei->fMask & (SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
651 SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
652 SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE |
653 SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR ))
655 FIXME("flags ignored: 0x%08lx\n", sei->fMask);
658 /* process the IDList */
659 if ( (sei->fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST) /*0x0c*/
661 szApplicationName[0] = '"';
662 SHGetPathFromIDListA (sei->lpIDList,szApplicationName + 1);
663 strcat(szApplicationName, "\"");
664 TRACE("-- idlist=%p (%s)\n", sei->lpIDList, szApplicationName);
668 if (sei->fMask & SEE_MASK_IDLIST )
670 pos = strstr(szCommandline, "%I");
674 HGLOBAL hmem = SHAllocShared ( sei->lpIDList, ILGetSize(sei->lpIDList), 0);
675 pv = SHLockShared(hmem,0);
676 sprintf(szPidl,":%p",pv );
679 gap = strlen(szPidl);
681 memmove(pos+gap,pos+2,len);
682 memcpy(pos,szPidl,gap);
687 if (sei->fMask & (SEE_MASK_CLASSNAME | SEE_MASK_CLASSKEY))
689 /* launch a document by fileclass like 'WordPad.Document.1' */
690 /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
691 /* FIXME: szCommandline should not be of a fixed size. Plus MAX_PATH is way too short! */
692 if (sei->fMask & SEE_MASK_CLASSKEY)
693 HCR_GetExecuteCommandExA(sei->hkeyClass,
694 (sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass: NULL,
695 (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, sizeof(szCommandline));
696 else if (sei->fMask & SEE_MASK_CLASSNAME)
697 HCR_GetExecuteCommandA(sei->lpClass, (sei->lpVerb) ? sei->lpVerb :
698 "open", szCommandline, sizeof(szCommandline));
700 /* FIXME: get the extension of lpFile, check if it fits to the lpClass */
701 TRACE("SEE_MASK_CLASSNAME->'%s', doc->'%s'\n", szCommandline, szApplicationName);
704 done = argify(cmd, sizeof(cmd), szCommandline, szApplicationName);
705 if (!done && szApplicationName[0])
708 strcat(cmd, szApplicationName);
710 retval = execfunc(cmd, NULL, sei, FALSE);
717 /* We set the default to open, and that should generally work.
718 But that is not really the way the MS docs say to do it. */
719 if (sei->lpVerb == NULL)
720 lpOperation = "open";
722 lpOperation = sei->lpVerb;
724 /* Else, try to execute the filename */
725 TRACE("execute:'%s','%s'\n",szApplicationName, szCommandline);
727 strcpy(fileName, szApplicationName);
729 if (szCommandline[0]) {
730 strcat(szApplicationName, " ");
731 strcat(szApplicationName, szCommandline);
734 retval = execfunc(szApplicationName, NULL, sei, FALSE);
738 /* Else, try to find the executable */
740 retval = SHELL_FindExecutable(sei->lpDirectory, lpFile, lpOperation, cmd, lpstrProtocol, &env);
741 if (retval > 32) /* Found */
743 CHAR szQuotedCmd[MAX_PATH+2];
744 /* Must quote to handle case where cmd contains spaces,
745 * else security hole if malicious user creates executable file "C:\\Program"
747 if (szCommandline[0])
748 sprintf(szQuotedCmd, "\"%s\" %s", cmd, szCommandline);
750 sprintf(szQuotedCmd, "\"%s\"", cmd);
751 TRACE("%s/%s => %s/%s\n", szApplicationName, lpOperation, szQuotedCmd, lpstrProtocol);
753 retval = execute_from_key(lpstrProtocol, szApplicationName, env, sei, execfunc);
755 retval = execfunc(szQuotedCmd, env, sei, FALSE);
756 if (env) HeapFree( GetProcessHeap(), 0, env );
758 else if (PathIsURLA((LPSTR)lpFile)) /* File not found, check for URL */
763 lpstrRes = strchr(lpFile, ':');
765 iSize = lpstrRes - lpFile;
767 iSize = strlen(lpFile);
769 TRACE("Got URL: %s\n", lpFile);
770 /* Looking for ...protocol\shell\lpOperation\command */
771 strncpy(lpstrProtocol, lpFile, iSize);
772 lpstrProtocol[iSize] = '\0';
773 strcat(lpstrProtocol, "\\shell\\");
774 strcat(lpstrProtocol, lpOperation);
775 strcat(lpstrProtocol, "\\command");
777 /* Remove File Protocol from lpFile */
778 /* In the case file://path/file */
779 if (!strncasecmp(lpFile, "file", iSize))
782 while (*lpFile == ':') lpFile++;
784 retval = execute_from_key(lpstrProtocol, lpFile, NULL, sei, execfunc);
786 /* Check if file specified is in the form www.??????.*** */
787 else if (!strncasecmp(lpFile, "www", 3))
789 /* if so, append lpFile http:// and call ShellExecute */
790 char lpstrTmpFile[256] = "http://" ;
791 strcat(lpstrTmpFile, lpFile);
792 retval = (UINT)ShellExecuteA(sei->hwnd, lpOperation, lpstrTmpFile, NULL, NULL, 0);
797 sei->hInstApp = (HINSTANCE)retval;
801 sei->hInstApp = (HINSTANCE)33;
805 /*************************************************************************
806 * ShellExecuteA [SHELL32.290]
808 HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpOperation,LPCSTR lpFile,
809 LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd)
811 SHELLEXECUTEINFOA sei;
815 sei.cbSize = sizeof(sei);
818 sei.lpVerb = lpOperation;
820 sei.lpParameters = lpParameters;
821 sei.lpDirectory = lpDirectory;
822 sei.nShow = iShowCmd;
827 sei.hProcess = hProcess;
829 ShellExecuteExA32 (&sei, SHELL_ExecuteA);
833 /*************************************************************************
834 * ShellExecuteEx [SHELL32.291]
837 BOOL WINAPI ShellExecuteExAW (LPVOID sei)
839 if (SHELL_OsIsUnicode())
840 return ShellExecuteExW (sei);
841 return ShellExecuteExA32 (sei, SHELL_ExecuteA);
844 /*************************************************************************
845 * ShellExecuteExA [SHELL32.292]
848 BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei)
850 return ShellExecuteExA32 (sei, SHELL_ExecuteA);
853 /*************************************************************************
854 * ShellExecuteExW [SHELL32.293]
857 BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei)
859 SHELLEXECUTEINFOA seiA;
864 memcpy(&seiA, sei, sizeof(SHELLEXECUTEINFOA));
867 seiA.lpVerb = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpVerb);
870 seiA.lpFile = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpFile);
872 if (sei->lpParameters)
873 seiA.lpParameters = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpParameters);
875 if (sei->lpDirectory)
876 seiA.lpDirectory = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpDirectory);
878 if ((sei->fMask & SEE_MASK_CLASSNAME) && sei->lpClass)
879 seiA.lpClass = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpClass);
883 ret = ShellExecuteExA(&seiA);
885 if (seiA.lpVerb) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpVerb );
886 if (seiA.lpFile) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpFile );
887 if (seiA.lpParameters) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpParameters );
888 if (seiA.lpDirectory) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpDirectory );
889 if (seiA.lpClass) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpClass );
894 /*************************************************************************
895 * ShellExecuteW [SHELL32.294]
897 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
898 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
900 HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, LPCWSTR lpFile,
901 LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
903 SHELLEXECUTEINFOW sei;
907 sei.cbSize = sizeof(sei);
910 sei.lpVerb = lpOperation;
912 sei.lpParameters = lpParameters;
913 sei.lpDirectory = lpDirectory;
914 sei.nShow = nShowCmd;
919 sei.hProcess = hProcess;
921 ShellExecuteExW (&sei);