ReactOS 0.4.17-dev-684-ga6524ef
AssocQueryString.c File Reference
#include <apitest.h>
#include <shlwapi.h>
#include <stdio.h>
#include <versionhelpers.h>
Include dependency graph for AssocQueryString.c:

Go to the source code of this file.

Macros

#define NON_EXISTENT_FILENAME_A   "C:\\ThisIsNotExistentFile.txt"
 
#define NON_EXISTENT_FILENAME_W   L"C:\\ThisIsNotExistentFile.txt"
 

Functions

static void TEST_Start (void)
 
static void TEST_End (void)
 
static void TEST_AssocQueryStringA (void)
 
static void TEST_AssocQueryStringW (void)
 
static void TEST_TrickyPointers (void)
 
 START_TEST (AssocQueryString)
 

Variables

static CHAR s_szTextFileA [MAX_PATH] = ""
 
static WCHAR s_szTextFileW [MAX_PATH] = L""
 

Macro Definition Documentation

◆ NON_EXISTENT_FILENAME_A

#define NON_EXISTENT_FILENAME_A   "C:\\ThisIsNotExistentFile.txt"

Definition at line 15 of file AssocQueryString.c.

◆ NON_EXISTENT_FILENAME_W

#define NON_EXISTENT_FILENAME_W   L"C:\\ThisIsNotExistentFile.txt"

Definition at line 16 of file AssocQueryString.c.

Function Documentation

◆ START_TEST()

START_TEST ( AssocQueryString  )

Definition at line 190 of file AssocQueryString.c.

191{
192 HRESULT hrCoInit = CoInitialize(NULL);
193
194 TEST_Start();
198 TEST_End();
199
200 if (SUCCEEDED(hrCoInit))
202}
static void TEST_TrickyPointers(void)
static void TEST_Start(void)
static void TEST_AssocQueryStringA(void)
static void TEST_AssocQueryStringW(void)
static void TEST_End(void)
#define NULL
Definition: types.h:112
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
#define SUCCEEDED(hr)
Definition: intsafe.h:50

◆ TEST_AssocQueryStringA()

static void TEST_AssocQueryStringA ( void  )
static

Definition at line 37 of file AssocQueryString.c.

38{
39 /* Note: NT5 differs from NT6 because NT5 converts a NULL pszExtra to L"" */
40 CHAR szPath[MAX_PATH], szAnswer[MAX_PATH];
41 CHAR szDebug1[MAX_PATH], szDebug2[MAX_PATH];
42 HRESULT hr;
43 DWORD cch;
44
45 /* ".txt" */
50 {
51 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
52 ok_long(hr, S_OK);
53 ok_int(cch, lstrlenA(szAnswer) + 1);
54 }
55 else
56 {
57 lstrcpynA(szAnswer, ".txt", _countof(szAnswer));
60 }
61 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
62 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
63 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
64
65 /* s_szTextFileA */
70 {
71 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
72 ok_long(hr, S_OK);
73 ok_int(cch, lstrlenA(szAnswer) + 1);
74 }
75 else
76 {
77 lstrcpynA(szAnswer, s_szTextFileA, _countof(szAnswer));
80 }
81 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
82 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
83 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
84
85 /* NON_EXISTENT_FILENAME_A */
90 {
91 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
92 ok_long(hr, S_OK);
93 ok_int(cch, lstrlenA(szAnswer) + 1);
94 }
95 else
96 {
97 lstrcpynA(szAnswer, NON_EXISTENT_FILENAME_A, _countof(szAnswer));
100 }
101 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
102 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
103 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
104}
#define NON_EXISTENT_FILENAME_A
static CHAR s_szTextFileA[MAX_PATH]
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define ok_int(expression, result)
Definition: atltest.h:134
HRESULT hr
Definition: delayimp.cpp:582
#define lstrcpynA
Definition: compat.h:751
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:372
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc, LPCSTR pszExtra, LPSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:612
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:52
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPCWSTR szPath
Definition: env.c:37
char CHAR
Definition: pedump.c:57
@ ASSOCSTR_EXECUTABLE
Definition: shlwapi.h:887
@ ASSOCF_NONE
Definition: shlwapi.h:858
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:152
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
#define _countof(array)
Definition: sndvol32.h:70
VERSIONHELPERAPI IsWindowsVistaOrGreater()
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by START_TEST().

