ReactOS 0.4.16-dev-1493-ge7358c5
ShellExecCmdLine.cpp File Reference
#include "shelltest.h"
#include <shlwapi.h>
#include <strsafe.h>
#include <versionhelpers.h>
#include "shell32_apitest_sub.h"
#include "closewnd.h"
#include <debug.h>
#include <stdio.h>
Include dependency graph for ShellExecCmdLine.cpp:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 

Macros

#define NDEBUG
 
#define SECL_NO_UI   0x2
 
#define SECL_LOG_USAGE   0x8
 
#define SECL_USE_IDLIST   0x10
 
#define SECL_ALLOW_NONEXE   0x20
 
#define SECL_RUNAS   0x40
 
#define ShellExecCmdLine   proxy_ShellExecCmdLine
 
#define shell32_hInstance   GetModuleHandle(NULL)
 
#define IDS_FILE_NOT_FOUND   (-1)
 

Typedefs

typedef HRESULT(WINAPISHELLEXECCMDLINE) (HWND, LPCWSTR, LPCWSTR, INT, LPVOID, DWORD)
 
typedef struct TEST_ENTRY TEST_ENTRY
 

Functions

static __inline void __SHCloneStrW (WCHAR **target, const WCHAR *source)
 
static LPCWSTR SplitParams (LPCWSTR psz, LPWSTR pszArg0, size_t cchArg0)
 
HRESULT WINAPI ShellExecCmdLine (HWND hwnd, LPCWSTR pwszCommand, LPCWSTR pwszStartDir, int nShow, LPVOID pUnused, DWORD dwSeclFlags)
 
static void DoEntry (const TEST_ENTRY *pEntry)
 
static VOID TEST_ShellExecCmdLine (VOID)
 
 START_TEST (ShellExecCmdLine)
 

Variables

static const WCHAR wszExe [] = L".exe"
 
static const WCHAR wszCom [] = L".com"
 
SHELLEXECCMDLINE g_pShellExecCmdLine = NULL
 
static WCHAR s_sub_program [MAX_PATH]
 
static WCHAR s_win_test_exe [MAX_PATH]
 
static WCHAR s_sys_bat_file [MAX_PATH]
 
static WCHAR s_cur_dir [MAX_PATH]
 
static const TEST_ENTRY s_entries_1 []
 
static const TEST_ENTRY s_entries_2 []
 
static WINDOW_LIST s_List1
 
static WINDOW_LIST s_List2
 

Macro Definition Documentation

◆ IDS_FILE_NOT_FOUND

#define IDS_FILE_NOT_FOUND   (-1)

Definition at line 29 of file ShellExecCmdLine.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file ShellExecCmdLine.cpp.

◆ SECL_ALLOW_NONEXE

#define SECL_ALLOW_NONEXE   0x20

Definition at line 22 of file ShellExecCmdLine.cpp.

◆ SECL_LOG_USAGE

#define SECL_LOG_USAGE   0x8

Definition at line 20 of file ShellExecCmdLine.cpp.

◆ SECL_NO_UI

#define SECL_NO_UI   0x2

Definition at line 19 of file ShellExecCmdLine.cpp.

◆ SECL_RUNAS

#define SECL_RUNAS   0x40

Definition at line 23 of file ShellExecCmdLine.cpp.

◆ SECL_USE_IDLIST

#define SECL_USE_IDLIST   0x10

Definition at line 21 of file ShellExecCmdLine.cpp.

◆ shell32_hInstance

HINSTANCE shell32_hInstance   GetModuleHandle(NULL)

Definition at line 28 of file ShellExecCmdLine.cpp.

