Index: rostests/apitests/shell32/ShellExecuteEx.cpp =================================================================== --- rostests/apitests/shell32/ShellExecuteEx.cpp (revision 74622) +++ rostests/apitests/shell32/ShellExecuteEx.cpp (working copy) @@ -2,15 +2,15 @@ * PROJECT: ReactOS api tests * LICENSE: GPLv2+ - See COPYING in the top level directory * PURPOSE: Testing ShellExecuteEx - * PROGRAMMER: Yaroslav Veremenko + * PROGRAMMERS: Yaroslav Veremenko + * Katayama Hirofumi MZ */ #include "shelltest.h" - - #define ok_ShellExecuteEx (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : TestShellExecuteEx +#define ok_ShellExecuteEx2 (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : TestShellExecuteEx2 static BOOL @@ -84,7 +84,8 @@ } } -START_TEST(ShellExecuteEx) +static void +Test_ShellExecuteEx(void) { ok_ShellExecuteEx(L"iexplore", TRUE); ok_ShellExecuteEx(L"iexplore.exe", TRUE); @@ -103,3 +104,134 @@ DeleteAppPathRegKey(L"iexplore.bat.exe"); } } + +static void +TestShellExecuteEx2(const WCHAR* File, const WCHAR* Params, BOOL ExpectedResult) +{ + SHELLEXECUTEINFOW ShellExecInfo; + BOOL Result; + ZeroMemory(&ShellExecInfo, sizeof(ShellExecInfo)); + ShellExecInfo.cbSize = sizeof(ShellExecInfo); + ShellExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI | + SEE_MASK_WAITFORINPUTIDLE; + ShellExecInfo.hwnd = NULL; + ShellExecInfo.nShow = SW_SHOWNORMAL; + ShellExecInfo.lpFile = File; + ShellExecInfo.lpParameters = Params; + Result = ShellExecuteExW(&ShellExecInfo); + ok(Result == ExpectedResult, "ShellExecute (%s, %s) failed. Error: %lu\n", + wine_dbgstr_w(File), wine_dbgstr_w(Params), GetLastError()); + if (ShellExecInfo.hProcess) + { + Result = TerminateProcess(ShellExecInfo.hProcess, 0); + if (!Result) trace("Terminate process failed. Error: %lu\n", GetLastError()); + WaitForSingleObject(ShellExecInfo.hProcess, 1000); + CloseHandle(ShellExecInfo.hProcess); + } +} + +static void +Test_ShellExecuteEx2(void) +{ + WCHAR WinDir[MAX_PATH], SysDir[MAX_PATH], FontsDir[MAX_PATH]; + WCHAR *pch, ReadMePath[MAX_PATH], ModifiedPath[MAX_PATH]; + + GetWindowsDirectoryW(WinDir, _countof(WinDir)); + GetSystemDirectoryW(SysDir, _countof(SysDir)); + lstrcpyW(FontsDir, WinDir); + lstrcatW(FontsDir, L"\\Fonts"); + + ok_ShellExecuteEx2(WinDir, NULL, TRUE); + ok_ShellExecuteEx2(SysDir, NULL, TRUE); + ok_ShellExecuteEx2(FontsDir, NULL, TRUE); + ok_ShellExecuteEx2(L"fonts", NULL, TRUE); + + ok_ShellExecuteEx2(L"explorer", WinDir, TRUE); + ok_ShellExecuteEx2(L"explorer", SysDir, TRUE); + ok_ShellExecuteEx2(L"explorer", FontsDir, TRUE); + ok_ShellExecuteEx2(L"explorer", L"fonts", TRUE); + + ok_ShellExecuteEx2(L"EXPLORER", WinDir, TRUE); + ok_ShellExecuteEx2(L"EXPLORER", SysDir, TRUE); + ok_ShellExecuteEx2(L"EXPLORER", FontsDir, TRUE); + ok_ShellExecuteEx2(L"EXPLORER", L"fonts", TRUE); + + ok_ShellExecuteEx2(L"explorer.exe", WinDir, TRUE); + ok_ShellExecuteEx2(L"explorer.exe", SysDir, TRUE); + ok_ShellExecuteEx2(L"explorer.exe", FontsDir, TRUE); + ok_ShellExecuteEx2(L"explorer.exe", L"fonts", TRUE); + + ok_ShellExecuteEx2(L"EXPLORER.EXE", WinDir, TRUE); + ok_ShellExecuteEx2(L"EXPLORER.EXE", SysDir, TRUE); + ok_ShellExecuteEx2(L"EXPLORER.EXE", FontsDir, TRUE); + ok_ShellExecuteEx2(L"EXPLORER.EXE", L"fonts", TRUE); + + ok_ShellExecuteEx2(L"notepad", NULL, TRUE); + ok_ShellExecuteEx2(L"NOTEPAD", NULL, TRUE); + + ok_ShellExecuteEx2(L"notepad.exe", NULL, TRUE); + ok_ShellExecuteEx2(L"NOTEPAD.EXE", NULL, TRUE); + + ok_ShellExecuteEx2(L"notepad.exe ", NULL, TRUE); + ok_ShellExecuteEx2(L"notepad.exe\t", NULL, FALSE); + ok_ShellExecuteEx2(L"notepad.exe\n", NULL, FALSE); + + ok_ShellExecuteEx2(L" notepad.exe", NULL, FALSE); + ok_ShellExecuteEx2(L"\tnotepad.exe", NULL, FALSE); + ok_ShellExecuteEx2(L"\nnotepad.exe", NULL, FALSE); + + GetModuleFileNameW(NULL, ReadMePath, _countof(ReadMePath)); + pch = wcsrchr(ReadMePath, L'\\'); + lstrcpyW(pch, L"\\testdata\\README.txt"); + + if (GetFileAttributesW(ReadMePath) == INVALID_FILE_ATTRIBUTES) + { + skip("Not found: %s\n", wine_dbgstr_w(ReadMePath)); + } + else + { + ok_ShellExecuteEx2(ReadMePath, NULL, TRUE); + + ok_ShellExecuteEx2(L"notepad", ReadMePath, TRUE); + ok_ShellExecuteEx2(L"NOTEPAD", ReadMePath, TRUE); + ok_ShellExecuteEx2(L"notepad.exe", ReadMePath, TRUE); + ok_ShellExecuteEx2(L"NOTEPAD.EXE", ReadMePath, TRUE); + + ok_ShellExecuteEx2(L"notepad.exe ", ReadMePath, TRUE); + ok_ShellExecuteEx2(L"notepad.exe\t", ReadMePath, FALSE); + ok_ShellExecuteEx2(L"notepad.exe\n", ReadMePath, FALSE); + ok_ShellExecuteEx2(L" notepad.exe", ReadMePath, FALSE); + ok_ShellExecuteEx2(L"\tnotepad.exe", ReadMePath, FALSE); + ok_ShellExecuteEx2(L"\nnotepad.exe", ReadMePath, FALSE); + + lstrcpyW(ModifiedPath, ReadMePath); + lstrcatW(ModifiedPath, L" "); + ok_ShellExecuteEx2(ModifiedPath, NULL, TRUE); + + lstrcpyW(ModifiedPath, ReadMePath); + lstrcatW(ModifiedPath, L"\t"); + ok_ShellExecuteEx2(ModifiedPath, NULL, FALSE); + + lstrcpyW(ModifiedPath, ReadMePath); + lstrcatW(ModifiedPath, L"\n"); + ok_ShellExecuteEx2(ModifiedPath, NULL, FALSE); + + lstrcpyW(ModifiedPath, L" "); + lstrcatW(ModifiedPath, ReadMePath); + ok_ShellExecuteEx2(ModifiedPath, NULL, FALSE); + + lstrcpyW(ModifiedPath, L"\t"); + lstrcatW(ModifiedPath, ReadMePath); + ok_ShellExecuteEx2(ModifiedPath, NULL, FALSE); + + lstrcpyW(ModifiedPath, L"\n"); + lstrcatW(ModifiedPath, ReadMePath); + ok_ShellExecuteEx2(ModifiedPath, NULL, FALSE); + } +} + +START_TEST(ShellExecuteEx) +{ + Test_ShellExecuteEx(); + Test_ShellExecuteEx2(); +}