ReactOS 0.4.15-dev-8219-ge8b88cf
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"
 

Typedefs

typedef HRESULT(WINAPIFN_AssocQueryStringA) (ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc, LPCSTR pszExtra, LPSTR pszOut, DWORD *pcchOut)
 
typedef HRESULT(WINAPIFN_AssocQueryStringW) (ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
 

Functions

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

Variables

static HINSTANCE s_hSHLWAPI = NULL
 
static FN_AssocQueryStringA s_fnAssocQueryStringA = NULL
 
static FN_AssocQueryStringW s_fnAssocQueryStringW = NULL
 
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 33 of file AssocQueryString.c.

◆ NON_EXISTENT_FILENAME_W

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

Definition at line 34 of file AssocQueryString.c.

Typedef Documentation

◆ FN_AssocQueryStringA

typedef HRESULT(WINAPI * FN_AssocQueryStringA) (ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc, LPCSTR pszExtra, LPSTR pszOut, DWORD *pcchOut)

Definition at line 13 of file AssocQueryString.c.

◆ FN_AssocQueryStringW

typedef HRESULT(WINAPI * FN_AssocQueryStringW) (ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)

Definition at line 20 of file AssocQueryString.c.

Function Documentation

◆ START_TEST()

START_TEST ( AssocQueryString  )

Definition at line 164 of file AssocQueryString.c.

165{
166 HRESULT hrCoInit = CoInitialize(NULL);
167
168 s_hSHLWAPI = LoadLibraryW(L"shlwapi.dll");
172 {
173 skip("AssocQueryStringA or AssocQueryStringW not found: %p, %p\n",
175 return;
176 }
177
178 TEST_Start();
181 TEST_End();
182
184
185 if (SUCCEEDED(hrCoInit))
187}
HRESULT(WINAPI * FN_AssocQueryStringW)(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
static FN_AssocQueryStringA s_fnAssocQueryStringA
static HINSTANCE s_hSHLWAPI
static void TEST_Start(void)
static void TEST_AssocQueryStringA(void)
HRESULT(WINAPI * FN_AssocQueryStringA)(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc, LPCSTR pszExtra, LPSTR pszOut, DWORD *pcchOut)
static void TEST_AssocQueryStringW(void)
static void TEST_End(void)
static FN_AssocQueryStringW s_fnAssocQueryStringW
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define L(x)
Definition: ntvdm.h:50

◆ TEST_AssocQueryStringA()

static void TEST_AssocQueryStringA ( void  )
static

Definition at line 55 of file AssocQueryString.c.

56{
57 CHAR szPath[MAX_PATH], szAnswer[MAX_PATH];
58 CHAR szDebug1[MAX_PATH], szDebug2[MAX_PATH];
59 HRESULT hr;
60 DWORD cch;
61
62 /* ".txt" */
67 {
68 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
69 ok_long(hr, S_OK);
70 ok_int(cch, lstrlenA(szAnswer) + 1);
71 }
72 else
73 {
74 lstrcpynA(szAnswer, ".txt", _countof(szAnswer));
77 }
78 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
79 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
80 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
81
82 /* s_szTextFileA */
87 {
88 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
89 ok_long(hr, S_OK);
90 ok_int(cch, lstrlenA(szAnswer) + 1);
91 }
92 else
93 {
94 lstrcpynA(szAnswer, s_szTextFileA, _countof(szAnswer));
97 }
98 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
99 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
100 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
101
102 /* NON_EXISTENT_FILENAME_A */
107 {
108 ExpandEnvironmentStringsA("%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
109 ok_long(hr, S_OK);
110 ok_int(cch, lstrlenA(szAnswer) + 1);
111 }
112 else
113 {
114 lstrcpynA(szAnswer, NON_EXISTENT_FILENAME_A, _countof(szAnswer));
117 }
118 lstrcpynA(szDebug1, wine_dbgstr_a(szPath), _countof(szDebug1));
119 lstrcpynA(szDebug2, wine_dbgstr_a(szAnswer), _countof(szDebug2));
120 ok(lstrcmpiA(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
121}
#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
#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:399
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4223
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
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition: debug.h:187
HRESULT hr
Definition: shlfolder.c:183
@ ASSOCSTR_EXECUTABLE
Definition: shlwapi.h:604
#define _countof(array)
Definition: sndvol32.h:70
VERSIONHELPERAPI IsWindowsVistaOrGreater()
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ TEST_AssocQueryStringW()

static void TEST_AssocQueryStringW ( void  )
static

Definition at line 123 of file AssocQueryString.c.

124{
125 WCHAR szPath[MAX_PATH], szAnswer[MAX_PATH];
126 CHAR szDebug1[MAX_PATH], szDebug2[MAX_PATH];
127 HRESULT hr;
128 DWORD cch;
129
130 /* ".txt" */
131 lstrcpynW(szPath, L".txt", _countof(szPath));
134 ok_long(hr, S_OK);
135 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
136 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
137 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
138 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
139 ok_int(cch, lstrlenW(szAnswer) + 1);
140
141 /* s_szTextFileW */
145 ok_long(hr, S_OK);
146 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
147 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
148 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
149 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
150 ok_int(cch, lstrlenW(szAnswer) + 1);
151
152 /* NON_EXISTENT_FILENAME_W */
156 ok_long(hr, S_OK);
157 ExpandEnvironmentStringsW(L"%WINDIR%\\system32\\notepad.exe", szAnswer, _countof(szAnswer));
158 lstrcpynA(szDebug1, wine_dbgstr_w(szPath), _countof(szDebug1));
159 lstrcpynA(szDebug2, wine_dbgstr_w(szAnswer), _countof(szDebug2));
160 ok(lstrcmpiW(szPath, szAnswer) == 0, "%s vs %s\n", szDebug1, szDebug2);
161 ok_int(cch, lstrlenW(szAnswer) + 1);
162}
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:519
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc, LPCWSTR pszExtra, LPWSTR pszOut, DWORD *pcchOut)
Definition: assoc.c:436
#define wine_dbgstr_w
Definition: kernel32.h:34
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ TEST_End()

static void TEST_End ( void  )
static

Definition at line 45 of file AssocQueryString.c.

46{
48}
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 36 of file AssocQueryString.c.

37{
38 ExpandEnvironmentStringsA( "%APPDATA%\\This is a test.txt", s_szTextFileA, _countof(s_szTextFileA));
39 ExpandEnvironmentStringsW(L"%APPDATA%\\This is a test.txt", s_szTextFileW, _countof(s_szTextFileW));
43}
#define trace
Definition: atltest.h:70
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)

Referenced by START_TEST().

Variable Documentation

◆ s_fnAssocQueryStringA

FN_AssocQueryStringA s_fnAssocQueryStringA = NULL
static

Definition at line 29 of file AssocQueryString.c.

Referenced by START_TEST().

◆ s_fnAssocQueryStringW

FN_AssocQueryStringW s_fnAssocQueryStringW = NULL
static

Definition at line 30 of file AssocQueryString.c.

Referenced by START_TEST().

◆ s_hSHLWAPI

HINSTANCE s_hSHLWAPI = NULL
static

Definition at line 28 of file AssocQueryString.c.

Referenced by START_TEST().

◆ s_szTextFileA

CHAR s_szTextFileA[MAX_PATH] = ""
static

Definition at line 31 of file AssocQueryString.c.

Referenced by TEST_AssocQueryStringA(), and TEST_Start().

◆ s_szTextFileW

WCHAR s_szTextFileW[MAX_PATH] = L""
static

Definition at line 32 of file AssocQueryString.c.

Referenced by TEST_AssocQueryStringW(), TEST_End(), and TEST_Start().