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
.wShowWindow
= 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
.wShowWindow
= 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
, KF_FLAG_DEFAULT_PATH
, NULL
, &path
);
864 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
865 ok(path
!= NULL
, "expected path != NULL\n");
869 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, 0, NULL
, &path
);
870 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
871 ok(path
!= NULL
, "expected path != NULL\n");
873 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, MAX_PATH
);
874 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
875 ok(!lstrcmpiW(path
, buffer
), "expected equal paths\n");
876 len
= lstrlenW(buffer
);
879 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, 0);
880 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
882 if (0) { /* crashes */
883 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, NULL
, len
+ 1);
884 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
886 hr
= pSHGetFolderPathEx(NULL
, 0, NULL
, buffer
, MAX_PATH
);
887 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
889 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
);
890 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr
);
892 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
+ 1);
893 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
896 /* Standard CSIDL values (and their flags) uses only two less-significant bytes */
897 #define NO_CSIDL 0x10000
898 #define WINE_ATTRIBUTES_OPTIONAL 0x20000
899 #define KNOWN_FOLDER(id, csidl, name, category, parent1, parent2, relative_path, parsing_name, attributes, definitionFlags) \
900 { &id, # id, csidl, # csidl, name, category, {&parent1, &parent2}, relative_path, parsing_name, attributes, definitionFlags, __LINE__ }
902 /* non-published known folders test */
903 static const GUID _FOLDERID_CryptoKeys
= {0xB88F4DAA, 0xE7BD, 0x49A9, {0xB7, 0x4D, 0x02, 0x88, 0x5A, 0x5D, 0xC7, 0x65} };
904 static const GUID _FOLDERID_DpapiKeys
= {0x10C07CD0, 0xEF91, 0x4567, {0xB8, 0x50, 0x44, 0x8B, 0x77, 0xCB, 0x37, 0xF9} };
905 static const GUID _FOLDERID_SystemCertificates
= {0x54EED2E0, 0xE7CA, 0x4FDB, {0x91, 0x48, 0x0F, 0x42, 0x47, 0x29, 0x1C, 0xFA} };
906 static const GUID _FOLDERID_CredentialManager
= {0x915221FB, 0x9EFE, 0x4BDA, {0x8F, 0xD7, 0xF7, 0x8D, 0xCA, 0x77, 0x4F, 0x87} };
908 struct knownFolderDef
{
909 const KNOWNFOLDERID
*folderId
;
910 const char *sFolderId
;
914 const KF_CATEGORY category
;
915 const KNOWNFOLDERID
*fidParents
[2];
916 const char *sRelativePath
;
917 const char *sParsingName
;
918 const DWORD attributes
;
919 const KF_DEFINITION_FLAGS definitionFlags
;
923 /* Note: content of parsing name may vary between Windows versions.
924 * As a base, values from 6.0 (Vista) were used. Some entries may contain
925 * alternative values. In that case, Windows version where the value was
928 * The list of values for parsing name was encoded as a number of null-
929 * terminated strings placed one by one (separated by null byte only).
930 * End of list is marked by two consecutive null bytes.
932 static const struct knownFolderDef known_folders
[] = {
933 KNOWN_FOLDER(FOLDERID_AddNewPrograms
,
935 "AddNewProgramsFolder",
937 GUID_NULL
, GUID_NULL
,
939 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0"
940 "shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0\0" /* 6.1 */,
943 KNOWN_FOLDER(FOLDERID_AdminTools
,
945 "Administrative Tools",
947 FOLDERID_Programs
, GUID_NULL
,
948 "Administrative Tools",
950 FILE_ATTRIBUTE_READONLY
,
952 KNOWN_FOLDER(FOLDERID_AppUpdates
,
956 GUID_NULL
, GUID_NULL
,
958 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0"
959 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0\0" /* 6.1 */,
962 KNOWN_FOLDER(FOLDERID_CDBurning
,
966 FOLDERID_LocalAppData
, GUID_NULL
,
967 "Microsoft\\Windows\\Burn\\Burn",
969 FILE_ATTRIBUTE_READONLY
,
970 KFDF_LOCAL_REDIRECT_ONLY
),
971 KNOWN_FOLDER(FOLDERID_ChangeRemovePrograms
,
973 "ChangeRemoveProgramsFolder",
975 GUID_NULL
, GUID_NULL
,
977 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0"
978 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0\0" /* 6.1 */,
981 KNOWN_FOLDER(FOLDERID_CommonAdminTools
,
982 CSIDL_COMMON_ADMINTOOLS
,
983 "Common Administrative Tools",
985 FOLDERID_CommonPrograms
, GUID_NULL
,
986 "Administrative Tools",
988 FILE_ATTRIBUTE_READONLY
,
990 KNOWN_FOLDER(FOLDERID_CommonOEMLinks
,
991 CSIDL_COMMON_OEM_LINKS
,
994 FOLDERID_ProgramData
, GUID_NULL
,
999 KNOWN_FOLDER(FOLDERID_CommonPrograms
,
1000 CSIDL_COMMON_PROGRAMS
,
1003 FOLDERID_CommonStartMenu
, GUID_NULL
,
1006 FILE_ATTRIBUTE_READONLY
,
1008 KNOWN_FOLDER(FOLDERID_CommonStartMenu
,
1009 CSIDL_COMMON_STARTMENU
,
1010 "Common Start Menu",
1012 FOLDERID_ProgramData
, GUID_NULL
,
1013 "Microsoft\\Windows\\Start Menu\0",
1015 FILE_ATTRIBUTE_READONLY
,
1017 KNOWN_FOLDER(FOLDERID_CommonStartup
,
1018 CSIDL_COMMON_STARTUP
,
1021 FOLDERID_CommonPrograms
, GUID_NULL
,
1024 FILE_ATTRIBUTE_READONLY
,
1026 KNOWN_FOLDER(FOLDERID_CommonTemplates
,
1027 CSIDL_COMMON_TEMPLATES
,
1030 FOLDERID_ProgramData
, GUID_NULL
,
1031 "Microsoft\\Windows\\Templates\0",
1035 KNOWN_FOLDER(FOLDERID_ComputerFolder
,
1038 KF_CATEGORY_VIRTUAL
,
1039 GUID_NULL
, GUID_NULL
,
1041 "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\0\0",
1044 KNOWN_FOLDER(FOLDERID_ConflictFolder
,
1047 KF_CATEGORY_VIRTUAL
,
1048 GUID_NULL
, GUID_NULL
,
1050 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0"
1051 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0\0" /* 6.1 */,
1054 KNOWN_FOLDER(FOLDERID_ConnectionsFolder
,
1056 "ConnectionsFolder",
1057 KF_CATEGORY_VIRTUAL
,
1058 GUID_NULL
, GUID_NULL
,
1060 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0"
1061 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0\0" /* 6.1 */,
1064 KNOWN_FOLDER(FOLDERID_Contacts
,
1067 KF_CATEGORY_PERUSER
,
1068 FOLDERID_Profile
, GUID_NULL
,
1070 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{56784854-C6CB-462B-8169-88E350ACB882}\0\0",
1071 FILE_ATTRIBUTE_READONLY
,
1072 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1073 KNOWN_FOLDER(FOLDERID_ControlPanelFolder
,
1075 "ControlPanelFolder",
1076 KF_CATEGORY_VIRTUAL
,
1077 GUID_NULL
, GUID_NULL
,
1079 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\0"
1080 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\0\0" /* 6.1 */,
1083 KNOWN_FOLDER(FOLDERID_Cookies
,
1086 KF_CATEGORY_PERUSER
,
1087 FOLDERID_RoamingAppData
, FOLDERID_LocalAppData
,
1088 "Microsoft\\Windows\\Cookies\0Microsoft\\Windows\\INetCookies\0" /* win8 */,
1092 KNOWN_FOLDER(FOLDERID_Desktop
,
1095 KF_CATEGORY_PERUSER
,
1096 FOLDERID_Profile
, GUID_NULL
,
1099 FILE_ATTRIBUTE_READONLY
,
1100 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1101 KNOWN_FOLDER(FOLDERID_DeviceMetadataStore
,
1103 "Device Metadata Store",
1105 FOLDERID_ProgramData
, GUID_NULL
,
1106 "Microsoft\\Windows\\DeviceMetadataStore\0",
1110 KNOWN_FOLDER(FOLDERID_Documents
,
1113 KF_CATEGORY_PERUSER
,
1114 FOLDERID_Profile
, GUID_NULL
,
1116 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{FDD39AD0-238F-46AF-ADB4-6C85480369C7}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}\0\0", /* win8 */
1117 FILE_ATTRIBUTE_READONLY
,
1118 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1119 KNOWN_FOLDER(FOLDERID_DocumentsLibrary
,
1122 KF_CATEGORY_PERUSER
,
1123 FOLDERID_Libraries
, GUID_NULL
,
1124 "Documents.library-ms\0",
1125 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{7b0db17d-9cd2-4a93-9733-46cc89022e7c}\0\0",
1127 KFDF_PRECREATE
| KFDF_STREAM
),
1128 KNOWN_FOLDER(FOLDERID_Downloads
,
1131 KF_CATEGORY_PERUSER
,
1132 FOLDERID_Profile
, GUID_NULL
,
1134 "(null)\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{374DE290-123F-4565-9164-39C4925E467B}\0\0", /* win8 */
1135 FILE_ATTRIBUTE_READONLY
,
1136 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1137 KNOWN_FOLDER(FOLDERID_Favorites
,
1140 KF_CATEGORY_PERUSER
,
1141 FOLDERID_Profile
, GUID_NULL
,
1144 FILE_ATTRIBUTE_READONLY
,
1145 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1146 KNOWN_FOLDER(FOLDERID_Fonts
,
1150 FOLDERID_Windows
, GUID_NULL
,
1155 KNOWN_FOLDER(FOLDERID_Games
,
1158 KF_CATEGORY_VIRTUAL
,
1159 GUID_NULL
, GUID_NULL
,
1161 "::{ED228FDF-9EA8-4870-83b1-96b02CFE0D52}\0\0",
1164 KNOWN_FOLDER(FOLDERID_GameTasks
,
1167 KF_CATEGORY_PERUSER
,
1168 FOLDERID_LocalAppData
, GUID_NULL
,
1169 "Microsoft\\Windows\\GameExplorer\0",
1172 KFDF_LOCAL_REDIRECT_ONLY
),
1173 KNOWN_FOLDER(FOLDERID_History
,
1176 KF_CATEGORY_PERUSER
,
1177 FOLDERID_LocalAppData
, GUID_NULL
,
1178 "Microsoft\\Windows\\History\0",
1181 KFDF_LOCAL_REDIRECT_ONLY
),
1182 KNOWN_FOLDER(FOLDERID_HomeGroup
,
1185 KF_CATEGORY_VIRTUAL
,
1186 GUID_NULL
, GUID_NULL
,
1188 "::{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\0\0",
1191 KNOWN_FOLDER(FOLDERID_ImplicitAppShortcuts
,
1193 "ImplicitAppShortcuts",
1194 KF_CATEGORY_PERUSER
,
1195 FOLDERID_UserPinned
, GUID_NULL
,
1196 "ImplicitAppShortcuts\0",
1200 KNOWN_FOLDER(FOLDERID_InternetCache
,
1201 CSIDL_INTERNET_CACHE
,
1203 KF_CATEGORY_PERUSER
,
1204 FOLDERID_LocalAppData
, GUID_NULL
,
1205 "Microsoft\\Windows\\Temporary Internet Files\0Microsoft\\Windows\\INetCache\0\0", /* win8 */
1208 KFDF_LOCAL_REDIRECT_ONLY
),
1209 KNOWN_FOLDER(FOLDERID_InternetFolder
,
1212 KF_CATEGORY_VIRTUAL
,
1213 GUID_NULL
, GUID_NULL
,
1215 "::{871C5380-42A0-1069-A2EA-08002B30309D}\0\0",
1218 KNOWN_FOLDER(FOLDERID_Libraries
,
1221 KF_CATEGORY_PERUSER
,
1222 FOLDERID_RoamingAppData
, GUID_NULL
,
1223 "Microsoft\\Windows\\Libraries\0",
1226 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1227 KNOWN_FOLDER(FOLDERID_Links
,
1230 KF_CATEGORY_PERUSER
,
1231 FOLDERID_Profile
, GUID_NULL
,
1233 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}\0\0",
1234 FILE_ATTRIBUTE_READONLY
,
1235 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1236 KNOWN_FOLDER(FOLDERID_LocalAppData
,
1237 CSIDL_LOCAL_APPDATA
,
1239 KF_CATEGORY_PERUSER
,
1240 FOLDERID_Profile
, GUID_NULL
,
1244 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
),
1245 KNOWN_FOLDER(FOLDERID_LocalAppDataLow
,
1248 KF_CATEGORY_PERUSER
,
1249 FOLDERID_Profile
, GUID_NULL
,
1250 "AppData\\LocalLow\0",
1252 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
,
1253 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1254 KNOWN_FOLDER(FOLDERID_LocalizedResourcesDir
,
1255 CSIDL_RESOURCES_LOCALIZED
,
1256 "LocalizedResourcesDir",
1258 GUID_NULL
, GUID_NULL
,
1263 KNOWN_FOLDER(FOLDERID_Music
,
1266 KF_CATEGORY_PERUSER
,
1267 FOLDERID_Profile
, GUID_NULL
,
1269 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4BD8D571-6D19-48D3-BE97-422220080E43}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{1CF1260C-4DD0-4EBB-811F-33C572699FDE}\0\0", /* win8 */
1270 FILE_ATTRIBUTE_READONLY
,
1271 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1272 KNOWN_FOLDER(FOLDERID_MusicLibrary
,
1275 KF_CATEGORY_PERUSER
,
1276 FOLDERID_Libraries
, GUID_NULL
,
1277 "Music.library-ms\0",
1278 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{2112AB0A-C86A-4ffe-A368-0DE96E47012E}\0\0",
1280 KFDF_PRECREATE
| KFDF_STREAM
),
1281 KNOWN_FOLDER(FOLDERID_NetHood
,
1284 KF_CATEGORY_PERUSER
,
1285 FOLDERID_RoamingAppData
, GUID_NULL
,
1286 "Microsoft\\Windows\\Network Shortcuts\0",
1290 KNOWN_FOLDER(FOLDERID_NetworkFolder
,
1292 "NetworkPlacesFolder",
1293 KF_CATEGORY_VIRTUAL
,
1294 GUID_NULL
, GUID_NULL
,
1296 "::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\0\0",
1299 KNOWN_FOLDER(FOLDERID_OriginalImages
,
1302 KF_CATEGORY_PERUSER
,
1303 FOLDERID_LocalAppData
, GUID_NULL
,
1304 "Microsoft\\Windows Photo Gallery\\Original Images\0",
1308 KNOWN_FOLDER(FOLDERID_PhotoAlbums
,
1311 KF_CATEGORY_PERUSER
,
1312 FOLDERID_Pictures
, GUID_NULL
,
1315 FILE_ATTRIBUTE_READONLY
,
1317 KNOWN_FOLDER(FOLDERID_Pictures
,
1320 KF_CATEGORY_PERUSER
,
1321 FOLDERID_Profile
, GUID_NULL
,
1323 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{33E28130-4E1E-4676-835A-98395C3BC3BB}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{3ADD1653-EB32-4CB0-BBD7-DFA0ABB5ACCA}\0\0", /* win8 */
1324 FILE_ATTRIBUTE_READONLY
,
1325 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1326 KNOWN_FOLDER(FOLDERID_PicturesLibrary
,
1329 KF_CATEGORY_PERUSER
,
1330 FOLDERID_Libraries
, GUID_NULL
,
1331 "Pictures.library-ms\0",
1332 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{A990AE9F-A03B-4e80-94BC-9912D7504104}\0\0",
1334 KFDF_PRECREATE
| KFDF_STREAM
),
1335 KNOWN_FOLDER(FOLDERID_Playlists
,
1338 KF_CATEGORY_PERUSER
,
1339 FOLDERID_Music
, GUID_NULL
,
1342 FILE_ATTRIBUTE_READONLY
,
1344 KNOWN_FOLDER(FOLDERID_PrintersFolder
,
1347 KF_CATEGORY_VIRTUAL
,
1348 GUID_NULL
, GUID_NULL
,
1350 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}\0\0",
1353 KNOWN_FOLDER(FOLDERID_PrintHood
,
1356 KF_CATEGORY_PERUSER
,
1357 FOLDERID_RoamingAppData
, GUID_NULL
,
1358 "Microsoft\\Windows\\Printer Shortcuts\0",
1362 KNOWN_FOLDER(FOLDERID_Profile
,
1366 GUID_NULL
, GUID_NULL
,
1371 KNOWN_FOLDER(FOLDERID_ProgramData
,
1372 CSIDL_COMMON_APPDATA
,
1375 GUID_NULL
, GUID_NULL
,
1380 KNOWN_FOLDER(FOLDERID_ProgramFiles
,
1381 CSIDL_PROGRAM_FILES
,
1384 GUID_NULL
, GUID_NULL
,
1387 FILE_ATTRIBUTE_READONLY
,
1390 KNOWN_FOLDER(FOLDERID_ProgramFilesCommon
,
1391 CSIDL_PROGRAM_FILES_COMMON
,
1392 "ProgramFilesCommon",
1394 GUID_NULL
, GUID_NULL
,
1399 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX64
,
1401 "ProgramFilesCommonX64",
1403 GUID_NULL
, GUID_NULL
,
1408 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX86
,
1410 "ProgramFilesCommonX86",
1412 GUID_NULL
, GUID_NULL
,
1417 KNOWN_FOLDER(FOLDERID_ProgramFilesX64
,
1421 GUID_NULL
, GUID_NULL
,
1426 KNOWN_FOLDER(FOLDERID_ProgramFilesX86
,
1427 CSIDL_PROGRAM_FILESX86
,
1430 GUID_NULL
, GUID_NULL
,
1433 FILE_ATTRIBUTE_READONLY
,
1435 KNOWN_FOLDER(FOLDERID_Programs
,
1438 KF_CATEGORY_PERUSER
,
1439 FOLDERID_StartMenu
, GUID_NULL
,
1442 FILE_ATTRIBUTE_READONLY
,
1444 KNOWN_FOLDER(FOLDERID_Public
,
1448 GUID_NULL
, GUID_NULL
,
1450 "::{4336a54d-038b-4685-ab02-99bb52d3fb8b}\0"
1451 "(null)\0\0" /* 6.1 */,
1452 FILE_ATTRIBUTE_READONLY
,
1454 KNOWN_FOLDER(FOLDERID_PublicDesktop
,
1455 CSIDL_COMMON_DESKTOPDIRECTORY
,
1458 FOLDERID_Public
, GUID_NULL
,
1461 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
1463 KNOWN_FOLDER(FOLDERID_PublicDocuments
,
1464 CSIDL_COMMON_DOCUMENTS
,
1467 FOLDERID_Public
, GUID_NULL
,
1470 FILE_ATTRIBUTE_READONLY
,
1472 KNOWN_FOLDER(FOLDERID_PublicDownloads
,
1476 FOLDERID_Public
, GUID_NULL
,
1479 FILE_ATTRIBUTE_READONLY
,
1481 KNOWN_FOLDER(FOLDERID_PublicGameTasks
,
1485 FOLDERID_ProgramData
, GUID_NULL
,
1486 "Microsoft\\Windows\\GameExplorer\0",
1489 KFDF_LOCAL_REDIRECT_ONLY
),
1490 KNOWN_FOLDER(FOLDERID_PublicLibraries
,
1494 FOLDERID_Public
, GUID_NULL
,
1497 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
1499 KNOWN_FOLDER(FOLDERID_PublicMusic
,
1503 FOLDERID_Public
, GUID_NULL
,
1506 FILE_ATTRIBUTE_READONLY
,
1508 KNOWN_FOLDER(FOLDERID_PublicPictures
,
1509 CSIDL_COMMON_PICTURES
,
1512 FOLDERID_Public
, GUID_NULL
,
1515 FILE_ATTRIBUTE_READONLY
,
1517 KNOWN_FOLDER(FOLDERID_PublicRingtones
,
1521 FOLDERID_ProgramData
, GUID_NULL
,
1522 "Microsoft\\Windows\\Ringtones\0",
1526 KNOWN_FOLDER(FOLDERID_PublicVideos
,
1530 FOLDERID_Public
, GUID_NULL
,
1533 FILE_ATTRIBUTE_READONLY
,
1535 KNOWN_FOLDER(FOLDERID_QuickLaunch
,
1538 KF_CATEGORY_PERUSER
,
1539 FOLDERID_RoamingAppData
, GUID_NULL
,
1540 "Microsoft\\Internet Explorer\\Quick Launch\0",
1544 KNOWN_FOLDER(FOLDERID_Recent
,
1547 KF_CATEGORY_PERUSER
,
1548 FOLDERID_RoamingAppData
, GUID_NULL
,
1549 "Microsoft\\Windows\\Recent\0",
1551 FILE_ATTRIBUTE_READONLY
,
1553 KNOWN_FOLDER(FOLDERID_RecordedTVLibrary
,
1555 "RecordedTVLibrary",
1557 FOLDERID_PublicLibraries
, GUID_NULL
,
1558 "RecordedTV.library-ms\0",
1561 KFDF_PRECREATE
| KFDF_STREAM
),
1562 KNOWN_FOLDER(FOLDERID_RecycleBinFolder
,
1565 KF_CATEGORY_VIRTUAL
,
1566 GUID_NULL
, GUID_NULL
,
1568 "::{645FF040-5081-101B-9F08-00AA002F954E}\0\0",
1571 KNOWN_FOLDER(FOLDERID_ResourceDir
,
1575 GUID_NULL
, GUID_NULL
,
1580 KNOWN_FOLDER(FOLDERID_Ringtones
,
1583 KF_CATEGORY_PERUSER
,
1584 FOLDERID_LocalAppData
, GUID_NULL
,
1585 "Microsoft\\Windows\\Ringtones\0",
1589 KNOWN_FOLDER(FOLDERID_RoamingAppData
,
1592 KF_CATEGORY_PERUSER
,
1593 FOLDERID_Profile
, GUID_NULL
,
1594 "AppData\\Roaming\0",
1598 KNOWN_FOLDER(FOLDERID_SampleMusic
,
1599 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1602 FOLDERID_PublicMusic
, GUID_NULL
,
1605 FILE_ATTRIBUTE_READONLY
,
1607 KNOWN_FOLDER(FOLDERID_SamplePictures
,
1608 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1611 FOLDERID_PublicPictures
, GUID_NULL
,
1612 "Sample Pictures\0",
1614 FILE_ATTRIBUTE_READONLY
,
1616 KNOWN_FOLDER(FOLDERID_SamplePlaylists
,
1620 FOLDERID_PublicMusic
, GUID_NULL
,
1621 "Sample Playlists\0",
1623 FILE_ATTRIBUTE_READONLY
,
1625 KNOWN_FOLDER(FOLDERID_SampleVideos
,
1626 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1629 FOLDERID_PublicVideos
, GUID_NULL
,
1632 FILE_ATTRIBUTE_READONLY
,
1634 KNOWN_FOLDER(FOLDERID_SavedGames
,
1637 KF_CATEGORY_PERUSER
,
1638 FOLDERID_Profile
, GUID_NULL
,
1640 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}\0\0",
1641 FILE_ATTRIBUTE_READONLY
,
1642 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1643 KNOWN_FOLDER(FOLDERID_SavedSearches
,
1646 KF_CATEGORY_PERUSER
,
1647 FOLDERID_Profile
, GUID_NULL
,
1649 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{7d1d3a04-debb-4115-95cf-2f29da2920da}\0\0",
1650 FILE_ATTRIBUTE_READONLY
,
1651 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1652 KNOWN_FOLDER(FOLDERID_SEARCH_CSC
,
1655 KF_CATEGORY_VIRTUAL
,
1656 GUID_NULL
, GUID_NULL
,
1658 "shell:::{BD7A2E7B-21CB-41b2-A086-B309680C6B7E}\\*\0\0",
1661 KNOWN_FOLDER(FOLDERID_SearchHome
,
1664 KF_CATEGORY_VIRTUAL
,
1665 GUID_NULL
, GUID_NULL
,
1667 "::{9343812e-1c37-4a49-a12e-4b2d810d956b}\0\0",
1670 KNOWN_FOLDER(FOLDERID_SEARCH_MAPI
,
1673 KF_CATEGORY_VIRTUAL
,
1674 GUID_NULL
, GUID_NULL
,
1676 "shell:::{89D83576-6BD1-4C86-9454-BEB04E94C819}\\*\0\0",
1679 KNOWN_FOLDER(FOLDERID_SendTo
,
1682 KF_CATEGORY_PERUSER
,
1683 FOLDERID_RoamingAppData
, GUID_NULL
,
1684 "Microsoft\\Windows\\SendTo\0",
1688 KNOWN_FOLDER(FOLDERID_SidebarDefaultParts
,
1692 FOLDERID_ProgramFiles
, GUID_NULL
,
1693 "Windows Sidebar\\Gadgets\0",
1697 KNOWN_FOLDER(FOLDERID_SidebarParts
,
1700 KF_CATEGORY_PERUSER
,
1701 FOLDERID_LocalAppData
, GUID_NULL
,
1702 "Microsoft\\Windows Sidebar\\Gadgets\0",
1706 KNOWN_FOLDER(FOLDERID_StartMenu
,
1709 KF_CATEGORY_PERUSER
,
1710 FOLDERID_RoamingAppData
, GUID_NULL
,
1711 "Microsoft\\Windows\\Start Menu\0",
1713 FILE_ATTRIBUTE_READONLY
,
1715 KNOWN_FOLDER(FOLDERID_Startup
,
1718 KF_CATEGORY_PERUSER
,
1719 FOLDERID_Programs
, GUID_NULL
,
1722 FILE_ATTRIBUTE_READONLY
,
1724 KNOWN_FOLDER(FOLDERID_SyncManagerFolder
,
1727 KF_CATEGORY_VIRTUAL
,
1728 GUID_NULL
, GUID_NULL
,
1730 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0"
1731 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0\0" /* 6.1 */,
1734 KNOWN_FOLDER(FOLDERID_SyncResultsFolder
,
1736 "SyncResultsFolder",
1737 KF_CATEGORY_VIRTUAL
,
1738 GUID_NULL
, GUID_NULL
,
1740 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0"
1741 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0\0",
1744 KNOWN_FOLDER(FOLDERID_SyncSetupFolder
,
1747 KF_CATEGORY_VIRTUAL
,
1748 GUID_NULL
, GUID_NULL
,
1750 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0"
1751 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0\0" /* 6.1 */,
1754 KNOWN_FOLDER(FOLDERID_System
,
1758 GUID_NULL
, GUID_NULL
,
1763 KNOWN_FOLDER(FOLDERID_SystemX86
,
1767 GUID_NULL
, GUID_NULL
,
1772 KNOWN_FOLDER(FOLDERID_Templates
,
1775 KF_CATEGORY_PERUSER
,
1776 FOLDERID_RoamingAppData
, GUID_NULL
,
1777 "Microsoft\\Windows\\Templates\0",
1781 KNOWN_FOLDER(FOLDERID_UserPinned
,
1784 KF_CATEGORY_PERUSER
,
1785 FOLDERID_QuickLaunch
, GUID_NULL
,
1788 FILE_ATTRIBUTE_HIDDEN
,
1790 KNOWN_FOLDER(FOLDERID_UserProfiles
,
1794 GUID_NULL
, GUID_NULL
,
1797 FILE_ATTRIBUTE_READONLY
,
1799 KNOWN_FOLDER(FOLDERID_UserProgramFiles
,
1802 KF_CATEGORY_PERUSER
,
1803 FOLDERID_LocalAppData
, GUID_NULL
,
1808 KNOWN_FOLDER(FOLDERID_UserProgramFilesCommon
,
1810 "UserProgramFilesCommon",
1811 KF_CATEGORY_PERUSER
,
1812 FOLDERID_UserProgramFiles
, GUID_NULL
,
1817 KNOWN_FOLDER(FOLDERID_UsersFiles
,
1820 KF_CATEGORY_VIRTUAL
,
1821 GUID_NULL
, GUID_NULL
,
1823 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\0\0",
1826 KNOWN_FOLDER(FOLDERID_UsersLibraries
,
1828 "UsersLibrariesFolder",
1829 KF_CATEGORY_VIRTUAL
,
1830 GUID_NULL
, GUID_NULL
,
1832 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\0\0",
1835 KNOWN_FOLDER(FOLDERID_Videos
,
1838 KF_CATEGORY_PERUSER
,
1839 FOLDERID_Profile
, GUID_NULL
,
1841 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{18989B1D-99B5-455B-841C-AB7C74E4DDFC}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A0953C92-50DC-43BF-BE83-3742FED03C9C}\0\0", /* win8 */
1842 FILE_ATTRIBUTE_READONLY
,
1843 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1844 KNOWN_FOLDER(FOLDERID_VideosLibrary
,
1847 KF_CATEGORY_PERUSER
,
1848 FOLDERID_Libraries
, GUID_NULL
,
1849 "Videos.library-ms\0",
1850 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{491E922F-5643-4af4-A7EB-4E7A138D8174}\0\0",
1852 KFDF_PRECREATE
| KFDF_STREAM
),
1853 KNOWN_FOLDER(FOLDERID_Windows
,
1857 GUID_NULL
, GUID_NULL
,
1862 KNOWN_FOLDER(_FOLDERID_CredentialManager
,
1864 "CredentialManager",
1866 GUID_NULL
, GUID_NULL
,
1871 KNOWN_FOLDER(_FOLDERID_CryptoKeys
,
1875 GUID_NULL
, GUID_NULL
,
1880 KNOWN_FOLDER(_FOLDERID_DpapiKeys
,
1884 GUID_NULL
, GUID_NULL
,
1889 KNOWN_FOLDER(_FOLDERID_SystemCertificates
,
1891 "SystemCertificates",
1893 GUID_NULL
, GUID_NULL
,
1901 BOOL known_folder_found
[sizeof(known_folders
)/sizeof(known_folders
[0])-1];
1903 static BOOL
is_in_strarray(const WCHAR
*needle
, const char *hay
)
1905 WCHAR wstr
[MAX_PATH
];
1914 if(strcmp(hay
, "(null)") == 0 && !needle
)
1917 ret
= MultiByteToWideChar(CP_ACP
, 0, hay
, -1, wstr
, sizeof(wstr
)/sizeof(wstr
[0]));
1920 ok(0, "Failed to convert string\n");
1924 if(lstrcmpW(wstr
, needle
) == 0)
1927 hay
+= strlen(hay
) + 1;
1933 static void check_known_folder(IKnownFolderManager
*mgr
, KNOWNFOLDERID
*folderId
)
1936 const struct knownFolderDef
*known_folder
= &known_folders
[0];
1937 int csidl
, expectedCsidl
, ret
;
1938 KNOWNFOLDER_DEFINITION kfd
;
1939 IKnownFolder
*folder
;
1941 BOOL
*current_known_folder_found
= &known_folder_found
[0];
1944 while(known_folder
->folderId
!= NULL
)
1946 if(IsEqualGUID(known_folder
->folderId
, folderId
))
1948 *current_known_folder_found
= TRUE
;
1951 if(!(known_folder
->csidl
& NO_CSIDL
))
1953 /* mask off winetest flags */
1954 expectedCsidl
= known_folder
->csidl
& 0xFFFF;
1956 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, folderId
, &csidl
);
1957 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot retrieve CSIDL for folder %s\n", known_folder
->sFolderId
);
1959 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
);
1962 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
1963 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder for %s\n", known_folder
->sFolderId
);
1966 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
1967 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder definition for %s\n", known_folder
->sFolderId
);
1970 ret
= MultiByteToWideChar(CP_ACP
, 0, known_folder
->sName
, -1, sName
, sizeof(sName
)/sizeof(sName
[0]));
1971 ok_(__FILE__
, known_folder
->line
)(ret
!= 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder
->sName
);
1973 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
));
1975 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
);
1977 ok_(__FILE__
, known_folder
->line
)(IsEqualGUID(known_folder
->fidParents
[0], &kfd
.fidParent
) ||
1978 IsEqualGUID(known_folder
->fidParents
[1], &kfd
.fidParent
),
1979 "invalid known folder parent for %s: %s retrieved\n",
1980 known_folder
->sFolderId
, wine_dbgstr_guid(&kfd
.fidParent
));
1982 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
));
1984 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
));
1986 ok_(__FILE__
, known_folder
->line
)(known_folder
->attributes
== kfd
.dwAttributes
||
1987 (known_folder
->csidl
& WINE_ATTRIBUTES_OPTIONAL
&& kfd
.dwAttributes
== 0),
1988 "invalid known folder attributes for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder
->sFolderId
, known_folder
->attributes
, kfd
.dwAttributes
);
1990 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
);
1992 FreeKnownFolderDefinitionFields(&kfd
);
1995 IKnownFolder_Release(folder
);
2001 current_known_folder_found
++;
2006 trace("unknown known folder found: %s\n", wine_dbgstr_guid(folderId
));
2008 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
2009 ok(hr
== S_OK
, "cannot get known folder for %s\n", wine_dbgstr_guid(folderId
));
2012 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
2014 ok(hr
== S_OK
, "cannot get known folder definition for %s\n", wine_dbgstr_guid(folderId
));
2017 trace(" category: %d\n", kfd
.category
);
2018 trace(" name: %s\n", wine_dbgstr_w(kfd
.pszName
));
2019 trace(" description: %s\n", wine_dbgstr_w(kfd
.pszDescription
));
2020 trace(" parent: %s\n", wine_dbgstr_guid(&kfd
.fidParent
));
2021 trace(" relative path: %s\n", wine_dbgstr_w(kfd
.pszRelativePath
));
2022 trace(" parsing name: %s\n", wine_dbgstr_w(kfd
.pszParsingName
));
2023 trace(" tooltip: %s\n", wine_dbgstr_w(kfd
.pszTooltip
));
2024 trace(" localized name: %s\n", wine_dbgstr_w(kfd
.pszLocalizedName
));
2025 trace(" icon: %s\n", wine_dbgstr_w(kfd
.pszIcon
));
2026 trace(" security: %s\n", wine_dbgstr_w(kfd
.pszSecurity
));
2027 trace(" attributes: 0x%08x\n", kfd
.dwAttributes
);
2028 trace(" flags: 0x%08x\n", kfd
.kfdFlags
);
2029 trace(" type: %s\n", wine_dbgstr_guid(&kfd
.ftidType
));
2030 FreeKnownFolderDefinitionFields(&kfd
);
2033 IKnownFolder_Release(folder
);
2039 static void test_knownFolders(void)
2041 static const WCHAR sWindows
[] = {'W','i','n','d','o','w','s',0};
2042 static const WCHAR sWindows2
[] = {'w','i','n','d','o','w','s',0};
2043 static const WCHAR sExample
[] = {'E','x','a','m','p','l','e',0};
2044 static const WCHAR sExample2
[] = {'E','x','a','m','p','l','e','2',0};
2045 static const WCHAR sSubFolder
[] = {'S','u','b','F','o','l','d','e','r',0};
2046 static const WCHAR sNoSuch
[] = {'N','o','S','u','c','h',0};
2047 static const WCHAR sBackslash
[] = {'\\',0};
2048 static const KNOWNFOLDERID newFolderId
= {0x01234567, 0x89AB, 0xCDEF, {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x01} };
2049 static const KNOWNFOLDERID subFolderId
= {0xFEDCBA98, 0x7654, 0x3210, {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF} };
2051 IKnownFolderManager
*mgr
= NULL
;
2052 IKnownFolder
*folder
= NULL
, *subFolder
= NULL
;
2053 KNOWNFOLDERID folderId
, *folders
;
2054 KF_CATEGORY cat
= 0;
2055 KNOWNFOLDER_DEFINITION kfDefinition
, kfSubDefinition
;
2058 LPWSTR folderPath
, errorMsg
;
2059 KF_REDIRECTION_CAPABILITIES redirectionCapabilities
= 1;
2060 WCHAR sWinDir
[MAX_PATH
], sExamplePath
[MAX_PATH
], sExample2Path
[MAX_PATH
], sSubFolderPath
[MAX_PATH
], sSubFolder2Path
[MAX_PATH
];
2064 GetWindowsDirectoryW( sWinDir
, MAX_PATH
);
2066 GetTempPathW(sizeof(sExamplePath
)/sizeof(sExamplePath
[0]), sExamplePath
);
2067 lstrcatW(sExamplePath
, sExample
);
2069 GetTempPathW(sizeof(sExample2Path
)/sizeof(sExample2Path
[0]), sExample2Path
);
2070 lstrcatW(sExample2Path
, sExample2
);
2072 lstrcpyW(sSubFolderPath
, sExamplePath
);
2073 lstrcatW(sSubFolderPath
, sBackslash
);
2074 lstrcatW(sSubFolderPath
, sSubFolder
);
2076 lstrcpyW(sSubFolder2Path
, sExample2Path
);
2077 lstrcatW(sSubFolder2Path
, sBackslash
);
2078 lstrcatW(sSubFolder2Path
, sSubFolder
);
2082 hr
= CoCreateInstance(&CLSID_KnownFolderManager
, NULL
, CLSCTX_INPROC_SERVER
,
2083 &IID_IKnownFolderManager
, (LPVOID
*)&mgr
);
2084 if(hr
== REGDB_E_CLASSNOTREG
)
2085 win_skip("IKnownFolderManager unavailable\n");
2090 ok(hr
== S_OK
, "failed to create KnownFolderManager instance: 0x%08x\n", hr
);
2092 hr
= IKnownFolderManager_QueryInterface(mgr
, &IID_IMarshal
, (void**)&unk
);
2093 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2095 hr
= IKnownFolderManager_FolderIdFromCsidl(mgr
, CSIDL_WINDOWS
, &folderId
);
2096 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2097 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2099 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, &FOLDERID_Windows
, &csidl
);
2100 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2101 ok(csidl
== CSIDL_WINDOWS
, "invalid CSIDL returned\n");
2103 hr
= IKnownFolderManager_GetFolder(mgr
, &FOLDERID_Windows
, &folder
);
2104 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2107 hr
= IKnownFolder_QueryInterface(folder
, &IID_IMarshal
, (void**)&unk
);
2108 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2110 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2111 ok(hr
== S_OK
, "failed to get folder category: 0x%08x\n", hr
);
2112 ok(cat
==KF_CATEGORY_FIXED
, "invalid folder category: %d\n", cat
);
2114 hr
= IKnownFolder_GetId(folder
, &folderId
);
2115 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2116 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2118 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2119 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2120 ok(lstrcmpiW(sWinDir
, folderPath
)==0, "invalid path returned: \"%s\", expected: \"%s\"\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sWinDir
));
2121 CoTaskMemFree(folderPath
);
2123 hr
= IKnownFolder_GetRedirectionCapabilities(folder
, &redirectionCapabilities
);
2125 ok(hr
== S_OK
, "failed to get redirection capabilities: 0x%08x\n", hr
);
2127 ok(redirectionCapabilities
==0, "invalid redirection capabilities returned: %d\n", redirectionCapabilities
);
2129 hr
= IKnownFolder_SetPath(folder
, 0, sWinDir
);
2131 ok(hr
== E_INVALIDARG
, "unexpected value from SetPath: 0x%08x\n", hr
);
2133 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfDefinition
);
2134 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2137 ok(kfDefinition
.category
==KF_CATEGORY_FIXED
, "invalid folder category: 0x%08x\n", kfDefinition
.category
);
2138 ok(lstrcmpW(kfDefinition
.pszName
, sWindows
)==0, "invalid folder name: %s\n", wine_dbgstr_w(kfDefinition
.pszName
));
2139 ok(kfDefinition
.dwAttributes
==0, "invalid folder attributes: %d\n", kfDefinition
.dwAttributes
);
2140 FreeKnownFolderDefinitionFields(&kfDefinition
);
2143 hr
= IKnownFolder_Release(folder
);
2144 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2147 hr
= IKnownFolderManager_GetFolderByName(mgr
, sWindows
, &folder
);
2148 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2151 hr
= IKnownFolder_GetId(folder
, &folderId
);
2152 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2153 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2155 hr
= IKnownFolder_Release(folder
);
2156 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2159 hr
= IKnownFolderManager_GetFolderByName(mgr
, sWindows2
, &folder
);
2160 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2163 hr
= IKnownFolder_GetId(folder
, &folderId
);
2164 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2165 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2167 hr
= IKnownFolder_Release(folder
);
2168 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2171 folder
= (IKnownFolder
*)0xdeadbeef;
2172 hr
= IKnownFolderManager_GetFolderByName(mgr
, sNoSuch
, &folder
);
2173 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
2174 ok(folder
== NULL
, "got %p\n", folder
);
2176 for(i
=0; i
<sizeof(known_folder_found
)/sizeof(known_folder_found
[0]); ++i
)
2177 known_folder_found
[i
] = FALSE
;
2179 hr
= IKnownFolderManager_GetFolderIds(mgr
, &folders
, &nCount
);
2180 ok(hr
== S_OK
, "failed to get known folders: 0x%08x\n", hr
);
2181 for(i
=0;i
<nCount
;++i
)
2182 check_known_folder(mgr
, &folders
[i
]);
2184 for(i
=0; i
<sizeof(known_folder_found
)/sizeof(known_folder_found
[0]); ++i
)
2185 if(!known_folder_found
[i
])
2186 trace("Known folder %s not found on current platform\n", known_folders
[i
].sFolderId
);
2188 CoTaskMemFree(folders
);
2190 /* test of registering new known folders */
2191 bRes
= CreateDirectoryW(sExamplePath
, NULL
);
2192 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExamplePath
));
2193 bRes
= CreateDirectoryW(sExample2Path
, NULL
);
2194 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExample2Path
));
2195 bRes
= CreateDirectoryW(sSubFolderPath
, NULL
);
2196 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolderPath
));
2198 ZeroMemory(&kfDefinition
, sizeof(kfDefinition
));
2199 kfDefinition
.category
= KF_CATEGORY_PERUSER
;
2200 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample
));
2201 lstrcpyW(kfDefinition
.pszName
, sExample
);
2202 kfDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sExample
));
2203 lstrcpyW(kfDefinition
.pszDescription
, sExample
);
2204 kfDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sExamplePath
));
2205 lstrcpyW(kfDefinition
.pszRelativePath
, sExamplePath
);
2207 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2208 if(hr
== HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED
))
2209 win_skip("No permissions required to register custom known folder\n");
2212 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2215 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2216 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2219 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2220 ok(hr
== S_OK
, "failed to get folder category: hr=0x%0x\n", hr
);
2221 ok(cat
== KF_CATEGORY_PERUSER
, "invalid category returned: %d, while %d (KF_CATEGORY_PERUSER) expected\n", cat
, KF_CATEGORY_PERUSER
);
2223 hr
= IKnownFolder_GetId(folder
, &folderId
);
2224 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2225 ok(IsEqualGUID(&folderId
, &newFolderId
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2227 /* current path should be Temp\Example */
2228 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2229 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2230 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2231 CoTaskMemFree(folderPath
);
2233 /* register sub-folder and mark it as child of Example folder */
2234 ZeroMemory(&kfSubDefinition
, sizeof(kfSubDefinition
));
2235 kfSubDefinition
.category
= KF_CATEGORY_PERUSER
;
2236 kfSubDefinition
.pszName
= CoTaskMemAlloc(sizeof(sSubFolder
));
2237 lstrcpyW(kfSubDefinition
.pszName
, sSubFolder
);
2238 kfSubDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sSubFolder
));
2239 lstrcpyW(kfSubDefinition
.pszDescription
, sSubFolder
);
2240 kfSubDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sSubFolder
));
2241 lstrcpyW(kfSubDefinition
.pszRelativePath
, sSubFolder
);
2242 kfSubDefinition
.fidParent
= newFolderId
;
2244 hr
= IKnownFolderManager_RegisterFolder(mgr
, &subFolderId
, &kfSubDefinition
);
2245 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2249 hr
= IKnownFolderManager_GetFolder(mgr
, &subFolderId
, &subFolder
);
2250 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2253 /* check sub folder path */
2254 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2255 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2256 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2257 CoTaskMemFree(folderPath
);
2260 /* try to redirect Example to Temp\Example2 */
2261 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2262 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2265 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2266 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2267 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2268 CoTaskMemFree(folderPath
);
2270 /* verify sub folder - it should fail now, as we redirected its parent folder, but we have no sub folder in new location */
2271 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2272 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "unexpected value from GetPath(): 0x%08x\n", hr
);
2273 ok(folderPath
==NULL
, "invalid known folder path retrieved: \"%s\" when NULL pointer was expected\n", wine_dbgstr_w(folderPath
));
2274 CoTaskMemFree(folderPath
);
2277 /* set Example path to original. Using SetPath() is valid here, as it also uses redirection internally */
2278 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2279 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2282 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2283 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2284 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2285 CoTaskMemFree(folderPath
);
2288 /* create sub folder in Temp\Example2 */
2289 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2290 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2292 /* again perform that same redirection */
2293 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2294 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2296 /* verify sub folder. It should succeed now, as the required sub folder exists */
2297 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2298 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2299 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2300 CoTaskMemFree(folderPath
);
2302 /* remove newly created directory */
2303 RemoveDirectoryW(sSubFolder2Path
);
2305 /* verify subfolder. It still succeeds, so Windows does not check folder presence each time */
2306 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2308 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2310 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2311 CoTaskMemFree(folderPath
);
2314 /* set Example path to original */
2315 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2316 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2319 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2320 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2321 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2322 CoTaskMemFree(folderPath
);
2324 /* verify sub folder */
2325 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2326 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2327 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2328 CoTaskMemFree(folderPath
);
2331 /* create sub folder in Temp\Example2 */
2332 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2333 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2335 /* do that same redirection, but try to exclude sub-folder */
2336 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 1, &subFolderId
, &errorMsg
);
2337 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2340 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2341 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2342 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2343 CoTaskMemFree(folderPath
);
2345 /* 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 */
2346 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2347 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2348 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2349 CoTaskMemFree(folderPath
);
2351 /* remove newly created directory */
2352 RemoveDirectoryW(sSubFolder2Path
);
2355 /* set Example path to original */
2356 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2357 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2360 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2361 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2362 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2363 CoTaskMemFree(folderPath
);
2365 /* verify sub folder */
2366 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2367 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2368 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2369 CoTaskMemFree(folderPath
);
2372 /* do that same redirection again, but set it to copy content. It should also copy the sub folder, so checking it would succeed now */
2373 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2374 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2377 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2378 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2379 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2380 CoTaskMemFree(folderPath
);
2382 /* verify sub folder */
2383 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2384 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2385 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2386 CoTaskMemFree(folderPath
);
2388 /* remove copied directory */
2389 RemoveDirectoryW(sSubFolder2Path
);
2392 /* set Example path to original */
2393 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2394 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2397 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2398 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2399 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2400 CoTaskMemFree(folderPath
);
2402 /* verify sub folder */
2403 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2404 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2405 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2406 CoTaskMemFree(folderPath
);
2409 /* redirect again, set it to copy content and remove originals */
2410 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
| KF_REDIRECT_DEL_SOURCE_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2411 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2414 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2415 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2416 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2417 CoTaskMemFree(folderPath
);
2419 /* verify sub folder */
2420 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2421 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2422 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2423 CoTaskMemFree(folderPath
);
2425 /* check if original directory was really removed */
2426 dwAttributes
= GetFileAttributesW(sExamplePath
);
2427 ok(dwAttributes
==INVALID_FILE_ATTRIBUTES
, "directory should not exist, but has attributes: 0x%08x\n", dwAttributes
);
2430 /* redirect (with copy) to original path */
2431 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExamplePath
, 0, NULL
, &errorMsg
);
2432 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2435 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2436 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2437 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2438 CoTaskMemFree(folderPath
);
2440 /* verify sub folder */
2441 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2442 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2443 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2444 CoTaskMemFree(folderPath
);
2446 /* check shell utility functions */
2447 if(!pSHGetKnownFolderPath
|| !pSHSetKnownFolderPath
)
2449 win_skip("cannot get SHGet/SetKnownFolderPath routines\n");
2452 /* try to get current known folder path */
2453 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2455 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2457 ok(lstrcmpW(folderPath
, sExamplePath
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2459 /* set it to new value */
2460 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExample2Path
);
2462 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2464 /* check if it changed */
2465 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2467 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2469 ok(lstrcmpW(folderPath
, sExample2Path
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2472 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExamplePath
);
2474 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2477 IKnownFolder_Release(subFolder
);
2480 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &subFolderId
);
2481 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2484 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2486 hr
= IKnownFolder_Release(folder
);
2487 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2489 /* update the folder */
2490 CoTaskMemFree(kfDefinition
.pszName
);
2491 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample2
));
2492 lstrcpyW(kfDefinition
.pszName
, sExample2
);
2493 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2494 ok(hr
== S_OK
, "failed to re-register known folder: 0x%08x\n", hr
);
2496 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2497 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2499 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfSubDefinition
);
2500 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2501 ok(!memcmp(kfDefinition
.pszName
, kfSubDefinition
.pszName
, sizeof(sExample2
)),
2502 "Got wrong updated name: %s\n", wine_dbgstr_w(kfSubDefinition
.pszName
));
2504 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2506 hr
= IKnownFolder_Release(folder
);
2507 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2510 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &newFolderId
);
2511 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2514 FreeKnownFolderDefinitionFields(&kfDefinition
);
2516 RemoveDirectoryW(sSubFolder2Path
);
2517 RemoveDirectoryW(sSubFolderPath
);
2518 RemoveDirectoryW(sExamplePath
);
2519 RemoveDirectoryW(sExample2Path
);
2521 hr
= IKnownFolderManager_Release(mgr
);
2522 ok(hr
== S_OK
, "failed to release KnownFolderManager instance: 0x%08x\n", hr
);
2528 static void test_DoEnvironmentSubst(void)
2530 WCHAR expectedW
[MAX_PATH
];
2531 WCHAR bufferW
[MAX_PATH
];
2532 CHAR expectedA
[MAX_PATH
];
2533 CHAR bufferA
[MAX_PATH
];
2538 static const WCHAR does_not_existW
[] = {'%','D','O','E','S','_','N','O','T','_','E','X','I','S','T','%',0};
2539 static const CHAR does_not_existA
[] = "%DOES_NOT_EXIST%";
2540 static const CHAR
*names
[] = {
2541 /* interactive apps and services (works on all windows versions) */
2542 "%ALLUSERSPROFILE%", "%APPDATA%", "%LOCALAPPDATA%",
2543 "%NUMBER_OF_PROCESSORS%", "%OS%", "%PROCESSOR_ARCHITECTURE%",
2544 "%PROCESSOR_IDENTIFIER%", "%PROCESSOR_LEVEL%", "%PROCESSOR_REVISION%",
2545 "%ProgramFiles%", "%SystemDrive%",
2546 "%SystemRoot%", "%USERPROFILE%", "%windir%",
2547 /* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
2549 /* replace more than one var is allowed */
2550 "%HOMEDRIVE%%HOMEPATH%",
2551 "%OS% %windir%"}; /* always the last entry in the table */
2553 for (i
= 0; i
< (sizeof(names
)/sizeof(LPSTR
)); i
++)
2555 memset(bufferA
, '#', MAX_PATH
- 1);
2556 bufferA
[MAX_PATH
- 1] = 0;
2557 lstrcpyA(bufferA
, names
[i
]);
2558 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2560 res2
= ExpandEnvironmentStringsA(names
[i
], expectedA
, MAX_PATH
);
2561 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2563 /* is the space for the terminating 0 included? */
2564 if (!i
&& HIWORD(res
) && (LOWORD(res
) == (lstrlenA(bufferA
))))
2566 win_skip("DoEnvironmentSubstA/W are broken on NT 4\n");
2569 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2570 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2571 ok(!lstrcmpA(bufferA
, expectedA
),
2572 "%d: got %s (expected %s)\n", i
, bufferA
, expectedA
);
2574 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2575 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2576 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2577 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2578 ok(!lstrcmpW(bufferW
, expectedW
),
2579 "%d: got %s (expected %s)\n", i
, wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2582 i
--; /* reuse data in the last table entry */
2583 len
= LOWORD(res
); /* needed length */
2585 /* one character extra is fine */
2586 memset(bufferA
, '#', MAX_PATH
- 1);
2587 bufferA
[len
+ 2] = 0;
2588 lstrcpyA(bufferA
, names
[i
]);
2589 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2591 res2
= ExpandEnvironmentStringsA(bufferA
, expectedA
, MAX_PATH
);
2592 res
= DoEnvironmentSubstA(bufferA
, len
+ 1);
2593 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2594 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2595 ok(!lstrcmpA(bufferA
, expectedA
),
2596 "+1: got %s (expected %s)\n", bufferA
, expectedA
);
2598 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2599 res
= DoEnvironmentSubstW(bufferW
, len
+ 1);
2600 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2601 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2602 ok(!lstrcmpW(bufferW
, expectedW
),
2603 "+1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2606 /* minimal buffer length (result string and terminating 0) */
2607 memset(bufferA
, '#', MAX_PATH
- 1);
2608 bufferA
[len
+ 2] = 0;
2609 lstrcpyA(bufferA
, names
[i
]);
2610 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2612 /* ANSI version failed without an extra byte, as documented on msdn */
2613 res
= DoEnvironmentSubstA(bufferA
, len
);
2614 ok(!HIWORD(res
) && (LOWORD(res
) == len
),
2615 " 0: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
);
2616 ok(!lstrcmpA(bufferA
, names
[i
]),
2617 " 0: got %s (expected %s)\n", bufferA
, names
[i
]);
2619 /* DoEnvironmentSubstW works as expected */
2620 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2621 res
= DoEnvironmentSubstW(bufferW
, len
);
2622 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2623 " 0: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2624 ok(!lstrcmpW(bufferW
, expectedW
),
2625 " 0: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2628 /* Buffer too small */
2629 /* result: FALSE / provided buffer length / the buffer is untouched */
2630 memset(bufferA
, '#', MAX_PATH
- 1);
2631 bufferA
[len
+ 2] = 0;
2632 lstrcpyA(bufferA
, names
[i
]);
2633 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2635 res
= DoEnvironmentSubstA(bufferA
, len
- 1);
2636 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2637 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2638 ok(!lstrcmpA(bufferA
, names
[i
]),
2639 "-1: got %s (expected %s)\n", bufferA
, names
[i
]);
2641 lstrcpyW(expectedW
, bufferW
);
2642 res
= DoEnvironmentSubstW(bufferW
, len
- 1);
2643 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2644 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2645 ok(!lstrcmpW(bufferW
, expectedW
),
2646 "-1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2649 /* unknown variable */
2650 /* result: TRUE / string length including terminating 0 / the buffer is untouched */
2651 memset(bufferA
, '#', MAX_PATH
- 1);
2652 bufferA
[MAX_PATH
- 1] = 0;
2653 lstrcpyA(bufferA
, does_not_existA
);
2654 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, sizeof(bufferW
)/sizeof(WCHAR
));
2656 res2
= lstrlenA(does_not_existA
) + 1;
2657 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2658 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2659 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2660 ok(!lstrcmpA(bufferA
, does_not_existA
),
2661 "%d: got %s (expected %s)\n", i
, bufferA
, does_not_existA
);
2663 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2664 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2665 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2666 ok(!lstrcmpW(bufferW
, does_not_existW
),
2667 "%d: got %s (expected %s)\n", i
, wine_dbgstr_w(bufferW
), wine_dbgstr_w(does_not_existW
));
2672 /* NULL crashes on windows */
2673 res
= DoEnvironmentSubstA(NULL
, MAX_PATH
);
2674 res
= DoEnvironmentSubstW(NULL
, MAX_PATH
);
2678 static void test_PathYetAnotherMakeUniqueName(void)
2680 static const WCHAR shortW
[] = {'f','i','l','e','.','t','s','t',0};
2681 static const WCHAR short2W
[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
2682 static const WCHAR tmpW
[] = {'t','m','p',0};
2683 static const WCHAR longW
[] = {'n','a','m','e',0};
2684 static const WCHAR long2W
[] = {'n','a','m','e',' ','(','2',')',0};
2685 WCHAR nameW
[MAX_PATH
], buffW
[MAX_PATH
], pathW
[MAX_PATH
];
2689 if (!pPathYetAnotherMakeUniqueName
)
2691 win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
2697 /* crashes on Windows */
2698 ret
= pPathYetAnotherMakeUniqueName(NULL
, NULL
, NULL
, NULL
);
2699 ok(!ret
, "got %d\n", ret
);
2701 ret
= pPathYetAnotherMakeUniqueName(nameW
, NULL
, NULL
, NULL
);
2702 ok(!ret
, "got %d\n", ret
);
2705 GetTempPathW(sizeof(pathW
)/sizeof(WCHAR
), pathW
);
2707 /* Using short name only first */
2709 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2710 ok(ret
, "got %d\n", ret
);
2711 lstrcpyW(buffW
, pathW
);
2712 lstrcatW(buffW
, shortW
);
2713 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2715 /* now create a file with this name and get next name */
2716 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2717 ok(file
!= NULL
, "got %p\n", file
);
2720 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2721 ok(ret
, "got %d\n", ret
);
2722 lstrcpyW(buffW
, pathW
);
2723 lstrcatW(buffW
, short2W
);
2724 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2728 /* Using short and long */
2730 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2731 ok(ret
, "got %d\n", ret
);
2732 lstrcpyW(buffW
, pathW
);
2733 lstrcatW(buffW
, longW
);
2734 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2736 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2737 ok(file
!= NULL
, "got %p\n", file
);
2740 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2741 ok(ret
, "got %d\n", ret
);
2742 lstrcpyW(buffW
, pathW
);
2743 lstrcatW(buffW
, long2W
);
2744 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2748 /* Using long only */
2750 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, NULL
, longW
);
2751 ok(ret
, "got %d\n", ret
);
2752 lstrcpyW(buffW
, pathW
);
2753 lstrcatW(buffW
, longW
);
2754 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2757 static void test_SHGetKnownFolderIDList(void)
2759 PIDLIST_ABSOLUTE pidl
;
2762 if (!pSHGetKnownFolderIDList
)
2764 win_skip("SHGetKnownFolderIDList is not available.\n");
2768 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, NULL
);
2769 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2771 if (0) { /* crashes on native */
2772 pidl
= (void*)0xdeadbeef;
2773 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, &pidl
);
2775 /* not a known folder */
2776 pidl
= (void*)0xdeadbeef;
2777 hr
= pSHGetKnownFolderIDList(&IID_IUnknown
, 0, NULL
, &pidl
);
2778 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
2779 ok(pidl
== NULL
, "got %p\n", pidl
);
2781 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, NULL
);
2782 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2784 pidl
= (void*)0xdeadbeef;
2785 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, &pidl
);
2786 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2787 ok(ILIsEmpty(pidl
), "pidl should be empty.\n");
2788 ok(pidl
->mkid
.cb
== 0, "get wrong value: %d\n", pidl
->mkid
.cb
);
2791 pidl
= (void*)0xdeadbeef;
2792 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, KF_FLAG_NO_ALIAS
, NULL
, &pidl
);
2793 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2794 todo_wine
ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2795 todo_wine
ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2798 pidl
= (void*)0xdeadbeef;
2799 hr
= pSHGetKnownFolderIDList(&FOLDERID_Documents
, 0, NULL
, &pidl
);
2800 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2801 ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2802 ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2805 pidl
= (void*)0xdeadbeef;
2806 hr
= pSHGetKnownFolderIDList(&FOLDERID_Documents
, KF_FLAG_NO_ALIAS
, NULL
, &pidl
);
2807 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2808 ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2809 ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2813 START_TEST(shellpath
)
2815 if (!init()) return;
2818 pGetSystemWow64DirectoryA
= (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
2819 "GetSystemWow64DirectoryA" );
2824 /* Report missing functions once */
2825 if (!pSHGetFolderLocation
)
2826 win_skip("SHGetFolderLocation is not available\n");
2828 /* first test various combinations of parameters: */
2831 /* check known values: */
2837 test_NonExistentPath();
2838 test_SHGetFolderPathEx();
2839 test_knownFolders();
2840 test_DoEnvironmentSubst();
2841 test_PathYetAnotherMakeUniqueName();
2842 test_SHGetKnownFolderIDList();