Referenced by CFSDropTarget::_GetEffectFromMenu(), CFSDropTarget::_GetUniqueFileName(), _InsertMenuItemW(), _SetOperationTitle(), _SHGetDefaultValue(), AboutDlgProc(), ActionDlg_OnBrowse(), COpenWithMenu::AddChooseProgramItem(), CDefaultContextMenu::AddStaticContextMenusToMenu(), BrFolder_NewFolder(), COpenWithDialog::Browse(), CDefView::CDefView(), ConfirmDialog(), Control_CreateListView(), Control_DoInterface(), Control_WndProc(), Control_WndProc_Create(), CNewMenu::CreateNewFolder(), CShellLink::CreateShortcutIcon(), CreateToolTipForButtons(), do_error_dialog(), CDefaultContextMenu::DoCreateNewFolder(), DrivesContextMenuCallback(), EditTypeDlg_OnCommand(), CDrvDefExt::ExtraPageProc(), FancyLogoffOnInit(), FileTypesDlg_Initialize(), FileTypesDlg_InitListView(), CDefView::FillEditMenu(), CDefView::FillViewMenu(), FolderOptionsFileTypesDlg(), FormatDriveDlg(), FormatExCB(), GeneralDlg_UpdateIcons(), CControlPanelFolder::GetDetailsOf(), CDrivesFolder::GetDisplayNameOf(), GetDriveNameWithLetter(), GetExtensionDefaultDescription(), GetFileTypeIconsEx(), GetFriendlyVerb(), HCR_GetClassNameA(), HCR_GetClassNameW(), COpenWithDialog::Init(), CDrvDefExt::InitGeneralPage(), CFileDefExt::InitGeneralPage(), CDesktopBrowser::Initialize(), CNewMenu::Initialize(), InitializeDefaultIcons(), InitializeFormatDriveDlg(), InitializeRecycleBinDlg(), CFileDefExt::InitMultifilePage(), CFileDefExt::InitMultifilePageThread(), CFileDefExt::InitOpensWithField(), InsertDefaultClusterSizeForFs(), CNewMenu::InsertShellNewItems(), COpenWithDialog::IsNoOpen(), LogoffWindowsDialog(), CShellLink::OnCommand(), CDefView::OnCreate(), CShellLink::OnInitDialog(), PickIconDlg(), PickIconProc(), Printer_LoadIconsW(), PropSheetProc(), CDefViewBckgrndMenu::QueryContextMenu(), CNewMenu::QueryContextMenu(), COpenWithMenu::QueryContextMenu(), RunDlgProc(), RunFileDlg(), SH_CreatePropertySheetPageEx(), SH_FormatByteSize(), SHBrowseForFolderW(), SHCreateDirectoryExW(), SHELL32_AssocGetFSDirectoryDescription(), SHELL32_OpenPropSheet(), SHELL32_PropertySheet(), SHELL_ConfirmDialogW(), SHELL_ConfirmIDs(), SHELL_ConfirmMsgBox(), ShellAboutW(), ShellExecCmdLine(), SHEmptyRecycleBinW(), SHFormatDrive(), SHOpenWithDialog(), ShowFolderOptionsDialogThreadProc(), SHWinHelp(), SIC_Initialize(), CFileDefExt::UpdateDirStatsResults(), CFileDefExt::UpdateFolderIcon(), CDefView::UpdateStatusbar(), and CDefView::UpdateStatusbarLocation().

◆ ShellExecCmdLine

#define ShellExecCmdLine   proxy_ShellExecCmdLine

Definition at line 26 of file ShellExecCmdLine.cpp.

Typedef Documentation

◆ SHELLEXECCMDLINE

typedef HRESULT(WINAPI * SHELLEXECCMDLINE) (HWND, LPCWSTR, LPCWSTR, INT, LPVOID, DWORD)

Definition at line 242 of file ShellExecCmdLine.cpp.

◆ TEST_ENTRY

Function Documentation

◆ __SHCloneStrW()

static __inline void __SHCloneStrW ( WCHAR **  target,
const WCHAR source 
)
static

Definition at line 34 of file ShellExecCmdLine.cpp.

35{
36 *target = (WCHAR *)SHAlloc((lstrlenW(source) + 1) * sizeof(WCHAR) );
38}
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:348
GLenum target
Definition: glext.h:7315
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ShellExecCmdLine().

◆ DoEntry()

static void DoEntry ( const TEST_ENTRY pEntry)
static

Definition at line 552 of file ShellExecCmdLine.cpp.

