From 57ee58f10c7aadc1a351769060837f6c5a0cec50 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 30 Jul 2008 18:42:39 -0700 Subject: [PATCH] cmd: Use ShellExecuteExW instead of CreateProcess for opening files. --- programs/cmd/wcmdmain.c | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 454bd3c..58d998c 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1170,14 +1170,38 @@ void WCMD_run_program (WCHAR *command, int called) { else console = SHGetFileInfo (temp, 0, &psfi, sizeof(psfi), SHGFI_EXETYPE); + if (!assumeInternal) { + SHELLEXECUTEINFOW sei; + static const WCHAR openW[] = { 'o', 'p', 'e', 'n', 0 }; + + memset(&sei, 0, sizeof(sei)); + sei.cbSize = sizeof(sei); + sei.lpVerb = openW; + sei.nShow = SW_SHOWNORMAL; + sei.fMask = SEE_MASK_FLAG_DDEWAIT| + SEE_MASK_FLAG_NO_UI| + SEE_MASK_NOCLOSEPROCESS; + sei.lpFile = thisDir; + sei.lpParameters = command; + if (!ShellExecuteExW(&sei)) + WINE_ERR("Error executing %s\n", wine_dbgstr_w(command)); + + if (context || !HIWORD(console)) + WaitForSingleObject (sei.hProcess, INFINITE); + GetExitCodeProcess(sei.hProcess, &errorlevel); + if (errorlevel == STILL_ACTIVE) + errorlevel = 0; + CloseHandle(sei.hProcess); + return; + } + ZeroMemory (&st, sizeof(STARTUPINFO)); st.cb = sizeof(STARTUPINFO); init_msvcrt_io_block(&st); /* Launch the process and if a CUI wait on it to complete Note: Launching internal wine processes cannot specify a full path to exe */ - status = CreateProcess (assumeInternal?NULL : thisDir, - command, NULL, NULL, TRUE, 0, NULL, NULL, &st, &pe); + status = CreateProcess (NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, &st, &pe); if ((opt_c || opt_k) && !opt_s && !status && GetLastError()==ERROR_FILE_NOT_FOUND && command[0]=='\"') { /* strip first and last quote WCHARacters and try again */ -- 1.5.4.5