ReactOS 0.4.15-dev-7842-g558ab78
PathUnExpandEnvStringsForUser.c File Reference
#include <apitest.h>
#include <shlwapi.h>
#include <strsafe.h>
Include dependency graph for PathUnExpandEnvStringsForUser.c:

Go to the source code of this file.

Macros

#define DO_TEST(Res, hToken, TestStr, ExpStr, Len)
 
#define PathUnExpandEnvStringsForUserW   (*pPathUnExpandEnvStringsForUserW)
 

Typedefs

typedef BOOL(WINAPIPATHUNEXPANDENVSTRINGSFORUSERW) (HANDLE hToken, LPCWSTR pszPath, LPWSTR pszUnExpanded, INT cchUnExpanded)
 

Functions

 START_TEST (PathUnExpandEnvStringsForUser)
 

Variables

PATHUNEXPANDENVSTRINGSFORUSERW pPathUnExpandEnvStringsForUserW = NULL
 

Macro Definition Documentation

◆ DO_TEST

#define DO_TEST (   Res,
  hToken,
  TestStr,
  ExpStr,
  Len 
)
Value:
do { \
BOOL ret = PathUnExpandEnvStringsForUserW((hToken), (TestStr), OutStr, Len); \
ok(ret == (Res), "Tested %s, expected returned value %d, got %d\n", \
wine_dbgstr_w((TestStr)), (Res), ret); \
if (ret) \
ok(_wcsicmp(OutStr, (ExpStr)) == 0, "Tested %s, expected %s, got %s\n", \
wine_dbgstr_w((TestStr)), wine_dbgstr_w((ExpStr)), wine_dbgstr_w(OutStr)); \
} while (0)
#define PathUnExpandEnvStringsForUserW
#define Len
Definition: deflate.h:82
#define TestStr
Definition: edittest.c:28
unsigned int BOOL
Definition: ntddk_ex.h:94
#define wine_dbgstr_w
Definition: kernel32.h:34
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
int ret

Definition at line 12 of file PathUnExpandEnvStringsForUser.c.

◆ PathUnExpandEnvStringsForUserW

#define PathUnExpandEnvStringsForUserW   (*pPathUnExpandEnvStringsForUserW)

Typedef Documentation

◆ PATHUNEXPANDENVSTRINGSFORUSERW

typedef BOOL(WINAPI * PATHUNEXPANDENVSTRINGSFORUSERW) (HANDLE hToken, LPCWSTR pszPath, LPWSTR pszUnExpanded, INT cchUnExpanded)

Definition at line 23 of file PathUnExpandEnvStringsForUser.c.

Function Documentation

◆ START_TEST()

START_TEST ( PathUnExpandEnvStringsForUser  )

Definition at line 26 of file PathUnExpandEnvStringsForUser.c.