553{
554 HRESULT hr;
555 DWORD dwSeclFlags;
556 BOOL result;
557
558 if (pEntry->bAllowNonExe)
559 dwSeclFlags = SECL_NO_UI | SECL_ALLOW_NONEXE;
560 else
561 dwSeclFlags = SECL_NO_UI;
562
564 {
565 if (IsReactOS())
566 {
567 hr = proxy_ShellExecCmdLine(NULL, pEntry->pwszCommand, pEntry->pwszStartDir,
568 SW_SHOWNORMAL, NULL, dwSeclFlags);
569 }
570 else
571 {
572 hr = (*g_pShellExecCmdLine)(NULL, pEntry->pwszCommand, pEntry->pwszStartDir,
573 SW_SHOWNORMAL, NULL, dwSeclFlags);
574 }
575 }
577 {
578 hr = 0xBADFACE;
579 }
580 _SEH2_END;
581
582 if (hr == 0xBADFACE)
583 result = hr;
584 else
585 result = (hr == S_OK);
586
587 ok(result == pEntry->result, "Line %d: result expected %d, was %d\n",
588 pEntry->lineno, pEntry->result, result);
589}
#define SECL_ALLOW_NONEXE
#define SECL_NO_UI
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
GLuint64EXT * result
Definition: glext.h:11304
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define S_OK
Definition: intsafe.h:52
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
HRESULT hr
Definition: shlfolder.c:183
#define SW_SHOWNORMAL
Definition: winuser.h:781

Referenced by TEST_ShellExecCmdLine().

◆ ShellExecCmdLine()

HRESULT WINAPI ShellExecCmdLine ( HWND  hwnd,
LPCWSTR  pwszCommand,
LPCWSTR  pwszStartDir,
int  nShow,
LPVOID  pUnused,
DWORD  dwSeclFlags 
)

Definition at line 88 of file ShellExecCmdLine.cpp.

