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);
47 #define ARRAY_SIZE(x) ( sizeof(x) / sizeof((x)[0]) )
50 /* from pidl.h, not included here: */
51 #ifndef PT_CPL /* Guess, Win7 uses this for CSIDL_CONTROLS */
52 #define PT_CPL 0x01 /* no path */
55 #define PT_GUID 0x1f /* no path */
58 #define PT_DRIVE 0x23 /* has path */
61 #define PT_DRIVE2 0x25 /* has path */
64 #define PT_SHELLEXT 0x2e /* no path */
67 #define PT_FOLDER 0x31 /* has path */
70 #define PT_FOLDERW 0x35 /* has path */
73 #define PT_WORKGRP 0x41 /* no path */
76 #define PT_YAGUID 0x70 /* no path */
78 /* FIXME: this is used for history/favorites folders; what's a better name? */
80 #define PT_IESPECIAL2 0xb1 /* has path */
83 static GUID CLSID_CommonDocuments
= { 0x0000000c, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x1a } };
85 struct shellExpectedValues
{
91 static HRESULT (WINAPI
*pDllGetVersion
)(DLLVERSIONINFO
*);
92 static HRESULT (WINAPI
*pSHGetFolderPathA
)(HWND
, int, HANDLE
, DWORD
, LPSTR
);
93 static HRESULT (WINAPI
*pSHGetFolderLocation
)(HWND
, int, HANDLE
, DWORD
,
95 static BOOL (WINAPI
*pSHGetSpecialFolderPathA
)(HWND
, LPSTR
, int, BOOL
);
96 static HRESULT (WINAPI
*pSHGetSpecialFolderLocation
)(HWND
, int, LPITEMIDLIST
*);
97 static LPITEMIDLIST (WINAPI
*pILFindLastID
)(LPCITEMIDLIST
);
98 static int (WINAPI
*pSHFileOperationA
)(LPSHFILEOPSTRUCTA
);
99 static HRESULT (WINAPI
*pSHGetMalloc
)(LPMALLOC
*);
100 static UINT (WINAPI
*pGetSystemWow64DirectoryA
)(LPSTR
,UINT
);
101 static HRESULT (WINAPI
*pSHGetKnownFolderPath
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PWSTR
*);
102 static HRESULT (WINAPI
*pSHSetKnownFolderPath
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PWSTR
);
103 static HRESULT (WINAPI
*pSHGetFolderPathEx
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, LPWSTR
, DWORD
);
104 static BOOL (WINAPI
*pPathYetAnotherMakeUniqueName
)(PWSTR
, PCWSTR
, PCWSTR
, PCWSTR
);
105 static HRESULT (WINAPI
*pSHGetKnownFolderIDList
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PIDLIST_ABSOLUTE
*);
107 static DLLVERSIONINFO shellVersion
= { 0 };
108 static LPMALLOC pMalloc
;
109 static const BYTE guidType
[] = { PT_GUID
};
110 static const BYTE controlPanelType
[] = { PT_SHELLEXT
, PT_GUID
, PT_CPL
};
111 static const BYTE folderType
[] = { PT_FOLDER
, PT_FOLDERW
};
112 static const BYTE favoritesType
[] = { PT_FOLDER
, PT_FOLDERW
, 0, PT_IESPECIAL2
/* Win98 */ };
113 static const BYTE folderOrSpecialType
[] = { PT_FOLDER
, PT_IESPECIAL2
};
114 static const BYTE personalType
[] = { PT_FOLDER
, PT_GUID
, PT_DRIVE
, 0xff /* Win9x */,
115 PT_IESPECIAL2
/* Win98 */, 0 /* Vista */, PT_SHELLEXT
/* win8 */ };
116 /* FIXME: don't know the type of 0x71 returned by Vista/2008 for printers */
117 static const BYTE printersType
[] = { PT_YAGUID
, PT_SHELLEXT
, 0x71 };
118 static const BYTE ieSpecialType
[] = { PT_IESPECIAL2
};
119 static const BYTE shellExtType
[] = { PT_SHELLEXT
};
120 static const BYTE workgroupType
[] = { PT_WORKGRP
};
121 #define DECLARE_TYPE(x, y) { x, sizeof(y) / sizeof(y[0]), y }
122 static const struct shellExpectedValues requiredShellValues
[] = {
123 DECLARE_TYPE(CSIDL_BITBUCKET
, guidType
),
124 DECLARE_TYPE(CSIDL_CONTROLS
, controlPanelType
),
125 DECLARE_TYPE(CSIDL_COOKIES
, folderType
),
126 DECLARE_TYPE(CSIDL_DESKTOPDIRECTORY
, folderType
),
127 DECLARE_TYPE(CSIDL_DRIVES
, guidType
),
128 DECLARE_TYPE(CSIDL_FAVORITES
, favoritesType
),
129 DECLARE_TYPE(CSIDL_FONTS
, folderOrSpecialType
),
130 /* FIXME: the following fails in Wine, returns type PT_FOLDER
131 DECLARE_TYPE(CSIDL_HISTORY, ieSpecialType),
133 DECLARE_TYPE(CSIDL_INTERNET
, guidType
),
134 DECLARE_TYPE(CSIDL_NETHOOD
, folderType
),
135 DECLARE_TYPE(CSIDL_NETWORK
, guidType
),
136 DECLARE_TYPE(CSIDL_PERSONAL
, personalType
),
137 DECLARE_TYPE(CSIDL_PRINTERS
, printersType
),
138 DECLARE_TYPE(CSIDL_PRINTHOOD
, folderType
),
139 DECLARE_TYPE(CSIDL_PROGRAMS
, folderType
),
140 DECLARE_TYPE(CSIDL_RECENT
, folderOrSpecialType
),
141 DECLARE_TYPE(CSIDL_SENDTO
, folderType
),
142 DECLARE_TYPE(CSIDL_STARTMENU
, folderType
),
143 DECLARE_TYPE(CSIDL_STARTUP
, folderType
),
144 DECLARE_TYPE(CSIDL_TEMPLATES
, folderType
),
146 static const struct shellExpectedValues optionalShellValues
[] = {
147 /* FIXME: the following only semi-succeed; they return NULL PIDLs on XP.. hmm.
148 DECLARE_TYPE(CSIDL_ALTSTARTUP, folderType),
149 DECLARE_TYPE(CSIDL_COMMON_ALTSTARTUP, folderType),
150 DECLARE_TYPE(CSIDL_COMMON_OEM_LINKS, folderType),
152 /* Windows NT-only: */
153 DECLARE_TYPE(CSIDL_COMMON_DESKTOPDIRECTORY
, folderType
),
154 DECLARE_TYPE(CSIDL_COMMON_DOCUMENTS
, shellExtType
),
155 DECLARE_TYPE(CSIDL_COMMON_FAVORITES
, folderType
),
156 DECLARE_TYPE(CSIDL_COMMON_PROGRAMS
, folderType
),
157 DECLARE_TYPE(CSIDL_COMMON_STARTMENU
, folderType
),
158 DECLARE_TYPE(CSIDL_COMMON_STARTUP
, folderType
),
159 DECLARE_TYPE(CSIDL_COMMON_TEMPLATES
, folderType
),
160 /* first appearing in shell32 version 4.71: */
161 DECLARE_TYPE(CSIDL_APPDATA
, folderType
),
162 /* first appearing in shell32 version 4.72: */
163 DECLARE_TYPE(CSIDL_INTERNET_CACHE
, ieSpecialType
),
164 /* first appearing in shell32 version 5.0: */
165 DECLARE_TYPE(CSIDL_ADMINTOOLS
, folderType
),
166 DECLARE_TYPE(CSIDL_COMMON_APPDATA
, folderType
),
167 DECLARE_TYPE(CSIDL_LOCAL_APPDATA
, folderType
),
168 DECLARE_TYPE(OLD_CSIDL_MYDOCUMENTS
, folderType
),
169 DECLARE_TYPE(CSIDL_MYMUSIC
, folderType
),
170 DECLARE_TYPE(CSIDL_MYPICTURES
, folderType
),
171 DECLARE_TYPE(CSIDL_MYVIDEO
, folderType
),
172 DECLARE_TYPE(CSIDL_PROFILE
, folderType
),
173 DECLARE_TYPE(CSIDL_PROGRAM_FILES
, folderType
),
174 DECLARE_TYPE(CSIDL_PROGRAM_FILESX86
, folderType
),
175 DECLARE_TYPE(CSIDL_PROGRAM_FILES_COMMON
, folderType
),
176 DECLARE_TYPE(CSIDL_PROGRAM_FILES_COMMONX86
, folderType
),
177 DECLARE_TYPE(CSIDL_SYSTEM
, folderType
),
178 DECLARE_TYPE(CSIDL_WINDOWS
, folderType
),
179 /* first appearing in shell32 6.0: */
180 DECLARE_TYPE(CSIDL_CDBURN_AREA
, folderType
),
181 DECLARE_TYPE(CSIDL_COMMON_MUSIC
, folderType
),
182 DECLARE_TYPE(CSIDL_COMMON_PICTURES
, folderType
),
183 DECLARE_TYPE(CSIDL_COMMON_VIDEO
, folderType
),
184 DECLARE_TYPE(CSIDL_COMPUTERSNEARME
, workgroupType
),
185 DECLARE_TYPE(CSIDL_RESOURCES
, folderType
),
186 DECLARE_TYPE(CSIDL_RESOURCES_LOCALIZED
, folderType
),
190 static void loadShell32(void)
192 HMODULE hShell32
= GetModuleHandleA("shell32");
194 #define GET_PROC(func) \
195 p ## func = (void*)GetProcAddress(hShell32, #func); \
197 trace("GetProcAddress(%s) failed\n", #func);
199 GET_PROC(DllGetVersion
)
200 GET_PROC(SHGetFolderPathA
)
201 GET_PROC(SHGetFolderPathEx
)
202 GET_PROC(SHGetFolderLocation
)
203 GET_PROC(SHGetKnownFolderPath
)
204 GET_PROC(SHSetKnownFolderPath
)
205 GET_PROC(SHGetSpecialFolderPathA
)
206 GET_PROC(SHGetSpecialFolderLocation
)
207 GET_PROC(ILFindLastID
)
209 pILFindLastID
= (void *)GetProcAddress(hShell32
, (LPCSTR
)16);
210 GET_PROC(SHFileOperationA
)
211 GET_PROC(SHGetMalloc
)
212 GET_PROC(PathYetAnotherMakeUniqueName
)
213 GET_PROC(SHGetKnownFolderIDList
)
215 ok(pSHGetMalloc
!= NULL
, "shell32 is missing SHGetMalloc\n");
218 HRESULT hr
= pSHGetMalloc(&pMalloc
);
220 ok(hr
== S_OK
, "SHGetMalloc failed: 0x%08x\n", hr
);
221 ok(pMalloc
!= NULL
, "SHGetMalloc returned a NULL IMalloc\n");
226 shellVersion
.cbSize
= sizeof(shellVersion
);
227 pDllGetVersion(&shellVersion
);
228 trace("shell32 version is %d.%d\n",
229 shellVersion
.dwMajorVersion
, shellVersion
.dwMinorVersion
);
234 #ifndef CSIDL_PROFILES
235 #define CSIDL_PROFILES 0x003e
238 /* A couple utility printing functions */
239 static const char *getFolderName(int folder
)
241 static char unknown
[32];
243 #define CSIDL_TO_STR(x) case x: return#x;
246 CSIDL_TO_STR(CSIDL_DESKTOP
);
247 CSIDL_TO_STR(CSIDL_INTERNET
);
248 CSIDL_TO_STR(CSIDL_PROGRAMS
);
249 CSIDL_TO_STR(CSIDL_CONTROLS
);
250 CSIDL_TO_STR(CSIDL_PRINTERS
);
251 CSIDL_TO_STR(CSIDL_PERSONAL
);
252 CSIDL_TO_STR(CSIDL_FAVORITES
);
253 CSIDL_TO_STR(CSIDL_STARTUP
);
254 CSIDL_TO_STR(CSIDL_RECENT
);
255 CSIDL_TO_STR(CSIDL_SENDTO
);
256 CSIDL_TO_STR(CSIDL_BITBUCKET
);
257 CSIDL_TO_STR(CSIDL_STARTMENU
);
258 CSIDL_TO_STR(OLD_CSIDL_MYDOCUMENTS
);
259 CSIDL_TO_STR(CSIDL_MYMUSIC
);
260 CSIDL_TO_STR(CSIDL_MYVIDEO
);
261 CSIDL_TO_STR(CSIDL_DESKTOPDIRECTORY
);
262 CSIDL_TO_STR(CSIDL_DRIVES
);
263 CSIDL_TO_STR(CSIDL_NETWORK
);
264 CSIDL_TO_STR(CSIDL_NETHOOD
);
265 CSIDL_TO_STR(CSIDL_FONTS
);
266 CSIDL_TO_STR(CSIDL_TEMPLATES
);
267 CSIDL_TO_STR(CSIDL_COMMON_STARTMENU
);
268 CSIDL_TO_STR(CSIDL_COMMON_PROGRAMS
);
269 CSIDL_TO_STR(CSIDL_COMMON_STARTUP
);
270 CSIDL_TO_STR(CSIDL_COMMON_DESKTOPDIRECTORY
);
271 CSIDL_TO_STR(CSIDL_APPDATA
);
272 CSIDL_TO_STR(CSIDL_PRINTHOOD
);
273 CSIDL_TO_STR(CSIDL_LOCAL_APPDATA
);
274 CSIDL_TO_STR(CSIDL_ALTSTARTUP
);
275 CSIDL_TO_STR(CSIDL_COMMON_ALTSTARTUP
);
276 CSIDL_TO_STR(CSIDL_COMMON_FAVORITES
);
277 CSIDL_TO_STR(CSIDL_INTERNET_CACHE
);
278 CSIDL_TO_STR(CSIDL_COOKIES
);
279 CSIDL_TO_STR(CSIDL_HISTORY
);
280 CSIDL_TO_STR(CSIDL_COMMON_APPDATA
);
281 CSIDL_TO_STR(CSIDL_WINDOWS
);
282 CSIDL_TO_STR(CSIDL_SYSTEM
);
283 CSIDL_TO_STR(CSIDL_PROGRAM_FILES
);
284 CSIDL_TO_STR(CSIDL_MYPICTURES
);
285 CSIDL_TO_STR(CSIDL_PROFILE
);
286 CSIDL_TO_STR(CSIDL_SYSTEMX86
);
287 CSIDL_TO_STR(CSIDL_PROGRAM_FILESX86
);
288 CSIDL_TO_STR(CSIDL_PROGRAM_FILES_COMMON
);
289 CSIDL_TO_STR(CSIDL_PROGRAM_FILES_COMMONX86
);
290 CSIDL_TO_STR(CSIDL_COMMON_TEMPLATES
);
291 CSIDL_TO_STR(CSIDL_COMMON_DOCUMENTS
);
292 CSIDL_TO_STR(CSIDL_COMMON_ADMINTOOLS
);
293 CSIDL_TO_STR(CSIDL_ADMINTOOLS
);
294 CSIDL_TO_STR(CSIDL_CONNECTIONS
);
295 CSIDL_TO_STR(CSIDL_PROFILES
);
296 CSIDL_TO_STR(CSIDL_COMMON_MUSIC
);
297 CSIDL_TO_STR(CSIDL_COMMON_PICTURES
);
298 CSIDL_TO_STR(CSIDL_COMMON_VIDEO
);
299 CSIDL_TO_STR(CSIDL_RESOURCES
);
300 CSIDL_TO_STR(CSIDL_RESOURCES_LOCALIZED
);
301 CSIDL_TO_STR(CSIDL_COMMON_OEM_LINKS
);
302 CSIDL_TO_STR(CSIDL_CDBURN_AREA
);
303 CSIDL_TO_STR(CSIDL_COMPUTERSNEARME
);
306 sprintf(unknown
, "unknown (0x%04x)", folder
);
311 static void test_parameters(void)
313 LPITEMIDLIST pidl
= NULL
;
317 if (pSHGetFolderLocation
)
319 /* check a bogus CSIDL: */
321 hr
= pSHGetFolderLocation(NULL
, 0xeeee, NULL
, 0, &pidl
);
322 ok(hr
== E_INVALIDARG
, "got 0x%08x, expected E_INVALIDARG\n", hr
);
323 if (hr
== S_OK
) IMalloc_Free(pMalloc
, pidl
);
325 /* check a bogus user token: */
327 hr
= pSHGetFolderLocation(NULL
, CSIDL_FAVORITES
, (HANDLE
)2, 0, &pidl
);
328 ok(hr
== E_FAIL
|| hr
== E_HANDLE
, "got 0x%08x, expected E_FAIL or E_HANDLE\n", hr
);
329 if (hr
== S_OK
) IMalloc_Free(pMalloc
, pidl
);
331 /* a NULL pidl pointer crashes, so don't test it */
334 if (pSHGetSpecialFolderLocation
)
338 SHGetSpecialFolderLocation(NULL
, 0, NULL
);
340 hr
= pSHGetSpecialFolderLocation(NULL
, 0xeeee, &pidl
);
341 ok(hr
== E_INVALIDARG
, "got returned 0x%08x\n", hr
);
344 if (pSHGetFolderPathA
)
346 /* expect 2's a bogus handle, especially since we didn't open it */
347 hr
= pSHGetFolderPathA(NULL
, CSIDL_DESKTOP
, (HANDLE
)2, SHGFP_TYPE_DEFAULT
, path
);
348 ok(hr
== E_FAIL
|| hr
== E_HANDLE
|| /* Vista and 2k8 */
349 broken(hr
== S_OK
), /* W2k and Me */ "got 0x%08x, expected E_FAIL\n", hr
);
351 hr
= pSHGetFolderPathA(NULL
, 0xeeee, NULL
, SHGFP_TYPE_DEFAULT
, path
);
352 ok(hr
== E_INVALIDARG
, "got 0x%08x, expected E_INVALIDARG\n", hr
);
355 if (pSHGetSpecialFolderPathA
)
360 pSHGetSpecialFolderPathA(NULL
, NULL
, CSIDL_BITBUCKET
, FALSE
);
362 /* odd but true: calling with a NULL path still succeeds if it's a real
363 * dir (on some windows platform). on winME it generates exception.
365 ret
= pSHGetSpecialFolderPathA(NULL
, path
, CSIDL_PROGRAMS
, FALSE
);
366 ok(ret
, "got %d\n", ret
);
368 ret
= pSHGetSpecialFolderPathA(NULL
, path
, 0xeeee, FALSE
);
369 ok(!ret
, "got %d\n", ret
);
373 /* Returns the folder's PIDL type, or 0xff if one can't be found. */
374 static BYTE
testSHGetFolderLocation(int folder
)
380 /* treat absence of function as success */
381 if (!pSHGetFolderLocation
) return TRUE
;
384 hr
= pSHGetFolderLocation(NULL
, folder
, NULL
, 0, &pidl
);
389 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
391 ok(pidlLast
!= NULL
, "%s: ILFindLastID failed\n",
392 getFolderName(folder
));
394 ret
= pidlLast
->mkid
.abID
[0];
395 IMalloc_Free(pMalloc
, pidl
);
401 /* Returns the folder's PIDL type, or 0xff if one can't be found. */
402 static BYTE
testSHGetSpecialFolderLocation(int folder
)
408 /* treat absence of function as success */
409 if (!pSHGetSpecialFolderLocation
) return TRUE
;
412 hr
= pSHGetSpecialFolderLocation(NULL
, folder
, &pidl
);
417 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
420 "%s: ILFindLastID failed\n", getFolderName(folder
));
422 ret
= pidlLast
->mkid
.abID
[0];
423 IMalloc_Free(pMalloc
, pidl
);
429 static void test_SHGetFolderPath(BOOL optional
, int folder
)
434 if (!pSHGetFolderPathA
) return;
436 hr
= pSHGetFolderPathA(NULL
, folder
, NULL
, SHGFP_TYPE_CURRENT
, path
);
437 ok(hr
== S_OK
|| optional
,
438 "SHGetFolderPathA(NULL, %s, NULL, SHGFP_TYPE_CURRENT, path) failed: 0x%08x\n", getFolderName(folder
), hr
);
441 static void test_SHGetSpecialFolderPath(BOOL optional
, int folder
)
446 if (!pSHGetSpecialFolderPathA
) return;
448 ret
= pSHGetSpecialFolderPathA(NULL
, path
, folder
, FALSE
);
449 if (ret
&& winetest_interactive
)
450 printf("%s: %s\n", getFolderName(folder
), path
);
452 "SHGetSpecialFolderPathA(NULL, path, %s, FALSE) failed\n",
453 getFolderName(folder
));
456 static void test_ShellValues(const struct shellExpectedValues testEntries
[],
457 int numEntries
, BOOL optional
)
461 for (i
= 0; i
< numEntries
; i
++)
465 BOOL foundTypeMatch
= FALSE
;
467 if (pSHGetFolderLocation
)
469 type
= testSHGetFolderLocation(testEntries
[i
].folder
);
470 for (j
= 0; !foundTypeMatch
&& j
< testEntries
[i
].numTypes
; j
++)
471 if (testEntries
[i
].types
[j
] == type
)
472 foundTypeMatch
= TRUE
;
473 ok(foundTypeMatch
|| optional
|| broken(type
== 0xff) /* Win9x */,
474 "%s has unexpected type %d (0x%02x)\n",
475 getFolderName(testEntries
[i
].folder
), type
, type
);
477 type
= testSHGetSpecialFolderLocation(testEntries
[i
].folder
);
478 for (j
= 0, foundTypeMatch
= FALSE
; !foundTypeMatch
&&
479 j
< testEntries
[i
].numTypes
; j
++)
480 if (testEntries
[i
].types
[j
] == type
)
481 foundTypeMatch
= TRUE
;
482 ok(foundTypeMatch
|| optional
|| broken(type
== 0xff) /* Win9x */,
483 "%s has unexpected type %d (0x%02x)\n",
484 getFolderName(testEntries
[i
].folder
), type
, type
);
491 test_SHGetFolderPath(optional
, testEntries
[i
].folder
);
492 test_SHGetSpecialFolderPath(optional
, testEntries
[i
].folder
);
498 /* Attempts to verify that the folder path corresponding to the folder CSIDL
499 * value has the same value as the environment variable with name envVar.
500 * Doesn't mind if SHGetSpecialFolderPath fails for folder or if envVar isn't
501 * set in this environment; different OS and shell version behave differently.
502 * However, if both are present, fails if envVar's value is not the same
503 * (byte-for-byte) as what SHGetSpecialFolderPath returns.
505 static void matchSpecialFolderPathToEnv(int folder
, const char *envVar
)
509 if (!pSHGetSpecialFolderPathA
) return;
511 if (pSHGetSpecialFolderPathA(NULL
, path
, folder
, FALSE
))
513 char *envVal
= getenv(envVar
);
515 ok(!envVal
|| !lstrcmpiA(envVal
, path
),
516 "%%%s%% does not match SHGetSpecialFolderPath:\n"
517 "%%%s%% is %s\nSHGetSpecialFolderPath returns %s\n",
518 envVar
, envVar
, envVal
, path
);
522 /* Attempts to match the GUID returned by SHGetFolderLocation for folder with
523 * GUID. Assumes the type of the returned PIDL is in fact a GUID, but doesn't
524 * fail if it isn't--that check should already have been done.
525 * Fails if the returned PIDL is a GUID whose value does not match guid.
527 static void matchGUID(int folder
, const GUID
*guid
, const GUID
*guid_alt
)
532 if (!pSHGetFolderLocation
) return;
536 hr
= pSHGetFolderLocation(NULL
, folder
, NULL
, 0, &pidl
);
539 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
541 if (pidlLast
&& (pidlLast
->mkid
.abID
[0] == PT_SHELLEXT
||
542 pidlLast
->mkid
.abID
[0] == PT_GUID
))
544 GUID
*shellGuid
= (GUID
*)(pidlLast
->mkid
.abID
+ 2);
547 ok(IsEqualIID(shellGuid
, guid
),
548 "%s: got GUID %s, expected %s\n", getFolderName(folder
),
549 wine_dbgstr_guid(shellGuid
), wine_dbgstr_guid(guid
));
551 ok(IsEqualIID(shellGuid
, guid
) ||
552 IsEqualIID(shellGuid
, guid_alt
),
553 "%s: got GUID %s, expected %s or %s\n", getFolderName(folder
),
554 wine_dbgstr_guid(shellGuid
), wine_dbgstr_guid(guid
), wine_dbgstr_guid(guid_alt
));
556 IMalloc_Free(pMalloc
, pidl
);
560 /* Checks the PIDL type of all the known values. */
561 static void test_PidlTypes(void)
564 test_SHGetFolderPath(FALSE
, CSIDL_DESKTOP
);
565 test_SHGetSpecialFolderPath(FALSE
, CSIDL_DESKTOP
);
567 test_ShellValues(requiredShellValues
, ARRAY_SIZE(requiredShellValues
), FALSE
);
568 test_ShellValues(optionalShellValues
, ARRAY_SIZE(optionalShellValues
), TRUE
);
571 /* FIXME: Should be in shobjidl.idl */
572 DEFINE_GUID(CLSID_NetworkExplorerFolder
, 0xF02C1A0D, 0xBE21, 0x4350, 0x88, 0xB0, 0x73, 0x67, 0xFC, 0x96, 0xEF, 0x3C);
573 DEFINE_GUID(_CLSID_Documents
, 0xA8CDFF1C, 0x4878, 0x43be, 0xB5, 0xFD, 0xF8, 0x09, 0x1C, 0x1C, 0x60, 0xD0);
575 /* Verifies various shell virtual folders have the correct well-known GUIDs. */
576 static void test_GUIDs(void)
578 matchGUID(CSIDL_BITBUCKET
, &CLSID_RecycleBin
, NULL
);
579 matchGUID(CSIDL_CONTROLS
, &CLSID_ControlPanel
, NULL
);
580 matchGUID(CSIDL_DRIVES
, &CLSID_MyComputer
, NULL
);
581 matchGUID(CSIDL_INTERNET
, &CLSID_Internet
, NULL
);
582 matchGUID(CSIDL_NETWORK
, &CLSID_NetworkPlaces
, &CLSID_NetworkExplorerFolder
); /* Vista and higher */
583 matchGUID(CSIDL_PERSONAL
, &CLSID_MyDocuments
, &_CLSID_Documents
/* win8 */);
584 matchGUID(CSIDL_COMMON_DOCUMENTS
, &CLSID_CommonDocuments
, NULL
);
585 matchGUID(CSIDL_PRINTERS
, &CLSID_Printers
, NULL
);
588 /* Verifies various shell paths match the environment variables to which they
591 static void test_EnvVars(void)
593 matchSpecialFolderPathToEnv(CSIDL_PROGRAM_FILES
, "ProgramFiles");
594 matchSpecialFolderPathToEnv(CSIDL_APPDATA
, "APPDATA");
595 matchSpecialFolderPathToEnv(CSIDL_PROFILE
, "USERPROFILE");
596 matchSpecialFolderPathToEnv(CSIDL_WINDOWS
, "SystemRoot");
597 matchSpecialFolderPathToEnv(CSIDL_WINDOWS
, "windir");
598 matchSpecialFolderPathToEnv(CSIDL_PROGRAM_FILES_COMMON
, "CommonProgramFiles");
599 /* this is only set on Wine, but can't hurt to verify it: */
600 matchSpecialFolderPathToEnv(CSIDL_SYSTEM
, "winsysdir");
603 /* Loosely based on PathRemoveBackslashA from dlls/shlwapi/path.c */
604 static BOOL
myPathIsRootA(LPCSTR lpszPath
)
606 if (lpszPath
&& *lpszPath
&&
607 lpszPath
[1] == ':' && lpszPath
[2] == '\\' && lpszPath
[3] == '\0')
608 return TRUE
; /* X:\ */
611 static LPSTR
myPathRemoveBackslashA( LPSTR lpszPath
)
617 szTemp
= CharPrevA(lpszPath
, lpszPath
+ strlen(lpszPath
));
618 if (!myPathIsRootA(lpszPath
) && *szTemp
== '\\')
624 /* Verifies the shell path for CSIDL_WINDOWS matches the return from
625 * GetWindowsDirectory. If SHGetSpecialFolderPath fails, no harm, no foul--not
626 * every shell32 version supports CSIDL_WINDOWS.
628 static void testWinDir(void)
630 char windowsShellPath
[MAX_PATH
], windowsDir
[MAX_PATH
] = { 0 };
632 if (!pSHGetSpecialFolderPathA
) return;
634 if (pSHGetSpecialFolderPathA(NULL
, windowsShellPath
, CSIDL_WINDOWS
, FALSE
))
636 myPathRemoveBackslashA(windowsShellPath
);
637 GetWindowsDirectoryA(windowsDir
, sizeof(windowsDir
));
638 myPathRemoveBackslashA(windowsDir
);
639 ok(!lstrcmpiA(windowsDir
, windowsShellPath
),
640 "GetWindowsDirectory returns %s SHGetSpecialFolderPath returns %s\n",
641 windowsDir
, windowsShellPath
);
645 /* Verifies the shell path for CSIDL_SYSTEM matches the return from
646 * GetSystemDirectory. If SHGetSpecialFolderPath fails, no harm,
647 * no foul--not every shell32 version supports CSIDL_SYSTEM.
649 static void testSystemDir(void)
651 char systemShellPath
[MAX_PATH
], systemDir
[MAX_PATH
], systemDirx86
[MAX_PATH
];
653 if (!pSHGetSpecialFolderPathA
) return;
655 GetSystemDirectoryA(systemDir
, sizeof(systemDir
));
656 myPathRemoveBackslashA(systemDir
);
657 if (pSHGetSpecialFolderPathA(NULL
, systemShellPath
, CSIDL_SYSTEM
, FALSE
))
659 myPathRemoveBackslashA(systemShellPath
);
660 ok(!lstrcmpiA(systemDir
, systemShellPath
),
661 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
662 systemDir
, systemShellPath
);
665 if (!pGetSystemWow64DirectoryA
|| !pGetSystemWow64DirectoryA(systemDirx86
, sizeof(systemDirx86
)))
666 GetSystemDirectoryA(systemDirx86
, sizeof(systemDirx86
));
667 myPathRemoveBackslashA(systemDirx86
);
668 if (pSHGetSpecialFolderPathA(NULL
, systemShellPath
, CSIDL_SYSTEMX86
, FALSE
))
670 myPathRemoveBackslashA(systemShellPath
);
671 ok(!lstrcmpiA(systemDirx86
, systemShellPath
) || broken(!lstrcmpiA(systemDir
, systemShellPath
)),
672 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
673 systemDir
, systemShellPath
);
677 /* Globals used by subprocesses */
679 static char **myARGV
;
680 static char base
[MAX_PATH
];
681 static char selfname
[MAX_PATH
];
683 static BOOL
init(void)
685 myARGC
= winetest_get_mainargs(&myARGV
);
686 if (!GetCurrentDirectoryA(sizeof(base
), base
)) return FALSE
;
687 strcpy(selfname
, myARGV
[0]);
691 static void doChild(const char *arg
)
701 /* test what happens when CSIDL_FAVORITES is set to a nonexistent directory */
703 /* test some failure cases first: */
704 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
, NULL
, SHGFP_TYPE_CURRENT
, path
);
705 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
706 "SHGetFolderPath returned 0x%08x, expected 0x80070002\n", hr
);
709 hr
= pSHGetFolderLocation(NULL
, CSIDL_FAVORITES
, NULL
, 0, &pidl
);
710 ok(hr
== E_FAIL
|| hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
711 "SHGetFolderLocation returned 0x%08x\n", hr
);
712 if (hr
== S_OK
&& pidl
) IMalloc_Free(pMalloc
, pidl
);
714 ok(!pSHGetSpecialFolderPathA(NULL
, path
, CSIDL_FAVORITES
, FALSE
),
715 "SHGetSpecialFolderPath succeeded, expected failure\n");
718 hr
= pSHGetSpecialFolderLocation(NULL
, CSIDL_FAVORITES
, &pidl
);
719 ok(hr
== E_FAIL
|| hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
720 "SHGetFolderLocation returned 0x%08x\n", hr
);
722 if (hr
== S_OK
&& pidl
) IMalloc_Free(pMalloc
, pidl
);
724 /* now test success: */
725 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
| CSIDL_FLAG_CREATE
, NULL
,
726 SHGFP_TYPE_CURRENT
, path
);
727 ok (hr
== S_OK
, "got 0x%08x\n", hr
);
732 trace("CSIDL_FAVORITES was changed to %s\n", path
);
733 ret
= CreateDirectoryA(path
, NULL
);
734 ok(!ret
, "expected failure with ERROR_ALREADY_EXISTS\n");
736 ok(GetLastError() == ERROR_ALREADY_EXISTS
,
737 "got %d, expected ERROR_ALREADY_EXISTS\n", GetLastError());
739 p
= path
+ strlen(path
);
740 strcpy(p
, "\\desktop.ini");
743 SetFileAttributesA( path
, FILE_ATTRIBUTE_NORMAL
);
744 ret
= RemoveDirectoryA(path
);
745 ok( ret
, "failed to remove %s error %u\n", path
, GetLastError() );
748 else if (arg
[0] == '2')
750 /* make sure SHGetFolderPath still succeeds when the
751 original value of CSIDL_FAVORITES is restored. */
752 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
| CSIDL_FLAG_CREATE
, NULL
,
753 SHGFP_TYPE_CURRENT
, path
);
754 ok(hr
== S_OK
, "SHGetFolderPath failed: 0x%08x\n", hr
);
758 /* Tests the return values from the various shell functions both with and
759 * without the use of the CSIDL_FLAG_CREATE flag. This flag only appeared in
760 * version 5 of the shell, so don't test unless it's at least version 5.
761 * The test reads a value from the registry, modifies it, calls
762 * SHGetFolderPath once with the CSIDL_FLAG_CREATE flag, and immediately
763 * afterward without it. Then it restores the registry and deletes the folder
765 * One oddity with respect to restoration: shell32 caches somehow, so it needs
766 * to be reloaded in order to see the correct (restored) value.
767 * Some APIs unrelated to the ones under test may fail, but I expect they're
768 * covered by other unit tests; I just print out something about failure to
769 * help trace what's going on.
771 static void test_NonExistentPath(void)
773 static const char userShellFolders
[] =
774 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
775 char originalPath
[MAX_PATH
], modifiedPath
[MAX_PATH
];
778 if (!pSHGetFolderPathA
) return;
779 if (!pSHGetFolderLocation
) return;
780 if (!pSHGetSpecialFolderPathA
) return;
781 if (!pSHGetSpecialFolderLocation
) return;
782 if (!pSHFileOperationA
) return;
783 if (shellVersion
.dwMajorVersion
< 5) return;
785 if (!RegOpenKeyExA(HKEY_CURRENT_USER
, userShellFolders
, 0, KEY_ALL_ACCESS
,
790 len
= sizeof(originalPath
);
791 if (!RegQueryValueExA(key
, "Favorites", NULL
, &type
,
792 (LPBYTE
)&originalPath
, &len
))
794 size_t len
= strlen(originalPath
);
796 memcpy(modifiedPath
, originalPath
, len
);
797 modifiedPath
[len
++] = '2';
798 modifiedPath
[len
++] = '\0';
799 trace("Changing CSIDL_FAVORITES to %s\n", modifiedPath
);
800 if (!RegSetValueExA(key
, "Favorites", 0, type
,
801 (LPBYTE
)modifiedPath
, len
))
803 char buffer
[MAX_PATH
+20];
804 STARTUPINFOA startup
;
805 PROCESS_INFORMATION info
;
807 sprintf(buffer
, "%s tests/shellpath.c 1", selfname
);
808 memset(&startup
, 0, sizeof(startup
));
809 startup
.cb
= sizeof(startup
);
810 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
811 startup
.dwFlags
= SW_SHOWNORMAL
;
812 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
,
814 winetest_wait_child_process( info
.hProcess
);
816 /* restore original values: */
817 trace("Restoring CSIDL_FAVORITES to %s\n", originalPath
);
818 RegSetValueExA(key
, "Favorites", 0, type
, (LPBYTE
) originalPath
,
819 strlen(originalPath
) + 1);
822 sprintf(buffer
, "%s tests/shellpath.c 2", selfname
);
823 memset(&startup
, 0, sizeof(startup
));
824 startup
.cb
= sizeof(startup
);
825 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
826 startup
.dwFlags
= SW_SHOWNORMAL
;
827 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
,
829 ok(WaitForSingleObject(info
.hProcess
, 30000) == WAIT_OBJECT_0
,
830 "child process termination\n");
833 else skip("RegQueryValueExA(key, Favorites, ...) failed\n");
837 else skip("RegOpenKeyExA(HKEY_CURRENT_USER, %s, ...) failed\n", userShellFolders
);
840 static void test_SHGetFolderPathEx(void)
843 WCHAR buffer
[MAX_PATH
], *path
;
846 if (!pSHGetKnownFolderPath
|| !pSHGetFolderPathEx
)
848 win_skip("SHGetKnownFolderPath or SHGetFolderPathEx not available\n");
852 if (0) { /* crashes */
853 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, 0, NULL
, NULL
);
854 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
856 /* non-existent folder id */
857 path
= (void *)0xdeadbeef;
858 hr
= pSHGetKnownFolderPath(&IID_IOleObject
, 0, NULL
, &path
);
859 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
860 ok(path
== NULL
, "got %p\n", path
);
863 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, 0, NULL
, &path
);
864 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
865 ok(path
!= NULL
, "expected path != NULL\n");
867 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, MAX_PATH
);
868 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
869 ok(!lstrcmpiW(path
, buffer
), "expected equal paths\n");
870 len
= lstrlenW(buffer
);
873 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, 0);
874 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
876 if (0) { /* crashes */
877 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, NULL
, len
+ 1);
878 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
880 hr
= pSHGetFolderPathEx(NULL
, 0, NULL
, buffer
, MAX_PATH
);
881 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
883 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
);
884 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr
);
886 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
+ 1);
887 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
890 /* Standard CSIDL values (and their flags) uses only two less-significant bytes */
891 #define NO_CSIDL 0x10000
892 #define WINE_ATTRIBUTES_OPTIONAL 0x20000
893 #define KNOWN_FOLDER(id, csidl, name, category, parent1, parent2, relative_path, parsing_name, attributes, definitionFlags) \
894 { &id, # id, csidl, # csidl, name, category, {&parent1, &parent2}, relative_path, parsing_name, attributes, definitionFlags, __LINE__ }
896 /* non-published known folders test */
897 static const GUID _FOLDERID_CryptoKeys
= {0xB88F4DAA, 0xE7BD, 0x49A9, {0xB7, 0x4D, 0x02, 0x88, 0x5A, 0x5D, 0xC7, 0x65} };
898 static const GUID _FOLDERID_DpapiKeys
= {0x10C07CD0, 0xEF91, 0x4567, {0xB8, 0x50, 0x44, 0x8B, 0x77, 0xCB, 0x37, 0xF9} };
899 static const GUID _FOLDERID_SystemCertificates
= {0x54EED2E0, 0xE7CA, 0x4FDB, {0x91, 0x48, 0x0F, 0x42, 0x47, 0x29, 0x1C, 0xFA} };
900 static const GUID _FOLDERID_CredentialManager
= {0x915221FB, 0x9EFE, 0x4BDA, {0x8F, 0xD7, 0xF7, 0x8D, 0xCA, 0x77, 0x4F, 0x87} };
902 struct knownFolderDef
{
903 const KNOWNFOLDERID
*folderId
;
904 const char *sFolderId
;
908 const KF_CATEGORY category
;
909 const KNOWNFOLDERID
*fidParents
[2];
910 const char *sRelativePath
;
911 const char *sParsingName
;
912 const DWORD attributes
;
913 const KF_DEFINITION_FLAGS definitionFlags
;
917 /* Note: content of parsing name may vary between Windows versions.
918 * As a base, values from 6.0 (Vista) were used. Some entries may contain
919 * alternative values. In that case, Windows version where the value was
922 * The list of values for parsing name was encoded as a number of null-
923 * terminated strings placed one by one (separated by null byte only).
924 * End of list is marked by two consecutive null bytes.
926 static const struct knownFolderDef known_folders
[] = {
927 KNOWN_FOLDER(FOLDERID_AddNewPrograms
,
929 "AddNewProgramsFolder",
931 GUID_NULL
, GUID_NULL
,
933 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0"
934 "shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0\0" /* 6.1 */,
937 KNOWN_FOLDER(FOLDERID_AdminTools
,
939 "Administrative Tools",
941 FOLDERID_Programs
, GUID_NULL
,
942 "Administrative Tools",
944 FILE_ATTRIBUTE_READONLY
,
946 KNOWN_FOLDER(FOLDERID_AppUpdates
,
950 GUID_NULL
, GUID_NULL
,
952 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0"
953 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0\0" /* 6.1 */,
956 KNOWN_FOLDER(FOLDERID_CDBurning
,
960 FOLDERID_LocalAppData
, GUID_NULL
,
961 "Microsoft\\Windows\\Burn\\Burn",
963 FILE_ATTRIBUTE_READONLY
,
964 KFDF_LOCAL_REDIRECT_ONLY
),
965 KNOWN_FOLDER(FOLDERID_ChangeRemovePrograms
,
967 "ChangeRemoveProgramsFolder",
969 GUID_NULL
, GUID_NULL
,
971 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0"
972 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0\0" /* 6.1 */,
975 KNOWN_FOLDER(FOLDERID_CommonAdminTools
,
976 CSIDL_COMMON_ADMINTOOLS
,
977 "Common Administrative Tools",
979 FOLDERID_CommonPrograms
, GUID_NULL
,
980 "Administrative Tools",
982 FILE_ATTRIBUTE_READONLY
,
984 KNOWN_FOLDER(FOLDERID_CommonOEMLinks
,
985 CSIDL_COMMON_OEM_LINKS
,
988 FOLDERID_ProgramData
, GUID_NULL
,
993 KNOWN_FOLDER(FOLDERID_CommonPrograms
,
994 CSIDL_COMMON_PROGRAMS
,
997 FOLDERID_CommonStartMenu
, GUID_NULL
,
1000 FILE_ATTRIBUTE_READONLY
,
1002 KNOWN_FOLDER(FOLDERID_CommonStartMenu
,
1003 CSIDL_COMMON_STARTMENU
,
1004 "Common Start Menu",
1006 FOLDERID_ProgramData
, GUID_NULL
,
1007 "Microsoft\\Windows\\Start Menu\0",
1009 FILE_ATTRIBUTE_READONLY
,
1011 KNOWN_FOLDER(FOLDERID_CommonStartup
,
1012 CSIDL_COMMON_STARTUP
,
1015 FOLDERID_CommonPrograms
, GUID_NULL
,
1018 FILE_ATTRIBUTE_READONLY
,
1020 KNOWN_FOLDER(FOLDERID_CommonTemplates
,
1021 CSIDL_COMMON_TEMPLATES
,
1024 FOLDERID_ProgramData
, GUID_NULL
,
1025 "Microsoft\\Windows\\Templates\0",
1029 KNOWN_FOLDER(FOLDERID_ComputerFolder
,
1032 KF_CATEGORY_VIRTUAL
,
1033 GUID_NULL
, GUID_NULL
,
1035 "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\0\0",
1038 KNOWN_FOLDER(FOLDERID_ConflictFolder
,
1041 KF_CATEGORY_VIRTUAL
,
1042 GUID_NULL
, GUID_NULL
,
1044 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0"
1045 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0\0" /* 6.1 */,
1048 KNOWN_FOLDER(FOLDERID_ConnectionsFolder
,
1050 "ConnectionsFolder",
1051 KF_CATEGORY_VIRTUAL
,
1052 GUID_NULL
, GUID_NULL
,
1054 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0"
1055 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0\0" /* 6.1 */,
1058 KNOWN_FOLDER(FOLDERID_Contacts
,
1061 KF_CATEGORY_PERUSER
,
1062 FOLDERID_Profile
, GUID_NULL
,
1064 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{56784854-C6CB-462B-8169-88E350ACB882}\0\0",
1065 FILE_ATTRIBUTE_READONLY
,
1066 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1067 KNOWN_FOLDER(FOLDERID_ControlPanelFolder
,
1069 "ControlPanelFolder",
1070 KF_CATEGORY_VIRTUAL
,
1071 GUID_NULL
, GUID_NULL
,
1073 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\0"
1074 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\0\0" /* 6.1 */,
1077 KNOWN_FOLDER(FOLDERID_Cookies
,
1080 KF_CATEGORY_PERUSER
,
1081 FOLDERID_RoamingAppData
, FOLDERID_LocalAppData
,
1082 "Microsoft\\Windows\\Cookies\0Microsoft\\Windows\\INetCookies\0" /* win8 */,
1086 KNOWN_FOLDER(FOLDERID_Desktop
,
1089 KF_CATEGORY_PERUSER
,
1090 FOLDERID_Profile
, GUID_NULL
,
1093 FILE_ATTRIBUTE_READONLY
,
1094 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1095 KNOWN_FOLDER(FOLDERID_DeviceMetadataStore
,
1097 "Device Metadata Store",
1099 FOLDERID_ProgramData
, GUID_NULL
,
1100 "Microsoft\\Windows\\DeviceMetadataStore\0",
1104 KNOWN_FOLDER(FOLDERID_Documents
,
1107 KF_CATEGORY_PERUSER
,
1108 FOLDERID_Profile
, GUID_NULL
,
1110 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{FDD39AD0-238F-46AF-ADB4-6C85480369C7}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}\0\0", /* win8 */
1111 FILE_ATTRIBUTE_READONLY
,
1112 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1113 KNOWN_FOLDER(FOLDERID_DocumentsLibrary
,
1116 KF_CATEGORY_PERUSER
,
1117 FOLDERID_Libraries
, GUID_NULL
,
1118 "Documents.library-ms\0",
1119 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{7b0db17d-9cd2-4a93-9733-46cc89022e7c}\0\0",
1121 KFDF_PRECREATE
| KFDF_STREAM
),
1122 KNOWN_FOLDER(FOLDERID_Downloads
,
1125 KF_CATEGORY_PERUSER
,
1126 FOLDERID_Profile
, GUID_NULL
,
1128 "(null)\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{374DE290-123F-4565-9164-39C4925E467B}\0\0", /* win8 */
1129 FILE_ATTRIBUTE_READONLY
,
1130 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1131 KNOWN_FOLDER(FOLDERID_Favorites
,
1134 KF_CATEGORY_PERUSER
,
1135 FOLDERID_Profile
, GUID_NULL
,
1138 FILE_ATTRIBUTE_READONLY
,
1139 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1140 KNOWN_FOLDER(FOLDERID_Fonts
,
1144 FOLDERID_Windows
, GUID_NULL
,
1149 KNOWN_FOLDER(FOLDERID_Games
,
1152 KF_CATEGORY_VIRTUAL
,
1153 GUID_NULL
, GUID_NULL
,
1155 "::{ED228FDF-9EA8-4870-83b1-96b02CFE0D52}\0\0",
1158 KNOWN_FOLDER(FOLDERID_GameTasks
,
1161 KF_CATEGORY_PERUSER
,
1162 FOLDERID_LocalAppData
, GUID_NULL
,
1163 "Microsoft\\Windows\\GameExplorer\0",
1166 KFDF_LOCAL_REDIRECT_ONLY
),
1167 KNOWN_FOLDER(FOLDERID_History
,
1170 KF_CATEGORY_PERUSER
,
1171 FOLDERID_LocalAppData
, GUID_NULL
,
1172 "Microsoft\\Windows\\History\0",
1175 KFDF_LOCAL_REDIRECT_ONLY
),
1176 KNOWN_FOLDER(FOLDERID_HomeGroup
,
1179 KF_CATEGORY_VIRTUAL
,
1180 GUID_NULL
, GUID_NULL
,
1182 "::{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\0\0",
1185 KNOWN_FOLDER(FOLDERID_ImplicitAppShortcuts
,
1187 "ImplicitAppShortcuts",
1188 KF_CATEGORY_PERUSER
,
1189 FOLDERID_UserPinned
, GUID_NULL
,
1190 "ImplicitAppShortcuts\0",
1194 KNOWN_FOLDER(FOLDERID_InternetCache
,
1195 CSIDL_INTERNET_CACHE
,
1197 KF_CATEGORY_PERUSER
,
1198 FOLDERID_LocalAppData
, GUID_NULL
,
1199 "Microsoft\\Windows\\Temporary Internet Files\0Microsoft\\Windows\\INetCache\0\0", /* win8 */
1202 KFDF_LOCAL_REDIRECT_ONLY
),
1203 KNOWN_FOLDER(FOLDERID_InternetFolder
,
1206 KF_CATEGORY_VIRTUAL
,
1207 GUID_NULL
, GUID_NULL
,
1209 "::{871C5380-42A0-1069-A2EA-08002B30309D}\0\0",
1212 KNOWN_FOLDER(FOLDERID_Libraries
,
1215 KF_CATEGORY_PERUSER
,
1216 FOLDERID_RoamingAppData
, GUID_NULL
,
1217 "Microsoft\\Windows\\Libraries\0",
1220 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1221 KNOWN_FOLDER(FOLDERID_Links
,
1224 KF_CATEGORY_PERUSER
,
1225 FOLDERID_Profile
, GUID_NULL
,
1227 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}\0\0",
1228 FILE_ATTRIBUTE_READONLY
,
1229 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1230 KNOWN_FOLDER(FOLDERID_LocalAppData
,
1231 CSIDL_LOCAL_APPDATA
,
1233 KF_CATEGORY_PERUSER
,
1234 FOLDERID_Profile
, GUID_NULL
,
1238 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
),
1239 KNOWN_FOLDER(FOLDERID_LocalAppDataLow
,
1242 KF_CATEGORY_PERUSER
,
1243 FOLDERID_Profile
, GUID_NULL
,
1244 "AppData\\LocalLow\0",
1246 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
,
1247 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1248 KNOWN_FOLDER(FOLDERID_LocalizedResourcesDir
,
1249 CSIDL_RESOURCES_LOCALIZED
,
1250 "LocalizedResourcesDir",
1252 GUID_NULL
, GUID_NULL
,
1257 KNOWN_FOLDER(FOLDERID_Music
,
1260 KF_CATEGORY_PERUSER
,
1261 FOLDERID_Profile
, GUID_NULL
,
1263 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4BD8D571-6D19-48D3-BE97-422220080E43}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{1CF1260C-4DD0-4EBB-811F-33C572699FDE}\0\0", /* win8 */
1264 FILE_ATTRIBUTE_READONLY
,
1265 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1266 KNOWN_FOLDER(FOLDERID_MusicLibrary
,
1269 KF_CATEGORY_PERUSER
,
1270 FOLDERID_Libraries
, GUID_NULL
,
1271 "Music.library-ms\0",
1272 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{2112AB0A-C86A-4ffe-A368-0DE96E47012E}\0\0",
1274 KFDF_PRECREATE
| KFDF_STREAM
),
1275 KNOWN_FOLDER(FOLDERID_NetHood
,
1278 KF_CATEGORY_PERUSER
,
1279 FOLDERID_RoamingAppData
, GUID_NULL
,
1280 "Microsoft\\Windows\\Network Shortcuts\0",
1284 KNOWN_FOLDER(FOLDERID_NetworkFolder
,
1286 "NetworkPlacesFolder",
1287 KF_CATEGORY_VIRTUAL
,
1288 GUID_NULL
, GUID_NULL
,
1290 "::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\0\0",
1293 KNOWN_FOLDER(FOLDERID_OriginalImages
,
1296 KF_CATEGORY_PERUSER
,
1297 FOLDERID_LocalAppData
, GUID_NULL
,
1298 "Microsoft\\Windows Photo Gallery\\Original Images\0",
1302 KNOWN_FOLDER(FOLDERID_PhotoAlbums
,
1305 KF_CATEGORY_PERUSER
,
1306 FOLDERID_Pictures
, GUID_NULL
,
1309 FILE_ATTRIBUTE_READONLY
,
1311 KNOWN_FOLDER(FOLDERID_Pictures
,
1314 KF_CATEGORY_PERUSER
,
1315 FOLDERID_Profile
, GUID_NULL
,
1317 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{33E28130-4E1E-4676-835A-98395C3BC3BB}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{3ADD1653-EB32-4CB0-BBD7-DFA0ABB5ACCA}\0\0", /* win8 */
1318 FILE_ATTRIBUTE_READONLY
,
1319 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1320 KNOWN_FOLDER(FOLDERID_PicturesLibrary
,
1323 KF_CATEGORY_PERUSER
,
1324 FOLDERID_Libraries
, GUID_NULL
,
1325 "Pictures.library-ms\0",
1326 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{A990AE9F-A03B-4e80-94BC-9912D7504104}\0\0",
1328 KFDF_PRECREATE
| KFDF_STREAM
),
1329 KNOWN_FOLDER(FOLDERID_Playlists
,
1332 KF_CATEGORY_PERUSER
,
1333 FOLDERID_Music
, GUID_NULL
,
1336 FILE_ATTRIBUTE_READONLY
,
1338 KNOWN_FOLDER(FOLDERID_PrintersFolder
,
1341 KF_CATEGORY_VIRTUAL
,
1342 GUID_NULL
, GUID_NULL
,
1344 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}\0\0",
1347 KNOWN_FOLDER(FOLDERID_PrintHood
,
1350 KF_CATEGORY_PERUSER
,
1351 FOLDERID_RoamingAppData
, GUID_NULL
,
1352 "Microsoft\\Windows\\Printer Shortcuts\0",
1356 KNOWN_FOLDER(FOLDERID_Profile
,
1360 GUID_NULL
, GUID_NULL
,
1365 KNOWN_FOLDER(FOLDERID_ProgramData
,
1366 CSIDL_COMMON_APPDATA
,
1369 GUID_NULL
, GUID_NULL
,
1374 KNOWN_FOLDER(FOLDERID_ProgramFiles
,
1375 CSIDL_PROGRAM_FILES
,
1378 GUID_NULL
, GUID_NULL
,
1381 FILE_ATTRIBUTE_READONLY
,
1384 KNOWN_FOLDER(FOLDERID_ProgramFilesCommon
,
1385 CSIDL_PROGRAM_FILES_COMMON
,
1386 "ProgramFilesCommon",
1388 GUID_NULL
, GUID_NULL
,
1393 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX64
,
1395 "ProgramFilesCommonX64",
1397 GUID_NULL
, GUID_NULL
,
1402 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX86
,
1404 "ProgramFilesCommonX86",
1406 GUID_NULL
, GUID_NULL
,
1411 KNOWN_FOLDER(FOLDERID_ProgramFilesX64
,
1415 GUID_NULL
, GUID_NULL
,
1420 KNOWN_FOLDER(FOLDERID_ProgramFilesX86
,
1421 CSIDL_PROGRAM_FILESX86
,
1424 GUID_NULL
, GUID_NULL
,
1427 FILE_ATTRIBUTE_READONLY
,
1429 KNOWN_FOLDER(FOLDERID_Programs
,
1432 KF_CATEGORY_PERUSER
,
1433 FOLDERID_StartMenu
, GUID_NULL
,
1436 FILE_ATTRIBUTE_READONLY
,
1438 KNOWN_FOLDER(FOLDERID_Public
,
1442 GUID_NULL
, GUID_NULL
,
1444 "::{4336a54d-038b-4685-ab02-99bb52d3fb8b}\0"
1445 "(null)\0\0" /* 6.1 */,
1446 FILE_ATTRIBUTE_READONLY
,
1448 KNOWN_FOLDER(FOLDERID_PublicDesktop
,
1449 CSIDL_COMMON_DESKTOPDIRECTORY
,
1452 FOLDERID_Public
, GUID_NULL
,
1455 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
1457 KNOWN_FOLDER(FOLDERID_PublicDocuments
,
1458 CSIDL_COMMON_DOCUMENTS
,
1461 FOLDERID_Public
, GUID_NULL
,
1464 FILE_ATTRIBUTE_READONLY
,
1466 KNOWN_FOLDER(FOLDERID_PublicDownloads
,
1470 FOLDERID_Public
, GUID_NULL
,
1473 FILE_ATTRIBUTE_READONLY
,
1475 KNOWN_FOLDER(FOLDERID_PublicGameTasks
,
1479 FOLDERID_ProgramData
, GUID_NULL
,
1480 "Microsoft\\Windows\\GameExplorer\0",
1483 KFDF_LOCAL_REDIRECT_ONLY
),
1484 KNOWN_FOLDER(FOLDERID_PublicLibraries
,
1488 FOLDERID_Public
, GUID_NULL
,
1491 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
1493 KNOWN_FOLDER(FOLDERID_PublicMusic
,
1497 FOLDERID_Public
, GUID_NULL
,
1500 FILE_ATTRIBUTE_READONLY
,
1502 KNOWN_FOLDER(FOLDERID_PublicPictures
,
1503 CSIDL_COMMON_PICTURES
,
1506 FOLDERID_Public
, GUID_NULL
,
1509 FILE_ATTRIBUTE_READONLY
,
1511 KNOWN_FOLDER(FOLDERID_PublicRingtones
,
1515 FOLDERID_ProgramData
, GUID_NULL
,
1516 "Microsoft\\Windows\\Ringtones\0",
1520 KNOWN_FOLDER(FOLDERID_PublicVideos
,
1524 FOLDERID_Public
, GUID_NULL
,
1527 FILE_ATTRIBUTE_READONLY
,
1529 KNOWN_FOLDER(FOLDERID_QuickLaunch
,
1532 KF_CATEGORY_PERUSER
,
1533 FOLDERID_RoamingAppData
, GUID_NULL
,
1534 "Microsoft\\Internet Explorer\\Quick Launch\0",
1538 KNOWN_FOLDER(FOLDERID_Recent
,
1541 KF_CATEGORY_PERUSER
,
1542 FOLDERID_RoamingAppData
, GUID_NULL
,
1543 "Microsoft\\Windows\\Recent\0",
1545 FILE_ATTRIBUTE_READONLY
,
1547 KNOWN_FOLDER(FOLDERID_RecordedTVLibrary
,
1549 "RecordedTVLibrary",
1551 FOLDERID_PublicLibraries
, GUID_NULL
,
1552 "RecordedTV.library-ms\0",
1555 KFDF_PRECREATE
| KFDF_STREAM
),
1556 KNOWN_FOLDER(FOLDERID_RecycleBinFolder
,
1559 KF_CATEGORY_VIRTUAL
,
1560 GUID_NULL
, GUID_NULL
,
1562 "::{645FF040-5081-101B-9F08-00AA002F954E}\0\0",
1565 KNOWN_FOLDER(FOLDERID_ResourceDir
,
1569 GUID_NULL
, GUID_NULL
,
1574 KNOWN_FOLDER(FOLDERID_Ringtones
,
1577 KF_CATEGORY_PERUSER
,
1578 FOLDERID_LocalAppData
, GUID_NULL
,
1579 "Microsoft\\Windows\\Ringtones\0",
1583 KNOWN_FOLDER(FOLDERID_RoamingAppData
,
1586 KF_CATEGORY_PERUSER
,
1587 FOLDERID_Profile
, GUID_NULL
,
1588 "AppData\\Roaming\0",
1592 KNOWN_FOLDER(FOLDERID_SampleMusic
,
1593 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1596 FOLDERID_PublicMusic
, GUID_NULL
,
1599 FILE_ATTRIBUTE_READONLY
,
1601 KNOWN_FOLDER(FOLDERID_SamplePictures
,
1602 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1605 FOLDERID_PublicPictures
, GUID_NULL
,
1606 "Sample Pictures\0",
1608 FILE_ATTRIBUTE_READONLY
,
1610 KNOWN_FOLDER(FOLDERID_SamplePlaylists
,
1614 FOLDERID_PublicMusic
, GUID_NULL
,
1615 "Sample Playlists\0",
1617 FILE_ATTRIBUTE_READONLY
,
1619 KNOWN_FOLDER(FOLDERID_SampleVideos
,
1620 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1623 FOLDERID_PublicVideos
, GUID_NULL
,
1626 FILE_ATTRIBUTE_READONLY
,
1628 KNOWN_FOLDER(FOLDERID_SavedGames
,
1631 KF_CATEGORY_PERUSER
,
1632 FOLDERID_Profile
, GUID_NULL
,
1634 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}\0\0",
1635 FILE_ATTRIBUTE_READONLY
,
1636 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1637 KNOWN_FOLDER(FOLDERID_SavedSearches
,
1640 KF_CATEGORY_PERUSER
,
1641 FOLDERID_Profile
, GUID_NULL
,
1643 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{7d1d3a04-debb-4115-95cf-2f29da2920da}\0\0",
1644 FILE_ATTRIBUTE_READONLY
,
1645 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1646 KNOWN_FOLDER(FOLDERID_SEARCH_CSC
,
1649 KF_CATEGORY_VIRTUAL
,
1650 GUID_NULL
, GUID_NULL
,
1652 "shell:::{BD7A2E7B-21CB-41b2-A086-B309680C6B7E}\\*\0\0",
1655 KNOWN_FOLDER(FOLDERID_SearchHome
,
1658 KF_CATEGORY_VIRTUAL
,
1659 GUID_NULL
, GUID_NULL
,
1661 "::{9343812e-1c37-4a49-a12e-4b2d810d956b}\0\0",
1664 KNOWN_FOLDER(FOLDERID_SEARCH_MAPI
,
1667 KF_CATEGORY_VIRTUAL
,
1668 GUID_NULL
, GUID_NULL
,
1670 "shell:::{89D83576-6BD1-4C86-9454-BEB04E94C819}\\*\0\0",
1673 KNOWN_FOLDER(FOLDERID_SendTo
,
1676 KF_CATEGORY_PERUSER
,
1677 FOLDERID_RoamingAppData
, GUID_NULL
,
1678 "Microsoft\\Windows\\SendTo\0",
1682 KNOWN_FOLDER(FOLDERID_SidebarDefaultParts
,
1686 FOLDERID_ProgramFiles
, GUID_NULL
,
1687 "Windows Sidebar\\Gadgets\0",
1691 KNOWN_FOLDER(FOLDERID_SidebarParts
,
1694 KF_CATEGORY_PERUSER
,
1695 FOLDERID_LocalAppData
, GUID_NULL
,
1696 "Microsoft\\Windows Sidebar\\Gadgets\0",
1700 KNOWN_FOLDER(FOLDERID_StartMenu
,
1703 KF_CATEGORY_PERUSER
,
1704 FOLDERID_RoamingAppData
, GUID_NULL
,
1705 "Microsoft\\Windows\\Start Menu\0",
1707 FILE_ATTRIBUTE_READONLY
,
1709 KNOWN_FOLDER(FOLDERID_Startup
,
1712 KF_CATEGORY_PERUSER
,
1713 FOLDERID_Programs
, GUID_NULL
,
1716 FILE_ATTRIBUTE_READONLY
,
1718 KNOWN_FOLDER(FOLDERID_SyncManagerFolder
,
1721 KF_CATEGORY_VIRTUAL
,
1722 GUID_NULL
, GUID_NULL
,
1724 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0"
1725 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0\0" /* 6.1 */,
1728 KNOWN_FOLDER(FOLDERID_SyncResultsFolder
,
1730 "SyncResultsFolder",
1731 KF_CATEGORY_VIRTUAL
,
1732 GUID_NULL
, GUID_NULL
,
1734 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0"
1735 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0\0",
1738 KNOWN_FOLDER(FOLDERID_SyncSetupFolder
,
1741 KF_CATEGORY_VIRTUAL
,
1742 GUID_NULL
, GUID_NULL
,
1744 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0"
1745 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0\0" /* 6.1 */,
1748 KNOWN_FOLDER(FOLDERID_System
,
1752 GUID_NULL
, GUID_NULL
,
1757 KNOWN_FOLDER(FOLDERID_SystemX86
,
1761 GUID_NULL
, GUID_NULL
,
1766 KNOWN_FOLDER(FOLDERID_Templates
,
1769 KF_CATEGORY_PERUSER
,
1770 FOLDERID_RoamingAppData
, GUID_NULL
,
1771 "Microsoft\\Windows\\Templates\0",
1775 KNOWN_FOLDER(FOLDERID_UserPinned
,
1778 KF_CATEGORY_PERUSER
,
1779 FOLDERID_QuickLaunch
, GUID_NULL
,
1782 FILE_ATTRIBUTE_HIDDEN
,
1784 KNOWN_FOLDER(FOLDERID_UserProfiles
,
1788 GUID_NULL
, GUID_NULL
,
1791 FILE_ATTRIBUTE_READONLY
,
1793 KNOWN_FOLDER(FOLDERID_UserProgramFiles
,
1796 KF_CATEGORY_PERUSER
,
1797 FOLDERID_LocalAppData
, GUID_NULL
,
1802 KNOWN_FOLDER(FOLDERID_UserProgramFilesCommon
,
1804 "UserProgramFilesCommon",
1805 KF_CATEGORY_PERUSER
,
1806 FOLDERID_UserProgramFiles
, GUID_NULL
,
1811 KNOWN_FOLDER(FOLDERID_UsersFiles
,
1814 KF_CATEGORY_VIRTUAL
,
1815 GUID_NULL
, GUID_NULL
,
1817 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\0\0",
1820 KNOWN_FOLDER(FOLDERID_UsersLibraries
,
1822 "UsersLibrariesFolder",
1823 KF_CATEGORY_VIRTUAL
,
1824 GUID_NULL
, GUID_NULL
,
1826 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\0\0",
1829 KNOWN_FOLDER(FOLDERID_Videos
,
1832 KF_CATEGORY_PERUSER
,
1833 FOLDERID_Profile
, GUID_NULL
,
1835 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{18989B1D-99B5-455B-841C-AB7C74E4DDFC}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A0953C92-50DC-43BF-BE83-3742FED03C9C}\0\0", /* win8 */
1836 FILE_ATTRIBUTE_READONLY
,
1837 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1838 KNOWN_FOLDER(FOLDERID_VideosLibrary
,
1841 KF_CATEGORY_PERUSER
,
1842 FOLDERID_Libraries
, GUID_NULL
,
1843 "Videos.library-ms\0",
1844 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{491E922F-5643-4af4-A7EB-4E7A138D8174}\0\0",
1846 KFDF_PRECREATE
| KFDF_STREAM
),
1847 KNOWN_FOLDER(FOLDERID_Windows
,
1851 GUID_NULL
, GUID_NULL
,
1856 KNOWN_FOLDER(_FOLDERID_CredentialManager
,
1858 "CredentialManager",
1860 GUID_NULL
, GUID_NULL
,
1865 KNOWN_FOLDER(_FOLDERID_CryptoKeys
,
1869 GUID_NULL
, GUID_NULL
,
1874 KNOWN_FOLDER(_FOLDERID_DpapiKeys
,
1878 GUID_NULL
, GUID_NULL
,
1883 KNOWN_FOLDER(_FOLDERID_SystemCertificates
,
1885 "SystemCertificates",
1887 GUID_NULL
, GUID_NULL
,
1895 BOOL known_folder_found
[sizeof(known_folders
)/sizeof(known_folders
[0])-1];
1897 static BOOL
is_in_strarray(const WCHAR
*needle
, const char *hay
)
1899 WCHAR wstr
[MAX_PATH
];
1908 if(strcmp(hay
, "(null)") == 0 && !needle
)
1911 ret
= MultiByteToWideChar(CP_ACP
, 0, hay
, -1, wstr
, sizeof(wstr
)/sizeof(wstr
[0]));
1914 ok(0, "Failed to convert string\n");
1918 if(lstrcmpW(wstr
, needle
) == 0)
1921 hay
+= strlen(hay
) + 1;
1927 static void check_known_folder(IKnownFolderManager
*mgr
, KNOWNFOLDERID
*folderId
)
1930 const struct knownFolderDef
*known_folder
= &known_folders
[0];
1931 int csidl
, expectedCsidl
, ret
;
1932 KNOWNFOLDER_DEFINITION kfd
;
1933 IKnownFolder
*folder
;
1935 BOOL
*current_known_folder_found
= &known_folder_found
[0];
1938 while(known_folder
->folderId
!= NULL
)
1940 if(IsEqualGUID(known_folder
->folderId
, folderId
))
1942 *current_known_folder_found
= TRUE
;
1945 if(!(known_folder
->csidl
& NO_CSIDL
))
1947 /* mask off winetest flags */
1948 expectedCsidl
= known_folder
->csidl
& 0xFFFF;
1950 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, folderId
, &csidl
);
1951 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot retrieve CSIDL for folder %s\n", known_folder
->sFolderId
);
1953 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
);
1956 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
1957 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder for %s\n", known_folder
->sFolderId
);
1960 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
1961 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder definition for %s\n", known_folder
->sFolderId
);
1964 ret
= MultiByteToWideChar(CP_ACP
, 0, known_folder
->sName
, -1, sName
, sizeof(sName
)/sizeof(sName
[0]));
1965 ok_(__FILE__
, known_folder
->line
)(ret
!= 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder
->sName
);
1967 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
));
1969 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
);
1971 ok_(__FILE__
, known_folder
->line
)(IsEqualGUID(known_folder
->fidParents
[0], &kfd
.fidParent
) ||
1972 IsEqualGUID(known_folder
->fidParents
[1], &kfd
.fidParent
),
1973 "invalid known folder parent for %s: %s retrieved\n",
1974 known_folder
->sFolderId
, wine_dbgstr_guid(&kfd
.fidParent
));
1976 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
));
1978 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
));
1980 ok_(__FILE__
, known_folder
->line
)(known_folder
->attributes
== kfd
.dwAttributes
||
1981 (known_folder
->csidl
& WINE_ATTRIBUTES_OPTIONAL
&& kfd
.dwAttributes
== 0),
1982 "invalid known folder attributes for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder
->sFolderId
, known_folder
->attributes
, kfd
.dwAttributes
);
1984 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
);
1986 FreeKnownFolderDefinitionFields(&kfd
);
1989 IKnownFolder_Release(folder
);
1995 current_known_folder_found
++;
2000 trace("unknown known folder found: %s\n", wine_dbgstr_guid(folderId
));
2002 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
2003 ok(hr
== S_OK
, "cannot get known folder for %s\n", wine_dbgstr_guid(folderId
));
2006 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
2008 ok(hr
== S_OK
, "cannot get known folder definition for %s\n", wine_dbgstr_guid(folderId
));
2011 trace(" category: %d\n", kfd
.category
);
2012 trace(" name: %s\n", wine_dbgstr_w(kfd
.pszName
));
2013 trace(" description: %s\n", wine_dbgstr_w(kfd
.pszDescription
));
2014 trace(" parent: %s\n", wine_dbgstr_guid(&kfd
.fidParent
));
2015 trace(" relative path: %s\n", wine_dbgstr_w(kfd
.pszRelativePath
));
2016 trace(" parsing name: %s\n", wine_dbgstr_w(kfd
.pszParsingName
));
2017 trace(" tooltip: %s\n", wine_dbgstr_w(kfd
.pszTooltip
));
2018 trace(" localized name: %s\n", wine_dbgstr_w(kfd
.pszLocalizedName
));
2019 trace(" icon: %s\n", wine_dbgstr_w(kfd
.pszIcon
));
2020 trace(" security: %s\n", wine_dbgstr_w(kfd
.pszSecurity
));
2021 trace(" attributes: 0x%08x\n", kfd
.dwAttributes
);
2022 trace(" flags: 0x%08x\n", kfd
.kfdFlags
);
2023 trace(" type: %s\n", wine_dbgstr_guid(&kfd
.ftidType
));
2024 FreeKnownFolderDefinitionFields(&kfd
);
2027 IKnownFolder_Release(folder
);
2033 static void test_knownFolders(void)
2035 static const WCHAR sWindows
[] = {'W','i','n','d','o','w','s',0};
2036 static const WCHAR sExample
[] = {'E','x','a','m','p','l','e',0};
2037 static const WCHAR sExample2
[] = {'E','x','a','m','p','l','e','2',0};
2038 static const WCHAR sSubFolder
[] = {'S','u','b','F','o','l','d','e','r',0};
2039 static const WCHAR sBackslash
[] = {'\\',0};
2040 static const KNOWNFOLDERID newFolderId
= {0x01234567, 0x89AB, 0xCDEF, {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x01} };
2041 static const KNOWNFOLDERID subFolderId
= {0xFEDCBA98, 0x7654, 0x3210, {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF} };
2043 IKnownFolderManager
*mgr
= NULL
;
2044 IKnownFolder
*folder
= NULL
, *subFolder
= NULL
;
2045 KNOWNFOLDERID folderId
, *folders
;
2046 KF_CATEGORY cat
= 0;
2047 KNOWNFOLDER_DEFINITION kfDefinition
, kfSubDefinition
;
2050 LPWSTR folderPath
, errorMsg
;
2051 KF_REDIRECTION_CAPABILITIES redirectionCapabilities
= 1;
2052 WCHAR sWinDir
[MAX_PATH
], sExamplePath
[MAX_PATH
], sExample2Path
[MAX_PATH
], sSubFolderPath
[MAX_PATH
], sSubFolder2Path
[MAX_PATH
];
2056 GetWindowsDirectoryW( sWinDir
, MAX_PATH
);
2058 GetTempPathW(sizeof(sExamplePath
)/sizeof(sExamplePath
[0]), sExamplePath
);
2059 lstrcatW(sExamplePath
, sExample
);
2061 GetTempPathW(sizeof(sExample2Path
)/sizeof(sExample2Path
[0]), sExample2Path
);
2062 lstrcatW(sExample2Path
, sExample2
);
2064 lstrcpyW(sSubFolderPath
, sExamplePath
);
2065 lstrcatW(sSubFolderPath
, sBackslash
);
2066 lstrcatW(sSubFolderPath
, sSubFolder
);
2068 lstrcpyW(sSubFolder2Path
, sExample2Path
);
2069 lstrcatW(sSubFolder2Path
, sBackslash
);
2070 lstrcatW(sSubFolder2Path
, sSubFolder
);
2074 hr
= CoCreateInstance(&CLSID_KnownFolderManager
, NULL
, CLSCTX_INPROC_SERVER
,
2075 &IID_IKnownFolderManager
, (LPVOID
*)&mgr
);
2076 if(hr
== REGDB_E_CLASSNOTREG
)
2077 win_skip("IKnownFolderManager unavailable\n");
2082 ok(hr
== S_OK
, "failed to create KnownFolderManager instance: 0x%08x\n", hr
);
2084 hr
= IKnownFolderManager_QueryInterface(mgr
, &IID_IMarshal
, (void**)&unk
);
2085 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2087 hr
= IKnownFolderManager_FolderIdFromCsidl(mgr
, CSIDL_WINDOWS
, &folderId
);
2088 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2089 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2091 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, &FOLDERID_Windows
, &csidl
);
2092 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2093 ok(csidl
== CSIDL_WINDOWS
, "invalid CSIDL returned\n");
2095 hr
= IKnownFolderManager_GetFolder(mgr
, &FOLDERID_Windows
, &folder
);
2096 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2099 hr
= IKnownFolder_QueryInterface(folder
, &IID_IMarshal
, (void**)&unk
);
2100 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2102 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2103 ok(hr
== S_OK
, "failed to get folder category: 0x%08x\n", hr
);
2104 ok(cat
==KF_CATEGORY_FIXED
, "invalid folder category: %d\n", cat
);
2106 hr
= IKnownFolder_GetId(folder
, &folderId
);
2107 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2108 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2110 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2111 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2112 ok(lstrcmpiW(sWinDir
, folderPath
)==0, "invalid path returned: \"%s\", expected: \"%s\"\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sWinDir
));
2113 CoTaskMemFree(folderPath
);
2115 hr
= IKnownFolder_GetRedirectionCapabilities(folder
, &redirectionCapabilities
);
2117 ok(hr
== S_OK
, "failed to get redirection capabilities: 0x%08x\n", hr
);
2119 ok(redirectionCapabilities
==0, "invalid redirection capabilities returned: %d\n", redirectionCapabilities
);
2121 hr
= IKnownFolder_SetPath(folder
, 0, sWinDir
);
2123 ok(hr
== E_INVALIDARG
, "unexpected value from SetPath: 0x%08x\n", hr
);
2125 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfDefinition
);
2126 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2129 ok(kfDefinition
.category
==KF_CATEGORY_FIXED
, "invalid folder category: 0x%08x\n", kfDefinition
.category
);
2130 ok(lstrcmpW(kfDefinition
.pszName
, sWindows
)==0, "invalid folder name: %s\n", wine_dbgstr_w(kfDefinition
.pszName
));
2131 ok(kfDefinition
.dwAttributes
==0, "invalid folder attributes: %d\n", kfDefinition
.dwAttributes
);
2132 FreeKnownFolderDefinitionFields(&kfDefinition
);
2135 hr
= IKnownFolder_Release(folder
);
2136 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2139 hr
= IKnownFolderManager_GetFolderByName(mgr
, sWindows
, &folder
);
2141 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2144 hr
= IKnownFolder_GetId(folder
, &folderId
);
2145 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2146 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2148 hr
= IKnownFolder_Release(folder
);
2149 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2152 for(i
=0; i
<sizeof(known_folder_found
)/sizeof(known_folder_found
[0]); ++i
)
2153 known_folder_found
[i
] = FALSE
;
2155 hr
= IKnownFolderManager_GetFolderIds(mgr
, &folders
, &nCount
);
2156 ok(hr
== S_OK
, "failed to get known folders: 0x%08x\n", hr
);
2157 for(i
=0;i
<nCount
;++i
)
2158 check_known_folder(mgr
, &folders
[i
]);
2160 for(i
=0; i
<sizeof(known_folder_found
)/sizeof(known_folder_found
[0]); ++i
)
2161 if(!known_folder_found
[i
])
2162 trace("Known folder %s not found on current platform\n", known_folders
[i
].sFolderId
);
2164 CoTaskMemFree(folders
);
2166 /* test of registering new known folders */
2167 bRes
= CreateDirectoryW(sExamplePath
, NULL
);
2168 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExamplePath
));
2169 bRes
= CreateDirectoryW(sExample2Path
, NULL
);
2170 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExample2Path
));
2171 bRes
= CreateDirectoryW(sSubFolderPath
, NULL
);
2172 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolderPath
));
2174 ZeroMemory(&kfDefinition
, sizeof(kfDefinition
));
2175 kfDefinition
.category
= KF_CATEGORY_PERUSER
;
2176 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample
));
2177 lstrcpyW(kfDefinition
.pszName
, sExample
);
2178 kfDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sExample
));
2179 lstrcpyW(kfDefinition
.pszDescription
, sExample
);
2180 kfDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sExamplePath
));
2181 lstrcpyW(kfDefinition
.pszRelativePath
, sExamplePath
);
2183 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2184 if(hr
== HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED
))
2185 win_skip("No permissions required to register custom known folder\n");
2188 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2191 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2192 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2195 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2196 ok(hr
== S_OK
, "failed to get folder category: hr=0x%0x\n", hr
);
2197 ok(cat
== KF_CATEGORY_PERUSER
, "invalid category returned: %d, while %d (KF_CATEGORY_PERUSER) expected\n", cat
, KF_CATEGORY_PERUSER
);
2199 hr
= IKnownFolder_GetId(folder
, &folderId
);
2200 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2201 ok(IsEqualGUID(&folderId
, &newFolderId
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2203 /* current path should be Temp\Example */
2204 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2205 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2206 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2207 CoTaskMemFree(folderPath
);
2209 /* register sub-folder and mark it as child of Example folder */
2210 ZeroMemory(&kfSubDefinition
, sizeof(kfSubDefinition
));
2211 kfSubDefinition
.category
= KF_CATEGORY_PERUSER
;
2212 kfSubDefinition
.pszName
= CoTaskMemAlloc(sizeof(sSubFolder
));
2213 lstrcpyW(kfSubDefinition
.pszName
, sSubFolder
);
2214 kfSubDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sSubFolder
));
2215 lstrcpyW(kfSubDefinition
.pszDescription
, sSubFolder
);
2216 kfSubDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sSubFolder
));
2217 lstrcpyW(kfSubDefinition
.pszRelativePath
, sSubFolder
);
2218 kfSubDefinition
.fidParent
= newFolderId
;
2220 hr
= IKnownFolderManager_RegisterFolder(mgr
, &subFolderId
, &kfSubDefinition
);
2221 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2225 hr
= IKnownFolderManager_GetFolder(mgr
, &subFolderId
, &subFolder
);
2226 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2229 /* check sub folder path */
2230 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2231 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2232 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2233 CoTaskMemFree(folderPath
);
2236 /* try to redirect Example to Temp\Example2 */
2237 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2238 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2241 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2242 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2243 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2244 CoTaskMemFree(folderPath
);
2246 /* verify sub folder - it should fail now, as we redirected its parent folder, but we have no sub folder in new location */
2247 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2248 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "unexpected value from GetPath(): 0x%08x\n", hr
);
2249 ok(folderPath
==NULL
, "invalid known folder path retrieved: \"%s\" when NULL pointer was expected\n", wine_dbgstr_w(folderPath
));
2250 CoTaskMemFree(folderPath
);
2253 /* set Example path to original. Using SetPath() is valid here, as it also uses redirection internally */
2254 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2255 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2258 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2259 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2260 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2261 CoTaskMemFree(folderPath
);
2264 /* create sub folder in Temp\Example2 */
2265 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2266 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2268 /* again perform that same redirection */
2269 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2270 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2272 /* verify sub folder. It should succeed now, as the required sub folder exists */
2273 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2274 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2275 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2276 CoTaskMemFree(folderPath
);
2278 /* remove newly created directory */
2279 RemoveDirectoryW(sSubFolder2Path
);
2281 /* verify subfolder. It still succeeds, so Windows does not check folder presence each time */
2282 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2284 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2286 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2287 CoTaskMemFree(folderPath
);
2290 /* set Example path to original */
2291 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2292 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2295 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2296 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2297 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2298 CoTaskMemFree(folderPath
);
2300 /* verify sub folder */
2301 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2302 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2303 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2304 CoTaskMemFree(folderPath
);
2307 /* create sub folder in Temp\Example2 */
2308 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2309 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2311 /* do that same redirection, but try to exclude sub-folder */
2312 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 1, &subFolderId
, &errorMsg
);
2313 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2316 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2317 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2318 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2319 CoTaskMemFree(folderPath
);
2321 /* 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 */
2322 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2323 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2324 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2325 CoTaskMemFree(folderPath
);
2327 /* remove newly created directory */
2328 RemoveDirectoryW(sSubFolder2Path
);
2331 /* set Example path to original */
2332 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2333 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2336 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2337 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2338 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2339 CoTaskMemFree(folderPath
);
2341 /* verify sub folder */
2342 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2343 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2344 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2345 CoTaskMemFree(folderPath
);
2348 /* do that same redirection again, but set it to copy content. It should also copy the sub folder, so checking it would succeed now */
2349 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2350 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2353 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2354 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2355 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2356 CoTaskMemFree(folderPath
);
2358 /* verify sub folder */
2359 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2360 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2361 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2362 CoTaskMemFree(folderPath
);
2364 /* remove copied directory */
2365 RemoveDirectoryW(sSubFolder2Path
);
2368 /* set Example path to original */
2369 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2370 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2373 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2374 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2375 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2376 CoTaskMemFree(folderPath
);
2378 /* verify sub folder */
2379 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2380 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2381 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2382 CoTaskMemFree(folderPath
);
2385 /* redirect again, set it to copy content and remove originals */
2386 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
| KF_REDIRECT_DEL_SOURCE_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2387 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2390 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2391 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2392 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2393 CoTaskMemFree(folderPath
);
2395 /* verify sub folder */
2396 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2397 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2398 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2399 CoTaskMemFree(folderPath
);
2401 /* check if original directory was really removed */
2402 dwAttributes
= GetFileAttributesW(sExamplePath
);
2403 ok(dwAttributes
==INVALID_FILE_ATTRIBUTES
, "directory should not exist, but has attributes: 0x%08x\n", dwAttributes
);
2406 /* redirect (with copy) to original path */
2407 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExamplePath
, 0, NULL
, &errorMsg
);
2408 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2411 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2412 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2413 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2414 CoTaskMemFree(folderPath
);
2416 /* verify sub folder */
2417 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2418 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2419 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2420 CoTaskMemFree(folderPath
);
2422 /* check shell utility functions */
2423 if(!pSHGetKnownFolderPath
|| !pSHSetKnownFolderPath
)
2425 win_skip("cannot get SHGet/SetKnownFolderPath routines\n");
2428 /* try to get current known folder path */
2429 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2431 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2433 ok(lstrcmpW(folderPath
, sExamplePath
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2435 /* set it to new value */
2436 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExample2Path
);
2438 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2440 /* check if it changed */
2441 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2443 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2445 ok(lstrcmpW(folderPath
, sExample2Path
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2448 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExamplePath
);
2450 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2453 IKnownFolder_Release(subFolder
);
2456 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &subFolderId
);
2457 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2460 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2462 hr
= IKnownFolder_Release(folder
);
2463 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2465 /* update the folder */
2466 CoTaskMemFree(kfDefinition
.pszName
);
2467 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample2
));
2468 lstrcpyW(kfDefinition
.pszName
, sExample2
);
2469 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2470 ok(hr
== S_OK
, "failed to re-register known folder: 0x%08x\n", hr
);
2472 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2473 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2475 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfSubDefinition
);
2476 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2477 ok(!memcmp(kfDefinition
.pszName
, kfSubDefinition
.pszName
, sizeof(sExample2
)),
2478 "Got wrong updated name: %s\n", wine_dbgstr_w(kfSubDefinition
.pszName
));
2480 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2482 hr
= IKnownFolder_Release(folder
);
2483 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2486 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &newFolderId
);
2487 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2490 FreeKnownFolderDefinitionFields(&kfDefinition
);
2492 RemoveDirectoryW(sSubFolder2Path
);
2493 RemoveDirectoryW(sSubFolderPath
);
2494 RemoveDirectoryW(sExamplePath
);
2495 RemoveDirectoryW(sExample2Path
);
2497 hr
= IKnownFolderManager_Release(mgr
);
2498 ok(hr
== S_OK
, "failed to release KnownFolderManager instance: 0x%08x\n", hr
);
2504 static void test_DoEnvironmentSubst(void)
2506 WCHAR expectedW
[MAX_PATH
];
2507 WCHAR bufferW
[MAX_PATH
];
2508 CHAR expectedA
[MAX_PATH
];
2509 CHAR bufferA
[MAX_PATH
];
2514 static const WCHAR does_not_existW
[] = {'%','D','O','E','S','_','N','O','T','_','E','X','I','S','T','%',0};
2515 static const CHAR does_not_existA
[] = "%DOES_NOT_EXIST%";
2516 static const CHAR
*names
[] = {
2517 /* interactive apps and services (works on all windows versions) */
2518 "%ALLUSERSPROFILE%", "%APPDATA%", "%LOCALAPPDATA%",
2519 "%NUMBER_OF_PROCESSORS%", "%OS%", "%PROCESSOR_ARCHITECTURE%",
2520 "%PROCESSOR_IDENTIFIER%", "%PROCESSOR_LEVEL%", "%PROCESSOR_REVISION%",
2521 "%ProgramFiles%", "%SystemDrive%",
2522 "%SystemRoot%", "%USERPROFILE%", "%windir%",
2523 /* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
2525 /* replace more than one var is allowed */
2526 "%HOMEDRIVE%%HOMEPATH%",
2527 "%OS% %windir%"}; /* always the last entry in the table */
2529 for (i
= 0; i
< (sizeof(names
)/sizeof(LPSTR
)); i
++)
2531 memset(bufferA
, '#', MAX_PATH
- 1);
2532 bufferA
[MAX_PATH
- 1] = 0;
2533 lstrcpyA(bufferA
, names
[i
]);
2534 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2536 res2
= ExpandEnvironmentStringsA(names
[i
], expectedA
, MAX_PATH
);
2537 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2539 /* is the space for the terminating 0 included? */
2540 if (!i
&& HIWORD(res
) && (LOWORD(res
) == (lstrlenA(bufferA
))))
2542 win_skip("DoEnvironmentSubstA/W are broken on NT 4\n");
2545 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2546 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2547 ok(!lstrcmpA(bufferA
, expectedA
),
2548 "%d: got %s (expected %s)\n", i
, bufferA
, expectedA
);
2550 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2551 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2552 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2553 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2554 ok(!lstrcmpW(bufferW
, expectedW
),
2555 "%d: got %s (expected %s)\n", i
, wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2558 i
--; /* reuse data in the last table entry */
2559 len
= LOWORD(res
); /* needed length */
2561 /* one character extra is fine */
2562 memset(bufferA
, '#', MAX_PATH
- 1);
2563 bufferA
[len
+ 2] = 0;
2564 lstrcpyA(bufferA
, names
[i
]);
2565 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2567 res2
= ExpandEnvironmentStringsA(bufferA
, expectedA
, MAX_PATH
);
2568 res
= DoEnvironmentSubstA(bufferA
, len
+ 1);
2569 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2570 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2571 ok(!lstrcmpA(bufferA
, expectedA
),
2572 "+1: got %s (expected %s)\n", bufferA
, expectedA
);
2574 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2575 res
= DoEnvironmentSubstW(bufferW
, len
+ 1);
2576 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2577 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2578 ok(!lstrcmpW(bufferW
, expectedW
),
2579 "+1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2582 /* minimal buffer length (result string and terminating 0) */
2583 memset(bufferA
, '#', MAX_PATH
- 1);
2584 bufferA
[len
+ 2] = 0;
2585 lstrcpyA(bufferA
, names
[i
]);
2586 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2588 /* ANSI version failed without an extra byte, as documented on msdn */
2589 res
= DoEnvironmentSubstA(bufferA
, len
);
2590 ok(!HIWORD(res
) && (LOWORD(res
) == len
),
2591 " 0: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
);
2592 ok(!lstrcmpA(bufferA
, names
[i
]),
2593 " 0: got %s (expected %s)\n", bufferA
, names
[i
]);
2595 /* DoEnvironmentSubstW works as expected */
2596 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2597 res
= DoEnvironmentSubstW(bufferW
, len
);
2598 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2599 " 0: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2600 ok(!lstrcmpW(bufferW
, expectedW
),
2601 " 0: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2604 /* Buffer too small */
2605 /* result: FALSE / provided buffer length / the buffer is untouched */
2606 memset(bufferA
, '#', MAX_PATH
- 1);
2607 bufferA
[len
+ 2] = 0;
2608 lstrcpyA(bufferA
, names
[i
]);
2609 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2611 res
= DoEnvironmentSubstA(bufferA
, len
- 1);
2612 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2613 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2614 ok(!lstrcmpA(bufferA
, names
[i
]),
2615 "-1: got %s (expected %s)\n", bufferA
, names
[i
]);
2617 lstrcpyW(expectedW
, bufferW
);
2618 res
= DoEnvironmentSubstW(bufferW
, len
- 1);
2619 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2620 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2621 ok(!lstrcmpW(bufferW
, expectedW
),
2622 "-1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2625 /* unknown variable */
2626 /* result: TRUE / string length including terminating 0 / the buffer is untouched */
2627 memset(bufferA
, '#', MAX_PATH
- 1);
2628 bufferA
[MAX_PATH
- 1] = 0;
2629 lstrcpyA(bufferA
, does_not_existA
);
2630 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2632 res2
= lstrlenA(does_not_existA
) + 1;
2633 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2634 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2635 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2636 ok(!lstrcmpA(bufferA
, does_not_existA
),
2637 "%d: got %s (expected %s)\n", i
, bufferA
, does_not_existA
);
2639 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2640 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2641 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2642 ok(!lstrcmpW(bufferW
, does_not_existW
),
2643 "%d: got %s (expected %s)\n", i
, wine_dbgstr_w(bufferW
), wine_dbgstr_w(does_not_existW
));
2648 /* NULL crashes on windows */
2649 res
= DoEnvironmentSubstA(NULL
, MAX_PATH
);
2650 res
= DoEnvironmentSubstW(NULL
, MAX_PATH
);
2654 static void test_PathYetAnotherMakeUniqueName(void)
2656 static const WCHAR shortW
[] = {'f','i','l','e','.','t','s','t',0};
2657 static const WCHAR short2W
[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
2658 static const WCHAR tmpW
[] = {'t','m','p',0};
2659 static const WCHAR longW
[] = {'n','a','m','e',0};
2660 static const WCHAR long2W
[] = {'n','a','m','e',' ','(','2',')',0};
2661 WCHAR nameW
[MAX_PATH
], buffW
[MAX_PATH
], pathW
[MAX_PATH
];
2665 if (!pPathYetAnotherMakeUniqueName
)
2667 win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
2673 /* crashes on Windows */
2674 ret
= pPathYetAnotherMakeUniqueName(NULL
, NULL
, NULL
, NULL
);
2675 ok(!ret
, "got %d\n", ret
);
2677 ret
= pPathYetAnotherMakeUniqueName(nameW
, NULL
, NULL
, NULL
);
2678 ok(!ret
, "got %d\n", ret
);
2681 GetTempPathW(sizeof(pathW
)/sizeof(WCHAR
), pathW
);
2683 /* Using short name only first */
2685 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2686 ok(ret
, "got %d\n", ret
);
2687 lstrcpyW(buffW
, pathW
);
2688 lstrcatW(buffW
, shortW
);
2689 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2691 /* now create a file with this name and get next name */
2692 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2693 ok(file
!= NULL
, "got %p\n", file
);
2696 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2697 ok(ret
, "got %d\n", ret
);
2698 lstrcpyW(buffW
, pathW
);
2699 lstrcatW(buffW
, short2W
);
2700 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2704 /* Using short and long */
2706 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2707 ok(ret
, "got %d\n", ret
);
2708 lstrcpyW(buffW
, pathW
);
2709 lstrcatW(buffW
, longW
);
2710 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2712 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2713 ok(file
!= NULL
, "got %p\n", file
);
2716 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2717 ok(ret
, "got %d\n", ret
);
2718 lstrcpyW(buffW
, pathW
);
2719 lstrcatW(buffW
, long2W
);
2720 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2724 /* Using long only */
2726 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, NULL
, longW
);
2727 ok(ret
, "got %d\n", ret
);
2728 lstrcpyW(buffW
, pathW
);
2729 lstrcatW(buffW
, longW
);
2730 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2733 static void test_SHGetKnownFolderIDList(void)
2735 PIDLIST_ABSOLUTE pidl
;
2738 if (!pSHGetKnownFolderIDList
)
2740 win_skip("SHGetKnownFolderIDList is not available.\n");
2744 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, NULL
);
2745 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2747 if (0) { /* crashes on native */
2748 pidl
= (void*)0xdeadbeef;
2749 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, &pidl
);
2751 /* not a known folder */
2752 pidl
= (void*)0xdeadbeef;
2753 hr
= pSHGetKnownFolderIDList(&IID_IUnknown
, 0, NULL
, &pidl
);
2754 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
2755 ok(pidl
== NULL
, "got %p\n", pidl
);
2757 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, NULL
);
2758 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2760 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, &pidl
);
2761 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
2762 CoTaskMemFree(pidl
);
2765 START_TEST(shellpath
)
2767 if (!init()) return;
2770 pGetSystemWow64DirectoryA
= (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
2771 "GetSystemWow64DirectoryA" );
2776 /* Report missing functions once */
2777 if (!pSHGetFolderLocation
)
2778 win_skip("SHGetFolderLocation is not available\n");
2780 /* first test various combinations of parameters: */
2783 /* check known values: */
2789 test_NonExistentPath();
2790 test_SHGetFolderPathEx();
2791 test_knownFolders();
2792 test_DoEnvironmentSubst();
2793 test_PathYetAnotherMakeUniqueName();
2794 test_SHGetKnownFolderIDList();