Make some shell32 files compile in MSVC.
[wine/multimedia.git] / dlls / shell32 / shlexec.c
blob6da4c82a9c4a57dc25576026159cd424516793b1
1 /*
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
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdlib.h>
26 #include <string.h>
27 #include <stdio.h>
28 #ifdef HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
31 #include <ctype.h>
32 #include <assert.h>
34 #include "windef.h"
35 #include "winerror.h"
36 #include "winreg.h"
37 #include "wownt32.h"
38 #include "heap.h"
39 #include "shellapi.h"
40 #include "shlobj.h"
41 #include "shlwapi.h"
42 #include "ddeml.h"
44 #include "wine/winbase16.h"
45 #include "shell32_main.h"
46 #include "undocshell.h"
48 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(exec);
52 /***********************************************************************
53 * this function is supposed to expand the escape sequences found in the registry
54 * some diving reported that the following were used:
55 * + %1, %2... seem to report to parameter of index N in ShellExecute pmts
56 * %1 file
57 * %2 printer
58 * %3 driver
59 * %4 port
60 * %I adress of a global item ID (explorer switch /idlist)
61 * %L seems to be %1 as long filename followed by the 8+3 variation
62 * %S ???
63 * %* all following parameters (see batfile)
65 static BOOL argify(char* res, int len, const char* fmt, const char* lpFile)
67 char xlpFile[1024];
68 BOOL done = FALSE;
70 while (*fmt)
72 if (*fmt == '%')
74 switch (*++fmt)
76 case '\0':
77 case '%':
78 *res++ = '%';
79 break;
80 case '1':
81 case '*':
82 if (!done || (*fmt == '1'))
84 if (SearchPathA(NULL, lpFile, ".exe", sizeof(xlpFile), xlpFile, NULL))
86 strcpy(res, xlpFile);
87 res += strlen(xlpFile);
89 else
91 strcpy(res, lpFile);
92 res += strlen(lpFile);
95 break;
96 default: FIXME("Unknown escape sequence %%%c\n", *fmt);
98 fmt++;
99 done = TRUE;
101 else
102 *res++ = *fmt++;
104 *res = '\0';
105 return done;
108 /*************************************************************************
109 * SHELL_ExecuteA [Internal]
112 static UINT SHELL_ExecuteA(char *lpCmd, LPSHELLEXECUTEINFOA sei, BOOL shWait)
114 STARTUPINFOA startup;
115 PROCESS_INFORMATION info;
116 UINT retval = 31;
118 TRACE("Execute %s from directory %s\n", lpCmd, sei->lpDirectory);
119 ZeroMemory(&startup,sizeof(STARTUPINFOA));
120 startup.cb = sizeof(STARTUPINFOA);
121 startup.dwFlags = STARTF_USESHOWWINDOW;
122 startup.wShowWindow = sei->nShow;
123 if (CreateProcessA(NULL, lpCmd, NULL, NULL, FALSE, 0,
124 NULL, sei->lpDirectory, &startup, &info))
126 /* Give 30 seconds to the app to come up, if desired. Probably only needed
127 when starting app immediately before making a DDE connection. */
128 if (shWait)
129 if (WaitForInputIdle( info.hProcess, 30000 ) == -1)
130 WARN("WaitForInputIdle failed: Error %ld\n", GetLastError() );
131 retval = 33;
132 if(sei->fMask & SEE_MASK_NOCLOSEPROCESS)
133 sei->hProcess = info.hProcess;
134 else
135 CloseHandle( info.hProcess );
136 CloseHandle( info.hThread );
138 else if ((retval = GetLastError()) >= 32)
140 FIXME("Strange error set by CreateProcess: %d\n", retval);
141 retval = ERROR_BAD_FORMAT;
144 sei->hInstApp = (HINSTANCE)retval;
145 return retval;
148 /*************************************************************************
149 * SHELL_FindExecutable [Internal]
151 * Utility for code sharing between FindExecutable and ShellExecute
152 * in:
153 * lpFile the name of a file
154 * lpOperation the operation on it (open)
155 * out:
156 * lpResult a buffer, big enough :-(, to store the command to do the
157 * operation on the file
158 * key a buffer, big enough, to get the key name to do actually the
159 * command (it'll be used afterwards for more information
160 * on the operation)
162 static UINT SHELL_FindExecutable(LPCSTR lpPath, LPCSTR lpFile, LPCSTR lpOperation,
163 LPSTR lpResult, LPSTR key)
165 char *extension = NULL; /* pointer to file extension */
166 char tmpext[5]; /* local copy to mung as we please */
167 char filetype[256]; /* registry name for this filetype */
168 LONG filetypelen = 256; /* length of above */
169 char command[256]; /* command from registry */
170 LONG commandlen = 256; /* This is the most DOS can handle :) */
171 char buffer[256]; /* Used to GetProfileString */
172 UINT retval = 31; /* default - 'No association was found' */
173 char *tok; /* token pointer */
174 char xlpFile[256] = ""; /* result of SearchPath */
176 TRACE("%s\n", (lpFile != NULL) ? lpFile : "-");
178 lpResult[0] = '\0'; /* Start off with an empty return string */
180 /* trap NULL parameters on entry */
181 if ((lpFile == NULL) || (lpResult == NULL) || (lpOperation == NULL))
183 WARN("(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
184 lpFile, lpOperation, lpResult);
185 return 2; /* File not found. Close enough, I guess. */
188 if (SearchPathA(lpPath, lpFile, ".exe", sizeof(xlpFile), xlpFile, NULL))
190 TRACE("SearchPathA returned non-zero\n");
191 lpFile = xlpFile;
194 /* First thing we need is the file's extension */
195 extension = strrchr(xlpFile, '.'); /* Assume last "." is the one; */
196 /* File->Run in progman uses */
197 /* .\FILE.EXE :( */
198 TRACE("xlpFile=%s,extension=%s\n", xlpFile, extension);
200 if ((extension == NULL) || (extension == &xlpFile[strlen(xlpFile)]))
202 WARN("Returning 31 - No association\n");
203 return 31; /* no association */
206 /* Make local copy & lowercase it for reg & 'programs=' lookup */
207 lstrcpynA(tmpext, extension, 5);
208 CharLowerA(tmpext);
209 TRACE("%s file\n", tmpext);
211 /* Three places to check: */
212 /* 1. win.ini, [windows], programs (NB no leading '.') */
213 /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
214 /* 3. win.ini, [extensions], extension (NB no leading '.' */
215 /* All I know of the order is that registry is checked before */
216 /* extensions; however, it'd make sense to check the programs */
217 /* section first, so that's what happens here. */
219 if (key) *key = '\0';
221 /* See if it's a program - if GetProfileString fails, we skip this
222 * section. Actually, if GetProfileString fails, we've probably
223 * got a lot more to worry about than running a program... */
224 if (GetProfileStringA("windows", "programs", "exe pif bat com",
225 buffer, sizeof(buffer)) > 0)
227 UINT i;
229 for (i = 0;i<strlen(buffer); i++) buffer[i] = tolower(buffer[i]);
231 tok = strtok(buffer, " \t"); /* ? */
232 while (tok!= NULL)
234 if (strcmp(tok, &tmpext[1]) == 0) /* have to skip the leading "." */
236 strcpy(lpResult, xlpFile);
237 /* Need to perhaps check that the file has a path
238 * attached */
239 TRACE("found %s\n", lpResult);
240 return 33;
242 /* Greater than 32 to indicate success FIXME According to the
243 * docs, I should be returning a handle for the
244 * executable. Does this mean I'm supposed to open the
245 * executable file or something? More RTFM, I guess... */
247 tok = strtok(NULL, " \t");
251 /* Check registry */
252 if (RegQueryValueA(HKEY_CLASSES_ROOT, tmpext, filetype,
253 &filetypelen) == ERROR_SUCCESS)
255 filetype[filetypelen] = '\0';
256 TRACE("File type: %s\n", filetype);
258 /* Looking for ...buffer\shell\lpOperation\command */
259 strcat(filetype, "\\shell\\");
260 strcat(filetype, lpOperation);
261 strcat(filetype, "\\command");
263 if (RegQueryValueA(HKEY_CLASSES_ROOT, filetype, command,
264 &commandlen) == ERROR_SUCCESS)
266 if (key) strcpy(key, filetype);
267 #if 0
268 LPSTR tmp;
269 char param[256];
270 LONG paramlen = 256;
272 /* FIXME: it seems all Windows version don't behave the same here.
273 * the doc states that this ddeexec information can be found after
274 * the exec names.
275 * on Win98, it doesn't appear, but I think it does on Win2k
277 /* Get the parameters needed by the application
278 from the associated ddeexec key */
279 tmp = strstr(filetype, "command");
280 tmp[0] = '\0';
281 strcat(filetype, "ddeexec");
283 if (RegQueryValueA(HKEY_CLASSES_ROOT, filetype, param, &paramlen) == ERROR_SUCCESS)
285 strcat(command, " ");
286 strcat(command, param);
287 commandlen += paramlen;
289 #endif
290 command[commandlen] = '\0';
291 argify(lpResult, sizeof(lpResult), command, xlpFile);
292 retval = 33; /* FIXME see above */
295 else /* Check win.ini */
297 /* Toss the leading dot */
298 extension++;
299 if (GetProfileStringA("extensions", extension, "", command,
300 sizeof(command)) > 0)
302 if (strlen(command) != 0)
304 strcpy(lpResult, command);
305 tok = strstr(lpResult, "^"); /* should be ^.extension? */
306 if (tok != NULL)
308 tok[0] = '\0';
309 strcat(lpResult, xlpFile); /* what if no dir in xlpFile? */
310 tok = strstr(command, "^"); /* see above */
311 if ((tok != NULL) && (strlen(tok)>5))
313 strcat(lpResult, &tok[5]);
316 retval = 33; /* FIXME - see above */
321 TRACE("returning %s\n", lpResult);
322 return retval;
325 /******************************************************************
326 * dde_cb
328 * callback for the DDE connection. not really usefull
330 static HDDEDATA CALLBACK dde_cb(UINT uType, UINT uFmt, HCONV hConv,
331 HSZ hsz1, HSZ hsz2,
332 HDDEDATA hData, DWORD dwData1, DWORD dwData2)
334 return NULL;
337 /******************************************************************
338 * dde_connect
340 * ShellExecute helper. Used to do an operation with a DDE connection
342 * Handles both the direct connection (try #1), and if it fails,
343 * launching an application and trying (#2) to connect to it
346 static unsigned dde_connect(char* key, char* start, char* ddeexec,
347 const char* lpFile,
348 LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc)
350 char* endkey = key + strlen(key);
351 char app[256], topic[256], ifexec[256], res[256];
352 LONG applen, topiclen, ifexeclen;
353 char* exec;
354 DWORD ddeInst = 0;
355 DWORD tid;
356 HSZ hszApp, hszTopic;
357 HCONV hConv;
358 unsigned ret = 31;
360 strcpy(endkey, "\\application");
361 applen = sizeof(app);
362 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, app, &applen) != ERROR_SUCCESS)
364 FIXME("default app name NIY %s\n", key);
365 return 2;
368 strcpy(endkey, "\\topic");
369 topiclen = sizeof(topic);
370 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, topic, &topiclen) != ERROR_SUCCESS)
372 strcpy(topic, "System");
375 if (DdeInitializeA(&ddeInst, dde_cb, APPCMD_CLIENTONLY, 0L) != DMLERR_NO_ERROR)
377 return 2;
380 hszApp = DdeCreateStringHandleA(ddeInst, app, CP_WINANSI);
381 hszTopic = DdeCreateStringHandleA(ddeInst, topic, CP_WINANSI);
383 hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL);
384 exec = ddeexec;
385 if (!hConv)
387 TRACE("Launching '%s'\n", start);
388 ret = execfunc(start, sei, TRUE);
389 if (ret < 32)
391 TRACE("Couldn't launch\n");
392 goto error;
394 hConv = DdeConnect(ddeInst, hszApp, hszTopic, NULL);
395 if (!hConv)
397 TRACE("Couldn't connect. ret=%d\n", ret);
398 ret = 30; /* whatever */
399 goto error;
401 strcpy(endkey, "\\ifexec");
402 ifexeclen = sizeof(ifexec);
403 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, ifexec, &ifexeclen) == ERROR_SUCCESS)
405 exec = ifexec;
409 argify(res, sizeof(res), exec, lpFile);
410 TRACE("%s %s => %s\n", exec, lpFile, res);
412 ret = (DdeClientTransaction(res, strlen(res) + 1, hConv, 0L, 0,
413 XTYP_EXECUTE, 10000, &tid) != DMLERR_NO_ERROR) ? 31 : 33;
414 DdeDisconnect(hConv);
415 error:
416 DdeUninitialize(ddeInst);
417 return ret;
420 /*************************************************************************
421 * execute_from_key [Internal]
423 static UINT execute_from_key(LPSTR key, LPCSTR lpFile, LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc)
425 char cmd[1024] = "";
426 LONG cmdlen = sizeof(cmd);
427 UINT retval = 31;
429 /* Get the application for the registry */
430 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, cmd, &cmdlen) == ERROR_SUCCESS)
432 LPSTR tmp;
433 char param[256] = "";
434 LONG paramlen = 256;
436 /* Get the parameters needed by the application
437 from the associated ddeexec key */
438 tmp = strstr(key, "command");
439 assert(tmp);
440 strcpy(tmp, "ddeexec");
442 if (RegQueryValueA(HKEY_CLASSES_ROOT, key, param, &paramlen) == ERROR_SUCCESS)
444 TRACE("Got ddeexec %s => %s\n", key, param);
445 retval = dde_connect(key, cmd, param, lpFile, sei, execfunc);
447 else
449 /* Is there a replace() function anywhere? */
450 cmd[cmdlen] = '\0';
451 argify(param, sizeof(param), cmd, lpFile);
452 retval = execfunc(param, sei, FALSE);
455 else TRACE("ooch\n");
457 return retval;
460 /*************************************************************************
461 * FindExecutableA [SHELL32.@]
463 HINSTANCE WINAPI FindExecutableA(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
465 UINT retval = 31; /* default - 'No association was found' */
466 char old_dir[1024];
468 TRACE("File %s, Dir %s\n",
469 (lpFile != NULL ? lpFile : "-"), (lpDirectory != NULL ? lpDirectory : "-"));
471 lpResult[0] = '\0'; /* Start off with an empty return string */
473 /* trap NULL parameters on entry */
474 if ((lpFile == NULL) || (lpResult == NULL))
476 /* FIXME - should throw a warning, perhaps! */
477 return (HINSTANCE)2; /* File not found. Close enough, I guess. */
480 if (lpDirectory)
482 GetCurrentDirectoryA(sizeof(old_dir), old_dir);
483 SetCurrentDirectoryA(lpDirectory);
486 retval = SHELL_FindExecutable(lpDirectory, lpFile, "open", lpResult, NULL);
488 TRACE("returning %s\n", lpResult);
489 if (lpDirectory)
490 SetCurrentDirectoryA(old_dir);
491 return (HINSTANCE)retval;
494 /*************************************************************************
495 * FindExecutableW [SHELL32.@]
497 HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpResult)
499 FIXME("(%p,%p,%p): stub\n", lpFile, lpDirectory, lpResult);
500 return (HINSTANCE)31; /* default - 'No association was found' */
503 /*************************************************************************
504 * ShellExecuteExA32 [Internal]
506 BOOL WINAPI ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc)
508 CHAR szApplicationName[MAX_PATH],szCommandline[MAX_PATH],szPidl[20],fileName[MAX_PATH];
509 LPSTR pos;
510 int gap, len;
511 char lpstrProtocol[256];
512 LPCSTR lpFile,lpOperation;
513 UINT retval = 31;
514 char cmd[1024];
515 BOOL done;
517 TRACE("mask=0x%08lx hwnd=%p verb=%s file=%s parm=%s dir=%s show=0x%08x class=%s\n",
518 sei->fMask, sei->hwnd, debugstr_a(sei->lpVerb),
519 debugstr_a(sei->lpFile), debugstr_a(sei->lpParameters),
520 debugstr_a(sei->lpDirectory), sei->nShow,
521 (sei->fMask & SEE_MASK_CLASSNAME) ? debugstr_a(sei->lpClass) : "not used");
523 sei->hProcess = (HANDLE)NULL;
524 ZeroMemory(szApplicationName,MAX_PATH);
525 if (sei->lpFile)
526 strcpy(szApplicationName, sei->lpFile);
528 ZeroMemory(szCommandline,MAX_PATH);
529 if (sei->lpParameters)
530 strcpy(szCommandline, sei->lpParameters);
532 if (sei->fMask & ((SEE_MASK_CLASSKEY & ~SEE_MASK_CLASSNAME) |
533 SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY |
534 SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT |
535 SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE |
536 SEE_MASK_NO_CONSOLE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR ))
538 FIXME("flags ignored: 0x%08lx\n", sei->fMask);
541 /* process the IDList */
542 if ( (sei->fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST) /*0x0c*/
544 SHGetPathFromIDListA (sei->lpIDList,szApplicationName);
545 TRACE("-- idlist=%p (%s)\n", sei->lpIDList, szApplicationName);
547 else
549 if (sei->fMask & SEE_MASK_IDLIST )
551 pos = strstr(szCommandline, "%I");
552 if (pos)
554 LPVOID pv;
555 HGLOBAL hmem = SHAllocShared ( sei->lpIDList, ILGetSize(sei->lpIDList), 0);
556 pv = SHLockShared(hmem,0);
557 sprintf(szPidl,":%p",pv );
558 SHUnlockShared(pv);
560 gap = strlen(szPidl);
561 len = strlen(pos)-2;
562 memmove(pos+gap,pos+2,len);
563 memcpy(pos,szPidl,gap);
568 if (sei->fMask & SEE_MASK_CLASSNAME)
570 /* launch a document by fileclass like 'WordPad.Document.1' */
571 /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
572 /* FIXME: szCommandline should not be of a fixed size. Plus MAX_PATH is way too short! */
573 HCR_GetExecuteCommandA(sei->lpClass, (sei->lpVerb) ? sei->lpVerb : "open", szCommandline, sizeof(szCommandline));
574 /* FIXME: get the extension of lpFile, check if it fits to the lpClass */
575 TRACE("SEE_MASK_CLASSNAME->'%s', doc->'%s'\n", szCommandline, szApplicationName);
577 cmd[0] = '\0';
578 done = argify(cmd, sizeof(cmd), szCommandline, szApplicationName);
579 if (!done && szApplicationName[0])
581 strcat(cmd, " ");
582 strcat(cmd, szApplicationName);
584 retval = execfunc(cmd, sei, FALSE);
585 if (retval > 32)
586 return TRUE;
587 else
588 return FALSE;
591 /* We set the default to open, and that should generally work.
592 But that is not really the way the MS docs say to do it. */
593 if (sei->lpVerb == NULL)
594 lpOperation = "open";
595 else
596 lpOperation = sei->lpVerb;
598 /* Else, try to execute the filename */
599 TRACE("execute:'%s','%s'\n",szApplicationName, szCommandline);
601 strcpy(fileName, szApplicationName);
602 lpFile = fileName;
603 if (szCommandline[0]) {
604 strcat(szApplicationName, " ");
605 strcat(szApplicationName, szCommandline);
608 retval = execfunc(szApplicationName, sei, FALSE);
609 if (retval > 32)
610 return TRUE;
612 /* Else, try to find the executable */
613 cmd[0] = '\0';
614 retval = SHELL_FindExecutable(sei->lpDirectory, lpFile, lpOperation, cmd, lpstrProtocol);
615 if (retval > 32) /* Found */
617 if (szCommandline[0]) {
618 strcat(cmd, " ");
619 strcat(cmd, szCommandline);
621 TRACE("%s/%s => %s/%s\n", szApplicationName, lpOperation, cmd, lpstrProtocol);
622 if (*lpstrProtocol)
623 retval = execute_from_key(lpstrProtocol, szApplicationName, sei, execfunc);
624 else
625 retval = execfunc(cmd, sei, FALSE);
627 else if (PathIsURLA((LPSTR)lpFile)) /* File not found, check for URL */
629 LPSTR lpstrRes;
630 INT iSize;
632 lpstrRes = strchr(lpFile, ':');
633 if (lpstrRes)
634 iSize = lpstrRes - lpFile;
635 else
636 iSize = strlen(lpFile);
638 TRACE("Got URL: %s\n", lpFile);
639 /* Looking for ...protocol\shell\lpOperation\command */
640 strncpy(lpstrProtocol, lpFile, iSize);
641 lpstrProtocol[iSize] = '\0';
642 strcat(lpstrProtocol, "\\shell\\");
643 strcat(lpstrProtocol, lpOperation);
644 strcat(lpstrProtocol, "\\command");
646 /* Remove File Protocol from lpFile */
647 /* In the case file://path/file */
648 if (!strncasecmp(lpFile, "file", iSize))
650 lpFile += iSize;
651 while (*lpFile == ':') lpFile++;
653 retval = execute_from_key(lpstrProtocol, lpFile, sei, execfunc);
655 /* Check if file specified is in the form www.??????.*** */
656 else if (!strncasecmp(lpFile, "www", 3))
658 /* if so, append lpFile http:// and call ShellExecute */
659 char lpstrTmpFile[256] = "http://" ;
660 strcat(lpstrTmpFile, lpFile);
661 retval = (UINT)ShellExecuteA(sei->hwnd, lpOperation, lpstrTmpFile, NULL, NULL, 0);
664 if (retval <= 32)
666 sei->hInstApp = (HINSTANCE)retval;
667 return FALSE;
670 sei->hInstApp = (HINSTANCE)33;
671 return TRUE;
674 /*************************************************************************
675 * ShellExecuteA [SHELL32.290]
677 HINSTANCE WINAPI ShellExecuteA(HWND hWnd, LPCSTR lpOperation,LPCSTR lpFile,
678 LPCSTR lpParameters,LPCSTR lpDirectory, INT iShowCmd)
680 SHELLEXECUTEINFOA sei;
681 HANDLE hProcess = 0;
683 TRACE("\n");
684 sei.cbSize = sizeof(sei);
685 sei.fMask = 0;
686 sei.hwnd = hWnd;
687 sei.lpVerb = lpOperation;
688 sei.lpFile = lpFile;
689 sei.lpParameters = lpParameters;
690 sei.lpDirectory = lpDirectory;
691 sei.nShow = iShowCmd;
692 sei.lpIDList = 0;
693 sei.lpClass = 0;
694 sei.hkeyClass = 0;
695 sei.dwHotKey = 0;
696 sei.hProcess = hProcess;
698 ShellExecuteExA32 (&sei, SHELL_ExecuteA);
699 return sei.hInstApp;
702 /*************************************************************************
703 * ShellExecuteEx [SHELL32.291]
706 BOOL WINAPI ShellExecuteExAW (LPVOID sei)
708 if (SHELL_OsIsUnicode())
709 return ShellExecuteExW (sei);
710 return ShellExecuteExA32 (sei, SHELL_ExecuteA);
713 /*************************************************************************
714 * ShellExecuteExA [SHELL32.292]
717 BOOL WINAPI ShellExecuteExA (LPSHELLEXECUTEINFOA sei)
719 return ShellExecuteExA32 (sei, SHELL_ExecuteA);
722 /*************************************************************************
723 * ShellExecuteExW [SHELL32.293]
726 BOOL WINAPI ShellExecuteExW (LPSHELLEXECUTEINFOW sei)
728 SHELLEXECUTEINFOA seiA;
729 DWORD ret;
731 TRACE("%p\n", sei);
733 memcpy(&seiA, sei, sizeof(SHELLEXECUTEINFOA));
735 if (sei->lpVerb)
736 seiA.lpVerb = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpVerb);
738 if (sei->lpFile)
739 seiA.lpFile = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpFile);
741 if (sei->lpParameters)
742 seiA.lpParameters = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpParameters);
744 if (sei->lpDirectory)
745 seiA.lpDirectory = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpDirectory);
747 if ((sei->fMask & SEE_MASK_CLASSNAME) && sei->lpClass)
748 seiA.lpClass = HEAP_strdupWtoA( GetProcessHeap(), 0, sei->lpClass);
749 else
750 seiA.lpClass = NULL;
752 ret = ShellExecuteExA(&seiA);
754 if (seiA.lpVerb) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpVerb );
755 if (seiA.lpFile) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpFile );
756 if (seiA.lpParameters) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpParameters );
757 if (seiA.lpDirectory) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpDirectory );
758 if (seiA.lpClass) HeapFree( GetProcessHeap(), 0, (LPSTR) seiA.lpClass );
760 return ret;
763 /*************************************************************************
764 * ShellExecuteW [SHELL32.294]
765 * from shellapi.h
766 * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation,
767 * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd);
769 HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, LPCWSTR lpFile,
770 LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
772 SHELLEXECUTEINFOW sei;
773 HANDLE hProcess = 0;
775 TRACE("\n");
776 sei.cbSize = sizeof(sei);
777 sei.fMask = 0;
778 sei.hwnd = hwnd;
779 sei.lpVerb = lpOperation;
780 sei.lpFile = lpFile;
781 sei.lpParameters = lpParameters;
782 sei.lpDirectory = lpDirectory;
783 sei.nShow = nShowCmd;
784 sei.lpIDList = 0;
785 sei.lpClass = 0;
786 sei.hkeyClass = 0;
787 sei.dwHotKey = 0;
788 sei.hProcess = hProcess;
790 ShellExecuteExW (&sei);
791 return sei.hInstApp;