95{
98 LPCWSTR pszVerb = NULL;
99 WCHAR szFile[MAX_PATH], szFile2[MAX_PATH];
100 HRESULT hr;
101 LPCWSTR pchParams;
102 LPWSTR lpCommand = NULL;
103
104 if (pwszCommand == NULL)
106 1, (ULONG_PTR*)pwszCommand);
107
108 __SHCloneStrW(&lpCommand, pwszCommand);
109 StrTrimW(lpCommand, L" \t");
110
111 if (dwSeclFlags & SECL_NO_UI)
113 if (dwSeclFlags & SECL_LOG_USAGE)
115 if (dwSeclFlags & SECL_USE_IDLIST)
117
118 if (dwSeclFlags & SECL_RUNAS)
119 {
120 dwSize = 0;
121 hr = AssocQueryStringW(0, ASSOCSTR_COMMAND, lpCommand, L"RunAs", NULL, &dwSize);
122 if (SUCCEEDED(hr) && dwSize != 0)
123 {
124 pszVerb = L"runas";
125 }
126 }
127
128 if (UrlIsFileUrlW(lpCommand))
129 {
130 StringCchCopyW(szFile, _countof(szFile), lpCommand);
131 pchParams = NULL;
132 }
133 else
134 {
135 pchParams = SplitParams(lpCommand, szFile, _countof(szFile));
136 if (szFile[0] != UNICODE_NULL && szFile[1] == L':' &&
137 szFile[2] == UNICODE_NULL)
138 {
139 PathAddBackslashW(szFile);
140 }
141
142 WCHAR szCurDir[MAX_PATH];
143 GetCurrentDirectoryW(_countof(szCurDir), szCurDir);
144 if (pwszStartDir)
145 {
146 SetCurrentDirectoryW(pwszStartDir);
147 }
148
149 if (PathIsRelativeW(szFile) &&
150 GetFullPathNameW(szFile, _countof(szFile2), szFile2, NULL) &&
151 PathFileExistsW(szFile2))
152 {
153 StringCchCopyW(szFile, _countof(szFile), szFile2);
154 }
155 else if (SearchPathW(NULL, szFile, NULL, _countof(szFile2), szFile2, NULL) ||
156 SearchPathW(NULL, szFile, wszExe, _countof(szFile2), szFile2, NULL) ||
157 SearchPathW(NULL, szFile, wszCom, _countof(szFile2), szFile2, NULL) ||
158 SearchPathW(pwszStartDir, szFile, NULL, _countof(szFile2), szFile2, NULL) ||
159 SearchPathW(pwszStartDir, szFile, wszExe, _countof(szFile2), szFile2, NULL) ||
160 SearchPathW(pwszStartDir, szFile, wszCom, _countof(szFile2), szFile2, NULL))
161 {
162 StringCchCopyW(szFile, _countof(szFile), szFile2);
163 }
164 else if (SearchPathW(NULL, lpCommand, NULL, _countof(szFile2), szFile2, NULL) ||
165 SearchPathW(NULL, lpCommand, wszExe, _countof(szFile2), szFile2, NULL) ||
166 SearchPathW(NULL, lpCommand, wszCom, _countof(szFile2), szFile2, NULL) ||
167 SearchPathW(pwszStartDir, lpCommand, NULL, _countof(szFile2), szFile2, NULL) ||
168 SearchPathW(pwszStartDir, lpCommand, wszExe, _countof(szFile2), szFile2, NULL) ||
169 SearchPathW(pwszStartDir, lpCommand, wszCom, _countof(szFile2), szFile2, NULL))
170 {
171 StringCchCopyW(szFile, _countof(szFile), szFile2);
172 pchParams = NULL;
173 }
174
175 if (pwszStartDir)
176 {
177 SetCurrentDirectoryW(szCurDir);
178 }
179
180 if (!(dwSeclFlags & SECL_ALLOW_NONEXE))
181 {
182 if (!GetBinaryTypeW(szFile, &dwType))
183 {
184 SHFree(lpCommand);
185
186 if (!(dwSeclFlags & SECL_NO_UI))
187 {
188 WCHAR szText[128 + MAX_PATH], szFormat[128];
190 StringCchPrintfW(szText, _countof(szText), szFormat, szFile);
192 }
193 return CO_E_APPNOTFOUND;
194 }
195 }
196 else
197 {
199 {
200 SHFree(lpCommand);
201
202 if (!(dwSeclFlags & SECL_NO_UI))
203 {
204 WCHAR szText[128 + MAX_PATH], szFormat[128];
206 StringCchPrintfW(szText, _countof(szText), szFormat, szFile);
208 }
210 }
211 }
212 }
213
214 ZeroMemory(&info, sizeof(info));
215 info.cbSize = sizeof(info);
216 info.fMask = dwFlags;
217 info.hwnd = hwnd;
218 info.lpVerb = pszVerb;
219 info.lpFile = szFile;
220 info.lpParameters = (pchParams && *pchParams) ? pchParams : NULL;
221 info.lpDirectory = pwszStartDir;
222 info.nShow = nShow;
223 if (ShellExecuteExW(&info))
224 {
225 if (info.lpIDList)
226 CoTaskMemFree(info.lpIDList);
227
228 SHFree(lpCommand);
229
230 return S_OK;
231 }
232
233 dwError = GetLastError();
234
235 SHFree(lpCommand);
236
237 return HRESULT_FROM_WIN32(dwError);
238}
#define SECL_USE_IDLIST
static const WCHAR wszCom[]
#define SECL_LOG_USAGE
#define IDS_FILE_NOT_FOUND
static LPCWSTR SplitParams(LPCWSTR psz, LPWSTR pszArg0, size_t cchArg0)
#define shell32_hInstance
#define SECL_RUNAS
static __inline void __SHCloneStrW(WCHAR **target, const WCHAR *source)
static const WCHAR wszExe[]
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define MAX_PATH
Definition: compat.h:34
VOID WINAPI RaiseException(_In_ DWORD dwExceptionCode, _In_ DWORD dwExceptionFlags, _In_ DWORD nNumberOfArguments, _In_opt_ const ULONG_PTR *lpArguments)
Definition: except.c:700
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2249
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
BOOL WINAPI GetBinaryTypeW(LPCWSTR lpApplicationName, LPDWORD lpBinaryType)
Definition: vdm.c:1243
BOOL WINAPI PathIsRelativeW(const WCHAR *path)
Definition: path.c:1030
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2607
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
BOOL WINAPI StrTrimW(WCHAR *str, const WCHAR *trim)
Definition: string.c:796
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:441
#define L(x)
Definition: resources.c:13
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define UNICODE_NULL
#define PathAddBackslashW
Definition: pathcch.h:302
#define SEE_MASK_FLAG_LOG_USAGE
Definition: shellapi.h:55
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:37
#define SEE_MASK_NOASYNC
Definition: shellapi.h:35
#define SEE_MASK_INVOKEIDLIST
Definition: shellapi.h:28
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:38
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2552
#define UrlIsFileUrlW(x)
Definition: shlwapi.h:1423
@ ASSOCSTR_COMMAND
Definition: shlwapi.h:612
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define EXCEPTION_NONCONTINUABLE
Definition: stubs.h:23
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define ZeroMemory
Definition: winbase.h:1753
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define EXCEPTION_ACCESS_VIOLATION
Definition: winbase.h:344
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define CO_E_APPNOTFOUND
Definition: winerror.h:2808
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:798
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ SplitParams()