27{
28 DWORD ret;
31
32 hShlwapi = GetModuleHandleW(L"shlwapi");
33 if (hShlwapi == NULL)
34 {
35 skip("shlwapi.dll was not loaded\n");
36 return;
37 }
38
40 (PATHUNEXPANDENVSTRINGSFORUSERW)GetProcAddress(hShlwapi, "PathUnExpandEnvStringsForUserW");
41
43 {
44 trace("PathUnExpandEnvStringsForUserW is not public\n");
47 }
49 {
50 skip("PathUnExpandEnvStringsForUserW was not found\n");
51 return;
52 }
53
54#define PathUnExpandEnvStringsForUserW (*pPathUnExpandEnvStringsForUserW)
55
56 /* empty string */
57 DO_TEST(FALSE, NULL, L"", L"", 0);
58 DO_TEST(FALSE, NULL, L"", L"", -1);
59 DO_TEST(FALSE, NULL, L"", L"", 2);
60 DO_TEST(FALSE, NULL, L"", L"", MAX_PATH);
61
62 /* No unexpansion possible */
63 DO_TEST(FALSE, NULL, L"ZZ:\\foobar\\directory", L"", 0);
64 DO_TEST(FALSE, NULL, L"ZZ:\\foobar\\directory", L"", -1);
65 DO_TEST(FALSE, NULL, L"ZZ:\\foobar\\directory", L"", 2);
66 DO_TEST(FALSE, NULL, L"ZZ:\\foobar\\directory", L"", MAX_PATH);
67
68 /* %APPDATA% */
70 ok(ret, "got %lu\n", ret);
71 DO_TEST(FALSE, NULL, TestStr, L"%APPDATA%", 0);
72 DO_TEST(FALSE, NULL, TestStr, L"%APPDATA%", -1);
73 DO_TEST(FALSE, NULL, TestStr, L"%APPDATA%", 2);
74 DO_TEST(TRUE, NULL, TestStr, L"%APPDATA%", MAX_PATH);
75 StringCbCatW(TestStr, sizeof(TestStr), L"\\TEST");
76 DO_TEST(FALSE, NULL, TestStr, L"%APPDATA%\\TEST", 0);
77 DO_TEST(FALSE, NULL, TestStr, L"%APPDATA%\\TEST", -1);
78 DO_TEST(FALSE, NULL, TestStr, L"%APPDATA%\\TEST", 2);
79 DO_TEST(TRUE, NULL, TestStr, L"%APPDATA%\\TEST", MAX_PATH);
80
81 /* %USERPROFILE% */
83 ok(ret, "got %lu\n", ret);
84 DO_TEST(FALSE, NULL, TestStr, L"%USERPROFILE%", 0);
85 DO_TEST(FALSE, NULL, TestStr, L"%USERPROFILE%", -1);
86 DO_TEST(FALSE, NULL, TestStr, L"%USERPROFILE%", 2);
87 DO_TEST(TRUE, NULL, TestStr, L"%USERPROFILE%", MAX_PATH);
88 StringCbCatW(TestStr, sizeof(TestStr), L"\\TEST");
89 DO_TEST(FALSE, NULL, TestStr, L"%USERPROFILE%\\TEST", 0);
90 DO_TEST(FALSE, NULL, TestStr, L"%USERPROFILE%\\TEST", -1);
91 DO_TEST(FALSE, NULL, TestStr, L"%USERPROFILE%\\TEST", 2);
92 DO_TEST(TRUE, NULL, TestStr, L"%USERPROFILE%\\TEST", MAX_PATH);
93
94 /* %ALLUSERSPROFILE% */
95 ret = GetEnvironmentVariableW(L"ALLUSERSPROFILE", TestStr, _countof(TestStr));
96 ok(ret, "got %lu\n", ret);
97 DO_TEST(FALSE, NULL, TestStr, L"%ALLUSERSPROFILE%", 0);
98 DO_TEST(FALSE, NULL, TestStr, L"%ALLUSERSPROFILE%", -1);
99 DO_TEST(FALSE, NULL, TestStr, L"%ALLUSERSPROFILE%", 2);
100 DO_TEST(TRUE, NULL, TestStr, L"%ALLUSERSPROFILE%", MAX_PATH);
101 StringCbCatW(TestStr, sizeof(TestStr), L"\\TEST");
102 DO_TEST(FALSE, NULL, TestStr, L"%ALLUSERSPROFILE%\\TEST", 0);
103 DO_TEST(FALSE, NULL, TestStr, L"%ALLUSERSPROFILE%\\TEST", -1);
104 DO_TEST(FALSE, NULL, TestStr, L"%ALLUSERSPROFILE%\\TEST", 2);
105 DO_TEST(TRUE, NULL, TestStr, L"%ALLUSERSPROFILE%\\TEST", MAX_PATH);
106
107 /* %ProgramFiles% */
109 ok(ret, "got %lu\n", ret);
110 DO_TEST(FALSE, NULL, TestStr, L"%ProgramFiles%", 0);
111 DO_TEST(FALSE, NULL, TestStr, L"%ProgramFiles%", -1);
112 DO_TEST(FALSE, NULL, TestStr, L"%ProgramFiles%", 2);
113 DO_TEST(TRUE, NULL, TestStr, L"%ProgramFiles%", MAX_PATH);
114 StringCbCatW(TestStr, sizeof(TestStr), L"\\TEST");
115 DO_TEST(FALSE, NULL, TestStr, L"%ProgramFiles%\\TEST", 0);
116 DO_TEST(FALSE, NULL, TestStr, L"%ProgramFiles%\\TEST", -1);
117 DO_TEST(FALSE, NULL, TestStr, L"%ProgramFiles%\\TEST", 2);
118 DO_TEST(TRUE, NULL, TestStr, L"%ProgramFiles%\\TEST", MAX_PATH);
119}
#define DO_TEST(Res, hToken, TestStr, ExpStr, Len)
PATHUNEXPANDENVSTRINGSFORUSERW pPathUnExpandEnvStringsForUserW
BOOL(WINAPI * PATHUNEXPANDENVSTRINGSFORUSERW)(HANDLE hToken, LPCWSTR pszPath, LPWSTR pszUnExpanded, INT cchUnExpanded)
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
static HMODULE hShlwapi
Definition: clsid.c:38
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
unsigned long DWORD
Definition: ntddk_ex.h:95
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
#define LONG_PTR
Definition: treelist.c:79
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180

Variable Documentation

◆ pPathUnExpandEnvStringsForUserW

PATHUNEXPANDENVSTRINGSFORUSERW pPathUnExpandEnvStringsForUserW = NULL

Definition at line 24 of file PathUnExpandEnvStringsForUser.c.

Referenced by START_TEST().