2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Testing ShellExecuteEx
5 * PROGRAMMER: Yaroslav Veremenko <yaroslav@veremenko.info>
13 #define ok_ShellExecuteEx (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : TestShellExecuteEx
17 CreateAppPathRegKey(const WCHAR
* Name
)
23 DWORD Length
= sizeof(KeyValue
);
26 wcscpy(Buffer
, L
"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
27 wcscat(Buffer
, L
"IEXPLORE.EXE");
28 Result
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, Buffer
, 0, KEY_READ
, &RegistryKey
);
29 if (Result
!= ERROR_SUCCESS
) trace("Could not open iexplore.exe key. Status: %lu\n", Result
);
31 Result
= RegQueryValueExW(RegistryKey
, NULL
, NULL
, NULL
, (LPBYTE
)KeyValue
, &Length
);
32 if (Result
!= ERROR_SUCCESS
) trace("Could not read iexplore.exe key. Status: %lu\n", Result
);
34 RegCloseKey(RegistryKey
);
36 wcscpy(Buffer
, L
"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
38 Result
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, Buffer
, 0, NULL
,
39 0, KEY_WRITE
, NULL
, &RegistryKey
, &Disposition
);
40 if (Result
!= ERROR_SUCCESS
) trace("Could not create test key. Status: %lu\n", Result
);
42 Result
= RegSetValueW(RegistryKey
, NULL
, REG_SZ
, KeyValue
, 0);
43 if (Result
!= ERROR_SUCCESS
) trace("Could not set value of the test key. Status: %lu\n", Result
);
45 RegCloseKey(RegistryKey
);
47 if (RegistryKey
) RegCloseKey(RegistryKey
);
48 return Result
== ERROR_SUCCESS
;
53 DeleteAppPathRegKey(const WCHAR
* Name
)
57 wcscpy(Buffer
, L
"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
59 Result
= RegDeleteKeyW(HKEY_LOCAL_MACHINE
, Buffer
);
60 if (Result
!= ERROR_SUCCESS
) trace("Could not remove the test key. Status: %lu\n", Result
);
65 TestShellExecuteEx(const WCHAR
* Name
, BOOL ExpectedResult
)
67 SHELLEXECUTEINFOW ShellExecInfo
;
69 ZeroMemory(&ShellExecInfo
, sizeof(ShellExecInfo
));
70 ShellExecInfo
.cbSize
= sizeof(ShellExecInfo
);
71 ShellExecInfo
.fMask
= SEE_MASK_NOCLOSEPROCESS
| SEE_MASK_FLAG_NO_UI
;
72 ShellExecInfo
.hwnd
= NULL
;
73 ShellExecInfo
.nShow
= SW_SHOWNORMAL
;
74 ShellExecInfo
.lpFile
= Name
;
75 ShellExecInfo
.lpDirectory
= NULL
;
76 Result
= ShellExecuteExW(&ShellExecInfo
);
77 ok(Result
== ExpectedResult
, "ShellExecuteEx lpFile %s failed. Error: %lu\n", wine_dbgstr_w(Name
), GetLastError());
78 if (ShellExecInfo
.hProcess
)
80 Result
= TerminateProcess(ShellExecInfo
.hProcess
, 0);
81 if (!Result
) trace("Terminate process failed. Error: %lu\n", GetLastError());
82 WaitForSingleObject(ShellExecInfo
.hProcess
, INFINITE
);
83 CloseHandle(ShellExecInfo
.hProcess
);
87 START_TEST(ShellExecuteEx
)
89 ok_ShellExecuteEx(L
"iexplore", TRUE
);
90 ok_ShellExecuteEx(L
"iexplore.exe", TRUE
);
92 if (CreateAppPathRegKey(L
"iexplore.bat"))
94 ok_ShellExecuteEx(L
"iexplore.bat", TRUE
);
95 ok_ShellExecuteEx(L
"iexplore.bat.exe", FALSE
);
96 DeleteAppPathRegKey(L
"iexplore.bat");
99 if (CreateAppPathRegKey(L
"iexplore.bat.exe"))
101 ok_ShellExecuteEx(L
"iexplore.bat", FALSE
);
102 ok_ShellExecuteEx(L
"iexplore.bat.exe", TRUE
);
103 DeleteAppPathRegKey(L
"iexplore.bat.exe");