ReactOS 0.4.17-dev-357-ga8f14ff
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 189 of file AssocQueryString.c.

190{
191 HRESULT hrCoInit = CoInitialize(NULL);
192
193 TEST_Start();
197 TEST_End();
198
199 if (SUCCEEDED(hrCoInit))
201}
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 CHAR szPath[MAX_PATH], szAnswer[MAX_PATH];
40 CHAR szDebug1[MAX_PATH], szDebug2[MAX_PATH];
41 HRESULT hr;
42 DWORD cch;
43
44 /* ".txt" */
49 {
50 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
51 ok_long(hr, S_OK);
52 ok_int(cch, lstrlenA(szAnswer) + 1);
53 }
54 else
55 {
56 lstrcpynA(szAnswer, ".txt", _countof(szAnswer));
59 }
60 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
61 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
62 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
63
64 /* s_szTextFileA */
69 {
70 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
71 ok_long(hr, S_OK);
72 ok_int(cch, lstrlenA(szAnswer) + 1);
73 }
74 else
75 {
76 lstrcpynA(szAnswer, s_szTextFileA, _countof(szAnswer));
79 }
80 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
81 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
82 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
83
84 /* NON_EXISTENT_FILENAME_A */
89 {
90 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
91 ok_long(hr, S_OK);
92 ok_int(cch, lstrlenA(szAnswer) + 1);
93 }
94 else
95 {
96 lstrcpynA(szAnswer, NON_EXISTENT_FILENAME_A, _countof(szAnswer));
99 }
100 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
101 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
102 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
103}
#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:479
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 105 of file AssocQueryString.c.

106{
107 WCHAR szPath[MAX_PATH], szAnswer[MAX_PATH];
108 CHAR szDebug1[MAX_PATH], szDebug2[MAX_PATH];
109 HRESULT hr;
110 DWORD cch;
111
112 /* ".txt" */
113 lstrcpynW(szPath, L".txt", _countof(szPath));
116 ok_long(hr, S_OK);
117 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
118 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
119 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
120 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
121 ok_int(cch, lstrlenW(szAnswer) + 1);
122
123 /* s_szTextFileW */
127 ok_long(hr, S_OK);
128 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
129 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
130 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
131 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
132 ok_int(cch, lstrlenW(szAnswer) + 1);
133
134 /* NON_EXISTENT_FILENAME_W */
138 ok_long(hr, S_OK);
139 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
140 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
141 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
142 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
143 ok_int(cch, lstrlenW(szAnswer) + 1);
144}
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:436
#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 146 of file AssocQueryString.c.

147{
148 HRESULT hr;
149 CHAR szPathA[MAX_PATH], szOutputA[MAX_PATH];
150 WCHAR szPathW[MAX_PATH], szOutputW[MAX_PATH];
151 DWORD cch;
152 BOOL bVistaPlus = IsWindowsVistaOrGreater();
153
154 lstrcpynA(szPathA, s_szTextFileA, _countof(szPathA));
155 cch = _countof(szOutputA);
157 {
159 }
161 {
162 hr = 0xDEADFACE;
163 }
164 _SEH2_END;
165
166 if (bVistaPlus)
167 ok_long(hr, 0xDEADFACE);
168 else
170
171 lstrcpynW(szPathW, s_szTextFileW, _countof(szPathW));
172 cch = _countof(szOutputW);
174 {
176 }
178 {
179 hr = 0xDEADFACE;
180 }
181 _SEH2_END;
182
183 if (bVistaPlus)
184 ok_long(hr, 0xDEADFACE);
185 else
186 ok_long(hr, S_OK);
187}
#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