mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 19:21:38 +00:00
[SHELL32][CMD][SHLWAPI] Use the openas verb when invoking unknown file types (#7981)
CORE-20184
This commit is contained in:
parent
6dd8e04438
commit
d663eb4466
11 changed files with 249 additions and 170 deletions
|
@ -266,10 +266,10 @@ typedef BOOL (WINAPI *MYEX)(LPSHELLEXECUTEINFO lpExecInfo);
|
|||
HANDLE RunFile(DWORD flags, LPTSTR filename, LPTSTR params,
|
||||
LPTSTR directory, INT show)
|
||||
{
|
||||
SHELLEXECUTEINFO sei;
|
||||
SHELLEXECUTEINFO sei = { sizeof(sei), flags | SEE_MASK_FLAG_DDEWAIT };
|
||||
HMODULE hShell32;
|
||||
MYEX hShExt;
|
||||
BOOL ret;
|
||||
UINT err;
|
||||
|
||||
TRACE ("RunFile(%s)\n", debugstr_aw(filename));
|
||||
hShell32 = LoadLibrary(_T("SHELL32.DLL"));
|
||||
|
@ -289,19 +289,17 @@ HANDLE RunFile(DWORD flags, LPTSTR filename, LPTSTR params,
|
|||
|
||||
TRACE ("RunFile: ShellExecuteExA/W is at %x\n", hShExt);
|
||||
|
||||
memset(&sei, 0, sizeof sei);
|
||||
sei.cbSize = sizeof sei;
|
||||
sei.fMask = flags;
|
||||
sei.lpFile = filename;
|
||||
sei.lpParameters = params;
|
||||
sei.lpDirectory = directory;
|
||||
sei.nShow = show;
|
||||
ret = hShExt(&sei);
|
||||
|
||||
TRACE ("RunFile: ShellExecuteExA/W returned 0x%p\n", ret);
|
||||
err = hShExt(&sei) ? ERROR_SUCCESS : GetLastError();
|
||||
TRACE ("RunFile: ShellExecuteExA/W returned error %#x\n", err);
|
||||
|
||||
FreeLibrary(hShell32);
|
||||
return ret ? sei.hProcess : NULL;
|
||||
|
||||
SetLastError(err);
|
||||
return err ? NULL : sei.hProcess;
|
||||
}
|
||||
|
||||
|
||||
|
@ -431,6 +429,7 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
|
|||
/* exec the program */
|
||||
PROCESS_INFORMATION prci;
|
||||
STARTUPINFO stui;
|
||||
UINT execerror = ERROR_FILE_NOT_FOUND;
|
||||
|
||||
/* build command line for CreateProcess(): FullName + " " + rest */
|
||||
BOOL quoted = !!_tcschr(First, _T(' '));
|
||||
|
@ -450,8 +449,8 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
|
|||
memset(&stui, 0, sizeof(stui));
|
||||
stui.cb = sizeof(stui);
|
||||
stui.lpTitle = Full;
|
||||
stui.dwFlags = STARTF_USESHOWWINDOW;
|
||||
stui.wShowWindow = SW_SHOWDEFAULT;
|
||||
stui.dwFlags = 0;
|
||||
stui.wShowWindow = SW_SHOWNORMAL;
|
||||
|
||||
/* Set the console to standard mode */
|
||||
SetConsoleMode(ConStreamGetOSHandle(StdIn),
|
||||
|
@ -470,14 +469,12 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
|
|||
{
|
||||
CloseHandle(prci.hThread);
|
||||
}
|
||||
else
|
||||
else if (GetLastError() == ERROR_BAD_EXE_FORMAT)
|
||||
{
|
||||
// See if we can run this with ShellExecute() ie myfile.xls
|
||||
prci.hProcess = RunFile(SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE,
|
||||
szFullName,
|
||||
rest,
|
||||
NULL,
|
||||
SW_SHOWNORMAL);
|
||||
HANDLE hProcess = RunFile(SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE,
|
||||
szFullName, rest, NULL, SW_SHOWNORMAL);
|
||||
execerror = hProcess ? ERROR_SUCCESS : GetLastError();
|
||||
}
|
||||
|
||||
*FirstEnd = _T('\0');
|
||||
|
@ -499,10 +496,13 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
|
|||
}
|
||||
CloseHandle(prci.hProcess);
|
||||
}
|
||||
else
|
||||
else if (execerror)
|
||||
{
|
||||
TRACE ("[ShellExecute failed!: %s]\n", debugstr_aw(Full));
|
||||
error_bad_command(first);
|
||||
if (execerror == ERROR_NO_ASSOCIATION)
|
||||
error_cant_exec_program();
|
||||
else
|
||||
error_bad_command(first);
|
||||
dwExitCode = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ VOID error_parameter_format(TCHAR ch);
|
|||
VOID error_invalid_switch(TCHAR ch);
|
||||
VOID error_invalid_parameter_format(PCTSTR s);
|
||||
VOID error_out_of_memory(VOID);
|
||||
VOID error_cant_exec_program(VOID);
|
||||
VOID error_syntax(PCTSTR s);
|
||||
|
||||
VOID msg_pause(VOID);
|
||||
|
|
|
@ -141,6 +141,13 @@ VOID error_out_of_memory(VOID)
|
|||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
VOID error_cant_exec_program(VOID)
|
||||
{
|
||||
/* TODO: Windows uses the custom string "The system cannot execute the specified program" here */
|
||||
ErrorMessage(ERROR_NO_ASSOCIATION, NULL);
|
||||
nErrorLevel = 1;
|
||||
}
|
||||
|
||||
|
||||
VOID error_invalid_parameter_format(PCWSTR s)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue