ReactOS 0.4.16-dev-1537-g4e425b5
ShellExecuteW.cpp File Reference
#include "shelltest.h"
#include <stdio.h>
#include <winbase.h>
#include <shlwapi.h>
#include "closewnd.h"
Include dependency graph for ShellExecuteW.cpp:

Go to the source code of this file.

Functions

static void CloseWindow (HINSTANCE hInstance, PCWSTR ClassName, PCWSTR Title)
 
 START_TEST (ShellExecuteW)
 

Variables

WINDOW_LIST g_winlist
 

Function Documentation

◆ CloseWindow()

static void CloseWindow ( HINSTANCE  hInstance,
PCWSTR  ClassName,
PCWSTR  Title 
)
static

Definition at line 20 of file ShellExecuteW.cpp.

21{
22 if ((SIZE_T)hInstance <= 32)
23 return;
24
25 HWND hWnd = NULL;
26 for (UINT i = 0; i < 1500; i += 250)
27 {
28 hWnd = FindWindowW(ClassName, Title);
30 break;
31 hWnd = NULL;
32 Sleep(250);
33 }
34
37}
WINDOW_LIST g_winlist
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: charmap.c:19
static HWND FindInWindowList(const WINDOW_LIST &list, HWND hWnd)
Definition: closewnd.h:80
static VOID CloseNewWindows(PWINDOW_LIST pExisting, PWINDOW_LIST pNew)
Definition: closewnd.h:101
#define NULL
Definition: types.h:112
static const WCHAR Title[]
Definition: oid.c:1259
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define WM_SYSCOMMAND
Definition: winuser.h:1769
#define SC_CLOSE
Definition: winuser.h:2628
#define PostMessage
Definition: winuser.h:5943
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by DIALOG_EXECUTE_DlgProc(), OnTimer(), PROGRAM_ExecuteProgram(), and START_TEST().

◆ START_TEST()

START_TEST ( ShellExecuteW  )

Definition at line 39 of file ShellExecuteW.cpp.

40{
41 INT ret;
43 WCHAR WinDir[MAX_PATH], SysDir[MAX_PATH], SysDrive[MAX_PATH];
44
45 if (!GetWindowsDirectoryW(WinDir, _countof(WinDir)))
46 {
47 skip("GetWindowsDirectoryW failed\n");
48 return;
49 }
50 if (!GetSystemDirectoryW(SysDir, _countof(SysDir)))
51 {
52 skip("GetSystemDirectoryW failed\n");
53 return;
54 }
55 if (!GetEnvironmentVariableW(L"SystemDrive", SysDrive, _countof(SysDrive)))
56 {
57 trace("GetEnvironmentVariableW('SystemDrive') failed\n");
58 SysDrive[0] = SysDir[0];
59 SysDrive[1] = L':';
60 SysDrive[2] = 0;
61 }
62 PathAddBackslashW(SysDrive);
63
65
66 // TEST #1: Open Control Panel
67 hInstance = ShellExecuteW(NULL, L"open", L"rundll32.exe", L"shell32.dll,Control_RunDLL desk.cpl",
70 ok(ret > 31, "TEST #1: ret:%d, LastError: %ld\n", ret, GetLastError());
71 trace("TEST #1 ret: %d.\n", ret);
72 CloseWindow(hInstance, NULL, L"Properties for Display"); // FIXME: Dynamically determine the window title.
73
74 // TEST #2: Open Notepad
75 hInstance = ShellExecuteW(NULL, L"open", L"notepad.exe", NULL, NULL, SW_SHOWNORMAL);
77 ok(ret > 31, "TEST #2: ret:%d, LastError: %ld\n", ret, GetLastError());
78 trace("TEST #2 ret: %d.\n", ret);
79 CloseWindow(hInstance, L"Notepad", L"Untitled - Notepad"); // FIXME: Dynamically determine the window title.
80
81 // TEST #3: Open Windows folder
84 ok(ret > 31, "TEST #3: ret:%d, LastError: %ld\n", ret, GetLastError());
85 trace("TEST #3 ret: %d.\n", ret);
86 CloseWindow(hInstance, L"CabinetWClass", PathFindFileNameW(WinDir));
87
88 // TEST #4: Open system32 folder
89 hInstance = ShellExecuteW(NULL, L"open", SysDir, NULL, NULL, SW_SHOWNORMAL);
91 ok(ret > 31, "TEST #4: ret:%d, LastError: %ld\n", ret, GetLastError());
92 trace("TEST #4 ret: %d.\n", ret);
93 CloseWindow(hInstance, L"CabinetWClass", PathFindFileNameW(SysDir));
94
95 // TEST #5: Open %SystemDrive%
96 hInstance = ShellExecuteW(NULL, L"explore", SysDrive, NULL, NULL, SW_SHOWNORMAL);
98 ok(ret > 31, "TEST #5: ret:%d, LastError: %ld\n", ret, GetLastError());
99 trace("TEST #5 ret: %d.\n", ret);
100 CloseWindow(hInstance, L"ExploreWClass", NULL);
101
102 // TEST #6: Open Explorer Search on %SYSTEMDRIVE%
103 hInstance = ShellExecuteW(NULL, L"find", SysDrive, NULL, NULL, SW_SHOWNORMAL);
105 ok(ret > 31, "TEST #6: ret:%d, LastError: %ld\n", ret, GetLastError());
106 trace("TEST #6 ret: %d.\n", ret);
107 CloseWindow(hInstance, L"CabinetWClass", L"Search Results"); // FIXME: Dynamically determine the window title.
108
109 // TEST #7: Open My Documents ("::{450d8fba-ad25-11d0-98a8-0800361b1103}")
110 hInstance = ShellExecuteW(NULL, NULL, L"::{450d8fba-ad25-11d0-98a8-0800361b1103}", NULL, NULL, SW_SHOWNORMAL);
112 ok(ret > 31, "TEST #7: ret:%d, LastError: %ld\n", ret, GetLastError());
113 trace("TEST #7 ret: %d.\n", ret);
114 CloseWindow(hInstance, L"CabinetWClass", NULL);
115
116 // TEST #8: Open My Documents ("shell:::{450d8fba-ad25-11d0-98a8-0800361b1103}")
117 hInstance = ShellExecuteW(NULL, L"open", L"shell:::{450d8fba-ad25-11d0-98a8-0800361b1103}", NULL, NULL, SW_SHOWNORMAL);
119 ok(ret > 31, "TEST #8: ret:%d, LastError: %ld\n", ret, GetLastError());
120 trace("TEST #8 ret: %d.\n", ret);
121 CloseWindow(hInstance, L"CabinetWClass", NULL);
122
125}
static void CloseWindow(HINSTANCE hInstance, PCWSTR ClassName, PCWSTR Title)
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
static VOID FreeWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:32
static VOID GetWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:54
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define PathAddBackslashW
Definition: pathcch.h:302
#define INT
Definition: polytest.cpp:20
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2607
#define _countof(array)
Definition: sndvol32.h:70
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SW_SHOWNORMAL
Definition: winuser.h:781
__wchar_t WCHAR
Definition: xmlstorage.h:180

Variable Documentation

◆ g_winlist

WINDOW_LIST g_winlist

Definition at line 18 of file ShellExecuteW.cpp.

Referenced by CloseWindow(), and START_TEST().