static LPCWSTR SplitParams ( LPCWSTR  psz,
LPWSTR  pszArg0,
size_t  cchArg0 
)
static

Definition at line 42 of file ShellExecCmdLine.cpp.

43{
45 size_t ich = 0;
46 if (*psz == L'"')
47 {
48 // 1st argument is quoted. the string in quotes is quoted 1st argument.
49 // [pch] --> [pszArg0+ich]
50 for (pch = psz + 1; *pch && ich + 1 < cchArg0; ++ich, ++pch)
51 {
52 if (*pch == L'"' && pch[1] == L'"')
53 {
54 // doubled double quotations found!
55 pszArg0[ich] = L'"';
56 }
57 else if (*pch == L'"')
58 {
59 // single double quotation found!
60 ++pch;
61 break;
62 }
63 else
64 {
65 // otherwise
66 pszArg0[ich] = *pch;
67 }
68 }
69 }
70 else
71 {
72 // 1st argument is unquoted. non-space sequence is 1st argument.
73 // [pch] --> [pszArg0+ich]
74 for (pch = psz; *pch && !iswspace(*pch) && ich + 1 < cchArg0; ++ich, ++pch)
75 {
76 pszArg0[ich] = *pch;
77 }
78 }
79 pszArg0[ich] = 0;
80
81 // skip space
82 while (iswspace(*pch))
83 ++pch;
84
85 return pch;
86}
#define iswspace(_c)
Definition: ctype.h:669
#define pch(ap)
Definition: match.c:418

Referenced by ShellExecCmdLine().

◆ START_TEST()

START_TEST ( ShellExecCmdLine  )

Definition at line 618 of file ShellExecCmdLine.cpp.

619{
620 using namespace std;
621
622 if (!IsReactOS())
623 {
625 {
626 skip("ShellExecCmdLine is not available on this platform\n");
627 return;
628 }
629
630 HMODULE hShell32 = GetModuleHandleA("shell32");
633 {
634 skip("ShellExecCmdLine is not found\n");
635 return;
636 }
637 }
638
640 {
641 skip("shell32_apitest_sub.exe is not found\n");
642 return;
643 }
644
645 // s_win_test_exe
647 PathAppendW(s_win_test_exe, L"test program.exe");
649 if (!ret)
650 {
651 skip("Please retry with admin rights\n");
652 return;
653 }
654
655 FILE *fp;
656
657 // s_sys_bat_file
659 PathAppendW(s_sys_bat_file, L"test program.bat");
660 fp = _wfopen(s_sys_bat_file, L"wb");
661 fclose(fp);
663
664 // "Test File 1.txt"
665 fp = fopen("Test File 1.txt", "wb");
666 ok(fp != NULL, "failed to create a test file\n");
667 fclose(fp);
668 ok_int(PathFileExistsA("Test File 1.txt"), TRUE);
669
670 // "Test File 2.bat"
671 fp = fopen("Test File 2.bat", "wb");
672 ok(fp != NULL, "failed to create a test file\n");
673 fclose(fp);
674 ok_int(PathFileExistsA("Test File 2.bat"), TRUE);
675
676 // s_cur_dir
678
680
681 // Some process can lock the file of s_win_test_exe
682 Sleep(1000);
683
684 // clean up
685 ok(DeleteFileW(s_win_test_exe), "failed to delete the test file\n");
686 ok(DeleteFileW(s_sys_bat_file), "failed to delete the test file\n");
687 ok(DeleteFileA("Test File 1.txt"), "failed to delete the test file\n");
688 ok(DeleteFileA("Test File 2.bat"), "failed to delete the test file\n");
689}
static WCHAR s_sys_bat_file[MAX_PATH]
static WCHAR s_win_test_exe[MAX_PATH]
HRESULT(WINAPI * SHELLEXECCMDLINE)(HWND, LPCWSTR, LPCWSTR, INT, LPVOID, DWORD)
static VOID TEST_ShellExecCmdLine(VOID)
static WCHAR s_sub_program[MAX_PATH]
SHELLEXECCMDLINE g_pShellExecCmdLine
static WCHAR s_cur_dir[MAX_PATH]
#define skip(...)
Definition: atltest.h:64
#define ok_int(expression, result)
Definition: atltest.h:134
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
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
BOOL WINAPI PathFileExistsA(const char *path)
Definition: path.c:2590
return ret
Definition: mutex.c:146
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
static HMODULE hShell32
Definition: string.c:34
Definition: features.h:417
#define PathAppendW
Definition: pathcch.h:310
static BOOL FindSubProgram(LPWSTR pszSubProgram, DWORD cchSubProgram)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int32_t INT_PTR
Definition: typedefs.h:64
VERSIONHELPERAPI IsWindowsVistaOrGreater()
const char * LPCSTR
Definition: xmlstorage.h:183

