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
, 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 NULL
, 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
;
162 /***********************************************************************
165 * Helper function for SHELL_FindExecutable
166 * @param lpResult - pointer to a buffer of size MAX_PATH
167 * On entry: szName is a filename (probably without path separators).
168 * On exit: if szName found in "App Path", place full path in lpResult, and return true
170 static BOOL
SHELL_TryAppPath( LPCSTR szName
, LPSTR lpResult
)
178 sprintf(szAppKey
, "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s", szName
);
179 res
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
, szAppKey
, 0, KEY_READ
, &hkApp
);
181 /*TRACE("RegOpenKeyExA(HKEY_LOCAL_MACHINE, %s,) returns %ld\n", szAppKey, res);*/
186 res
= RegQueryValueA(hkApp
, NULL
, lpResult
, &len
);
188 /*TRACE("RegQueryValueA(hkApp, NULL,) returns %ld\n", res);*/
191 /*TRACE("%s -> %s\n", szName, lpResult);*/
195 if (hkApp
) RegCloseKey(hkApp
);
199 /*************************************************************************
200 * SHELL_FindExecutable [Internal]
202 * Utility for code sharing between FindExecutable and ShellExecute
204 * lpFile the name of a file
205 * lpOperation the operation on it (open)
207 * lpResult a buffer, big enough :-(, to store the command to do the
208 * operation on the file
209 * key a buffer, big enough, to get the key name to do actually the
210 * command (it'll be used afterwards for more information
213 static UINT
SHELL_FindExecutable(LPCSTR lpPath
, LPCSTR lpFile
, LPCSTR lpOperation
,
214 LPSTR lpResult
, LPSTR key
)
216 char *extension
= NULL
; /* pointer to file extension */
217 char tmpext
[5]; /* local copy to mung as we please */
218 char filetype
[256]; /* registry name for this filetype */
219 LONG filetypelen
= 256; /* length of above */
220 char command
[256]; /* command from registry */
221 LONG commandlen
= 256; /* This is the most DOS can handle :) */
222 char buffer
[256]; /* Used to GetProfileString */
223 UINT retval
= 31; /* default - 'No association was found' */
224 char *tok
; /* token pointer */
225 char xlpFile
[256] = ""; /* result of SearchPath */
227 TRACE("%s\n", (lpFile
!= NULL
) ? lpFile
: "-");
229 lpResult
[0] = '\0'; /* Start off with an empty return string */
230 if (key
) *key
= '\0';
232 /* trap NULL parameters on entry */
233 if ((lpFile
== NULL
) || (lpResult
== NULL
) || (lpOperation
== NULL
))
235 WARN("(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
236 lpFile
, lpOperation
, lpResult
);
237 return 2; /* File not found. Close enough, I guess. */
240 if (SHELL_TryAppPath( lpFile
, lpResult
))
242 TRACE("found %s via App Paths\n", lpResult
);
246 if (SearchPathA(lpPath
, lpFile
, ".exe", sizeof(xlpFile
), xlpFile
, NULL
))
248 TRACE("SearchPathA returned non-zero\n");
250 /* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
253 /* First thing we need is the file's extension */
254 extension
= strrchr(xlpFile
, '.'); /* Assume last "." is the one; */
255 /* File->Run in progman uses */
257 TRACE("xlpFile=%s,extension=%s\n", xlpFile
, extension
);
259 if ((extension
== NULL
) || (extension
== &xlpFile
[strlen(xlpFile
)]))
261 WARN("Returning 31 - No association\n");
262 return 31; /* no association */
265 /* Make local copy & lowercase it for reg & 'programs=' lookup */
266 lstrcpynA(tmpext
, extension
, 5);
268 TRACE("%s file\n", tmpext
);
270 /* Three places to check: */
271 /* 1. win.ini, [windows], programs (NB no leading '.') */
272 /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
273 /* 3. win.ini, [extensions], extension (NB no leading '.' */
274 /* All I know of the order is that registry is checked before */
275 /* extensions; however, it'd make sense to check the programs */
276 /* section first, so that's what happens here. */
278 /* See if it's a program - if GetProfileString fails, we skip this
279 * section. Actually, if GetProfileString fails, we've probably
280 * got a lot more to worry about than running a program... */
281 if (GetProfileStringA("windows", "programs", "exe pif bat cmd com",
282 buffer
, sizeof(buffer
)) > 0)
286 for (i
= 0;i
<strlen(buffer
); i
++) buffer
[i
] = tolower(buffer
[i
]);
288 tok
= strtok(buffer
, " \t"); /* ? */
291 if (strcmp(tok
, &tmpext
[1]) == 0) /* have to skip the leading "." */
293 strcpy(lpResult
, xlpFile
);
294 /* Need to perhaps check that the file has a path
296 TRACE("found %s\n", lpResult
);
299 /* Greater than 32 to indicate success FIXME According to the
300 * docs, I should be returning a handle for the
301 * executable. Does this mean I'm supposed to open the
302 * executable file or something? More RTFM, I guess... */
304 tok
= strtok(NULL
, " \t");
309 if (RegQueryValueA(HKEY_CLASSES_ROOT
, tmpext
, filetype
,
310 &filetypelen
) == ERROR_SUCCESS
)
312 filetype
[filetypelen
] = '\0';
313 TRACE("File type: %s\n", filetype
);
315 /* Looking for ...buffer\shell\lpOperation\command */
316 strcat(filetype
, "\\shell\\");
317 strcat(filetype
, lpOperation
);
318 strcat(filetype
, "\\command");
320 if (RegQueryValueA(HKEY_CLASSES_ROOT
, filetype
, command
,
321 &commandlen
) == ERROR_SUCCESS
)
323 if (key
) strcpy(key
, filetype
);
329 /* FIXME: it seems all Windows version don't behave the same here.
330 * the doc states that this ddeexec information can be found after
332 * on Win98, it doesn't appear, but I think it does on Win2k
334 /* Get the parameters needed by the application
335 from the associated ddeexec key */
336 tmp
= strstr(filetype
, "command");
338 strcat(filetype
, "ddeexec");
340 if (RegQueryValueA(HKEY_CLASSES_ROOT
, filetype
, param
, ¶mlen
) == ERROR_SUCCESS
)
342 strcat(command
, " ");
343 strcat(command
, param
);
344 commandlen
+= paramlen
;
347 command
[commandlen
] = '\0';
348 argify(lpResult
, sizeof(lpResult
), command
, xlpFile
);
349 retval
= 33; /* FIXME see above */
352 else /* Check win.ini */
354 /* Toss the leading dot */
356 if (GetProfileStringA("extensions", extension
, "", command
,
357 sizeof(command
)) > 0)
359 if (strlen(command
) != 0)
361 strcpy(lpResult
, command
);
362 tok
= strstr(lpResult
, "^"); /* should be ^.extension? */
366 strcat(lpResult
, xlpFile
); /* what if no dir in xlpFile? */
367 tok
= strstr(command
, "^"); /* see above */
368 if ((tok
!= NULL
) && (strlen(tok
)>5))
370 strcat(lpResult
, &tok
[5]);
373 retval
= 33; /* FIXME - see above */
378 TRACE("returning %s\n", lpResult
);
382 /******************************************************************
385 * callback for the DDE connection. not really usefull
387 static HDDEDATA CALLBACK
dde_cb(UINT uType
, UINT uFmt
, HCONV hConv
,
389 HDDEDATA hData
, DWORD dwData1
, DWORD dwData2
)
394 /******************************************************************
397 * ShellExecute helper. Used to do an operation with a DDE connection
399 * Handles both the direct connection (try #1), and if it fails,
400 * launching an application and trying (#2) to connect to it
403 static unsigned dde_connect(char* key
, char* start
, char* ddeexec
,
405 LPSHELLEXECUTEINFOA sei
, SHELL_ExecuteA1632 execfunc
)
407 char* endkey
= key
+ strlen(key
);
408 char app
[256], topic
[256], ifexec
[256], res
[256];
409 LONG applen
, topiclen
, ifexeclen
;
413 HSZ hszApp
, hszTopic
;
417 strcpy(endkey
, "\\application");
418 applen
= sizeof(app
);
419 if (RegQueryValueA(HKEY_CLASSES_ROOT
, key
, app
, &applen
) != ERROR_SUCCESS
)
421 FIXME("default app name NIY %s\n", key
);
425 strcpy(endkey
, "\\topic");
426 topiclen
= sizeof(topic
);
427 if (RegQueryValueA(HKEY_CLASSES_ROOT
, key
, topic
, &topiclen
) != ERROR_SUCCESS
)
429 strcpy(topic
, "System");
432 if (DdeInitializeA(&ddeInst
, dde_cb
, APPCMD_CLIENTONLY
, 0L) != DMLERR_NO_ERROR
)
437 hszApp
= DdeCreateStringHandleA(ddeInst
, app
, CP_WINANSI
);
438 hszTopic
= DdeCreateStringHandleA(ddeInst
, topic
, CP_WINANSI
);
440 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
444 TRACE("Launching '%s'\n", start
);
445 ret
= execfunc(start
, sei
, TRUE
);
448 TRACE("Couldn't launch\n");
451 hConv
= DdeConnect(ddeInst
, hszApp
, hszTopic
, NULL
);
454 TRACE("Couldn't connect. ret=%d\n", ret
);
455 ret
= 30; /* whatever */
458 strcpy(endkey
, "\\ifexec");
459 ifexeclen
= sizeof(ifexec
);
460 if (RegQueryValueA(HKEY_CLASSES_ROOT
, key
, ifexec
, &ifexeclen
) == ERROR_SUCCESS
)
466 argify(res
, sizeof(res
), exec
, lpFile
);
467 TRACE("%s %s => %s\n", exec
, lpFile
, res
);
469 ret
= (DdeClientTransaction(res
, strlen(res
) + 1, hConv
, 0L, 0,
470 XTYP_EXECUTE
, 10000, &tid
) != DMLERR_NO_ERROR
) ? 31 : 33;
471 DdeDisconnect(hConv
);
473 DdeUninitialize(ddeInst
);
477 /*************************************************************************
478 * execute_from_key [Internal]
480 static UINT
execute_from_key(LPSTR key
, LPCSTR lpFile
, LPSHELLEXECUTEINFOA sei
, SHELL_ExecuteA1632 execfunc
)
483 LONG cmdlen
= sizeof(cmd
);
486 /* Get the application for the registry */
487 if (RegQueryValueA(HKEY_CLASSES_ROOT
, key
, cmd
, &cmdlen
) == ERROR_SUCCESS
)
490 char param
[256] = "";
493 /* Get the parameters needed by the application
494 from the associated ddeexec key */
495 tmp
= strstr(key
, "command");
497 strcpy(tmp
, "ddeexec");
499 if (RegQueryValueA(HKEY_CLASSES_ROOT
, key
, param
, ¶mlen
) == ERROR_SUCCESS
)
501 TRACE("Got ddeexec %s => %s\n", key
, param
);
502 retval
= dde_connect(key
, cmd
, param
, lpFile
, sei
, execfunc
);
506 /* Is there a replace() function anywhere? */
508 argify(param
, sizeof(param
), cmd
, lpFile
);
509 retval
= execfunc(param
, sei
, FALSE
);
512 else TRACE("ooch\n");
517 /*************************************************************************
518 * FindExecutableA [SHELL32.@]
520 HINSTANCE WINAPI
FindExecutableA(LPCSTR lpFile
, LPCSTR lpDirectory
, LPSTR lpResult
)
522 UINT retval
= 31; /* default - 'No association was found' */
525 TRACE("File %s, Dir %s\n",
526 (lpFile
!= NULL
? lpFile
: "-"), (lpDirectory
!= NULL
? lpDirectory
: "-"));
528 lpResult
[0] = '\0'; /* Start off with an empty return string */
530 /* trap NULL parameters on entry */
531 if ((lpFile
== NULL
) || (lpResult
== NULL
))
533 /* FIXME - should throw a warning, perhaps! */
534 return (HINSTANCE
)2; /* File not found. Close enough, I guess. */
539 GetCurrentDirectoryA(sizeof(old_dir
), old_dir
);
540 SetCurrentDirectoryA(lpDirectory
);
543 retval
= SHELL_FindExecutable(lpDirectory
, lpFile
, "open", lpResult
, NULL
);
545 TRACE("returning %s\n", lpResult
);
547 SetCurrentDirectoryA(old_dir
);
548 return (HINSTANCE
)retval
;
551 /*************************************************************************
552 * FindExecutableW [SHELL32.@]
554 HINSTANCE WINAPI
FindExecutableW(LPCWSTR lpFile
, LPCWSTR lpDirectory
, LPWSTR lpResult
)
556 FIXME("(%p,%p,%p): stub\n", lpFile
, lpDirectory
, lpResult
);
557 return (HINSTANCE
)31; /* default - 'No association was found' */
560 /*************************************************************************
561 * ShellExecuteExA32 [Internal]
563 BOOL WINAPI
ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei
, SHELL_ExecuteA1632 execfunc
)
565 CHAR szApplicationName
[MAX_PATH
],szCommandline
[MAX_PATH
],szPidl
[20],fileName
[MAX_PATH
];
568 char lpstrProtocol
[256];
569 LPCSTR lpFile
,lpOperation
;
574 TRACE("mask=0x%08lx hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
575 sei
->fMask
, sei
->hwnd
, debugstr_a(sei
->lpVerb
),
576 debugstr_a(sei
->lpFile
), debugstr_a(sei
->lpParameters
),
577 debugstr_a(sei
->lpDirectory
), sei
->nShow
,
578 (sei
->fMask
& SEE_MASK_CLASSNAME
) ? debugstr_a(sei
->lpClass
) : "not used");
580 sei
->hProcess
= NULL
;
581 ZeroMemory(szApplicationName
,MAX_PATH
);
583 strcpy(szApplicationName
, sei
->lpFile
);
585 ZeroMemory(szCommandline
,MAX_PATH
);
586 if (sei
->lpParameters
)
587 strcpy(szCommandline
, sei
->lpParameters
);
589 if (sei
->fMask
& (SEE_MASK_INVOKEIDLIST
| SEE_MASK_ICON
| SEE_MASK_HOTKEY
|
590 SEE_MASK_CONNECTNETDRV
| SEE_MASK_FLAG_DDEWAIT
|
591 SEE_MASK_DOENVSUBST
| SEE_MASK_FLAG_NO_UI
| SEE_MASK_UNICODE
|
592 SEE_MASK_NO_CONSOLE
| SEE_MASK_ASYNCOK
| SEE_MASK_HMONITOR
))
594 FIXME("flags ignored: 0x%08lx\n", sei
->fMask
);
597 /* process the IDList */
598 if ( (sei
->fMask
& SEE_MASK_INVOKEIDLIST
) == SEE_MASK_INVOKEIDLIST
) /*0x0c*/
600 SHGetPathFromIDListA (sei
->lpIDList
,szApplicationName
);
601 TRACE("-- idlist=%p (%s)\n", sei
->lpIDList
, szApplicationName
);
605 if (sei
->fMask
& SEE_MASK_IDLIST
)
607 pos
= strstr(szCommandline
, "%I");
611 HGLOBAL hmem
= SHAllocShared ( sei
->lpIDList
, ILGetSize(sei
->lpIDList
), 0);
612 pv
= SHLockShared(hmem
,0);
613 sprintf(szPidl
,":%p",pv
);
616 gap
= strlen(szPidl
);
618 memmove(pos
+gap
,pos
+2,len
);
619 memcpy(pos
,szPidl
,gap
);
624 if (sei
->fMask
& (SEE_MASK_CLASSNAME
| SEE_MASK_CLASSKEY
))
626 /* launch a document by fileclass like 'WordPad.Document.1' */
627 /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
628 /* FIXME: szCommandline should not be of a fixed size. Plus MAX_PATH is way too short! */
629 if (sei
->fMask
& SEE_MASK_CLASSKEY
)
630 HCR_GetExecuteCommandEx(sei
->hkeyClass
,
631 (sei
->fMask
& SEE_MASK_CLASSNAME
) ? sei
->lpClass
: NULL
,
632 (sei
->lpVerb
) ? sei
->lpVerb
: "open", szCommandline
, sizeof(szCommandline
));
633 else if (sei
->fMask
& SEE_MASK_CLASSNAME
)
634 HCR_GetExecuteCommandA(sei
->lpClass
, (sei
->lpVerb
) ? sei
->lpVerb
:
635 "open", szCommandline
, sizeof(szCommandline
));
637 /* FIXME: get the extension of lpFile, check if it fits to the lpClass */
638 TRACE("SEE_MASK_CLASSNAME->'%s', doc->'%s'\n", szCommandline
, szApplicationName
);
641 done
= argify(cmd
, sizeof(cmd
), szCommandline
, szApplicationName
);
642 if (!done
&& szApplicationName
[0])
645 strcat(cmd
, szApplicationName
);
647 retval
= execfunc(cmd
, sei
, FALSE
);
654 /* We set the default to open, and that should generally work.
655 But that is not really the way the MS docs say to do it. */
656 if (sei
->lpVerb
== NULL
)
657 lpOperation
= "open";
659 lpOperation
= sei
->lpVerb
;
661 /* Else, try to execute the filename */
662 TRACE("execute:'%s','%s'\n",szApplicationName
, szCommandline
);
664 strcpy(fileName
, szApplicationName
);
666 if (szCommandline
[0]) {
667 strcat(szApplicationName
, " ");
668 strcat(szApplicationName
, szCommandline
);
671 retval
= execfunc(szApplicationName
, sei
, FALSE
);
675 /* Else, try to find the executable */
677 retval
= SHELL_FindExecutable(sei
->lpDirectory
, lpFile
, lpOperation
, cmd
, lpstrProtocol
);
678 if (retval
> 32) /* Found */
680 CHAR szQuotedCmd
[MAX_PATH
+2];
681 /* Must quote to handle case where cmd contains spaces,
682 * else security hole if malicious user creates executable file "C:\\Program"
684 if (szCommandline
[0])
685 sprintf(szQuotedCmd
, "\"%s\" %s", cmd
, szCommandline
);
687 sprintf(szQuotedCmd
, "\"%s\"", cmd
);
688 TRACE("%s/%s => %s/%s\n", szApplicationName
, lpOperation
, szQuotedCmd
, lpstrProtocol
);
690 retval
= execute_from_key(lpstrProtocol
, szApplicationName
, sei
, execfunc
);
692 retval
= execfunc(szQuotedCmd
, sei
, FALSE
);
694 else if (PathIsURLA((LPSTR
)lpFile
)) /* File not found, check for URL */
699 lpstrRes
= strchr(lpFile
, ':');
701 iSize
= lpstrRes
- lpFile
;
703 iSize
= strlen(lpFile
);
705 TRACE("Got URL: %s\n", lpFile
);
706 /* Looking for ...protocol\shell\lpOperation\command */
707 strncpy(lpstrProtocol
, lpFile
, iSize
);
708 lpstrProtocol
[iSize
] = '\0';
709 strcat(lpstrProtocol
, "\\shell\\");
710 strcat(lpstrProtocol
, lpOperation
);
711 strcat(lpstrProtocol
, "\\command");
713 /* Remove File Protocol from lpFile */
714 /* In the case file://path/file */
715 if (!strncasecmp(lpFile
, "file", iSize
))
718 while (*lpFile
== ':') lpFile
++;
720 retval
= execute_from_key(lpstrProtocol
, lpFile
, sei
, execfunc
);
722 /* Check if file specified is in the form www.??????.*** */
723 else if (!strncasecmp(lpFile
, "www", 3))
725 /* if so, append lpFile http:// and call ShellExecute */
726 char lpstrTmpFile
[256] = "http://" ;
727 strcat(lpstrTmpFile
, lpFile
);
728 retval
= (UINT
)ShellExecuteA(sei
->hwnd
, lpOperation
, lpstrTmpFile
, NULL
, NULL
, 0);
733 sei
->hInstApp
= (HINSTANCE
)retval
;
737 sei
->hInstApp
= (HINSTANCE
)33;
741 /*************************************************************************
742 * ShellExecuteA [SHELL32.290]
744 HINSTANCE WINAPI
ShellExecuteA(HWND hWnd
, LPCSTR lpOperation
,LPCSTR lpFile
,
745 LPCSTR lpParameters
,LPCSTR lpDirectory
, INT iShowCmd
)
747 SHELLEXECUTEINFOA sei
;
751 sei
.cbSize
= sizeof(sei
);
754 sei
.lpVerb
= lpOperation
;
756 sei
.lpParameters
= lpParameters
;
757 sei
.lpDirectory
= lpDirectory
;
758 sei
.nShow
= iShowCmd
;
763 sei
.hProcess
= hProcess
;
765 ShellExecuteExA32 (&sei
, SHELL_ExecuteA
);
769 /*************************************************************************
770 * ShellExecuteEx [SHELL32.291]
773 BOOL WINAPI
ShellExecuteExAW (LPVOID sei
)
775 if (SHELL_OsIsUnicode())
776 return ShellExecuteExW (sei
);
777 return ShellExecuteExA32 (sei
, SHELL_ExecuteA
);
780 /*************************************************************************
781 * ShellExecuteExA [SHELL32.292]
784 BOOL WINAPI
ShellExecuteExA (LPSHELLEXECUTEINFOA sei
)
786 return ShellExecuteExA32 (sei
, SHELL_ExecuteA
);
789 /*************************************************************************
790 * ShellExecuteExW [SHELL32.293]
793 BOOL WINAPI
ShellExecuteExW (LPSHELLEXECUTEINFOW sei
)
795 SHELLEXECUTEINFOA seiA
;
800 memcpy(&seiA
, sei
, sizeof(SHELLEXECUTEINFOA
));
803 seiA
.lpVerb
= HEAP_strdupWtoA( GetProcessHeap(), 0, sei
->lpVerb
);
806 seiA
.lpFile
= HEAP_strdupWtoA( GetProcessHeap(), 0, sei
->lpFile
);
808 if (sei
->lpParameters
)
809 seiA
.lpParameters
= HEAP_strdupWtoA( GetProcessHeap(), 0, sei
->lpParameters
);
811 if (sei
->lpDirectory
)
812 seiA
.lpDirectory
= HEAP_strdupWtoA( GetProcessHeap(), 0, sei
->lpDirectory
);
814 if ((sei
->fMask
& SEE_MASK_CLASSNAME
) && sei
->lpClass
)
815 seiA
.lpClass
= HEAP_strdupWtoA( GetProcessHeap(), 0, sei
->lpClass
);
819 ret
= ShellExecuteExA(&seiA
);
821 if (seiA
.lpVerb
) HeapFree( GetProcessHeap(), 0, (LPSTR
) seiA
.lpVerb
);
822 if (seiA
.lpFile
) HeapFree( GetProcessHeap(), 0, (LPSTR
) seiA
.lpFile
);
823 if (seiA
.lpParameters
) HeapFree( GetProcessHeap(), 0, (LPSTR
) seiA
.lpParameters
);
824 if (seiA
.lpDirectory
) HeapFree( GetProcessHeap(), 0, (LPSTR
) seiA
.lpDirectory
);
825 if (seiA
.lpClass
) HeapFree( GetProcessHeap(), 0, (LPSTR
) seiA
.lpClass
);
830 /*************************************************************************
831 * ShellExecuteW [SHELL32.294]
833 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
834 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
836 HINSTANCE WINAPI
ShellExecuteW(HWND hwnd
, LPCWSTR lpOperation
, LPCWSTR lpFile
,
837 LPCWSTR lpParameters
, LPCWSTR lpDirectory
, INT nShowCmd
)
839 SHELLEXECUTEINFOW sei
;
843 sei
.cbSize
= sizeof(sei
);
846 sei
.lpVerb
= lpOperation
;
848 sei
.lpParameters
= lpParameters
;
849 sei
.lpDirectory
= lpDirectory
;
850 sei
.nShow
= nShowCmd
;
855 sei
.hProcess
= hProcess
;
857 ShellExecuteExW (&sei
);