◆ TEST_AssocQueryStringW()

static void TEST_AssocQueryStringW ( void  )
static

Definition at line 106 of file AssocQueryString.c.

107{
108 WCHAR szPath[MAX_PATH], szAnswer[MAX_PATH];
109 CHAR szDebug1[MAX_PATH], szDebug2[MAX_PATH];
110 HRESULT hr;
111 DWORD cch;
112
113 /* ".txt" */
114 lstrcpynW(szPath, L".txt", _countof(szPath));
117 ok_long(hr, S_OK);
118 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
119 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
120 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
121 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
122 ok_int(cch, lstrlenW(szAnswer) + 1);
123
124 /* s_szTextFileW */
128 ok_long(hr, S_OK);
129 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
130 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
131 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
132 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
133 ok_int(cch, lstrlenW(szAnswer) + 1);
134
135 /* NON_EXISTENT_FILENAME_W */
139 ok_long(hr, S_OK);
140 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
141 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
142 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
143 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
144 ok_int(cch, lstrlenW(szAnswer) + 1);
145}
static WCHAR s_szTextFileW[MAX_PATH]
#define NON_EXISTENT_FILENAME_W
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:569
#define L(x)
Definition: resources.c:13
#define wine_dbgstr_w
Definition: kernel32.h:34
short WCHAR
Definition: pedump.c:58

Referenced by START_TEST().

◆ TEST_End()

static void TEST_End ( void  )
static

Definition at line 27 of file AssocQueryString.c.

28{
30}
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39

Referenced by START_TEST().

◆ TEST_Start()

static void TEST_Start ( void  )
static

Definition at line 18 of file AssocQueryString.c.

19{
20 ExpandEnvironmentStringsA( "%APPDATA%\\This is a test.txt", s_szTextFileA, _countof(s_szTextFileA));
21 ExpandEnvironmentStringsW(L"%APPDATA%\\This is a test.txt", s_szTextFileW, _countof(s_szTextFileW));
25}
#define trace
Definition: atltest.h:70
int CDECL fclose(FILE *file)
Definition: file.c:3757
FILE *CDECL _wfopen(const wchar_t *path, const wchar_t *mode)
Definition: file.c:4335

Referenced by START_TEST().

◆ TEST_TrickyPointers()

static void TEST_TrickyPointers ( void  )
static

Definition at line 147 of file AssocQueryString.c.

148{
149 HRESULT hr;
150 CHAR szPathA[MAX_PATH], szOutputA[MAX_PATH];
151 WCHAR szPathW[MAX_PATH], szOutputW[MAX_PATH];
152 DWORD cch;
153 BOOL bVistaPlus = IsWindowsVistaOrGreater();
154
155 lstrcpynA(szPathA, s_szTextFileA, _countof(szPathA));
156 cch = _countof(szOutputA);
158 {
160 }
162 {
163 hr = 0xDEADFACE;
164 }
165 _SEH2_END;
166
167 if (bVistaPlus)
168 ok_long(hr, 0xDEADFACE);
169 else
171
172 lstrcpynW(szPathW, s_szTextFileW, _countof(szPathW));
173 cch = _countof(szOutputW);
175 {
177 }
179 {
180 hr = 0xDEADFACE;
181 }
182 _SEH2_END;
183
184 if (bVistaPlus)
185 ok_long(hr, 0xDEADFACE);
186 else
187 ok_long(hr, S_OK);
188}
#define UlongToPtr(u)
Definition: config.h:106
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
DWORD * PDWORD
Definition: pedump.c:68
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93

Referenced by START_TEST().

Variable Documentation

◆ s_szTextFileA

CHAR s_szTextFileA[MAX_PATH] = ""
static

Definition at line 13 of file AssocQueryString.c.

Referenced by TEST_AssocQueryStringA(), TEST_Start(), and TEST_TrickyPointers().

◆ s_szTextFileW

WCHAR s_szTextFileW[MAX_PATH] = L""
static