2 * Unit tests for shell32 SHGet{Special}Folder{Path|Location} functions.
4 * Copyright 2004 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 * This is a test program for the SHGet{Special}Folder{Path|Location} functions
20 * of shell32, that get either a filesystem path or a LPITEMIDLIST (shell
21 * namespace) path for a given folder (CSIDL value).
33 #include "knownfolders.h"
35 #include "wine/test.h"
39 /* CSIDL_MYDOCUMENTS is now the same as CSIDL_PERSONAL, but what we want
40 * here is its original value.
42 #define OLD_CSIDL_MYDOCUMENTS 0x000c
44 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
46 /* from pidl.h, not included here: */
47 #ifndef PT_CPL /* Guess, Win7 uses this for CSIDL_CONTROLS */
48 #define PT_CPL 0x01 /* no path */
51 #define PT_GUID 0x1f /* no path */
54 #define PT_DRIVE 0x23 /* has path */
57 #define PT_DRIVE2 0x25 /* has path */
60 #define PT_SHELLEXT 0x2e /* no path */
63 #define PT_FOLDER 0x31 /* has path */
66 #define PT_FOLDERW 0x35 /* has path */
69 #define PT_WORKGRP 0x41 /* no path */
72 #define PT_YAGUID 0x70 /* no path */
74 /* FIXME: this is used for history/favorites folders; what's a better name? */
76 #define PT_IESPECIAL2 0xb1 /* has path */
79 static GUID CLSID_CommonDocuments
= { 0x0000000c, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x1a } };
81 struct shellExpectedValues
{
87 static HRESULT (WINAPI
*pDllGetVersion
)(DLLVERSIONINFO
*);
88 static HRESULT (WINAPI
*pSHGetFolderPathA
)(HWND
, int, HANDLE
, DWORD
, LPSTR
);
89 static HRESULT (WINAPI
*pSHGetFolderLocation
)(HWND
, int, HANDLE
, DWORD
,
91 static BOOL (WINAPI
*pSHGetSpecialFolderPathA
)(HWND
, LPSTR
, int, BOOL
);
92 static HRESULT (WINAPI
*pSHGetSpecialFolderLocation
)(HWND
, int, LPITEMIDLIST
*);
93 static LPITEMIDLIST (WINAPI
*pILFindLastID
)(LPCITEMIDLIST
);
94 static int (WINAPI
*pSHFileOperationA
)(LPSHFILEOPSTRUCTA
);
95 static HRESULT (WINAPI
*pSHGetMalloc
)(LPMALLOC
*);
96 static UINT (WINAPI
*pGetSystemWow64DirectoryA
)(LPSTR
,UINT
);
97 static HRESULT (WINAPI
*pSHGetKnownFolderPath
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PWSTR
*);
98 static HRESULT (WINAPI
*pSHSetKnownFolderPath
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PWSTR
);
99 static HRESULT (WINAPI
*pSHGetFolderPathEx
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, LPWSTR
, DWORD
);
100 static BOOL (WINAPI
*pPathYetAnotherMakeUniqueName
)(PWSTR
, PCWSTR
, PCWSTR
, PCWSTR
);
101 static HRESULT (WINAPI
*pSHGetKnownFolderIDList
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PIDLIST_ABSOLUTE
*);
103 static DLLVERSIONINFO shellVersion
= { 0 };
104 static LPMALLOC pMalloc
;
105 static const BYTE guidType
[] = { PT_GUID
};
106 static const BYTE controlPanelType
[] = { PT_SHELLEXT
, PT_GUID
, PT_CPL
};
107 static const BYTE folderType
[] = { PT_FOLDER
, PT_FOLDERW
};
108 static const BYTE favoritesType
[] = { PT_FOLDER
, PT_FOLDERW
, 0, PT_IESPECIAL2
/* Win98 */ };
109 static const BYTE folderOrSpecialType
[] = { PT_FOLDER
, PT_IESPECIAL2
};
110 static const BYTE personalType
[] = { PT_FOLDER
, PT_GUID
, PT_DRIVE
, 0xff /* Win9x */,
111 PT_IESPECIAL2
/* Win98 */, 0 /* Vista */, PT_SHELLEXT
/* win8 */ };
112 /* FIXME: don't know the type of 0x71 returned by Vista/2008 for printers */
113 static const BYTE printersType
[] = { PT_YAGUID
, PT_SHELLEXT
, 0x71 };
114 static const BYTE ieSpecialType
[] = { PT_IESPECIAL2
};
115 static const BYTE shellExtType
[] = { PT_SHELLEXT
};
116 static const BYTE workgroupType
[] = { PT_WORKGRP
};
117 #define DECLARE_TYPE(x, y) { x, ARRAY_SIZE(y), y }
118 static const struct shellExpectedValues requiredShellValues
[] = {
119 DECLARE_TYPE(CSIDL_BITBUCKET
, guidType
),
120 DECLARE_TYPE(CSIDL_CONTROLS
, controlPanelType
),
121 DECLARE_TYPE(CSIDL_COOKIES
, folderType
),
122 DECLARE_TYPE(CSIDL_DESKTOPDIRECTORY
, folderType
),
123 DECLARE_TYPE(CSIDL_DRIVES
, guidType
),
124 DECLARE_TYPE(CSIDL_FAVORITES
, favoritesType
),
125 DECLARE_TYPE(CSIDL_FONTS
, folderOrSpecialType
),
126 /* FIXME: the following fails in Wine, returns type PT_FOLDER
127 DECLARE_TYPE(CSIDL_HISTORY, ieSpecialType),
129 DECLARE_TYPE(CSIDL_INTERNET
, guidType
),
130 DECLARE_TYPE(CSIDL_NETHOOD
, folderType
),
131 DECLARE_TYPE(CSIDL_NETWORK
, guidType
),
132 DECLARE_TYPE(CSIDL_PERSONAL
, personalType
),
133 DECLARE_TYPE(CSIDL_PRINTERS
, printersType
),
134 DECLARE_TYPE(CSIDL_PRINTHOOD
, folderType
),
135 DECLARE_TYPE(CSIDL_PROGRAMS
, folderType
),
136 DECLARE_TYPE(CSIDL_RECENT
, folderOrSpecialType
),
137 DECLARE_TYPE(CSIDL_SENDTO
, folderType
),
138 DECLARE_TYPE(CSIDL_STARTMENU
, folderType
),
139 DECLARE_TYPE(CSIDL_STARTUP
, folderType
),
140 DECLARE_TYPE(CSIDL_TEMPLATES
, folderType
),
142 static const struct shellExpectedValues optionalShellValues
[] = {
143 /* FIXME: the following only semi-succeed; they return NULL PIDLs on XP.. hmm.
144 DECLARE_TYPE(CSIDL_ALTSTARTUP, folderType),
145 DECLARE_TYPE(CSIDL_COMMON_ALTSTARTUP, folderType),
146 DECLARE_TYPE(CSIDL_COMMON_OEM_LINKS, folderType),
148 /* Windows NT-only: */
149 DECLARE_TYPE(CSIDL_COMMON_DESKTOPDIRECTORY
, folderType
),
150 DECLARE_TYPE(CSIDL_COMMON_DOCUMENTS
, shellExtType
),
151 DECLARE_TYPE(CSIDL_COMMON_FAVORITES
, folderType
),
152 DECLARE_TYPE(CSIDL_COMMON_PROGRAMS
, folderType
),
153 DECLARE_TYPE(CSIDL_COMMON_STARTMENU
, folderType
),
154 DECLARE_TYPE(CSIDL_COMMON_STARTUP
, folderType
),
155 DECLARE_TYPE(CSIDL_COMMON_TEMPLATES
, folderType
),
156 /* first appearing in shell32 version 4.71: */
157 DECLARE_TYPE(CSIDL_APPDATA
, folderType
),
158 /* first appearing in shell32 version 4.72: */
159 DECLARE_TYPE(CSIDL_INTERNET_CACHE
, ieSpecialType
),
160 /* first appearing in shell32 version 5.0: */
161 DECLARE_TYPE(CSIDL_ADMINTOOLS
, folderType
),
162 DECLARE_TYPE(CSIDL_COMMON_APPDATA
, folderType
),
163 DECLARE_TYPE(CSIDL_LOCAL_APPDATA
, folderType
),
164 DECLARE_TYPE(OLD_CSIDL_MYDOCUMENTS
, folderType
),
165 DECLARE_TYPE(CSIDL_MYMUSIC
, folderType
),
166 DECLARE_TYPE(CSIDL_MYPICTURES
, folderType
),
167 DECLARE_TYPE(CSIDL_MYVIDEO
, folderType
),
168 DECLARE_TYPE(CSIDL_PROFILE
, folderType
),
169 DECLARE_TYPE(CSIDL_PROGRAM_FILES
, folderType
),
170 DECLARE_TYPE(CSIDL_PROGRAM_FILESX86
, folderType
),
171 DECLARE_TYPE(CSIDL_PROGRAM_FILES_COMMON
, folderType
),
172 DECLARE_TYPE(CSIDL_PROGRAM_FILES_COMMONX86
, folderType
),
173 DECLARE_TYPE(CSIDL_SYSTEM
, folderType
),
174 DECLARE_TYPE(CSIDL_WINDOWS
, folderType
),
175 /* first appearing in shell32 6.0: */
176 DECLARE_TYPE(CSIDL_CDBURN_AREA
, folderType
),
177 DECLARE_TYPE(CSIDL_COMMON_MUSIC
, folderType
),
178 DECLARE_TYPE(CSIDL_COMMON_PICTURES
, folderType
),
179 DECLARE_TYPE(CSIDL_COMMON_VIDEO
, folderType
),
180 DECLARE_TYPE(CSIDL_COMPUTERSNEARME
, workgroupType
),
181 DECLARE_TYPE(CSIDL_RESOURCES
, folderType
),
182 DECLARE_TYPE(CSIDL_RESOURCES_LOCALIZED
, folderType
),
186 static void loadShell32(void)
188 HMODULE hShell32
= GetModuleHandleA("shell32");
190 #define GET_PROC(func) \
191 p ## func = (void*)GetProcAddress(hShell32, #func); \
193 trace("GetProcAddress(%s) failed\n", #func);
195 GET_PROC(DllGetVersion
)
196 GET_PROC(SHGetFolderPathA
)
197 GET_PROC(SHGetFolderPathEx
)
198 GET_PROC(SHGetFolderLocation
)
199 GET_PROC(SHGetKnownFolderPath
)
200 GET_PROC(SHSetKnownFolderPath
)
201 GET_PROC(SHGetSpecialFolderPathA
)
202 GET_PROC(SHGetSpecialFolderLocation
)
203 GET_PROC(ILFindLastID
)
205 pILFindLastID
= (void *)GetProcAddress(hShell32
, (LPCSTR
)16);
206 GET_PROC(SHFileOperationA
)
207 GET_PROC(SHGetMalloc
)
208 GET_PROC(PathYetAnotherMakeUniqueName
)
209 GET_PROC(SHGetKnownFolderIDList
)
211 ok(pSHGetMalloc
!= NULL
, "shell32 is missing SHGetMalloc\n");
214 HRESULT hr
= pSHGetMalloc(&pMalloc
);
216 ok(hr
== S_OK
, "SHGetMalloc failed: 0x%08x\n", hr
);
217 ok(pMalloc
!= NULL
, "SHGetMalloc returned a NULL IMalloc\n");
222 shellVersion
.cbSize
= sizeof(shellVersion
);
223 pDllGetVersion(&shellVersion
);
224 trace("shell32 version is %d.%d\n",
225 shellVersion
.dwMajorVersion
, shellVersion
.dwMinorVersion
);
230 #ifndef CSIDL_PROFILES
231 #define CSIDL_PROFILES 0x003e
234 /* A couple utility printing functions */
235 static const char *getFolderName(int folder
)
237 static char unknown
[32];
239 #define CSIDL_TO_STR(x) case x: return#x;
242 CSIDL_TO_STR(CSIDL_DESKTOP
);
243 CSIDL_TO_STR(CSIDL_INTERNET
);
244 CSIDL_TO_STR(CSIDL_PROGRAMS
);
245 CSIDL_TO_STR(CSIDL_CONTROLS
);
246 CSIDL_TO_STR(CSIDL_PRINTERS
);
247 CSIDL_TO_STR(CSIDL_PERSONAL
);
248 CSIDL_TO_STR(CSIDL_FAVORITES
);
249 CSIDL_TO_STR(CSIDL_STARTUP
);
250 CSIDL_TO_STR(CSIDL_RECENT
);
251 CSIDL_TO_STR(CSIDL_SENDTO
);
252 CSIDL_TO_STR(CSIDL_BITBUCKET
);
253 CSIDL_TO_STR(CSIDL_STARTMENU
);
254 CSIDL_TO_STR(OLD_CSIDL_MYDOCUMENTS
);
255 CSIDL_TO_STR(CSIDL_MYMUSIC
);
256 CSIDL_TO_STR(CSIDL_MYVIDEO
);
257 CSIDL_TO_STR(CSIDL_DESKTOPDIRECTORY
);
258 CSIDL_TO_STR(CSIDL_DRIVES
);
259 CSIDL_TO_STR(CSIDL_NETWORK
);
260 CSIDL_TO_STR(CSIDL_NETHOOD
);
261 CSIDL_TO_STR(CSIDL_FONTS
);
262 CSIDL_TO_STR(CSIDL_TEMPLATES
);
263 CSIDL_TO_STR(CSIDL_COMMON_STARTMENU
);
264 CSIDL_TO_STR(CSIDL_COMMON_PROGRAMS
);
265 CSIDL_TO_STR(CSIDL_COMMON_STARTUP
);
266 CSIDL_TO_STR(CSIDL_COMMON_DESKTOPDIRECTORY
);
267 CSIDL_TO_STR(CSIDL_APPDATA
);
268 CSIDL_TO_STR(CSIDL_PRINTHOOD
);
269 CSIDL_TO_STR(CSIDL_LOCAL_APPDATA
);
270 CSIDL_TO_STR(CSIDL_ALTSTARTUP
);
271 CSIDL_TO_STR(CSIDL_COMMON_ALTSTARTUP
);
272 CSIDL_TO_STR(CSIDL_COMMON_FAVORITES
);
273 CSIDL_TO_STR(CSIDL_INTERNET_CACHE
);
274 CSIDL_TO_STR(CSIDL_COOKIES
);
275 CSIDL_TO_STR(CSIDL_HISTORY
);
276 CSIDL_TO_STR(CSIDL_COMMON_APPDATA
);
277 CSIDL_TO_STR(CSIDL_WINDOWS
);
278 CSIDL_TO_STR(CSIDL_SYSTEM
);
279 CSIDL_TO_STR(CSIDL_PROGRAM_FILES
);
280 CSIDL_TO_STR(CSIDL_MYPICTURES
);
281 CSIDL_TO_STR(CSIDL_PROFILE
);
282 CSIDL_TO_STR(CSIDL_SYSTEMX86
);
283 CSIDL_TO_STR(CSIDL_PROGRAM_FILESX86
);
284 CSIDL_TO_STR(CSIDL_PROGRAM_FILES_COMMON
);
285 CSIDL_TO_STR(CSIDL_PROGRAM_FILES_COMMONX86
);
286 CSIDL_TO_STR(CSIDL_COMMON_TEMPLATES
);
287 CSIDL_TO_STR(CSIDL_COMMON_DOCUMENTS
);
288 CSIDL_TO_STR(CSIDL_COMMON_ADMINTOOLS
);
289 CSIDL_TO_STR(CSIDL_ADMINTOOLS
);
290 CSIDL_TO_STR(CSIDL_CONNECTIONS
);
291 CSIDL_TO_STR(CSIDL_PROFILES
);
292 CSIDL_TO_STR(CSIDL_COMMON_MUSIC
);
293 CSIDL_TO_STR(CSIDL_COMMON_PICTURES
);
294 CSIDL_TO_STR(CSIDL_COMMON_VIDEO
);
295 CSIDL_TO_STR(CSIDL_RESOURCES
);
296 CSIDL_TO_STR(CSIDL_RESOURCES_LOCALIZED
);
297 CSIDL_TO_STR(CSIDL_COMMON_OEM_LINKS
);
298 CSIDL_TO_STR(CSIDL_CDBURN_AREA
);
299 CSIDL_TO_STR(CSIDL_COMPUTERSNEARME
);
302 sprintf(unknown
, "unknown (0x%04x)", folder
);
307 static void test_parameters(void)
309 LPITEMIDLIST pidl
= NULL
;
313 if (pSHGetFolderLocation
)
315 /* check a bogus CSIDL: */
317 hr
= pSHGetFolderLocation(NULL
, 0xeeee, NULL
, 0, &pidl
);
318 ok(hr
== E_INVALIDARG
, "got 0x%08x, expected E_INVALIDARG\n", hr
);
319 if (hr
== S_OK
) IMalloc_Free(pMalloc
, pidl
);
321 /* check a bogus user token: */
323 hr
= pSHGetFolderLocation(NULL
, CSIDL_FAVORITES
, (HANDLE
)2, 0, &pidl
);
324 ok(hr
== E_FAIL
|| hr
== E_HANDLE
, "got 0x%08x, expected E_FAIL or E_HANDLE\n", hr
);
325 if (hr
== S_OK
) IMalloc_Free(pMalloc
, pidl
);
327 /* a NULL pidl pointer crashes, so don't test it */
330 if (pSHGetSpecialFolderLocation
)
334 SHGetSpecialFolderLocation(NULL
, 0, NULL
);
336 hr
= pSHGetSpecialFolderLocation(NULL
, 0xeeee, &pidl
);
337 ok(hr
== E_INVALIDARG
, "got returned 0x%08x\n", hr
);
340 if (pSHGetFolderPathA
)
342 /* expect 2's a bogus handle, especially since we didn't open it */
343 hr
= pSHGetFolderPathA(NULL
, CSIDL_DESKTOP
, (HANDLE
)2, SHGFP_TYPE_DEFAULT
, path
);
344 ok(hr
== E_FAIL
|| hr
== E_HANDLE
|| /* Vista and 2k8 */
345 broken(hr
== S_OK
), /* W2k and Me */ "got 0x%08x, expected E_FAIL\n", hr
);
347 hr
= pSHGetFolderPathA(NULL
, 0xeeee, NULL
, SHGFP_TYPE_DEFAULT
, path
);
348 ok(hr
== E_INVALIDARG
, "got 0x%08x, expected E_INVALIDARG\n", hr
);
351 if (pSHGetSpecialFolderPathA
)
356 pSHGetSpecialFolderPathA(NULL
, NULL
, CSIDL_BITBUCKET
, FALSE
);
358 /* odd but true: calling with a NULL path still succeeds if it's a real
359 * dir (on some windows platform). on winME it generates exception.
361 ret
= pSHGetSpecialFolderPathA(NULL
, path
, CSIDL_PROGRAMS
, FALSE
);
362 ok(ret
, "got %d\n", ret
);
364 ret
= pSHGetSpecialFolderPathA(NULL
, path
, 0xeeee, FALSE
);
365 ok(!ret
, "got %d\n", ret
);
369 /* Returns the folder's PIDL type, or 0xff if one can't be found. */
370 static BYTE
testSHGetFolderLocation(int folder
)
376 /* treat absence of function as success */
377 if (!pSHGetFolderLocation
) return TRUE
;
380 hr
= pSHGetFolderLocation(NULL
, folder
, NULL
, 0, &pidl
);
385 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
387 ok(pidlLast
!= NULL
, "%s: ILFindLastID failed\n",
388 getFolderName(folder
));
390 ret
= pidlLast
->mkid
.abID
[0];
391 IMalloc_Free(pMalloc
, pidl
);
397 /* Returns the folder's PIDL type, or 0xff if one can't be found. */
398 static BYTE
testSHGetSpecialFolderLocation(int folder
)
404 /* treat absence of function as success */
405 if (!pSHGetSpecialFolderLocation
) return TRUE
;
408 hr
= pSHGetSpecialFolderLocation(NULL
, folder
, &pidl
);
413 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
416 "%s: ILFindLastID failed\n", getFolderName(folder
));
418 ret
= pidlLast
->mkid
.abID
[0];
419 IMalloc_Free(pMalloc
, pidl
);
425 static void test_SHGetFolderPath(BOOL optional
, int folder
)
430 if (!pSHGetFolderPathA
) return;
432 hr
= pSHGetFolderPathA(NULL
, folder
, NULL
, SHGFP_TYPE_CURRENT
, path
);
433 ok(hr
== S_OK
|| optional
,
434 "SHGetFolderPathA(NULL, %s, NULL, SHGFP_TYPE_CURRENT, path) failed: 0x%08x\n", getFolderName(folder
), hr
);
437 static void test_SHGetSpecialFolderPath(BOOL optional
, int folder
)
442 if (!pSHGetSpecialFolderPathA
) return;
444 ret
= pSHGetSpecialFolderPathA(NULL
, path
, folder
, FALSE
);
445 if (ret
&& winetest_interactive
)
446 printf("%s: %s\n", getFolderName(folder
), path
);
448 "SHGetSpecialFolderPathA(NULL, path, %s, FALSE) failed\n",
449 getFolderName(folder
));
452 static void test_ShellValues(const struct shellExpectedValues testEntries
[],
453 int numEntries
, BOOL optional
)
457 for (i
= 0; i
< numEntries
; i
++)
461 BOOL foundTypeMatch
= FALSE
;
463 if (pSHGetFolderLocation
)
465 type
= testSHGetFolderLocation(testEntries
[i
].folder
);
466 for (j
= 0; !foundTypeMatch
&& j
< testEntries
[i
].numTypes
; j
++)
467 if (testEntries
[i
].types
[j
] == type
)
468 foundTypeMatch
= TRUE
;
469 ok(foundTypeMatch
|| optional
|| broken(type
== 0xff) /* Win9x */,
470 "%s has unexpected type %d (0x%02x)\n",
471 getFolderName(testEntries
[i
].folder
), type
, type
);
473 type
= testSHGetSpecialFolderLocation(testEntries
[i
].folder
);
474 for (j
= 0, foundTypeMatch
= FALSE
; !foundTypeMatch
&&
475 j
< testEntries
[i
].numTypes
; j
++)
476 if (testEntries
[i
].types
[j
] == type
)
477 foundTypeMatch
= TRUE
;
478 ok(foundTypeMatch
|| optional
|| broken(type
== 0xff) /* Win9x */,
479 "%s has unexpected type %d (0x%02x)\n",
480 getFolderName(testEntries
[i
].folder
), type
, type
);
487 test_SHGetFolderPath(optional
, testEntries
[i
].folder
);
488 test_SHGetSpecialFolderPath(optional
, testEntries
[i
].folder
);
494 /* Attempts to verify that the folder path corresponding to the folder CSIDL
495 * value has the same value as the environment variable with name envVar.
496 * Doesn't mind if SHGetSpecialFolderPath fails for folder or if envVar isn't
497 * set in this environment; different OS and shell version behave differently.
498 * However, if both are present, fails if envVar's value is not the same
499 * (byte-for-byte) as what SHGetSpecialFolderPath returns.
501 static void matchSpecialFolderPathToEnv(int folder
, const char *envVar
)
505 if (!pSHGetSpecialFolderPathA
) return;
507 if (pSHGetSpecialFolderPathA(NULL
, path
, folder
, FALSE
))
509 char *envVal
= getenv(envVar
);
511 ok(!envVal
|| !lstrcmpiA(envVal
, path
),
512 "%%%s%% does not match SHGetSpecialFolderPath:\n"
513 "%%%s%% is %s\nSHGetSpecialFolderPath returns %s\n",
514 envVar
, envVar
, envVal
, path
);
518 /* Attempts to match the GUID returned by SHGetFolderLocation for folder with
519 * GUID. Assumes the type of the returned PIDL is in fact a GUID, but doesn't
520 * fail if it isn't--that check should already have been done.
521 * Fails if the returned PIDL is a GUID whose value does not match guid.
523 static void matchGUID(int folder
, const GUID
*guid
, const GUID
*guid_alt
)
528 if (!pSHGetFolderLocation
) return;
532 hr
= pSHGetFolderLocation(NULL
, folder
, NULL
, 0, &pidl
);
535 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
537 if (pidlLast
&& (pidlLast
->mkid
.abID
[0] == PT_SHELLEXT
||
538 pidlLast
->mkid
.abID
[0] == PT_GUID
))
540 GUID
*shellGuid
= (GUID
*)(pidlLast
->mkid
.abID
+ 2);
543 ok(IsEqualIID(shellGuid
, guid
),
544 "%s: got GUID %s, expected %s\n", getFolderName(folder
),
545 wine_dbgstr_guid(shellGuid
), wine_dbgstr_guid(guid
));
547 ok(IsEqualIID(shellGuid
, guid
) ||
548 IsEqualIID(shellGuid
, guid_alt
),
549 "%s: got GUID %s, expected %s or %s\n", getFolderName(folder
),
550 wine_dbgstr_guid(shellGuid
), wine_dbgstr_guid(guid
), wine_dbgstr_guid(guid_alt
));
552 IMalloc_Free(pMalloc
, pidl
);
556 /* Checks the PIDL type of all the known values. */
557 static void test_PidlTypes(void)
560 test_SHGetFolderPath(FALSE
, CSIDL_DESKTOP
);
561 test_SHGetSpecialFolderPath(FALSE
, CSIDL_DESKTOP
);
563 test_ShellValues(requiredShellValues
, ARRAY_SIZE(requiredShellValues
), FALSE
);
564 test_ShellValues(optionalShellValues
, ARRAY_SIZE(optionalShellValues
), TRUE
);
567 /* FIXME: Should be in shobjidl.idl */
568 DEFINE_GUID(CLSID_NetworkExplorerFolder
, 0xF02C1A0D, 0xBE21, 0x4350, 0x88, 0xB0, 0x73, 0x67, 0xFC, 0x96, 0xEF, 0x3C);
569 DEFINE_GUID(_CLSID_Documents
, 0xA8CDFF1C, 0x4878, 0x43be, 0xB5, 0xFD, 0xF8, 0x09, 0x1C, 0x1C, 0x60, 0xD0);
571 /* Verifies various shell virtual folders have the correct well-known GUIDs. */
572 static void test_GUIDs(void)
574 matchGUID(CSIDL_BITBUCKET
, &CLSID_RecycleBin
, NULL
);
575 matchGUID(CSIDL_CONTROLS
, &CLSID_ControlPanel
, NULL
);
576 matchGUID(CSIDL_DRIVES
, &CLSID_MyComputer
, NULL
);
577 matchGUID(CSIDL_INTERNET
, &CLSID_Internet
, NULL
);
578 matchGUID(CSIDL_NETWORK
, &CLSID_NetworkPlaces
, &CLSID_NetworkExplorerFolder
); /* Vista and higher */
579 matchGUID(CSIDL_PERSONAL
, &CLSID_MyDocuments
, &_CLSID_Documents
/* win8 */);
580 matchGUID(CSIDL_COMMON_DOCUMENTS
, &CLSID_CommonDocuments
, NULL
);
581 matchGUID(CSIDL_PRINTERS
, &CLSID_Printers
, NULL
);
584 /* Verifies various shell paths match the environment variables to which they
587 static void test_EnvVars(void)
589 matchSpecialFolderPathToEnv(CSIDL_PROGRAM_FILES
, "ProgramFiles");
590 matchSpecialFolderPathToEnv(CSIDL_APPDATA
, "APPDATA");
591 matchSpecialFolderPathToEnv(CSIDL_PROFILE
, "USERPROFILE");
592 matchSpecialFolderPathToEnv(CSIDL_WINDOWS
, "SystemRoot");
593 matchSpecialFolderPathToEnv(CSIDL_WINDOWS
, "windir");
594 matchSpecialFolderPathToEnv(CSIDL_PROGRAM_FILES_COMMON
, "CommonProgramFiles");
595 /* this is only set on Wine, but can't hurt to verify it: */
596 matchSpecialFolderPathToEnv(CSIDL_SYSTEM
, "winsysdir");
599 /* Loosely based on PathRemoveBackslashA from dlls/shlwapi/path.c */
600 static BOOL
myPathIsRootA(LPCSTR lpszPath
)
602 if (lpszPath
&& *lpszPath
&&
603 lpszPath
[1] == ':' && lpszPath
[2] == '\\' && lpszPath
[3] == '\0')
604 return TRUE
; /* X:\ */
607 static LPSTR
myPathRemoveBackslashA( LPSTR lpszPath
)
613 szTemp
= CharPrevA(lpszPath
, lpszPath
+ strlen(lpszPath
));
614 if (!myPathIsRootA(lpszPath
) && *szTemp
== '\\')
620 /* Verifies the shell path for CSIDL_WINDOWS matches the return from
621 * GetWindowsDirectory. If SHGetSpecialFolderPath fails, no harm, no foul--not
622 * every shell32 version supports CSIDL_WINDOWS.
624 static void testWinDir(void)
626 char windowsShellPath
[MAX_PATH
], windowsDir
[MAX_PATH
] = { 0 };
628 if (!pSHGetSpecialFolderPathA
) return;
630 if (pSHGetSpecialFolderPathA(NULL
, windowsShellPath
, CSIDL_WINDOWS
, FALSE
))
632 myPathRemoveBackslashA(windowsShellPath
);
633 GetWindowsDirectoryA(windowsDir
, sizeof(windowsDir
));
634 myPathRemoveBackslashA(windowsDir
);
635 ok(!lstrcmpiA(windowsDir
, windowsShellPath
),
636 "GetWindowsDirectory returns %s SHGetSpecialFolderPath returns %s\n",
637 windowsDir
, windowsShellPath
);
641 /* Verifies the shell path for CSIDL_SYSTEM matches the return from
642 * GetSystemDirectory. If SHGetSpecialFolderPath fails, no harm,
643 * no foul--not every shell32 version supports CSIDL_SYSTEM.
645 static void testSystemDir(void)
647 char systemShellPath
[MAX_PATH
], systemDir
[MAX_PATH
], systemDirx86
[MAX_PATH
];
649 if (!pSHGetSpecialFolderPathA
) return;
651 GetSystemDirectoryA(systemDir
, sizeof(systemDir
));
652 myPathRemoveBackslashA(systemDir
);
653 if (pSHGetSpecialFolderPathA(NULL
, systemShellPath
, CSIDL_SYSTEM
, FALSE
))
655 myPathRemoveBackslashA(systemShellPath
);
656 ok(!lstrcmpiA(systemDir
, systemShellPath
),
657 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
658 systemDir
, systemShellPath
);
661 if (!pGetSystemWow64DirectoryA
|| !pGetSystemWow64DirectoryA(systemDirx86
, sizeof(systemDirx86
)))
662 GetSystemDirectoryA(systemDirx86
, sizeof(systemDirx86
));
663 myPathRemoveBackslashA(systemDirx86
);
664 if (pSHGetSpecialFolderPathA(NULL
, systemShellPath
, CSIDL_SYSTEMX86
, FALSE
))
666 myPathRemoveBackslashA(systemShellPath
);
667 ok(!lstrcmpiA(systemDirx86
, systemShellPath
) || broken(!lstrcmpiA(systemDir
, systemShellPath
)),
668 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
669 systemDir
, systemShellPath
);
673 /* Globals used by subprocesses */
675 static char **myARGV
;
676 static char base
[MAX_PATH
];
677 static char selfname
[MAX_PATH
];
679 static BOOL
init(void)
681 myARGC
= winetest_get_mainargs(&myARGV
);
682 if (!GetCurrentDirectoryA(sizeof(base
), base
)) return FALSE
;
683 strcpy(selfname
, myARGV
[0]);
687 static void doChild(const char *arg
)
697 /* test what happens when CSIDL_FAVORITES is set to a nonexistent directory */
699 /* test some failure cases first: */
700 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
, NULL
, SHGFP_TYPE_CURRENT
, path
);
701 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
702 "SHGetFolderPath returned 0x%08x, expected 0x80070002\n", hr
);
705 hr
= pSHGetFolderLocation(NULL
, CSIDL_FAVORITES
, NULL
, 0, &pidl
);
706 ok(hr
== E_FAIL
|| hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
707 "SHGetFolderLocation returned 0x%08x\n", hr
);
708 if (hr
== S_OK
&& pidl
) IMalloc_Free(pMalloc
, pidl
);
710 ok(!pSHGetSpecialFolderPathA(NULL
, path
, CSIDL_FAVORITES
, FALSE
),
711 "SHGetSpecialFolderPath succeeded, expected failure\n");
714 hr
= pSHGetSpecialFolderLocation(NULL
, CSIDL_FAVORITES
, &pidl
);
715 ok(hr
== E_FAIL
|| hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
716 "SHGetFolderLocation returned 0x%08x\n", hr
);
718 if (hr
== S_OK
&& pidl
) IMalloc_Free(pMalloc
, pidl
);
720 /* now test success: */
721 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
| CSIDL_FLAG_CREATE
, NULL
,
722 SHGFP_TYPE_CURRENT
, path
);
723 ok (hr
== S_OK
, "got 0x%08x\n", hr
);
728 trace("CSIDL_FAVORITES was changed to %s\n", path
);
729 ret
= CreateDirectoryA(path
, NULL
);
730 ok(!ret
, "expected failure with ERROR_ALREADY_EXISTS\n");
732 ok(GetLastError() == ERROR_ALREADY_EXISTS
,
733 "got %d, expected ERROR_ALREADY_EXISTS\n", GetLastError());
735 p
= path
+ strlen(path
);
736 strcpy(p
, "\\desktop.ini");
739 SetFileAttributesA( path
, FILE_ATTRIBUTE_NORMAL
);
740 ret
= RemoveDirectoryA(path
);
741 ok( ret
, "failed to remove %s error %u\n", path
, GetLastError() );
744 else if (arg
[0] == '2')
746 /* make sure SHGetFolderPath still succeeds when the
747 original value of CSIDL_FAVORITES is restored. */
748 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
| CSIDL_FLAG_CREATE
, NULL
,
749 SHGFP_TYPE_CURRENT
, path
);
750 ok(hr
== S_OK
, "SHGetFolderPath failed: 0x%08x\n", hr
);
754 /* Tests the return values from the various shell functions both with and
755 * without the use of the CSIDL_FLAG_CREATE flag. This flag only appeared in
756 * version 5 of the shell, so don't test unless it's at least version 5.
757 * The test reads a value from the registry, modifies it, calls
758 * SHGetFolderPath once with the CSIDL_FLAG_CREATE flag, and immediately
759 * afterward without it. Then it restores the registry and deletes the folder
761 * One oddity with respect to restoration: shell32 caches somehow, so it needs
762 * to be reloaded in order to see the correct (restored) value.
763 * Some APIs unrelated to the ones under test may fail, but I expect they're
764 * covered by other unit tests; I just print out something about failure to
765 * help trace what's going on.
767 static void test_NonExistentPath(void)
769 static const char userShellFolders
[] =
770 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
771 char originalPath
[MAX_PATH
], modifiedPath
[MAX_PATH
];
774 if (!pSHGetFolderPathA
) return;
775 if (!pSHGetFolderLocation
) return;
776 if (!pSHGetSpecialFolderPathA
) return;
777 if (!pSHGetSpecialFolderLocation
) return;
778 if (!pSHFileOperationA
) return;
779 if (shellVersion
.dwMajorVersion
< 5) return;
781 if (!RegOpenKeyExA(HKEY_CURRENT_USER
, userShellFolders
, 0, KEY_ALL_ACCESS
,
786 len
= sizeof(originalPath
);
787 if (!RegQueryValueExA(key
, "Favorites", NULL
, &type
,
788 (LPBYTE
)&originalPath
, &len
))
790 size_t len
= strlen(originalPath
);
792 memcpy(modifiedPath
, originalPath
, len
);
793 modifiedPath
[len
++] = '2';
794 modifiedPath
[len
++] = '\0';
795 trace("Changing CSIDL_FAVORITES to %s\n", modifiedPath
);
796 if (!RegSetValueExA(key
, "Favorites", 0, type
,
797 (LPBYTE
)modifiedPath
, len
))
799 char buffer
[MAX_PATH
+20];
800 STARTUPINFOA startup
;
801 PROCESS_INFORMATION info
;
803 sprintf(buffer
, "%s tests/shellpath.c 1", selfname
);
804 memset(&startup
, 0, sizeof(startup
));
805 startup
.cb
= sizeof(startup
);
806 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
807 startup
.wShowWindow
= SW_SHOWNORMAL
;
808 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
,
810 winetest_wait_child_process( info
.hProcess
);
812 /* restore original values: */
813 trace("Restoring CSIDL_FAVORITES to %s\n", originalPath
);
814 RegSetValueExA(key
, "Favorites", 0, type
, (LPBYTE
) originalPath
,
815 strlen(originalPath
) + 1);
818 sprintf(buffer
, "%s tests/shellpath.c 2", selfname
);
819 memset(&startup
, 0, sizeof(startup
));
820 startup
.cb
= sizeof(startup
);
821 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
822 startup
.wShowWindow
= SW_SHOWNORMAL
;
823 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
,
825 ok(WaitForSingleObject(info
.hProcess
, 30000) == WAIT_OBJECT_0
,
826 "child process termination\n");
829 else skip("RegQueryValueExA(key, Favorites, ...) failed\n");
833 else skip("RegOpenKeyExA(HKEY_CURRENT_USER, %s, ...) failed\n", userShellFolders
);
836 static void test_SHGetFolderPathEx(void)
839 WCHAR buffer
[MAX_PATH
], *path
;
842 if (!pSHGetKnownFolderPath
|| !pSHGetFolderPathEx
)
844 win_skip("SHGetKnownFolderPath or SHGetFolderPathEx not available\n");
848 if (0) { /* crashes */
849 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, 0, NULL
, NULL
);
850 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
852 /* non-existent folder id */
853 path
= (void *)0xdeadbeef;
854 hr
= pSHGetKnownFolderPath(&IID_IOleObject
, 0, NULL
, &path
);
855 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
856 ok(path
== NULL
, "got %p\n", path
);
859 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, KF_FLAG_DEFAULT_PATH
, NULL
, &path
);
860 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
861 ok(path
!= NULL
, "expected path != NULL\n");
865 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, 0, NULL
, &path
);
866 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
867 ok(path
!= NULL
, "expected path != NULL\n");
869 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, MAX_PATH
);
870 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
871 ok(!lstrcmpiW(path
, buffer
), "expected equal paths\n");
872 len
= lstrlenW(buffer
);
875 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, 0);
876 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
878 if (0) { /* crashes */
879 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, NULL
, len
+ 1);
880 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
882 hr
= pSHGetFolderPathEx(NULL
, 0, NULL
, buffer
, MAX_PATH
);
883 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
885 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
);
886 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr
);
888 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
+ 1);
889 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
892 /* Standard CSIDL values (and their flags) uses only two less-significant bytes */
893 #define NO_CSIDL 0x10000
894 #define WINE_ATTRIBUTES_OPTIONAL 0x20000
895 #define KNOWN_FOLDER(id, csidl, name, category, parent1, parent2, relative_path, parsing_name, attributes, definitionFlags) \
896 { &id, # id, csidl, # csidl, name, category, {&parent1, &parent2}, relative_path, parsing_name, attributes, definitionFlags, __LINE__ }
898 /* non-published known folders test */
899 static const GUID _FOLDERID_CryptoKeys
= {0xB88F4DAA, 0xE7BD, 0x49A9, {0xB7, 0x4D, 0x02, 0x88, 0x5A, 0x5D, 0xC7, 0x65} };
900 static const GUID _FOLDERID_DpapiKeys
= {0x10C07CD0, 0xEF91, 0x4567, {0xB8, 0x50, 0x44, 0x8B, 0x77, 0xCB, 0x37, 0xF9} };
901 static const GUID _FOLDERID_SystemCertificates
= {0x54EED2E0, 0xE7CA, 0x4FDB, {0x91, 0x48, 0x0F, 0x42, 0x47, 0x29, 0x1C, 0xFA} };
902 static const GUID _FOLDERID_CredentialManager
= {0x915221FB, 0x9EFE, 0x4BDA, {0x8F, 0xD7, 0xF7, 0x8D, 0xCA, 0x77, 0x4F, 0x87} };
904 struct knownFolderDef
{
905 const KNOWNFOLDERID
*folderId
;
906 const char *sFolderId
;
910 const KF_CATEGORY category
;
911 const KNOWNFOLDERID
*fidParents
[2];
912 const char *sRelativePath
;
913 const char *sParsingName
;
914 const DWORD attributes
;
915 const KF_DEFINITION_FLAGS definitionFlags
;
919 /* Note: content of parsing name may vary between Windows versions.
920 * As a base, values from 6.0 (Vista) were used. Some entries may contain
921 * alternative values. In that case, Windows version where the value was
924 * The list of values for parsing name was encoded as a number of null-
925 * terminated strings placed one by one (separated by null byte only).
926 * End of list is marked by two consecutive null bytes.
928 static const struct knownFolderDef known_folders
[] = {
929 KNOWN_FOLDER(FOLDERID_AddNewPrograms
,
931 "AddNewProgramsFolder",
933 GUID_NULL
, GUID_NULL
,
935 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0"
936 "shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0\0" /* 6.1 */,
939 KNOWN_FOLDER(FOLDERID_AdminTools
,
941 "Administrative Tools",
943 FOLDERID_Programs
, GUID_NULL
,
944 "Administrative Tools",
946 FILE_ATTRIBUTE_READONLY
,
948 KNOWN_FOLDER(FOLDERID_AppUpdates
,
952 GUID_NULL
, GUID_NULL
,
954 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0"
955 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0\0" /* 6.1 */,
958 KNOWN_FOLDER(FOLDERID_CDBurning
,
962 FOLDERID_LocalAppData
, GUID_NULL
,
963 "Microsoft\\Windows\\Burn\\Burn",
965 FILE_ATTRIBUTE_READONLY
,
966 KFDF_LOCAL_REDIRECT_ONLY
),
967 KNOWN_FOLDER(FOLDERID_ChangeRemovePrograms
,
969 "ChangeRemoveProgramsFolder",
971 GUID_NULL
, GUID_NULL
,
973 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0"
974 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0\0" /* 6.1 */,
977 KNOWN_FOLDER(FOLDERID_CommonAdminTools
,
978 CSIDL_COMMON_ADMINTOOLS
,
979 "Common Administrative Tools",
981 FOLDERID_CommonPrograms
, GUID_NULL
,
982 "Administrative Tools",
984 FILE_ATTRIBUTE_READONLY
,
986 KNOWN_FOLDER(FOLDERID_CommonOEMLinks
,
987 CSIDL_COMMON_OEM_LINKS
,
990 FOLDERID_ProgramData
, GUID_NULL
,
995 KNOWN_FOLDER(FOLDERID_CommonPrograms
,
996 CSIDL_COMMON_PROGRAMS
,
999 FOLDERID_CommonStartMenu
, GUID_NULL
,
1002 FILE_ATTRIBUTE_READONLY
,
1004 KNOWN_FOLDER(FOLDERID_CommonStartMenu
,
1005 CSIDL_COMMON_STARTMENU
,
1006 "Common Start Menu",
1008 FOLDERID_ProgramData
, GUID_NULL
,
1009 "Microsoft\\Windows\\Start Menu\0",
1011 FILE_ATTRIBUTE_READONLY
,
1013 KNOWN_FOLDER(FOLDERID_CommonStartup
,
1014 CSIDL_COMMON_STARTUP
,
1017 FOLDERID_CommonPrograms
, GUID_NULL
,
1020 FILE_ATTRIBUTE_READONLY
,
1022 KNOWN_FOLDER(FOLDERID_CommonTemplates
,
1023 CSIDL_COMMON_TEMPLATES
,
1026 FOLDERID_ProgramData
, GUID_NULL
,
1027 "Microsoft\\Windows\\Templates\0",
1031 KNOWN_FOLDER(FOLDERID_ComputerFolder
,
1034 KF_CATEGORY_VIRTUAL
,
1035 GUID_NULL
, GUID_NULL
,
1037 "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\0\0",
1040 KNOWN_FOLDER(FOLDERID_ConflictFolder
,
1043 KF_CATEGORY_VIRTUAL
,
1044 GUID_NULL
, GUID_NULL
,
1046 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0"
1047 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0\0" /* 6.1 */,
1050 KNOWN_FOLDER(FOLDERID_ConnectionsFolder
,
1052 "ConnectionsFolder",
1053 KF_CATEGORY_VIRTUAL
,
1054 GUID_NULL
, GUID_NULL
,
1056 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0"
1057 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0\0" /* 6.1 */,
1060 KNOWN_FOLDER(FOLDERID_Contacts
,
1063 KF_CATEGORY_PERUSER
,
1064 FOLDERID_Profile
, GUID_NULL
,
1066 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{56784854-C6CB-462B-8169-88E350ACB882}\0\0",
1067 FILE_ATTRIBUTE_READONLY
,
1068 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1069 KNOWN_FOLDER(FOLDERID_ControlPanelFolder
,
1071 "ControlPanelFolder",
1072 KF_CATEGORY_VIRTUAL
,
1073 GUID_NULL
, GUID_NULL
,
1075 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\0"
1076 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\0\0" /* 6.1 */,
1079 KNOWN_FOLDER(FOLDERID_Cookies
,
1082 KF_CATEGORY_PERUSER
,
1083 FOLDERID_RoamingAppData
, FOLDERID_LocalAppData
,
1084 "Microsoft\\Windows\\Cookies\0Microsoft\\Windows\\INetCookies\0" /* win8 */,
1088 KNOWN_FOLDER(FOLDERID_Desktop
,
1091 KF_CATEGORY_PERUSER
,
1092 FOLDERID_Profile
, GUID_NULL
,
1095 FILE_ATTRIBUTE_READONLY
,
1096 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1097 KNOWN_FOLDER(FOLDERID_DeviceMetadataStore
,
1099 "Device Metadata Store",
1101 FOLDERID_ProgramData
, GUID_NULL
,
1102 "Microsoft\\Windows\\DeviceMetadataStore\0",
1106 KNOWN_FOLDER(FOLDERID_Documents
,
1109 KF_CATEGORY_PERUSER
,
1110 FOLDERID_Profile
, GUID_NULL
,
1112 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{FDD39AD0-238F-46AF-ADB4-6C85480369C7}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}\0\0", /* win8 */
1113 FILE_ATTRIBUTE_READONLY
,
1114 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1115 KNOWN_FOLDER(FOLDERID_DocumentsLibrary
,
1118 KF_CATEGORY_PERUSER
,
1119 FOLDERID_Libraries
, GUID_NULL
,
1120 "Documents.library-ms\0",
1121 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{7b0db17d-9cd2-4a93-9733-46cc89022e7c}\0\0",
1123 KFDF_PRECREATE
| KFDF_STREAM
),
1124 KNOWN_FOLDER(FOLDERID_Downloads
,
1127 KF_CATEGORY_PERUSER
,
1128 FOLDERID_Profile
, GUID_NULL
,
1130 "(null)\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{374DE290-123F-4565-9164-39C4925E467B}\0\0", /* win8 */
1131 FILE_ATTRIBUTE_READONLY
,
1132 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1133 KNOWN_FOLDER(FOLDERID_Favorites
,
1136 KF_CATEGORY_PERUSER
,
1137 FOLDERID_Profile
, GUID_NULL
,
1140 FILE_ATTRIBUTE_READONLY
,
1141 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1142 KNOWN_FOLDER(FOLDERID_Fonts
,
1146 FOLDERID_Windows
, GUID_NULL
,
1151 KNOWN_FOLDER(FOLDERID_Games
,
1154 KF_CATEGORY_VIRTUAL
,
1155 GUID_NULL
, GUID_NULL
,
1157 "::{ED228FDF-9EA8-4870-83b1-96b02CFE0D52}\0\0",
1160 KNOWN_FOLDER(FOLDERID_GameTasks
,
1163 KF_CATEGORY_PERUSER
,
1164 FOLDERID_LocalAppData
, GUID_NULL
,
1165 "Microsoft\\Windows\\GameExplorer\0",
1168 KFDF_LOCAL_REDIRECT_ONLY
),
1169 KNOWN_FOLDER(FOLDERID_History
,
1172 KF_CATEGORY_PERUSER
,
1173 FOLDERID_LocalAppData
, GUID_NULL
,
1174 "Microsoft\\Windows\\History\0",
1177 KFDF_LOCAL_REDIRECT_ONLY
),
1178 KNOWN_FOLDER(FOLDERID_HomeGroup
,
1181 KF_CATEGORY_VIRTUAL
,
1182 GUID_NULL
, GUID_NULL
,
1184 "::{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\0\0",
1187 KNOWN_FOLDER(FOLDERID_ImplicitAppShortcuts
,
1189 "ImplicitAppShortcuts",
1190 KF_CATEGORY_PERUSER
,
1191 FOLDERID_UserPinned
, GUID_NULL
,
1192 "ImplicitAppShortcuts\0",
1196 KNOWN_FOLDER(FOLDERID_InternetCache
,
1197 CSIDL_INTERNET_CACHE
,
1199 KF_CATEGORY_PERUSER
,
1200 FOLDERID_LocalAppData
, GUID_NULL
,
1201 "Microsoft\\Windows\\Temporary Internet Files\0Microsoft\\Windows\\INetCache\0\0", /* win8 */
1204 KFDF_LOCAL_REDIRECT_ONLY
),
1205 KNOWN_FOLDER(FOLDERID_InternetFolder
,
1208 KF_CATEGORY_VIRTUAL
,
1209 GUID_NULL
, GUID_NULL
,
1211 "::{871C5380-42A0-1069-A2EA-08002B30309D}\0\0",
1214 KNOWN_FOLDER(FOLDERID_Libraries
,
1217 KF_CATEGORY_PERUSER
,
1218 FOLDERID_RoamingAppData
, GUID_NULL
,
1219 "Microsoft\\Windows\\Libraries\0",
1222 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1223 KNOWN_FOLDER(FOLDERID_Links
,
1226 KF_CATEGORY_PERUSER
,
1227 FOLDERID_Profile
, GUID_NULL
,
1229 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}\0\0",
1230 FILE_ATTRIBUTE_READONLY
,
1231 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1232 KNOWN_FOLDER(FOLDERID_LocalAppData
,
1233 CSIDL_LOCAL_APPDATA
,
1235 KF_CATEGORY_PERUSER
,
1236 FOLDERID_Profile
, GUID_NULL
,
1240 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
),
1241 KNOWN_FOLDER(FOLDERID_LocalAppDataLow
,
1244 KF_CATEGORY_PERUSER
,
1245 FOLDERID_Profile
, GUID_NULL
,
1246 "AppData\\LocalLow\0",
1248 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
,
1249 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1250 KNOWN_FOLDER(FOLDERID_LocalizedResourcesDir
,
1251 CSIDL_RESOURCES_LOCALIZED
,
1252 "LocalizedResourcesDir",
1254 GUID_NULL
, GUID_NULL
,
1259 KNOWN_FOLDER(FOLDERID_Music
,
1262 KF_CATEGORY_PERUSER
,
1263 FOLDERID_Profile
, GUID_NULL
,
1265 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4BD8D571-6D19-48D3-BE97-422220080E43}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{1CF1260C-4DD0-4EBB-811F-33C572699FDE}\0\0", /* win8 */
1266 FILE_ATTRIBUTE_READONLY
,
1267 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1268 KNOWN_FOLDER(FOLDERID_MusicLibrary
,
1271 KF_CATEGORY_PERUSER
,
1272 FOLDERID_Libraries
, GUID_NULL
,
1273 "Music.library-ms\0",
1274 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{2112AB0A-C86A-4ffe-A368-0DE96E47012E}\0\0",
1276 KFDF_PRECREATE
| KFDF_STREAM
),
1277 KNOWN_FOLDER(FOLDERID_NetHood
,
1280 KF_CATEGORY_PERUSER
,
1281 FOLDERID_RoamingAppData
, GUID_NULL
,
1282 "Microsoft\\Windows\\Network Shortcuts\0",
1286 KNOWN_FOLDER(FOLDERID_NetworkFolder
,
1288 "NetworkPlacesFolder",
1289 KF_CATEGORY_VIRTUAL
,
1290 GUID_NULL
, GUID_NULL
,
1292 "::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\0\0",
1295 KNOWN_FOLDER(FOLDERID_OriginalImages
,
1298 KF_CATEGORY_PERUSER
,
1299 FOLDERID_LocalAppData
, GUID_NULL
,
1300 "Microsoft\\Windows Photo Gallery\\Original Images\0",
1304 KNOWN_FOLDER(FOLDERID_PhotoAlbums
,
1307 KF_CATEGORY_PERUSER
,
1308 FOLDERID_Pictures
, GUID_NULL
,
1311 FILE_ATTRIBUTE_READONLY
,
1313 KNOWN_FOLDER(FOLDERID_Pictures
,
1316 KF_CATEGORY_PERUSER
,
1317 FOLDERID_Profile
, GUID_NULL
,
1319 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{33E28130-4E1E-4676-835A-98395C3BC3BB}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{3ADD1653-EB32-4CB0-BBD7-DFA0ABB5ACCA}\0\0", /* win8 */
1320 FILE_ATTRIBUTE_READONLY
,
1321 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1322 KNOWN_FOLDER(FOLDERID_PicturesLibrary
,
1325 KF_CATEGORY_PERUSER
,
1326 FOLDERID_Libraries
, GUID_NULL
,
1327 "Pictures.library-ms\0",
1328 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{A990AE9F-A03B-4e80-94BC-9912D7504104}\0\0",
1330 KFDF_PRECREATE
| KFDF_STREAM
),
1331 KNOWN_FOLDER(FOLDERID_Playlists
,
1334 KF_CATEGORY_PERUSER
,
1335 FOLDERID_Music
, GUID_NULL
,
1338 FILE_ATTRIBUTE_READONLY
,
1340 KNOWN_FOLDER(FOLDERID_PrintersFolder
,
1343 KF_CATEGORY_VIRTUAL
,
1344 GUID_NULL
, GUID_NULL
,
1346 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}\0\0",
1349 KNOWN_FOLDER(FOLDERID_PrintHood
,
1352 KF_CATEGORY_PERUSER
,
1353 FOLDERID_RoamingAppData
, GUID_NULL
,
1354 "Microsoft\\Windows\\Printer Shortcuts\0",
1358 KNOWN_FOLDER(FOLDERID_Profile
,
1362 GUID_NULL
, GUID_NULL
,
1367 KNOWN_FOLDER(FOLDERID_ProgramData
,
1368 CSIDL_COMMON_APPDATA
,
1371 GUID_NULL
, GUID_NULL
,
1376 KNOWN_FOLDER(FOLDERID_ProgramFiles
,
1377 CSIDL_PROGRAM_FILES
,
1380 GUID_NULL
, GUID_NULL
,
1383 FILE_ATTRIBUTE_READONLY
,
1386 KNOWN_FOLDER(FOLDERID_ProgramFilesCommon
,
1387 CSIDL_PROGRAM_FILES_COMMON
,
1388 "ProgramFilesCommon",
1390 GUID_NULL
, GUID_NULL
,
1395 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX64
,
1397 "ProgramFilesCommonX64",
1399 GUID_NULL
, GUID_NULL
,
1404 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX86
,
1406 "ProgramFilesCommonX86",
1408 GUID_NULL
, GUID_NULL
,
1413 KNOWN_FOLDER(FOLDERID_ProgramFilesX64
,
1417 GUID_NULL
, GUID_NULL
,
1422 KNOWN_FOLDER(FOLDERID_ProgramFilesX86
,
1423 CSIDL_PROGRAM_FILESX86
,
1426 GUID_NULL
, GUID_NULL
,
1429 FILE_ATTRIBUTE_READONLY
,
1431 KNOWN_FOLDER(FOLDERID_Programs
,
1434 KF_CATEGORY_PERUSER
,
1435 FOLDERID_StartMenu
, GUID_NULL
,
1438 FILE_ATTRIBUTE_READONLY
,
1440 KNOWN_FOLDER(FOLDERID_Public
,
1444 GUID_NULL
, GUID_NULL
,
1446 "::{4336a54d-038b-4685-ab02-99bb52d3fb8b}\0"
1447 "(null)\0\0" /* 6.1 */,
1448 FILE_ATTRIBUTE_READONLY
,
1450 KNOWN_FOLDER(FOLDERID_PublicDesktop
,
1451 CSIDL_COMMON_DESKTOPDIRECTORY
,
1454 FOLDERID_Public
, GUID_NULL
,
1457 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
1459 KNOWN_FOLDER(FOLDERID_PublicDocuments
,
1460 CSIDL_COMMON_DOCUMENTS
,
1463 FOLDERID_Public
, GUID_NULL
,
1466 FILE_ATTRIBUTE_READONLY
,
1468 KNOWN_FOLDER(FOLDERID_PublicDownloads
,
1472 FOLDERID_Public
, GUID_NULL
,
1475 FILE_ATTRIBUTE_READONLY
,
1477 KNOWN_FOLDER(FOLDERID_PublicGameTasks
,
1481 FOLDERID_ProgramData
, GUID_NULL
,
1482 "Microsoft\\Windows\\GameExplorer\0",
1485 KFDF_LOCAL_REDIRECT_ONLY
),
1486 KNOWN_FOLDER(FOLDERID_PublicLibraries
,
1490 FOLDERID_Public
, GUID_NULL
,
1493 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
1495 KNOWN_FOLDER(FOLDERID_PublicMusic
,
1499 FOLDERID_Public
, GUID_NULL
,
1502 FILE_ATTRIBUTE_READONLY
,
1504 KNOWN_FOLDER(FOLDERID_PublicPictures
,
1505 CSIDL_COMMON_PICTURES
,
1508 FOLDERID_Public
, GUID_NULL
,
1511 FILE_ATTRIBUTE_READONLY
,
1513 KNOWN_FOLDER(FOLDERID_PublicRingtones
,
1517 FOLDERID_ProgramData
, GUID_NULL
,
1518 "Microsoft\\Windows\\Ringtones\0",
1522 KNOWN_FOLDER(FOLDERID_PublicVideos
,
1526 FOLDERID_Public
, GUID_NULL
,
1529 FILE_ATTRIBUTE_READONLY
,
1531 KNOWN_FOLDER(FOLDERID_QuickLaunch
,
1534 KF_CATEGORY_PERUSER
,
1535 FOLDERID_RoamingAppData
, GUID_NULL
,
1536 "Microsoft\\Internet Explorer\\Quick Launch\0",
1540 KNOWN_FOLDER(FOLDERID_Recent
,
1543 KF_CATEGORY_PERUSER
,
1544 FOLDERID_RoamingAppData
, GUID_NULL
,
1545 "Microsoft\\Windows\\Recent\0",
1547 FILE_ATTRIBUTE_READONLY
,
1549 KNOWN_FOLDER(FOLDERID_RecordedTVLibrary
,
1551 "RecordedTVLibrary",
1553 FOLDERID_PublicLibraries
, GUID_NULL
,
1554 "RecordedTV.library-ms\0",
1557 KFDF_PRECREATE
| KFDF_STREAM
),
1558 KNOWN_FOLDER(FOLDERID_RecycleBinFolder
,
1561 KF_CATEGORY_VIRTUAL
,
1562 GUID_NULL
, GUID_NULL
,
1564 "::{645FF040-5081-101B-9F08-00AA002F954E}\0\0",
1567 KNOWN_FOLDER(FOLDERID_ResourceDir
,
1571 GUID_NULL
, GUID_NULL
,
1576 KNOWN_FOLDER(FOLDERID_Ringtones
,
1579 KF_CATEGORY_PERUSER
,
1580 FOLDERID_LocalAppData
, GUID_NULL
,
1581 "Microsoft\\Windows\\Ringtones\0",
1585 KNOWN_FOLDER(FOLDERID_RoamingAppData
,
1588 KF_CATEGORY_PERUSER
,
1589 FOLDERID_Profile
, GUID_NULL
,
1590 "AppData\\Roaming\0",
1594 KNOWN_FOLDER(FOLDERID_SampleMusic
,
1595 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1598 FOLDERID_PublicMusic
, GUID_NULL
,
1601 FILE_ATTRIBUTE_READONLY
,
1603 KNOWN_FOLDER(FOLDERID_SamplePictures
,
1604 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1607 FOLDERID_PublicPictures
, GUID_NULL
,
1608 "Sample Pictures\0",
1610 FILE_ATTRIBUTE_READONLY
,
1612 KNOWN_FOLDER(FOLDERID_SamplePlaylists
,
1616 FOLDERID_PublicMusic
, GUID_NULL
,
1617 "Sample Playlists\0",
1619 FILE_ATTRIBUTE_READONLY
,
1621 KNOWN_FOLDER(FOLDERID_SampleVideos
,
1622 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1625 FOLDERID_PublicVideos
, GUID_NULL
,
1628 FILE_ATTRIBUTE_READONLY
,
1630 KNOWN_FOLDER(FOLDERID_SavedGames
,
1633 KF_CATEGORY_PERUSER
,
1634 FOLDERID_Profile
, GUID_NULL
,
1636 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}\0\0",
1637 FILE_ATTRIBUTE_READONLY
,
1638 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1639 KNOWN_FOLDER(FOLDERID_SavedSearches
,
1642 KF_CATEGORY_PERUSER
,
1643 FOLDERID_Profile
, GUID_NULL
,
1645 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{7d1d3a04-debb-4115-95cf-2f29da2920da}\0\0",
1646 FILE_ATTRIBUTE_READONLY
,
1647 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1648 KNOWN_FOLDER(FOLDERID_SEARCH_CSC
,
1651 KF_CATEGORY_VIRTUAL
,
1652 GUID_NULL
, GUID_NULL
,
1654 "shell:::{BD7A2E7B-21CB-41b2-A086-B309680C6B7E}\\*\0\0",
1657 KNOWN_FOLDER(FOLDERID_SearchHome
,
1660 KF_CATEGORY_VIRTUAL
,
1661 GUID_NULL
, GUID_NULL
,
1663 "::{9343812e-1c37-4a49-a12e-4b2d810d956b}\0\0",
1666 KNOWN_FOLDER(FOLDERID_SEARCH_MAPI
,
1669 KF_CATEGORY_VIRTUAL
,
1670 GUID_NULL
, GUID_NULL
,
1672 "shell:::{89D83576-6BD1-4C86-9454-BEB04E94C819}\\*\0\0",
1675 KNOWN_FOLDER(FOLDERID_SendTo
,
1678 KF_CATEGORY_PERUSER
,
1679 FOLDERID_RoamingAppData
, GUID_NULL
,
1680 "Microsoft\\Windows\\SendTo\0",
1684 KNOWN_FOLDER(FOLDERID_SidebarDefaultParts
,
1688 FOLDERID_ProgramFiles
, GUID_NULL
,
1689 "Windows Sidebar\\Gadgets\0",
1693 KNOWN_FOLDER(FOLDERID_SidebarParts
,
1696 KF_CATEGORY_PERUSER
,
1697 FOLDERID_LocalAppData
, GUID_NULL
,
1698 "Microsoft\\Windows Sidebar\\Gadgets\0",
1702 KNOWN_FOLDER(FOLDERID_StartMenu
,
1705 KF_CATEGORY_PERUSER
,
1706 FOLDERID_RoamingAppData
, GUID_NULL
,
1707 "Microsoft\\Windows\\Start Menu\0",
1709 FILE_ATTRIBUTE_READONLY
,
1711 KNOWN_FOLDER(FOLDERID_Startup
,
1714 KF_CATEGORY_PERUSER
,
1715 FOLDERID_Programs
, GUID_NULL
,
1718 FILE_ATTRIBUTE_READONLY
,
1720 KNOWN_FOLDER(FOLDERID_SyncManagerFolder
,
1723 KF_CATEGORY_VIRTUAL
,
1724 GUID_NULL
, GUID_NULL
,
1726 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0"
1727 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0\0" /* 6.1 */,
1730 KNOWN_FOLDER(FOLDERID_SyncResultsFolder
,
1732 "SyncResultsFolder",
1733 KF_CATEGORY_VIRTUAL
,
1734 GUID_NULL
, GUID_NULL
,
1736 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0"
1737 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0\0",
1740 KNOWN_FOLDER(FOLDERID_SyncSetupFolder
,
1743 KF_CATEGORY_VIRTUAL
,
1744 GUID_NULL
, GUID_NULL
,
1746 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0"
1747 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0\0" /* 6.1 */,
1750 KNOWN_FOLDER(FOLDERID_System
,
1754 GUID_NULL
, GUID_NULL
,
1759 KNOWN_FOLDER(FOLDERID_SystemX86
,
1763 GUID_NULL
, GUID_NULL
,
1768 KNOWN_FOLDER(FOLDERID_Templates
,
1771 KF_CATEGORY_PERUSER
,
1772 FOLDERID_RoamingAppData
, GUID_NULL
,
1773 "Microsoft\\Windows\\Templates\0",
1777 KNOWN_FOLDER(FOLDERID_UserPinned
,
1780 KF_CATEGORY_PERUSER
,
1781 FOLDERID_QuickLaunch
, GUID_NULL
,
1784 FILE_ATTRIBUTE_HIDDEN
,
1786 KNOWN_FOLDER(FOLDERID_UserProfiles
,
1790 GUID_NULL
, GUID_NULL
,
1793 FILE_ATTRIBUTE_READONLY
,
1795 KNOWN_FOLDER(FOLDERID_UserProgramFiles
,
1798 KF_CATEGORY_PERUSER
,
1799 FOLDERID_LocalAppData
, GUID_NULL
,
1804 KNOWN_FOLDER(FOLDERID_UserProgramFilesCommon
,
1806 "UserProgramFilesCommon",
1807 KF_CATEGORY_PERUSER
,
1808 FOLDERID_UserProgramFiles
, GUID_NULL
,
1813 KNOWN_FOLDER(FOLDERID_UsersFiles
,
1816 KF_CATEGORY_VIRTUAL
,
1817 GUID_NULL
, GUID_NULL
,
1819 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\0\0",
1822 KNOWN_FOLDER(FOLDERID_UsersLibraries
,
1824 "UsersLibrariesFolder",
1825 KF_CATEGORY_VIRTUAL
,
1826 GUID_NULL
, GUID_NULL
,
1828 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\0\0",
1831 KNOWN_FOLDER(FOLDERID_Videos
,
1834 KF_CATEGORY_PERUSER
,
1835 FOLDERID_Profile
, GUID_NULL
,
1837 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{18989B1D-99B5-455B-841C-AB7C74E4DDFC}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A0953C92-50DC-43BF-BE83-3742FED03C9C}\0\0", /* win8 */
1838 FILE_ATTRIBUTE_READONLY
,
1839 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1840 KNOWN_FOLDER(FOLDERID_VideosLibrary
,
1843 KF_CATEGORY_PERUSER
,
1844 FOLDERID_Libraries
, GUID_NULL
,
1845 "Videos.library-ms\0",
1846 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{491E922F-5643-4af4-A7EB-4E7A138D8174}\0\0",
1848 KFDF_PRECREATE
| KFDF_STREAM
),
1849 KNOWN_FOLDER(FOLDERID_Windows
,
1853 GUID_NULL
, GUID_NULL
,
1858 KNOWN_FOLDER(_FOLDERID_CredentialManager
,
1860 "CredentialManager",
1862 GUID_NULL
, GUID_NULL
,
1867 KNOWN_FOLDER(_FOLDERID_CryptoKeys
,
1871 GUID_NULL
, GUID_NULL
,
1876 KNOWN_FOLDER(_FOLDERID_DpapiKeys
,
1880 GUID_NULL
, GUID_NULL
,
1885 KNOWN_FOLDER(_FOLDERID_SystemCertificates
,
1887 "SystemCertificates",
1889 GUID_NULL
, GUID_NULL
,
1897 BOOL known_folder_found
[ARRAY_SIZE(known_folders
)-1];
1899 static BOOL
is_in_strarray(const WCHAR
*needle
, const char *hay
)
1901 WCHAR wstr
[MAX_PATH
];
1910 if(strcmp(hay
, "(null)") == 0 && !needle
)
1913 ret
= MultiByteToWideChar(CP_ACP
, 0, hay
, -1, wstr
, ARRAY_SIZE(wstr
));
1916 ok(0, "Failed to convert string\n");
1920 if(lstrcmpW(wstr
, needle
) == 0)
1923 hay
+= strlen(hay
) + 1;
1929 static void check_known_folder(IKnownFolderManager
*mgr
, KNOWNFOLDERID
*folderId
)
1932 const struct knownFolderDef
*known_folder
= &known_folders
[0];
1933 int csidl
, expectedCsidl
, ret
;
1934 KNOWNFOLDER_DEFINITION kfd
;
1935 IKnownFolder
*folder
;
1937 BOOL
*current_known_folder_found
= &known_folder_found
[0];
1940 while(known_folder
->folderId
!= NULL
)
1942 if(IsEqualGUID(known_folder
->folderId
, folderId
))
1944 *current_known_folder_found
= TRUE
;
1947 if(!(known_folder
->csidl
& NO_CSIDL
))
1949 /* mask off winetest flags */
1950 expectedCsidl
= known_folder
->csidl
& 0xFFFF;
1952 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, folderId
, &csidl
);
1953 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot retrieve CSIDL for folder %s\n", known_folder
->sFolderId
);
1955 ok_(__FILE__
, known_folder
->line
)(csidl
== expectedCsidl
, "invalid CSIDL retrieved for folder %s. %d (%s) expected, but %d found\n", known_folder
->sFolderId
, expectedCsidl
, known_folder
->sCsidl
, csidl
);
1958 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
1959 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder for %s\n", known_folder
->sFolderId
);
1962 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
1963 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder definition for %s\n", known_folder
->sFolderId
);
1966 ret
= MultiByteToWideChar(CP_ACP
, 0, known_folder
->sName
, -1, sName
, ARRAY_SIZE(sName
));
1967 ok_(__FILE__
, known_folder
->line
)(ret
!= 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder
->sName
);
1969 ok_(__FILE__
, known_folder
->line
)(lstrcmpW(kfd
.pszName
, sName
)==0, "invalid known folder name returned for %s: %s expected, but %s retrieved\n", known_folder
->sFolderId
, wine_dbgstr_w(sName
), wine_dbgstr_w(kfd
.pszName
));
1971 ok_(__FILE__
, known_folder
->line
)(kfd
.category
== known_folder
->category
, "invalid known folder category for %s: %d expected, but %d retrieved\n", known_folder
->sFolderId
, known_folder
->category
, kfd
.category
);
1973 ok_(__FILE__
, known_folder
->line
)(IsEqualGUID(known_folder
->fidParents
[0], &kfd
.fidParent
) ||
1974 IsEqualGUID(known_folder
->fidParents
[1], &kfd
.fidParent
),
1975 "invalid known folder parent for %s: %s retrieved\n",
1976 known_folder
->sFolderId
, wine_dbgstr_guid(&kfd
.fidParent
));
1978 ok_(__FILE__
, known_folder
->line
)(is_in_strarray(kfd
.pszRelativePath
, known_folder
->sRelativePath
), "invalid known folder relative path returned for %s: %s expected, but %s retrieved\n", known_folder
->sFolderId
, known_folder
->sRelativePath
, wine_dbgstr_w(kfd
.pszRelativePath
));
1980 ok_(__FILE__
, known_folder
->line
)(is_in_strarray(kfd
.pszParsingName
, known_folder
->sParsingName
), "invalid known folder parsing name returned for %s: %s retrieved\n", known_folder
->sFolderId
, wine_dbgstr_w(kfd
.pszParsingName
));
1982 ok_(__FILE__
, known_folder
->line
)(known_folder
->attributes
== kfd
.dwAttributes
||
1983 (known_folder
->csidl
& WINE_ATTRIBUTES_OPTIONAL
&& kfd
.dwAttributes
== 0),
1984 "invalid known folder attributes for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder
->sFolderId
, known_folder
->attributes
, kfd
.dwAttributes
);
1986 ok_(__FILE__
, known_folder
->line
)(!(kfd
.kfdFlags
& (~known_folder
->definitionFlags
)), "invalid known folder flags for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder
->sFolderId
, known_folder
->definitionFlags
, kfd
.kfdFlags
);
1988 FreeKnownFolderDefinitionFields(&kfd
);
1991 IKnownFolder_Release(folder
);
1997 current_known_folder_found
++;
2002 trace("unknown known folder found: %s\n", wine_dbgstr_guid(folderId
));
2004 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
2005 ok(hr
== S_OK
, "cannot get known folder for %s\n", wine_dbgstr_guid(folderId
));
2008 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
2010 ok(hr
== S_OK
, "cannot get known folder definition for %s\n", wine_dbgstr_guid(folderId
));
2013 trace(" category: %d\n", kfd
.category
);
2014 trace(" name: %s\n", wine_dbgstr_w(kfd
.pszName
));
2015 trace(" description: %s\n", wine_dbgstr_w(kfd
.pszDescription
));
2016 trace(" parent: %s\n", wine_dbgstr_guid(&kfd
.fidParent
));
2017 trace(" relative path: %s\n", wine_dbgstr_w(kfd
.pszRelativePath
));
2018 trace(" parsing name: %s\n", wine_dbgstr_w(kfd
.pszParsingName
));
2019 trace(" tooltip: %s\n", wine_dbgstr_w(kfd
.pszTooltip
));
2020 trace(" localized name: %s\n", wine_dbgstr_w(kfd
.pszLocalizedName
));
2021 trace(" icon: %s\n", wine_dbgstr_w(kfd
.pszIcon
));
2022 trace(" security: %s\n", wine_dbgstr_w(kfd
.pszSecurity
));
2023 trace(" attributes: 0x%08x\n", kfd
.dwAttributes
);
2024 trace(" flags: 0x%08x\n", kfd
.kfdFlags
);
2025 trace(" type: %s\n", wine_dbgstr_guid(&kfd
.ftidType
));
2026 FreeKnownFolderDefinitionFields(&kfd
);
2029 IKnownFolder_Release(folder
);
2035 static void test_knownFolders(void)
2037 static const WCHAR sWindows
[] = {'W','i','n','d','o','w','s',0};
2038 static const WCHAR sWindows2
[] = {'w','i','n','d','o','w','s',0};
2039 static const WCHAR sExample
[] = {'E','x','a','m','p','l','e',0};
2040 static const WCHAR sExample2
[] = {'E','x','a','m','p','l','e','2',0};
2041 static const WCHAR sSubFolder
[] = {'S','u','b','F','o','l','d','e','r',0};
2042 static const WCHAR sNoSuch
[] = {'N','o','S','u','c','h',0};
2043 static const WCHAR sBackslash
[] = {'\\',0};
2044 static const KNOWNFOLDERID newFolderId
= {0x01234567, 0x89AB, 0xCDEF, {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x01} };
2045 static const KNOWNFOLDERID subFolderId
= {0xFEDCBA98, 0x7654, 0x3210, {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF} };
2047 IKnownFolderManager
*mgr
= NULL
;
2048 IKnownFolder
*folder
= NULL
, *subFolder
= NULL
;
2049 KNOWNFOLDERID folderId
, *folders
;
2050 KF_CATEGORY cat
= 0;
2051 KNOWNFOLDER_DEFINITION kfDefinition
, kfSubDefinition
;
2054 LPWSTR folderPath
, errorMsg
;
2055 KF_REDIRECTION_CAPABILITIES redirectionCapabilities
= 1;
2056 WCHAR sWinDir
[MAX_PATH
], sExamplePath
[MAX_PATH
], sExample2Path
[MAX_PATH
], sSubFolderPath
[MAX_PATH
], sSubFolder2Path
[MAX_PATH
];
2060 GetWindowsDirectoryW( sWinDir
, MAX_PATH
);
2062 GetTempPathW(ARRAY_SIZE(sExamplePath
), sExamplePath
);
2063 lstrcatW(sExamplePath
, sExample
);
2065 GetTempPathW(ARRAY_SIZE(sExample2Path
), sExample2Path
);
2066 lstrcatW(sExample2Path
, sExample2
);
2068 lstrcpyW(sSubFolderPath
, sExamplePath
);
2069 lstrcatW(sSubFolderPath
, sBackslash
);
2070 lstrcatW(sSubFolderPath
, sSubFolder
);
2072 lstrcpyW(sSubFolder2Path
, sExample2Path
);
2073 lstrcatW(sSubFolder2Path
, sBackslash
);
2074 lstrcatW(sSubFolder2Path
, sSubFolder
);
2078 hr
= CoCreateInstance(&CLSID_KnownFolderManager
, NULL
, CLSCTX_INPROC_SERVER
,
2079 &IID_IKnownFolderManager
, (LPVOID
*)&mgr
);
2080 if(hr
== REGDB_E_CLASSNOTREG
)
2081 win_skip("IKnownFolderManager unavailable\n");
2086 ok(hr
== S_OK
, "failed to create KnownFolderManager instance: 0x%08x\n", hr
);
2088 hr
= IKnownFolderManager_QueryInterface(mgr
, &IID_IMarshal
, (void**)&unk
);
2089 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2091 hr
= IKnownFolderManager_FolderIdFromCsidl(mgr
, CSIDL_WINDOWS
, &folderId
);
2092 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2093 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2095 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, &FOLDERID_Windows
, &csidl
);
2096 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2097 ok(csidl
== CSIDL_WINDOWS
, "invalid CSIDL returned\n");
2099 hr
= IKnownFolderManager_GetFolder(mgr
, &FOLDERID_Windows
, &folder
);
2100 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2103 hr
= IKnownFolder_QueryInterface(folder
, &IID_IMarshal
, (void**)&unk
);
2104 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2106 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2107 ok(hr
== S_OK
, "failed to get folder category: 0x%08x\n", hr
);
2108 ok(cat
==KF_CATEGORY_FIXED
, "invalid folder category: %d\n", cat
);
2110 hr
= IKnownFolder_GetId(folder
, &folderId
);
2111 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2112 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2114 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2115 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2116 ok(lstrcmpiW(sWinDir
, folderPath
)==0, "invalid path returned: \"%s\", expected: \"%s\"\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sWinDir
));
2117 CoTaskMemFree(folderPath
);
2119 hr
= IKnownFolder_GetRedirectionCapabilities(folder
, &redirectionCapabilities
);
2120 ok(hr
== S_OK
, "failed to get redirection capabilities: 0x%08x\n", hr
);
2122 ok(redirectionCapabilities
==0, "invalid redirection capabilities returned: %d\n", redirectionCapabilities
);
2124 hr
= IKnownFolder_SetPath(folder
, 0, sWinDir
);
2126 ok(hr
== E_INVALIDARG
, "unexpected value from SetPath: 0x%08x\n", hr
);
2128 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfDefinition
);
2129 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2132 ok(kfDefinition
.category
==KF_CATEGORY_FIXED
, "invalid folder category: 0x%08x\n", kfDefinition
.category
);
2133 ok(lstrcmpW(kfDefinition
.pszName
, sWindows
)==0, "invalid folder name: %s\n", wine_dbgstr_w(kfDefinition
.pszName
));
2134 ok(kfDefinition
.dwAttributes
==0, "invalid folder attributes: %d\n", kfDefinition
.dwAttributes
);
2135 FreeKnownFolderDefinitionFields(&kfDefinition
);
2138 hr
= IKnownFolder_Release(folder
);
2139 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2142 hr
= IKnownFolderManager_GetFolderByName(mgr
, sWindows
, &folder
);
2143 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2146 hr
= IKnownFolder_GetId(folder
, &folderId
);
2147 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2148 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2150 hr
= IKnownFolder_Release(folder
);
2151 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2154 hr
= IKnownFolderManager_GetFolderByName(mgr
, sWindows2
, &folder
);
2155 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2158 hr
= IKnownFolder_GetId(folder
, &folderId
);
2159 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2160 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2162 hr
= IKnownFolder_Release(folder
);
2163 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2166 folder
= (IKnownFolder
*)0xdeadbeef;
2167 hr
= IKnownFolderManager_GetFolderByName(mgr
, sNoSuch
, &folder
);
2168 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
2169 ok(folder
== NULL
, "got %p\n", folder
);
2171 for(i
=0; i
< ARRAY_SIZE(known_folder_found
); ++i
)
2172 known_folder_found
[i
] = FALSE
;
2174 hr
= IKnownFolderManager_GetFolderIds(mgr
, &folders
, &nCount
);
2175 ok(hr
== S_OK
, "failed to get known folders: 0x%08x\n", hr
);
2176 for(i
=0;i
<nCount
;++i
)
2177 check_known_folder(mgr
, &folders
[i
]);
2179 for(i
=0; i
< ARRAY_SIZE(known_folder_found
); ++i
)
2180 if(!known_folder_found
[i
])
2181 trace("Known folder %s not found on current platform\n", known_folders
[i
].sFolderId
);
2183 CoTaskMemFree(folders
);
2185 /* test of registering new known folders */
2186 bRes
= CreateDirectoryW(sExamplePath
, NULL
);
2187 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExamplePath
));
2188 bRes
= CreateDirectoryW(sExample2Path
, NULL
);
2189 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExample2Path
));
2190 bRes
= CreateDirectoryW(sSubFolderPath
, NULL
);
2191 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolderPath
));
2193 ZeroMemory(&kfDefinition
, sizeof(kfDefinition
));
2194 kfDefinition
.category
= KF_CATEGORY_PERUSER
;
2195 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample
));
2196 lstrcpyW(kfDefinition
.pszName
, sExample
);
2197 kfDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sExample
));
2198 lstrcpyW(kfDefinition
.pszDescription
, sExample
);
2199 kfDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sExamplePath
));
2200 lstrcpyW(kfDefinition
.pszRelativePath
, sExamplePath
);
2202 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2203 if(hr
== HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED
))
2204 win_skip("No permissions required to register custom known folder\n");
2207 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2210 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2211 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2214 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2215 ok(hr
== S_OK
, "failed to get folder category: hr=0x%0x\n", hr
);
2216 ok(cat
== KF_CATEGORY_PERUSER
, "invalid category returned: %d, while %d (KF_CATEGORY_PERUSER) expected\n", cat
, KF_CATEGORY_PERUSER
);
2218 hr
= IKnownFolder_GetId(folder
, &folderId
);
2219 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2220 ok(IsEqualGUID(&folderId
, &newFolderId
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2222 /* current path should be Temp\Example */
2223 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2224 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2225 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2226 CoTaskMemFree(folderPath
);
2228 /* register sub-folder and mark it as child of Example folder */
2229 ZeroMemory(&kfSubDefinition
, sizeof(kfSubDefinition
));
2230 kfSubDefinition
.category
= KF_CATEGORY_PERUSER
;
2231 kfSubDefinition
.pszName
= CoTaskMemAlloc(sizeof(sSubFolder
));
2232 lstrcpyW(kfSubDefinition
.pszName
, sSubFolder
);
2233 kfSubDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sSubFolder
));
2234 lstrcpyW(kfSubDefinition
.pszDescription
, sSubFolder
);
2235 kfSubDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sSubFolder
));
2236 lstrcpyW(kfSubDefinition
.pszRelativePath
, sSubFolder
);
2237 kfSubDefinition
.fidParent
= newFolderId
;
2239 hr
= IKnownFolderManager_RegisterFolder(mgr
, &subFolderId
, &kfSubDefinition
);
2240 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2244 hr
= IKnownFolderManager_GetFolder(mgr
, &subFolderId
, &subFolder
);
2245 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2248 /* check sub folder path */
2249 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2250 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2251 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2252 CoTaskMemFree(folderPath
);
2255 /* try to redirect Example to Temp\Example2 */
2256 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2257 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2260 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2261 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2262 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2263 CoTaskMemFree(folderPath
);
2265 /* verify sub folder - it should fail now, as we redirected its parent folder, but we have no sub folder in new location */
2266 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2267 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "unexpected value from GetPath(): 0x%08x\n", hr
);
2268 ok(folderPath
==NULL
, "invalid known folder path retrieved: \"%s\" when NULL pointer was expected\n", wine_dbgstr_w(folderPath
));
2269 CoTaskMemFree(folderPath
);
2272 /* set Example path to original. Using SetPath() is valid here, as it also uses redirection internally */
2273 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2274 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2277 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2278 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2279 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2280 CoTaskMemFree(folderPath
);
2283 /* create sub folder in Temp\Example2 */
2284 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2285 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2287 /* again perform that same redirection */
2288 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2289 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2291 /* verify sub folder. It should succeed now, as the required sub folder exists */
2292 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2293 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2294 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2295 CoTaskMemFree(folderPath
);
2297 /* remove newly created directory */
2298 RemoveDirectoryW(sSubFolder2Path
);
2300 /* verify subfolder. It still succeeds, so Windows does not check folder presence each time */
2301 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2303 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2305 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2306 CoTaskMemFree(folderPath
);
2309 /* set Example path to original */
2310 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2311 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2314 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2315 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2316 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2317 CoTaskMemFree(folderPath
);
2319 /* verify sub folder */
2320 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2321 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2322 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2323 CoTaskMemFree(folderPath
);
2326 /* create sub folder in Temp\Example2 */
2327 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2328 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2330 /* do that same redirection, but try to exclude sub-folder */
2331 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 1, &subFolderId
, &errorMsg
);
2332 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2335 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2336 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2337 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2338 CoTaskMemFree(folderPath
);
2340 /* verify sub folder. Unexpectedly, this path was also changed. So, exclusion seems to be ignored (Windows bug)? This test however will let us know, if this behavior is changed */
2341 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2342 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2343 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2344 CoTaskMemFree(folderPath
);
2346 /* remove newly created directory */
2347 RemoveDirectoryW(sSubFolder2Path
);
2350 /* set Example path to original */
2351 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2352 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2355 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2356 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2357 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2358 CoTaskMemFree(folderPath
);
2360 /* verify sub folder */
2361 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2362 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2363 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2364 CoTaskMemFree(folderPath
);
2367 /* do that same redirection again, but set it to copy content. It should also copy the sub folder, so checking it would succeed now */
2368 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2369 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2372 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2373 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2374 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2375 CoTaskMemFree(folderPath
);
2377 /* verify sub folder */
2378 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2379 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2380 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2381 CoTaskMemFree(folderPath
);
2383 /* remove copied directory */
2384 RemoveDirectoryW(sSubFolder2Path
);
2387 /* set Example path to original */
2388 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2389 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2392 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2393 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2394 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2395 CoTaskMemFree(folderPath
);
2397 /* verify sub folder */
2398 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2399 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2400 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2401 CoTaskMemFree(folderPath
);
2404 /* redirect again, set it to copy content and remove originals */
2405 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
| KF_REDIRECT_DEL_SOURCE_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2406 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2409 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2410 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2411 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2412 CoTaskMemFree(folderPath
);
2414 /* verify sub folder */
2415 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2416 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2417 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2418 CoTaskMemFree(folderPath
);
2420 /* check if original directory was really removed */
2421 dwAttributes
= GetFileAttributesW(sExamplePath
);
2422 ok(dwAttributes
==INVALID_FILE_ATTRIBUTES
, "directory should not exist, but has attributes: 0x%08x\n", dwAttributes
);
2425 /* redirect (with copy) to original path */
2426 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExamplePath
, 0, NULL
, &errorMsg
);
2427 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2430 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2431 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2432 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2433 CoTaskMemFree(folderPath
);
2435 /* verify sub folder */
2436 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2437 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2438 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2439 CoTaskMemFree(folderPath
);
2441 /* check shell utility functions */
2442 if(!pSHGetKnownFolderPath
|| !pSHSetKnownFolderPath
)
2444 win_skip("cannot get SHGet/SetKnownFolderPath routines\n");
2447 /* try to get current known folder path */
2448 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2450 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2452 ok(lstrcmpW(folderPath
, sExamplePath
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2454 /* set it to new value */
2455 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExample2Path
);
2457 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2459 /* check if it changed */
2460 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2462 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2464 ok(lstrcmpW(folderPath
, sExample2Path
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2467 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExamplePath
);
2469 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2472 IKnownFolder_Release(subFolder
);
2475 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &subFolderId
);
2476 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2479 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2481 hr
= IKnownFolder_Release(folder
);
2482 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2484 /* update the folder */
2485 CoTaskMemFree(kfDefinition
.pszName
);
2486 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample2
));
2487 lstrcpyW(kfDefinition
.pszName
, sExample2
);
2488 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2489 ok(hr
== S_OK
, "failed to re-register known folder: 0x%08x\n", hr
);
2491 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2492 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2494 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfSubDefinition
);
2495 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2496 ok(!memcmp(kfDefinition
.pszName
, kfSubDefinition
.pszName
, sizeof(sExample2
)),
2497 "Got wrong updated name: %s\n", wine_dbgstr_w(kfSubDefinition
.pszName
));
2499 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2501 hr
= IKnownFolder_Release(folder
);
2502 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2505 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &newFolderId
);
2506 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2509 FreeKnownFolderDefinitionFields(&kfDefinition
);
2511 RemoveDirectoryW(sSubFolder2Path
);
2512 RemoveDirectoryW(sSubFolderPath
);
2513 RemoveDirectoryW(sExamplePath
);
2514 RemoveDirectoryW(sExample2Path
);
2516 hr
= IKnownFolderManager_Release(mgr
);
2517 ok(hr
== S_OK
, "failed to release KnownFolderManager instance: 0x%08x\n", hr
);
2523 static void test_DoEnvironmentSubst(void)
2525 WCHAR expectedW
[MAX_PATH
];
2526 WCHAR bufferW
[MAX_PATH
];
2527 CHAR expectedA
[MAX_PATH
];
2528 CHAR bufferA
[MAX_PATH
];
2533 static const WCHAR does_not_existW
[] = {'%','D','O','E','S','_','N','O','T','_','E','X','I','S','T','%',0};
2534 static const CHAR does_not_existA
[] = "%DOES_NOT_EXIST%";
2535 static const CHAR
*names
[] = {
2536 /* interactive apps and services (works on all windows versions) */
2537 "%ALLUSERSPROFILE%", "%APPDATA%", "%LOCALAPPDATA%",
2538 "%NUMBER_OF_PROCESSORS%", "%OS%", "%PROCESSOR_ARCHITECTURE%",
2539 "%PROCESSOR_IDENTIFIER%", "%PROCESSOR_LEVEL%", "%PROCESSOR_REVISION%",
2540 "%ProgramFiles%", "%SystemDrive%",
2541 "%SystemRoot%", "%USERPROFILE%", "%windir%",
2542 /* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
2544 /* replace more than one var is allowed */
2545 "%HOMEDRIVE%%HOMEPATH%",
2546 "%OS% %windir%"}; /* always the last entry in the table */
2548 for (i
= 0; i
< (ARRAY_SIZE(names
)); i
++)
2550 memset(bufferA
, '#', MAX_PATH
- 1);
2551 bufferA
[MAX_PATH
- 1] = 0;
2552 lstrcpyA(bufferA
, names
[i
]);
2553 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2555 res2
= ExpandEnvironmentStringsA(names
[i
], expectedA
, MAX_PATH
);
2556 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2558 /* is the space for the terminating 0 included? */
2559 if (!i
&& HIWORD(res
) && (LOWORD(res
) == (lstrlenA(bufferA
))))
2561 win_skip("DoEnvironmentSubstA/W are broken on NT 4\n");
2564 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2565 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2566 ok(!lstrcmpA(bufferA
, expectedA
),
2567 "%d: got %s (expected %s)\n", i
, bufferA
, expectedA
);
2569 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2570 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2571 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2572 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2573 ok(!lstrcmpW(bufferW
, expectedW
),
2574 "%d: got %s (expected %s)\n", i
, wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2577 i
--; /* reuse data in the last table entry */
2578 len
= LOWORD(res
); /* needed length */
2580 /* one character extra is fine */
2581 memset(bufferA
, '#', MAX_PATH
- 1);
2582 bufferA
[len
+ 2] = 0;
2583 lstrcpyA(bufferA
, names
[i
]);
2584 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2586 res2
= ExpandEnvironmentStringsA(bufferA
, expectedA
, MAX_PATH
);
2587 res
= DoEnvironmentSubstA(bufferA
, len
+ 1);
2588 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2589 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2590 ok(!lstrcmpA(bufferA
, expectedA
),
2591 "+1: got %s (expected %s)\n", bufferA
, expectedA
);
2593 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2594 res
= DoEnvironmentSubstW(bufferW
, len
+ 1);
2595 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2596 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2597 ok(!lstrcmpW(bufferW
, expectedW
),
2598 "+1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2601 /* minimal buffer length (result string and terminating 0) */
2602 memset(bufferA
, '#', MAX_PATH
- 1);
2603 bufferA
[len
+ 2] = 0;
2604 lstrcpyA(bufferA
, names
[i
]);
2605 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2607 /* ANSI version failed without an extra byte, as documented on msdn */
2608 res
= DoEnvironmentSubstA(bufferA
, len
);
2609 ok(!HIWORD(res
) && (LOWORD(res
) == len
),
2610 " 0: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
);
2611 ok(!lstrcmpA(bufferA
, names
[i
]),
2612 " 0: got %s (expected %s)\n", bufferA
, names
[i
]);
2614 /* DoEnvironmentSubstW works as expected */
2615 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2616 res
= DoEnvironmentSubstW(bufferW
, len
);
2617 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2618 " 0: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2619 ok(!lstrcmpW(bufferW
, expectedW
),
2620 " 0: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2623 /* Buffer too small */
2624 /* result: FALSE / provided buffer length / the buffer is untouched */
2625 memset(bufferA
, '#', MAX_PATH
- 1);
2626 bufferA
[len
+ 2] = 0;
2627 lstrcpyA(bufferA
, names
[i
]);
2628 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2630 res
= DoEnvironmentSubstA(bufferA
, len
- 1);
2631 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2632 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2633 ok(!lstrcmpA(bufferA
, names
[i
]),
2634 "-1: got %s (expected %s)\n", bufferA
, names
[i
]);
2636 lstrcpyW(expectedW
, bufferW
);
2637 res
= DoEnvironmentSubstW(bufferW
, len
- 1);
2638 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2639 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2640 ok(!lstrcmpW(bufferW
, expectedW
),
2641 "-1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2644 /* unknown variable */
2645 /* result: TRUE / string length including terminating 0 / the buffer is untouched */
2646 memset(bufferA
, '#', MAX_PATH
- 1);
2647 bufferA
[MAX_PATH
- 1] = 0;
2648 lstrcpyA(bufferA
, does_not_existA
);
2649 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2651 res2
= lstrlenA(does_not_existA
) + 1;
2652 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2653 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2654 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2655 ok(!lstrcmpA(bufferA
, does_not_existA
),
2656 "%d: got %s (expected %s)\n", i
, bufferA
, does_not_existA
);
2658 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2659 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2660 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2661 ok(!lstrcmpW(bufferW
, does_not_existW
),
2662 "%d: got %s (expected %s)\n", i
, wine_dbgstr_w(bufferW
), wine_dbgstr_w(does_not_existW
));
2667 /* NULL crashes on windows */
2668 res
= DoEnvironmentSubstA(NULL
, MAX_PATH
);
2669 res
= DoEnvironmentSubstW(NULL
, MAX_PATH
);
2673 static void test_PathYetAnotherMakeUniqueName(void)
2675 static const WCHAR shortW
[] = {'f','i','l','e','.','t','s','t',0};
2676 static const WCHAR short2W
[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
2677 static const WCHAR tmpW
[] = {'t','m','p',0};
2678 static const WCHAR longW
[] = {'n','a','m','e',0};
2679 static const WCHAR long2W
[] = {'n','a','m','e',' ','(','2',')',0};
2680 WCHAR nameW
[MAX_PATH
], buffW
[MAX_PATH
], pathW
[MAX_PATH
];
2684 if (!pPathYetAnotherMakeUniqueName
)
2686 win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
2692 /* crashes on Windows */
2693 ret
= pPathYetAnotherMakeUniqueName(NULL
, NULL
, NULL
, NULL
);
2694 ok(!ret
, "got %d\n", ret
);
2696 ret
= pPathYetAnotherMakeUniqueName(nameW
, NULL
, NULL
, NULL
);
2697 ok(!ret
, "got %d\n", ret
);
2700 GetTempPathW(ARRAY_SIZE(pathW
), pathW
);
2702 /* Using short name only first */
2704 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2705 ok(ret
, "got %d\n", ret
);
2706 lstrcpyW(buffW
, pathW
);
2707 lstrcatW(buffW
, shortW
);
2708 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2710 /* now create a file with this name and get next name */
2711 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2712 ok(file
!= NULL
, "got %p\n", file
);
2715 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2716 ok(ret
, "got %d\n", ret
);
2717 lstrcpyW(buffW
, pathW
);
2718 lstrcatW(buffW
, short2W
);
2719 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2723 /* Using short and long */
2725 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2726 ok(ret
, "got %d\n", ret
);
2727 lstrcpyW(buffW
, pathW
);
2728 lstrcatW(buffW
, longW
);
2729 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2731 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2732 ok(file
!= NULL
, "got %p\n", file
);
2735 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2736 ok(ret
, "got %d\n", ret
);
2737 lstrcpyW(buffW
, pathW
);
2738 lstrcatW(buffW
, long2W
);
2739 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2743 /* Using long only */
2745 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, NULL
, longW
);
2746 ok(ret
, "got %d\n", ret
);
2747 lstrcpyW(buffW
, pathW
);
2748 lstrcatW(buffW
, longW
);
2749 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2752 static void test_SHGetKnownFolderIDList(void)
2754 PIDLIST_ABSOLUTE pidl
;
2757 if (!pSHGetKnownFolderIDList
)
2759 win_skip("SHGetKnownFolderIDList is not available.\n");
2763 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, NULL
);
2764 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2766 if (0) { /* crashes on native */
2767 pidl
= (void*)0xdeadbeef;
2768 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, &pidl
);
2770 /* not a known folder */
2771 pidl
= (void*)0xdeadbeef;
2772 hr
= pSHGetKnownFolderIDList(&IID_IUnknown
, 0, NULL
, &pidl
);
2773 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
2774 ok(pidl
== NULL
, "got %p\n", pidl
);
2776 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, NULL
);
2777 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2779 pidl
= (void*)0xdeadbeef;
2780 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, &pidl
);
2781 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2782 ok(ILIsEmpty(pidl
), "pidl should be empty.\n");
2783 ok(pidl
->mkid
.cb
== 0, "get wrong value: %d\n", pidl
->mkid
.cb
);
2786 pidl
= (void*)0xdeadbeef;
2787 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, KF_FLAG_NO_ALIAS
, NULL
, &pidl
);
2788 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2789 todo_wine
ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2790 todo_wine
ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2793 pidl
= (void*)0xdeadbeef;
2794 hr
= pSHGetKnownFolderIDList(&FOLDERID_Documents
, 0, NULL
, &pidl
);
2795 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2796 ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2797 ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2800 pidl
= (void*)0xdeadbeef;
2801 hr
= pSHGetKnownFolderIDList(&FOLDERID_Documents
, KF_FLAG_NO_ALIAS
, NULL
, &pidl
);
2802 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2803 ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2804 ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2808 START_TEST(shellpath
)
2810 if (!init()) return;
2813 pGetSystemWow64DirectoryA
= (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
2814 "GetSystemWow64DirectoryA" );
2819 /* Report missing functions once */
2820 if (!pSHGetFolderLocation
)
2821 win_skip("SHGetFolderLocation is not available\n");
2823 /* first test various combinations of parameters: */
2826 /* check known values: */
2832 test_NonExistentPath();
2833 test_SHGetFolderPathEx();
2834 test_knownFolders();
2835 test_DoEnvironmentSubst();
2836 test_PathYetAnotherMakeUniqueName();
2837 test_SHGetKnownFolderIDList();