◆ TEST_ShellExecCmdLine()

static VOID TEST_ShellExecCmdLine ( VOID  )
static

Definition at line 593 of file ShellExecCmdLine.cpp.

594{
596
597 // do tests
598 for (size_t i = 0; i < _countof(s_entries_1); ++i)
599 {
601 }
603 for (size_t i = 0; i < _countof(s_entries_2); ++i)
604 {
606 }
607
608 // Execution can be asynchronous; you have to wait for it to finish.
609 Sleep(2000);
610
611 // Close newly-opened window(s)
616}
static WINDOW_LIST s_List2
static const TEST_ENTRY s_entries_1[]
static void DoEntry(const TEST_ENTRY *pEntry)
static const TEST_ENTRY s_entries_2[]
static WINDOW_LIST s_List1
static VOID FreeWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:32
static VOID CloseNewWindows(PWINDOW_LIST pExisting, PWINDOW_LIST pNew)
Definition: closewnd.h:101
static VOID GetWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:54
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
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

Referenced by START_TEST().

Variable Documentation

◆ g_pShellExecCmdLine

SHELLEXECCMDLINE g_pShellExecCmdLine = NULL

Definition at line 243 of file ShellExecCmdLine.cpp.

Referenced by START_TEST().

◆ s_cur_dir

WCHAR s_cur_dir[MAX_PATH]
static

Definition at line 257 of file ShellExecCmdLine.cpp.

Referenced by START_TEST(), and TEST_ShellExecCmdLine().

◆ s_entries_1

const TEST_ENTRY s_entries_1[]
static

Definition at line 259 of file ShellExecCmdLine.cpp.

Referenced by TEST_ShellExecCmdLine().

◆ s_entries_2

const TEST_ENTRY s_entries_2[]
static

Definition at line 498 of file ShellExecCmdLine.cpp.

Referenced by TEST_ShellExecCmdLine().

◆ s_List1

WINDOW_LIST s_List1
static

Definition at line 591 of file ShellExecCmdLine.cpp.

Referenced by TEST_ShellExecCmdLine().

◆ s_List2

WINDOW_LIST s_List2
static

Definition at line 591 of file ShellExecCmdLine.cpp.

Referenced by TEST_ShellExecCmdLine().

◆ s_sub_program

WCHAR s_sub_program[MAX_PATH]
static

Definition at line 254 of file ShellExecCmdLine.cpp.

Referenced by START_TEST().

◆ s_sys_bat_file

WCHAR s_sys_bat_file[MAX_PATH]
static

Definition at line 256 of file ShellExecCmdLine.cpp.

Referenced by START_TEST().

◆ s_win_test_exe

WCHAR s_win_test_exe[MAX_PATH]
static

Definition at line 255 of file ShellExecCmdLine.cpp.

Referenced by START_TEST().

◆ wszCom

const WCHAR wszCom[] = L".com"
static

Definition at line 32 of file ShellExecCmdLine.cpp.

Referenced by ShellExecCmdLine().

◆ wszExe

const WCHAR wszExe[] = L".exe"
static

Definition at line 31 of file ShellExecCmdLine.cpp.

Referenced by ShellExecCmdLine().