2 * Unit tests for shell32 SHGet{Special}Folder{Path|Location} functions.
4 * Copyright 2004 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 * This is a test program for the SHGet{Special}Folder{Path|Location} functions
20 * of shell32, that get either a filesystem path or a LPITEMIDLIST (shell
21 * namespace) path for a given folder (CSIDL value).
33 #include "knownfolders.h"
35 #include "wine/test.h"
39 /* CSIDL_MYDOCUMENTS is now the same as CSIDL_PERSONAL, but what we want
40 * here is its original value.
42 #define OLD_CSIDL_MYDOCUMENTS 0x000c
44 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
46 /* from pidl.h, not included here: */
47 #ifndef PT_CPL /* Guess, Win7 uses this for CSIDL_CONTROLS */
48 #define PT_CPL 0x01 /* no path */
51 #define PT_GUID 0x1f /* no path */
54 #define PT_DRIVE 0x23 /* has path */
57 #define PT_DRIVE2 0x25 /* has path */
60 #define PT_SHELLEXT 0x2e /* no path */
63 #define PT_FOLDER 0x31 /* has path */
66 #define PT_FOLDERW 0x35 /* has path */
69 #define PT_WORKGRP 0x41 /* no path */
72 #define PT_YAGUID 0x70 /* no path */
74 /* FIXME: this is used for history/favorites folders; what's a better name? */
76 #define PT_IESPECIAL2 0xb1 /* has path */
79 static GUID CLSID_CommonDocuments
= { 0x0000000c, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x1a } };
81 struct shellExpectedValues
{
87 static HRESULT (WINAPI
*pDllGetVersion
)(DLLVERSIONINFO
*);
88 static HRESULT (WINAPI
*pSHGetFolderPathA
)(HWND
, int, HANDLE
, DWORD
, LPSTR
);
89 static BOOL (WINAPI
*pSHGetSpecialFolderPathA
)(HWND
, LPSTR
, int, BOOL
);
90 static HRESULT (WINAPI
*pSHGetSpecialFolderLocation
)(HWND
, int, LPITEMIDLIST
*);
91 static LPITEMIDLIST (WINAPI
*pILFindLastID
)(LPCITEMIDLIST
);
92 static int (WINAPI
*pSHFileOperationA
)(LPSHFILEOPSTRUCTA
);
93 static UINT (WINAPI
*pGetSystemWow64DirectoryA
)(LPSTR
,UINT
);
94 static HRESULT (WINAPI
*pSHGetKnownFolderPath
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PWSTR
*);
95 static HRESULT (WINAPI
*pSHSetKnownFolderPath
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PWSTR
);
96 static HRESULT (WINAPI
*pSHGetFolderPathEx
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, LPWSTR
, DWORD
);
97 static BOOL (WINAPI
*pPathYetAnotherMakeUniqueName
)(PWSTR
, PCWSTR
, PCWSTR
, PCWSTR
);
98 static HRESULT (WINAPI
*pSHGetKnownFolderIDList
)(REFKNOWNFOLDERID
, DWORD
, HANDLE
, PIDLIST_ABSOLUTE
*);
99 static BOOL (WINAPI
*pPathResolve
)(PWSTR
, PZPCWSTR
, UINT
);
101 static DLLVERSIONINFO shellVersion
= { 0 };
102 static const BYTE guidType
[] = { PT_GUID
};
103 static const BYTE controlPanelType
[] = { PT_SHELLEXT
, PT_GUID
, PT_CPL
};
104 static const BYTE folderType
[] = { PT_FOLDER
, PT_FOLDERW
};
105 static const BYTE favoritesType
[] = { PT_FOLDER
, PT_FOLDERW
, 0, PT_IESPECIAL2
/* Win98 */ };
106 static const BYTE folderOrSpecialType
[] = { PT_FOLDER
, PT_IESPECIAL2
};
107 static const BYTE personalType
[] = { PT_FOLDER
, PT_GUID
, PT_DRIVE
, 0xff /* Win9x */,
108 PT_IESPECIAL2
/* Win98 */, 0 /* Vista */, PT_SHELLEXT
/* win8 */ };
109 /* FIXME: don't know the type of 0x71 returned by Vista/2008 for printers */
110 static const BYTE printersType
[] = { PT_YAGUID
, PT_SHELLEXT
, 0x71 };
111 static const BYTE ieSpecialType
[] = { PT_IESPECIAL2
};
112 static const BYTE shellExtType
[] = { PT_SHELLEXT
};
113 static const BYTE workgroupType
[] = { PT_WORKGRP
};
114 static const BYTE missingType
[] = { 0xff };
115 #define DECLARE_TYPE(x, y) { x, ARRAY_SIZE(y), y }
116 static const struct shellExpectedValues requiredShellValues
[] = {
117 DECLARE_TYPE(CSIDL_BITBUCKET
, guidType
),
118 DECLARE_TYPE(CSIDL_CONTROLS
, controlPanelType
),
119 DECLARE_TYPE(CSIDL_COOKIES
, folderType
),
120 DECLARE_TYPE(CSIDL_DESKTOPDIRECTORY
, folderType
),
121 DECLARE_TYPE(CSIDL_DRIVES
, guidType
),
122 DECLARE_TYPE(CSIDL_FAVORITES
, favoritesType
),
123 DECLARE_TYPE(CSIDL_FONTS
, folderOrSpecialType
),
124 /* FIXME: the following fails in Wine, returns type PT_FOLDER
125 DECLARE_TYPE(CSIDL_HISTORY, ieSpecialType),
127 DECLARE_TYPE(CSIDL_INTERNET
, guidType
),
128 DECLARE_TYPE(CSIDL_NETHOOD
, folderType
),
129 DECLARE_TYPE(CSIDL_NETWORK
, guidType
),
130 DECLARE_TYPE(CSIDL_PERSONAL
, personalType
),
131 DECLARE_TYPE(CSIDL_PRINTERS
, printersType
),
132 DECLARE_TYPE(CSIDL_PRINTHOOD
, folderType
),
133 DECLARE_TYPE(CSIDL_PROGRAMS
, folderType
),
134 DECLARE_TYPE(CSIDL_RECENT
, folderOrSpecialType
),
135 DECLARE_TYPE(CSIDL_SENDTO
, folderType
),
136 DECLARE_TYPE(CSIDL_STARTMENU
, folderType
),
137 DECLARE_TYPE(CSIDL_STARTUP
, folderType
),
138 DECLARE_TYPE(CSIDL_TEMPLATES
, folderType
),
140 static const struct shellExpectedValues optionalShellValues
[] = {
141 /* FIXME: the following only semi-succeed; they return NULL PIDLs on XP.. hmm.
142 DECLARE_TYPE(CSIDL_ALTSTARTUP, folderType),
143 DECLARE_TYPE(CSIDL_COMMON_ALTSTARTUP, folderType),
144 DECLARE_TYPE(CSIDL_COMMON_OEM_LINKS, folderType),
146 /* Windows NT-only: */
147 DECLARE_TYPE(CSIDL_COMMON_DESKTOPDIRECTORY
, folderType
),
148 DECLARE_TYPE(CSIDL_COMMON_DOCUMENTS
, shellExtType
),
149 DECLARE_TYPE(CSIDL_COMMON_FAVORITES
, folderType
),
150 DECLARE_TYPE(CSIDL_COMMON_PROGRAMS
, folderType
),
151 DECLARE_TYPE(CSIDL_COMMON_STARTMENU
, folderType
),
152 DECLARE_TYPE(CSIDL_COMMON_STARTUP
, folderType
),
153 DECLARE_TYPE(CSIDL_COMMON_TEMPLATES
, folderType
),
154 /* first appearing in shell32 version 4.71: */
155 DECLARE_TYPE(CSIDL_APPDATA
, folderType
),
156 /* first appearing in shell32 version 4.72: */
157 DECLARE_TYPE(CSIDL_INTERNET_CACHE
, ieSpecialType
),
158 /* first appearing in shell32 version 5.0: */
159 DECLARE_TYPE(CSIDL_ADMINTOOLS
, folderType
),
160 DECLARE_TYPE(CSIDL_COMMON_APPDATA
, folderType
),
161 DECLARE_TYPE(CSIDL_LOCAL_APPDATA
, folderType
),
162 DECLARE_TYPE(OLD_CSIDL_MYDOCUMENTS
, folderType
),
163 DECLARE_TYPE(CSIDL_MYMUSIC
, folderType
),
164 DECLARE_TYPE(CSIDL_MYPICTURES
, folderType
),
165 DECLARE_TYPE(CSIDL_MYVIDEO
, folderType
),
166 DECLARE_TYPE(CSIDL_PROFILE
, folderType
),
167 DECLARE_TYPE(CSIDL_PROGRAM_FILES
, folderType
),
168 DECLARE_TYPE(CSIDL_PROGRAM_FILESX86
, folderType
),
169 DECLARE_TYPE(CSIDL_PROGRAM_FILES_COMMON
, folderType
),
170 DECLARE_TYPE(CSIDL_PROGRAM_FILES_COMMONX86
, folderType
),
171 DECLARE_TYPE(CSIDL_SYSTEM
, folderType
),
172 DECLARE_TYPE(CSIDL_WINDOWS
, folderType
),
173 /* first appearing in shell32 6.0: */
174 DECLARE_TYPE(CSIDL_CDBURN_AREA
, folderType
),
175 DECLARE_TYPE(CSIDL_COMMON_MUSIC
, folderType
),
176 DECLARE_TYPE(CSIDL_COMMON_PICTURES
, folderType
),
177 DECLARE_TYPE(CSIDL_COMMON_VIDEO
, folderType
),
178 DECLARE_TYPE(CSIDL_COMPUTERSNEARME
, workgroupType
),
179 DECLARE_TYPE(CSIDL_RESOURCES
, folderType
),
180 DECLARE_TYPE(CSIDL_RESOURCES_LOCALIZED
, folderType
),
182 static const struct shellExpectedValues undefinedShellValues
[] = {
183 DECLARE_TYPE(0x0f, missingType
),
184 DECLARE_TYPE(0x32, missingType
),
185 DECLARE_TYPE(0x33, missingType
),
186 DECLARE_TYPE(0x34, missingType
),
187 DECLARE_TYPE(0x3c, missingType
),
188 DECLARE_TYPE(0x45, missingType
),
192 static void loadShell32(void)
194 HMODULE hShell32
= GetModuleHandleA("shell32");
196 #define GET_PROC(func) \
197 p ## func = (void*)GetProcAddress(hShell32, #func); \
199 trace("GetProcAddress(%s) failed\n", #func);
201 GET_PROC(DllGetVersion
)
202 GET_PROC(SHGetFolderPathA
)
203 GET_PROC(SHGetFolderPathEx
)
204 GET_PROC(SHGetKnownFolderPath
)
205 GET_PROC(SHSetKnownFolderPath
)
206 GET_PROC(SHGetSpecialFolderPathA
)
207 GET_PROC(SHGetSpecialFolderLocation
)
208 GET_PROC(ILFindLastID
)
210 pILFindLastID
= (void *)GetProcAddress(hShell32
, (LPCSTR
)16);
211 GET_PROC(SHFileOperationA
)
212 GET_PROC(PathYetAnotherMakeUniqueName
)
213 GET_PROC(SHGetKnownFolderIDList
)
214 GET_PROC(PathResolve
);
218 shellVersion
.cbSize
= sizeof(shellVersion
);
219 pDllGetVersion(&shellVersion
);
220 trace("shell32 version is %d.%d\n",
221 shellVersion
.dwMajorVersion
, shellVersion
.dwMinorVersion
);
226 #ifndef CSIDL_PROFILES
227 #define CSIDL_PROFILES 0x003e
230 /* A couple utility printing functions */
231 static const char *getFolderName(int folder
)
233 static char unknown
[32];
235 #define CSIDL_TO_STR(x) case x: return#x;
238 CSIDL_TO_STR(CSIDL_DESKTOP
);
239 CSIDL_TO_STR(CSIDL_INTERNET
);
240 CSIDL_TO_STR(CSIDL_PROGRAMS
);
241 CSIDL_TO_STR(CSIDL_CONTROLS
);
242 CSIDL_TO_STR(CSIDL_PRINTERS
);
243 CSIDL_TO_STR(CSIDL_PERSONAL
);
244 CSIDL_TO_STR(CSIDL_FAVORITES
);
245 CSIDL_TO_STR(CSIDL_STARTUP
);
246 CSIDL_TO_STR(CSIDL_RECENT
);
247 CSIDL_TO_STR(CSIDL_SENDTO
);
248 CSIDL_TO_STR(CSIDL_BITBUCKET
);
249 CSIDL_TO_STR(CSIDL_STARTMENU
);
250 CSIDL_TO_STR(OLD_CSIDL_MYDOCUMENTS
);
251 CSIDL_TO_STR(CSIDL_MYMUSIC
);
252 CSIDL_TO_STR(CSIDL_MYVIDEO
);
253 CSIDL_TO_STR(CSIDL_DESKTOPDIRECTORY
);
254 CSIDL_TO_STR(CSIDL_DRIVES
);
255 CSIDL_TO_STR(CSIDL_NETWORK
);
256 CSIDL_TO_STR(CSIDL_NETHOOD
);
257 CSIDL_TO_STR(CSIDL_FONTS
);
258 CSIDL_TO_STR(CSIDL_TEMPLATES
);
259 CSIDL_TO_STR(CSIDL_COMMON_STARTMENU
);
260 CSIDL_TO_STR(CSIDL_COMMON_PROGRAMS
);
261 CSIDL_TO_STR(CSIDL_COMMON_STARTUP
);
262 CSIDL_TO_STR(CSIDL_COMMON_DESKTOPDIRECTORY
);
263 CSIDL_TO_STR(CSIDL_APPDATA
);
264 CSIDL_TO_STR(CSIDL_PRINTHOOD
);
265 CSIDL_TO_STR(CSIDL_LOCAL_APPDATA
);
266 CSIDL_TO_STR(CSIDL_ALTSTARTUP
);
267 CSIDL_TO_STR(CSIDL_COMMON_ALTSTARTUP
);
268 CSIDL_TO_STR(CSIDL_COMMON_FAVORITES
);
269 CSIDL_TO_STR(CSIDL_INTERNET_CACHE
);
270 CSIDL_TO_STR(CSIDL_COOKIES
);
271 CSIDL_TO_STR(CSIDL_HISTORY
);
272 CSIDL_TO_STR(CSIDL_COMMON_APPDATA
);
273 CSIDL_TO_STR(CSIDL_WINDOWS
);
274 CSIDL_TO_STR(CSIDL_SYSTEM
);
275 CSIDL_TO_STR(CSIDL_PROGRAM_FILES
);
276 CSIDL_TO_STR(CSIDL_MYPICTURES
);
277 CSIDL_TO_STR(CSIDL_PROFILE
);
278 CSIDL_TO_STR(CSIDL_SYSTEMX86
);
279 CSIDL_TO_STR(CSIDL_PROGRAM_FILESX86
);
280 CSIDL_TO_STR(CSIDL_PROGRAM_FILES_COMMON
);
281 CSIDL_TO_STR(CSIDL_PROGRAM_FILES_COMMONX86
);
282 CSIDL_TO_STR(CSIDL_COMMON_TEMPLATES
);
283 CSIDL_TO_STR(CSIDL_COMMON_DOCUMENTS
);
284 CSIDL_TO_STR(CSIDL_COMMON_ADMINTOOLS
);
285 CSIDL_TO_STR(CSIDL_ADMINTOOLS
);
286 CSIDL_TO_STR(CSIDL_CONNECTIONS
);
287 CSIDL_TO_STR(CSIDL_PROFILES
);
288 CSIDL_TO_STR(CSIDL_COMMON_MUSIC
);
289 CSIDL_TO_STR(CSIDL_COMMON_PICTURES
);
290 CSIDL_TO_STR(CSIDL_COMMON_VIDEO
);
291 CSIDL_TO_STR(CSIDL_RESOURCES
);
292 CSIDL_TO_STR(CSIDL_RESOURCES_LOCALIZED
);
293 CSIDL_TO_STR(CSIDL_COMMON_OEM_LINKS
);
294 CSIDL_TO_STR(CSIDL_CDBURN_AREA
);
295 CSIDL_TO_STR(CSIDL_COMPUTERSNEARME
);
298 sprintf(unknown
, "unknown (0x%04x)", folder
);
303 static LPWSTR
wcscasestr( LPCWSTR str
, LPCWSTR sub
)
307 const WCHAR
*p1
= str
, *p2
= sub
;
308 while (*p1
&& *p2
&& towlower(*p1
) == towlower(*p2
)) { p1
++; p2
++; }
309 if (!*p2
) return (WCHAR
*)str
;
315 /* Standard CSIDL values (and their flags) uses only two less-significant bytes */
316 #define NO_CSIDL 0x10000
317 #define WINE_ATTRIBUTES_OPTIONAL 0x20000
318 #define KNOWN_FOLDER(id, csidl, name, category, parent1, parent2, relative_path, parsing_name, attributes, definitionFlags) \
319 { &id, # id, csidl, # csidl, name, category, {&parent1, &parent2}, relative_path, parsing_name, attributes, definitionFlags, __LINE__ }
321 /* non-published known folders test */
322 static const GUID _FOLDERID_CryptoKeys
= {0xB88F4DAA, 0xE7BD, 0x49A9, {0xB7, 0x4D, 0x02, 0x88, 0x5A, 0x5D, 0xC7, 0x65} };
323 static const GUID _FOLDERID_DpapiKeys
= {0x10C07CD0, 0xEF91, 0x4567, {0xB8, 0x50, 0x44, 0x8B, 0x77, 0xCB, 0x37, 0xF9} };
324 static const GUID _FOLDERID_SystemCertificates
= {0x54EED2E0, 0xE7CA, 0x4FDB, {0x91, 0x48, 0x0F, 0x42, 0x47, 0x29, 0x1C, 0xFA} };
325 static const GUID _FOLDERID_CredentialManager
= {0x915221FB, 0x9EFE, 0x4BDA, {0x8F, 0xD7, 0xF7, 0x8D, 0xCA, 0x77, 0x4F, 0x87} };
327 struct knownFolderDef
{
328 const KNOWNFOLDERID
*folderId
;
329 const char *sFolderId
;
333 const KF_CATEGORY category
;
334 const KNOWNFOLDERID
*fidParents
[2];
335 const char *sRelativePath
;
336 const char *sParsingName
;
337 const DWORD attributes
;
338 const KF_DEFINITION_FLAGS definitionFlags
;
342 /* Note: content of parsing name may vary between Windows versions.
343 * As a base, values from 6.0 (Vista) were used. Some entries may contain
344 * alternative values. In that case, Windows version where the value was
347 * The list of values for parsing name was encoded as a number of null-
348 * terminated strings placed one by one (separated by null byte only).
349 * End of list is marked by two consecutive null bytes.
351 static const struct knownFolderDef known_folders
[] = {
352 KNOWN_FOLDER(FOLDERID_AddNewPrograms
,
354 "AddNewProgramsFolder",
356 GUID_NULL
, GUID_NULL
,
358 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0"
359 "shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0\0" /* 6.1 */,
362 KNOWN_FOLDER(FOLDERID_AdminTools
,
364 "Administrative Tools",
366 FOLDERID_Programs
, GUID_NULL
,
367 "Administrative Tools",
369 FILE_ATTRIBUTE_READONLY
,
371 KNOWN_FOLDER(FOLDERID_AppUpdates
,
375 GUID_NULL
, GUID_NULL
,
377 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0"
378 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0\0" /* 6.1 */,
381 KNOWN_FOLDER(FOLDERID_CDBurning
,
385 FOLDERID_LocalAppData
, GUID_NULL
,
386 "Microsoft\\Windows\\Burn\\Burn",
388 FILE_ATTRIBUTE_READONLY
,
389 KFDF_LOCAL_REDIRECT_ONLY
),
390 KNOWN_FOLDER(FOLDERID_ChangeRemovePrograms
,
392 "ChangeRemoveProgramsFolder",
394 GUID_NULL
, GUID_NULL
,
396 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0"
397 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0\0" /* 6.1 */,
400 KNOWN_FOLDER(FOLDERID_CommonAdminTools
,
401 CSIDL_COMMON_ADMINTOOLS
,
402 "Common Administrative Tools",
404 FOLDERID_CommonPrograms
, GUID_NULL
,
405 "Administrative Tools",
407 FILE_ATTRIBUTE_READONLY
,
409 KNOWN_FOLDER(FOLDERID_CommonOEMLinks
,
410 CSIDL_COMMON_OEM_LINKS
,
413 FOLDERID_ProgramData
, GUID_NULL
,
418 KNOWN_FOLDER(FOLDERID_CommonPrograms
,
419 CSIDL_COMMON_PROGRAMS
,
422 FOLDERID_CommonStartMenu
, GUID_NULL
,
425 FILE_ATTRIBUTE_READONLY
,
427 KNOWN_FOLDER(FOLDERID_CommonStartMenu
,
428 CSIDL_COMMON_STARTMENU
,
431 FOLDERID_ProgramData
, GUID_NULL
,
432 "Microsoft\\Windows\\Start Menu\0",
434 FILE_ATTRIBUTE_READONLY
,
436 KNOWN_FOLDER(FOLDERID_CommonStartup
,
437 CSIDL_COMMON_STARTUP
,
440 FOLDERID_CommonPrograms
, GUID_NULL
,
443 FILE_ATTRIBUTE_READONLY
,
445 KNOWN_FOLDER(FOLDERID_CommonTemplates
,
446 CSIDL_COMMON_TEMPLATES
,
449 FOLDERID_ProgramData
, GUID_NULL
,
450 "Microsoft\\Windows\\Templates\0",
454 KNOWN_FOLDER(FOLDERID_ComputerFolder
,
458 GUID_NULL
, GUID_NULL
,
460 "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\0\0",
463 KNOWN_FOLDER(FOLDERID_ConflictFolder
,
467 GUID_NULL
, GUID_NULL
,
469 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0"
470 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0\0" /* 6.1 */,
473 KNOWN_FOLDER(FOLDERID_ConnectionsFolder
,
477 GUID_NULL
, GUID_NULL
,
479 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0"
480 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0\0" /* 6.1 */,
483 KNOWN_FOLDER(FOLDERID_Contacts
,
487 FOLDERID_Profile
, GUID_NULL
,
489 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{56784854-C6CB-462B-8169-88E350ACB882}\0\0",
490 FILE_ATTRIBUTE_READONLY
,
491 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
492 KNOWN_FOLDER(FOLDERID_ControlPanelFolder
,
494 "ControlPanelFolder",
496 GUID_NULL
, GUID_NULL
,
498 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\0"
499 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\0\0" /* 6.1 */,
502 KNOWN_FOLDER(FOLDERID_Cookies
,
506 FOLDERID_RoamingAppData
, FOLDERID_LocalAppData
,
507 "Microsoft\\Windows\\Cookies\0Microsoft\\Windows\\INetCookies\0" /* win8 */,
511 KNOWN_FOLDER(FOLDERID_Desktop
,
515 FOLDERID_Profile
, GUID_NULL
,
518 FILE_ATTRIBUTE_READONLY
,
519 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
520 KNOWN_FOLDER(FOLDERID_DeviceMetadataStore
,
522 "Device Metadata Store",
524 FOLDERID_ProgramData
, GUID_NULL
,
525 "Microsoft\\Windows\\DeviceMetadataStore\0",
529 KNOWN_FOLDER(FOLDERID_Documents
,
533 FOLDERID_Profile
, GUID_NULL
,
535 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{FDD39AD0-238F-46AF-ADB4-6C85480369C7}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}\0\0", /* win8 */
536 FILE_ATTRIBUTE_READONLY
,
537 KFDF_ROAMABLE
| KFDF_PRECREATE
),
538 KNOWN_FOLDER(FOLDERID_DocumentsLibrary
,
542 FOLDERID_Libraries
, GUID_NULL
,
543 "Documents.library-ms\0",
544 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{7b0db17d-9cd2-4a93-9733-46cc89022e7c}\0\0",
546 KFDF_PRECREATE
| KFDF_STREAM
),
547 KNOWN_FOLDER(FOLDERID_Downloads
,
551 FOLDERID_Profile
, GUID_NULL
,
553 "(null)\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{374DE290-123F-4565-9164-39C4925E467B}\0\0", /* win8 */
554 FILE_ATTRIBUTE_READONLY
,
555 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
556 KNOWN_FOLDER(FOLDERID_Favorites
,
560 FOLDERID_Profile
, GUID_NULL
,
563 FILE_ATTRIBUTE_READONLY
,
564 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
565 KNOWN_FOLDER(FOLDERID_Fonts
,
569 FOLDERID_Windows
, GUID_NULL
,
574 KNOWN_FOLDER(FOLDERID_Games
,
578 GUID_NULL
, GUID_NULL
,
580 "::{ED228FDF-9EA8-4870-83b1-96b02CFE0D52}\0\0",
583 KNOWN_FOLDER(FOLDERID_GameTasks
,
587 FOLDERID_LocalAppData
, GUID_NULL
,
588 "Microsoft\\Windows\\GameExplorer\0",
591 KFDF_LOCAL_REDIRECT_ONLY
),
592 KNOWN_FOLDER(FOLDERID_History
,
596 FOLDERID_LocalAppData
, GUID_NULL
,
597 "Microsoft\\Windows\\History\0",
600 KFDF_LOCAL_REDIRECT_ONLY
),
601 KNOWN_FOLDER(FOLDERID_HomeGroup
,
605 GUID_NULL
, GUID_NULL
,
607 "::{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\0\0",
610 KNOWN_FOLDER(FOLDERID_ImplicitAppShortcuts
,
612 "ImplicitAppShortcuts",
614 FOLDERID_UserPinned
, GUID_NULL
,
615 "ImplicitAppShortcuts\0",
619 KNOWN_FOLDER(FOLDERID_InternetCache
,
620 CSIDL_INTERNET_CACHE
,
623 FOLDERID_LocalAppData
, GUID_NULL
,
624 "Microsoft\\Windows\\Temporary Internet Files\0Microsoft\\Windows\\INetCache\0\0", /* win8 */
627 KFDF_LOCAL_REDIRECT_ONLY
),
628 KNOWN_FOLDER(FOLDERID_InternetFolder
,
632 GUID_NULL
, GUID_NULL
,
634 "::{871C5380-42A0-1069-A2EA-08002B30309D}\0\0",
637 KNOWN_FOLDER(FOLDERID_Libraries
,
641 FOLDERID_RoamingAppData
, GUID_NULL
,
642 "Microsoft\\Windows\\Libraries\0",
645 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
646 KNOWN_FOLDER(FOLDERID_Links
,
650 FOLDERID_Profile
, GUID_NULL
,
652 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}\0\0",
653 FILE_ATTRIBUTE_READONLY
,
654 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
655 KNOWN_FOLDER(FOLDERID_LocalAppData
,
659 FOLDERID_Profile
, GUID_NULL
,
663 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
),
664 KNOWN_FOLDER(FOLDERID_LocalAppDataLow
,
668 FOLDERID_Profile
, GUID_NULL
,
669 "AppData\\LocalLow\0",
671 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
,
672 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
673 KNOWN_FOLDER(FOLDERID_LocalizedResourcesDir
,
674 CSIDL_RESOURCES_LOCALIZED
,
675 "LocalizedResourcesDir",
677 GUID_NULL
, GUID_NULL
,
682 KNOWN_FOLDER(FOLDERID_Music
,
686 FOLDERID_Profile
, GUID_NULL
,
688 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4BD8D571-6D19-48D3-BE97-422220080E43}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{1CF1260C-4DD0-4EBB-811F-33C572699FDE}\0\0", /* win8 */
689 FILE_ATTRIBUTE_READONLY
,
690 KFDF_ROAMABLE
| KFDF_PRECREATE
),
691 KNOWN_FOLDER(FOLDERID_MusicLibrary
,
695 FOLDERID_Libraries
, GUID_NULL
,
696 "Music.library-ms\0",
697 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{2112AB0A-C86A-4ffe-A368-0DE96E47012E}\0\0",
699 KFDF_PRECREATE
| KFDF_STREAM
),
700 KNOWN_FOLDER(FOLDERID_NetHood
,
704 FOLDERID_RoamingAppData
, GUID_NULL
,
705 "Microsoft\\Windows\\Network Shortcuts\0",
709 KNOWN_FOLDER(FOLDERID_NetworkFolder
,
711 "NetworkPlacesFolder",
713 GUID_NULL
, GUID_NULL
,
715 "::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\0\0",
718 KNOWN_FOLDER(FOLDERID_OriginalImages
,
722 FOLDERID_LocalAppData
, GUID_NULL
,
723 "Microsoft\\Windows Photo Gallery\\Original Images\0",
727 KNOWN_FOLDER(FOLDERID_PhotoAlbums
,
731 FOLDERID_Pictures
, GUID_NULL
,
734 FILE_ATTRIBUTE_READONLY
,
736 KNOWN_FOLDER(FOLDERID_Pictures
,
740 FOLDERID_Profile
, GUID_NULL
,
742 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{33E28130-4E1E-4676-835A-98395C3BC3BB}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{3ADD1653-EB32-4CB0-BBD7-DFA0ABB5ACCA}\0\0", /* win8 */
743 FILE_ATTRIBUTE_READONLY
,
744 KFDF_ROAMABLE
| KFDF_PRECREATE
),
745 KNOWN_FOLDER(FOLDERID_PicturesLibrary
,
749 FOLDERID_Libraries
, GUID_NULL
,
750 "Pictures.library-ms\0",
751 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{A990AE9F-A03B-4e80-94BC-9912D7504104}\0\0",
753 KFDF_PRECREATE
| KFDF_STREAM
),
754 KNOWN_FOLDER(FOLDERID_Playlists
,
758 FOLDERID_Music
, GUID_NULL
,
761 FILE_ATTRIBUTE_READONLY
,
763 KNOWN_FOLDER(FOLDERID_PrintersFolder
,
767 GUID_NULL
, GUID_NULL
,
769 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}\0\0",
772 KNOWN_FOLDER(FOLDERID_PrintHood
,
776 FOLDERID_RoamingAppData
, GUID_NULL
,
777 "Microsoft\\Windows\\Printer Shortcuts\0",
781 KNOWN_FOLDER(FOLDERID_Profile
,
785 GUID_NULL
, GUID_NULL
,
790 KNOWN_FOLDER(FOLDERID_ProgramData
,
791 CSIDL_COMMON_APPDATA
,
794 GUID_NULL
, GUID_NULL
,
799 KNOWN_FOLDER(FOLDERID_ProgramFiles
,
803 GUID_NULL
, GUID_NULL
,
806 FILE_ATTRIBUTE_READONLY
,
809 KNOWN_FOLDER(FOLDERID_ProgramFilesCommon
,
810 CSIDL_PROGRAM_FILES_COMMON
,
811 "ProgramFilesCommon",
813 GUID_NULL
, GUID_NULL
,
818 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX64
,
820 "ProgramFilesCommonX64",
822 GUID_NULL
, GUID_NULL
,
827 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX86
,
829 "ProgramFilesCommonX86",
831 GUID_NULL
, GUID_NULL
,
836 KNOWN_FOLDER(FOLDERID_ProgramFilesX64
,
840 GUID_NULL
, GUID_NULL
,
845 KNOWN_FOLDER(FOLDERID_ProgramFilesX86
,
846 CSIDL_PROGRAM_FILESX86
,
849 GUID_NULL
, GUID_NULL
,
852 FILE_ATTRIBUTE_READONLY
,
854 KNOWN_FOLDER(FOLDERID_Programs
,
858 FOLDERID_StartMenu
, GUID_NULL
,
861 FILE_ATTRIBUTE_READONLY
,
863 KNOWN_FOLDER(FOLDERID_Public
,
867 GUID_NULL
, GUID_NULL
,
869 "::{4336a54d-038b-4685-ab02-99bb52d3fb8b}\0"
870 "(null)\0\0" /* 6.1 */,
871 FILE_ATTRIBUTE_READONLY
,
873 KNOWN_FOLDER(FOLDERID_PublicDesktop
,
874 CSIDL_COMMON_DESKTOPDIRECTORY
,
877 FOLDERID_Public
, GUID_NULL
,
880 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
882 KNOWN_FOLDER(FOLDERID_PublicDocuments
,
883 CSIDL_COMMON_DOCUMENTS
,
886 FOLDERID_Public
, GUID_NULL
,
889 FILE_ATTRIBUTE_READONLY
,
891 KNOWN_FOLDER(FOLDERID_PublicDownloads
,
895 FOLDERID_Public
, GUID_NULL
,
898 FILE_ATTRIBUTE_READONLY
,
900 KNOWN_FOLDER(FOLDERID_PublicGameTasks
,
904 FOLDERID_ProgramData
, GUID_NULL
,
905 "Microsoft\\Windows\\GameExplorer\0",
908 KFDF_LOCAL_REDIRECT_ONLY
),
909 KNOWN_FOLDER(FOLDERID_PublicLibraries
,
913 FOLDERID_Public
, GUID_NULL
,
916 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
,
918 KNOWN_FOLDER(FOLDERID_PublicMusic
,
922 FOLDERID_Public
, GUID_NULL
,
925 FILE_ATTRIBUTE_READONLY
,
927 KNOWN_FOLDER(FOLDERID_PublicPictures
,
928 CSIDL_COMMON_PICTURES
,
931 FOLDERID_Public
, GUID_NULL
,
934 FILE_ATTRIBUTE_READONLY
,
936 KNOWN_FOLDER(FOLDERID_PublicRingtones
,
940 FOLDERID_ProgramData
, GUID_NULL
,
941 "Microsoft\\Windows\\Ringtones\0",
945 KNOWN_FOLDER(FOLDERID_PublicVideos
,
949 FOLDERID_Public
, GUID_NULL
,
952 FILE_ATTRIBUTE_READONLY
,
954 KNOWN_FOLDER(FOLDERID_QuickLaunch
,
958 FOLDERID_RoamingAppData
, GUID_NULL
,
959 "Microsoft\\Internet Explorer\\Quick Launch\0",
963 KNOWN_FOLDER(FOLDERID_Recent
,
967 FOLDERID_RoamingAppData
, GUID_NULL
,
968 "Microsoft\\Windows\\Recent\0",
970 FILE_ATTRIBUTE_READONLY
,
972 KNOWN_FOLDER(FOLDERID_RecordedTVLibrary
,
976 FOLDERID_PublicLibraries
, GUID_NULL
,
977 "RecordedTV.library-ms\0",
980 KFDF_PRECREATE
| KFDF_STREAM
),
981 KNOWN_FOLDER(FOLDERID_RecycleBinFolder
,
985 GUID_NULL
, GUID_NULL
,
987 "::{645FF040-5081-101B-9F08-00AA002F954E}\0\0",
990 KNOWN_FOLDER(FOLDERID_ResourceDir
,
994 GUID_NULL
, GUID_NULL
,
999 KNOWN_FOLDER(FOLDERID_Ringtones
,
1002 KF_CATEGORY_PERUSER
,
1003 FOLDERID_LocalAppData
, GUID_NULL
,
1004 "Microsoft\\Windows\\Ringtones\0",
1008 KNOWN_FOLDER(FOLDERID_RoamingAppData
,
1011 KF_CATEGORY_PERUSER
,
1012 FOLDERID_Profile
, GUID_NULL
,
1013 "AppData\\Roaming\0",
1017 KNOWN_FOLDER(FOLDERID_SampleMusic
,
1018 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1021 FOLDERID_PublicMusic
, GUID_NULL
,
1024 FILE_ATTRIBUTE_READONLY
,
1026 KNOWN_FOLDER(FOLDERID_SamplePictures
,
1027 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1030 FOLDERID_PublicPictures
, GUID_NULL
,
1031 "Sample Pictures\0",
1033 FILE_ATTRIBUTE_READONLY
,
1035 KNOWN_FOLDER(FOLDERID_SamplePlaylists
,
1039 FOLDERID_PublicMusic
, GUID_NULL
,
1040 "Sample Playlists\0",
1042 FILE_ATTRIBUTE_READONLY
,
1044 KNOWN_FOLDER(FOLDERID_SampleVideos
,
1045 NO_CSIDL
|WINE_ATTRIBUTES_OPTIONAL
/* win8 */,
1048 FOLDERID_PublicVideos
, GUID_NULL
,
1051 FILE_ATTRIBUTE_READONLY
,
1053 KNOWN_FOLDER(FOLDERID_SavedGames
,
1056 KF_CATEGORY_PERUSER
,
1057 FOLDERID_Profile
, GUID_NULL
,
1059 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}\0\0",
1060 FILE_ATTRIBUTE_READONLY
,
1061 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1062 KNOWN_FOLDER(FOLDERID_SavedSearches
,
1065 KF_CATEGORY_PERUSER
,
1066 FOLDERID_Profile
, GUID_NULL
,
1068 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{7d1d3a04-debb-4115-95cf-2f29da2920da}\0\0",
1069 FILE_ATTRIBUTE_READONLY
,
1070 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
),
1071 KNOWN_FOLDER(FOLDERID_SEARCH_CSC
,
1074 KF_CATEGORY_VIRTUAL
,
1075 GUID_NULL
, GUID_NULL
,
1077 "shell:::{BD7A2E7B-21CB-41b2-A086-B309680C6B7E}\\*\0\0",
1080 KNOWN_FOLDER(FOLDERID_SearchHome
,
1083 KF_CATEGORY_VIRTUAL
,
1084 GUID_NULL
, GUID_NULL
,
1086 "::{9343812e-1c37-4a49-a12e-4b2d810d956b}\0\0",
1089 KNOWN_FOLDER(FOLDERID_SEARCH_MAPI
,
1092 KF_CATEGORY_VIRTUAL
,
1093 GUID_NULL
, GUID_NULL
,
1095 "shell:::{89D83576-6BD1-4C86-9454-BEB04E94C819}\\*\0\0",
1098 KNOWN_FOLDER(FOLDERID_SendTo
,
1101 KF_CATEGORY_PERUSER
,
1102 FOLDERID_RoamingAppData
, GUID_NULL
,
1103 "Microsoft\\Windows\\SendTo\0",
1107 KNOWN_FOLDER(FOLDERID_SidebarDefaultParts
,
1111 FOLDERID_ProgramFiles
, GUID_NULL
,
1112 "Windows Sidebar\\Gadgets\0",
1116 KNOWN_FOLDER(FOLDERID_SidebarParts
,
1119 KF_CATEGORY_PERUSER
,
1120 FOLDERID_LocalAppData
, GUID_NULL
,
1121 "Microsoft\\Windows Sidebar\\Gadgets\0",
1125 KNOWN_FOLDER(FOLDERID_StartMenu
,
1128 KF_CATEGORY_PERUSER
,
1129 FOLDERID_RoamingAppData
, GUID_NULL
,
1130 "Microsoft\\Windows\\Start Menu\0",
1132 FILE_ATTRIBUTE_READONLY
,
1134 KNOWN_FOLDER(FOLDERID_Startup
,
1137 KF_CATEGORY_PERUSER
,
1138 FOLDERID_Programs
, GUID_NULL
,
1141 FILE_ATTRIBUTE_READONLY
,
1143 KNOWN_FOLDER(FOLDERID_SyncManagerFolder
,
1146 KF_CATEGORY_VIRTUAL
,
1147 GUID_NULL
, GUID_NULL
,
1149 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0"
1150 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0\0" /* 6.1 */,
1153 KNOWN_FOLDER(FOLDERID_SyncResultsFolder
,
1155 "SyncResultsFolder",
1156 KF_CATEGORY_VIRTUAL
,
1157 GUID_NULL
, GUID_NULL
,
1159 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0"
1160 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0\0",
1163 KNOWN_FOLDER(FOLDERID_SyncSetupFolder
,
1166 KF_CATEGORY_VIRTUAL
,
1167 GUID_NULL
, GUID_NULL
,
1169 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0"
1170 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0\0" /* 6.1 */,
1173 KNOWN_FOLDER(FOLDERID_System
,
1177 GUID_NULL
, GUID_NULL
,
1182 KNOWN_FOLDER(FOLDERID_SystemX86
,
1186 GUID_NULL
, GUID_NULL
,
1191 KNOWN_FOLDER(FOLDERID_Templates
,
1194 KF_CATEGORY_PERUSER
,
1195 FOLDERID_RoamingAppData
, GUID_NULL
,
1196 "Microsoft\\Windows\\Templates\0",
1200 KNOWN_FOLDER(FOLDERID_UserPinned
,
1203 KF_CATEGORY_PERUSER
,
1204 FOLDERID_QuickLaunch
, GUID_NULL
,
1207 FILE_ATTRIBUTE_HIDDEN
,
1209 KNOWN_FOLDER(FOLDERID_UserProfiles
,
1213 GUID_NULL
, GUID_NULL
,
1216 FILE_ATTRIBUTE_READONLY
,
1218 KNOWN_FOLDER(FOLDERID_UserProgramFiles
,
1221 KF_CATEGORY_PERUSER
,
1222 FOLDERID_LocalAppData
, GUID_NULL
,
1227 KNOWN_FOLDER(FOLDERID_UserProgramFilesCommon
,
1229 "UserProgramFilesCommon",
1230 KF_CATEGORY_PERUSER
,
1231 FOLDERID_UserProgramFiles
, GUID_NULL
,
1236 KNOWN_FOLDER(FOLDERID_UsersFiles
,
1239 KF_CATEGORY_VIRTUAL
,
1240 GUID_NULL
, GUID_NULL
,
1242 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\0\0",
1245 KNOWN_FOLDER(FOLDERID_UsersLibraries
,
1247 "UsersLibrariesFolder",
1248 KF_CATEGORY_VIRTUAL
,
1249 GUID_NULL
, GUID_NULL
,
1251 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\0\0",
1254 KNOWN_FOLDER(FOLDERID_Videos
,
1257 KF_CATEGORY_PERUSER
,
1258 FOLDERID_Profile
, GUID_NULL
,
1260 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{18989B1D-99B5-455B-841C-AB7C74E4DDFC}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A0953C92-50DC-43BF-BE83-3742FED03C9C}\0\0", /* win8 */
1261 FILE_ATTRIBUTE_READONLY
,
1262 KFDF_ROAMABLE
| KFDF_PRECREATE
),
1263 KNOWN_FOLDER(FOLDERID_VideosLibrary
,
1266 KF_CATEGORY_PERUSER
,
1267 FOLDERID_Libraries
, GUID_NULL
,
1268 "Videos.library-ms\0",
1269 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{491E922F-5643-4af4-A7EB-4E7A138D8174}\0\0",
1271 KFDF_PRECREATE
| KFDF_STREAM
),
1272 KNOWN_FOLDER(FOLDERID_Windows
,
1276 GUID_NULL
, GUID_NULL
,
1281 KNOWN_FOLDER(_FOLDERID_CredentialManager
,
1283 "CredentialManager",
1285 GUID_NULL
, GUID_NULL
,
1290 KNOWN_FOLDER(_FOLDERID_CryptoKeys
,
1294 GUID_NULL
, GUID_NULL
,
1299 KNOWN_FOLDER(_FOLDERID_DpapiKeys
,
1303 GUID_NULL
, GUID_NULL
,
1308 KNOWN_FOLDER(_FOLDERID_SystemCertificates
,
1310 "SystemCertificates",
1312 GUID_NULL
, GUID_NULL
,
1319 BOOL known_folder_found
[ARRAY_SIZE(known_folders
)];
1321 static void test_parameters(void)
1323 LPITEMIDLIST pidl
= NULL
;
1324 char path
[MAX_PATH
];
1327 /* check a bogus CSIDL: */
1329 hr
= SHGetFolderLocation(NULL
, 0xeeee, NULL
, 0, &pidl
);
1330 ok(hr
== E_INVALIDARG
, "got 0x%08x, expected E_INVALIDARG\n", hr
);
1332 /* check a bogus user token: */
1334 hr
= SHGetFolderLocation(NULL
, CSIDL_FAVORITES
, (HANDLE
)2, 0, &pidl
);
1335 ok(hr
== E_FAIL
|| hr
== E_HANDLE
, "got 0x%08x, expected E_FAIL or E_HANDLE\n", hr
);
1337 /* a NULL pidl pointer crashes, so don't test it */
1339 if (pSHGetSpecialFolderLocation
)
1343 SHGetSpecialFolderLocation(NULL
, 0, NULL
);
1345 hr
= pSHGetSpecialFolderLocation(NULL
, 0xeeee, &pidl
);
1346 ok(hr
== E_INVALIDARG
, "got returned 0x%08x\n", hr
);
1349 if (pSHGetFolderPathA
)
1351 /* expect 2's a bogus handle, especially since we didn't open it */
1352 hr
= pSHGetFolderPathA(NULL
, CSIDL_DESKTOP
, (HANDLE
)2, SHGFP_TYPE_DEFAULT
, path
);
1353 ok(hr
== E_FAIL
|| hr
== E_HANDLE
|| /* Vista and 2k8 */
1354 broken(hr
== S_OK
), /* W2k and Me */ "got 0x%08x, expected E_FAIL\n", hr
);
1356 hr
= pSHGetFolderPathA(NULL
, 0xeeee, NULL
, SHGFP_TYPE_DEFAULT
, path
);
1357 ok(hr
== E_INVALIDARG
, "got 0x%08x, expected E_INVALIDARG\n", hr
);
1360 if (pSHGetSpecialFolderPathA
)
1365 pSHGetSpecialFolderPathA(NULL
, NULL
, CSIDL_BITBUCKET
, FALSE
);
1367 /* odd but true: calling with a NULL path still succeeds if it's a real
1368 * dir (on some windows platform). on winME it generates exception.
1370 ret
= pSHGetSpecialFolderPathA(NULL
, path
, CSIDL_PROGRAMS
, FALSE
);
1371 ok(ret
, "got %d\n", ret
);
1373 ret
= pSHGetSpecialFolderPathA(NULL
, path
, 0xeeee, FALSE
);
1374 ok(!ret
, "got %d\n", ret
);
1378 /* Returns the folder's PIDL type, or 0xff if one can't be found. */
1379 static BYTE
testSHGetFolderLocation(int folder
)
1386 hr
= SHGetFolderLocation(NULL
, folder
, NULL
, 0, &pidl
);
1391 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
1393 ok(pidlLast
!= NULL
, "%s: ILFindLastID failed\n",
1394 getFolderName(folder
));
1396 ret
= pidlLast
->mkid
.abID
[0];
1404 /* Returns the folder's PIDL type, or 0xff if one can't be found. */
1405 static BYTE
testSHGetSpecialFolderLocation(int folder
)
1411 if (!pSHGetSpecialFolderLocation
) return ret
;
1414 hr
= pSHGetSpecialFolderLocation(NULL
, folder
, &pidl
);
1419 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
1421 ok(pidlLast
!= NULL
,
1422 "%s: ILFindLastID failed\n", getFolderName(folder
));
1424 ret
= pidlLast
->mkid
.abID
[0];
1431 static void test_SHGetFolderPath(BOOL optional
, int folder
)
1433 char path
[MAX_PATH
];
1436 if (!pSHGetFolderPathA
) return;
1438 hr
= pSHGetFolderPathA(NULL
, folder
, NULL
, SHGFP_TYPE_CURRENT
, path
);
1439 ok(hr
== S_OK
|| optional
,
1440 "SHGetFolderPathA(NULL, %s, NULL, SHGFP_TYPE_CURRENT, path) failed: 0x%08x\n", getFolderName(folder
), hr
);
1443 static void test_SHGetSpecialFolderPath(BOOL optional
, int folder
)
1445 char path
[MAX_PATH
];
1448 if (!pSHGetSpecialFolderPathA
) return;
1450 ret
= pSHGetSpecialFolderPathA(NULL
, path
, folder
, FALSE
);
1451 if (ret
&& winetest_interactive
)
1452 printf("%s: %s\n", getFolderName(folder
), path
);
1454 "SHGetSpecialFolderPathA(NULL, path, %s, FALSE) failed\n",
1455 getFolderName(folder
));
1458 enum ShellValuesTestExpect
{
1459 ShellValuesTestExpect_Required
,
1460 ShellValuesTestExpect_Optional
,
1461 ShellValuesTestExpect_Missing
,
1464 static void test_ShellValues(const struct shellExpectedValues testEntries
[],
1465 int numEntries
, enum ShellValuesTestExpect expect
)
1469 for (i
= 0; i
< numEntries
; i
++)
1473 BOOL foundTypeMatch
= FALSE
;
1475 type
= testSHGetFolderLocation(testEntries
[i
].folder
);
1476 for (j
= 0; !foundTypeMatch
&& j
< testEntries
[i
].numTypes
; j
++)
1477 if (testEntries
[i
].types
[j
] == type
)
1478 foundTypeMatch
= TRUE
;
1479 ok((expect
== ShellValuesTestExpect_Required
&& foundTypeMatch
) ||
1480 (expect
== ShellValuesTestExpect_Optional
) ||
1481 (expect
== ShellValuesTestExpect_Missing
&& type
== 0xff),
1482 "%s has unexpected type %d (0x%02x)\n",
1483 getFolderName(testEntries
[i
].folder
), type
, type
);
1485 type
= testSHGetSpecialFolderLocation(testEntries
[i
].folder
);
1486 for (j
= 0, foundTypeMatch
= FALSE
; !foundTypeMatch
&&
1487 j
< testEntries
[i
].numTypes
; j
++)
1488 if (testEntries
[i
].types
[j
] == type
)
1489 foundTypeMatch
= TRUE
;
1490 ok((expect
== ShellValuesTestExpect_Required
&& foundTypeMatch
) ||
1491 (expect
== ShellValuesTestExpect_Optional
) ||
1492 (expect
== ShellValuesTestExpect_Missing
&& type
== 0xff),
1493 "%s has unexpected type %d (0x%02x)\n",
1494 getFolderName(testEntries
[i
].folder
), type
, type
);
1495 if (expect
!= ShellValuesTestExpect_Missing
)
1503 test_SHGetFolderPath(expect
== ShellValuesTestExpect_Optional
, testEntries
[i
].folder
);
1504 test_SHGetSpecialFolderPath(expect
== ShellValuesTestExpect_Optional
, testEntries
[i
].folder
);
1511 /* Attempts to verify that the folder path corresponding to the folder CSIDL
1512 * value has the same value as the environment variable with name envVar.
1513 * Doesn't mind if SHGetSpecialFolderPath fails for folder or if envVar isn't
1514 * set in this environment; different OS and shell version behave differently.
1515 * However, if both are present, fails if envVar's value is not the same
1516 * (byte-for-byte) as what SHGetSpecialFolderPath returns.
1518 static void matchSpecialFolderPathToEnv(int folder
, const char *envVar
)
1520 char path
[MAX_PATH
];
1522 if (!pSHGetSpecialFolderPathA
) return;
1524 if (pSHGetSpecialFolderPathA(NULL
, path
, folder
, FALSE
))
1526 char *envVal
= getenv(envVar
);
1528 ok(!envVal
|| !lstrcmpiA(envVal
, path
),
1529 "%%%s%% does not match SHGetSpecialFolderPath:\n"
1530 "%%%s%% is %s\nSHGetSpecialFolderPath returns %s\n",
1531 envVar
, envVar
, envVal
, path
);
1535 /* Attempts to match the GUID returned by SHGetFolderLocation for folder with
1536 * GUID. Assumes the type of the returned PIDL is in fact a GUID, but doesn't
1537 * fail if it isn't--that check should already have been done.
1538 * Fails if the returned PIDL is a GUID whose value does not match guid.
1540 static void matchGUID(int folder
, const GUID
*guid
, const GUID
*guid_alt
)
1548 hr
= SHGetFolderLocation(NULL
, folder
, NULL
, 0, &pidl
);
1551 LPITEMIDLIST pidlLast
= pILFindLastID(pidl
);
1553 if (pidlLast
&& (pidlLast
->mkid
.abID
[0] == PT_SHELLEXT
||
1554 pidlLast
->mkid
.abID
[0] == PT_GUID
))
1556 GUID
*shellGuid
= (GUID
*)(pidlLast
->mkid
.abID
+ 2);
1559 ok(IsEqualIID(shellGuid
, guid
),
1560 "%s: got GUID %s, expected %s\n", getFolderName(folder
),
1561 wine_dbgstr_guid(shellGuid
), wine_dbgstr_guid(guid
));
1563 ok(IsEqualIID(shellGuid
, guid
) ||
1564 IsEqualIID(shellGuid
, guid_alt
),
1565 "%s: got GUID %s, expected %s or %s\n", getFolderName(folder
),
1566 wine_dbgstr_guid(shellGuid
), wine_dbgstr_guid(guid
), wine_dbgstr_guid(guid_alt
));
1572 /* Checks the PIDL type of all the known values. */
1573 static void test_PidlTypes(void)
1576 test_SHGetFolderPath(FALSE
, CSIDL_DESKTOP
);
1577 test_SHGetSpecialFolderPath(FALSE
, CSIDL_DESKTOP
);
1579 test_ShellValues(requiredShellValues
, ARRAY_SIZE(requiredShellValues
), ShellValuesTestExpect_Required
);
1580 test_ShellValues(optionalShellValues
, ARRAY_SIZE(optionalShellValues
), ShellValuesTestExpect_Optional
);
1581 test_ShellValues(undefinedShellValues
, ARRAY_SIZE(undefinedShellValues
), ShellValuesTestExpect_Missing
);
1584 /* FIXME: Should be in shobjidl.idl */
1585 DEFINE_GUID(CLSID_NetworkExplorerFolder
, 0xF02C1A0D, 0xBE21, 0x4350, 0x88, 0xB0, 0x73, 0x67, 0xFC, 0x96, 0xEF, 0x3C);
1586 DEFINE_GUID(_CLSID_Documents
, 0xA8CDFF1C, 0x4878, 0x43be, 0xB5, 0xFD, 0xF8, 0x09, 0x1C, 0x1C, 0x60, 0xD0);
1588 /* Verifies various shell virtual folders have the correct well-known GUIDs. */
1589 static void test_GUIDs(void)
1591 matchGUID(CSIDL_BITBUCKET
, &CLSID_RecycleBin
, NULL
);
1592 matchGUID(CSIDL_CONTROLS
, &CLSID_ControlPanel
, NULL
);
1593 matchGUID(CSIDL_DRIVES
, &CLSID_MyComputer
, NULL
);
1594 matchGUID(CSIDL_INTERNET
, &CLSID_Internet
, NULL
);
1595 matchGUID(CSIDL_NETWORK
, &CLSID_NetworkPlaces
, &CLSID_NetworkExplorerFolder
); /* Vista and higher */
1596 matchGUID(CSIDL_PERSONAL
, &CLSID_MyDocuments
, &_CLSID_Documents
/* win8 */);
1597 matchGUID(CSIDL_COMMON_DOCUMENTS
, &CLSID_CommonDocuments
, NULL
);
1598 matchGUID(CSIDL_PRINTERS
, &CLSID_Printers
, NULL
);
1601 /* Verifies various shell paths match the environment variables to which they
1604 static void test_EnvVars(void)
1606 matchSpecialFolderPathToEnv(CSIDL_PROGRAM_FILES
, "ProgramFiles");
1607 matchSpecialFolderPathToEnv(CSIDL_APPDATA
, "APPDATA");
1608 matchSpecialFolderPathToEnv(CSIDL_PROFILE
, "USERPROFILE");
1609 matchSpecialFolderPathToEnv(CSIDL_WINDOWS
, "SystemRoot");
1610 matchSpecialFolderPathToEnv(CSIDL_WINDOWS
, "windir");
1611 matchSpecialFolderPathToEnv(CSIDL_PROGRAM_FILES_COMMON
, "CommonProgramFiles");
1612 /* this is only set on Wine, but can't hurt to verify it: */
1613 matchSpecialFolderPathToEnv(CSIDL_SYSTEM
, "winsysdir");
1616 /* Loosely based on PathRemoveBackslashA from dlls/shlwapi/path.c */
1617 static BOOL
myPathIsRootA(LPCSTR lpszPath
)
1619 if (lpszPath
&& *lpszPath
&&
1620 lpszPath
[1] == ':' && lpszPath
[2] == '\\' && lpszPath
[3] == '\0')
1621 return TRUE
; /* X:\ */
1624 static LPSTR
myPathRemoveBackslashA( LPSTR lpszPath
)
1626 LPSTR szTemp
= NULL
;
1630 szTemp
= CharPrevA(lpszPath
, lpszPath
+ strlen(lpszPath
));
1631 if (!myPathIsRootA(lpszPath
) && *szTemp
== '\\')
1637 /* Verifies the shell path for CSIDL_WINDOWS matches the return from
1638 * GetWindowsDirectory. If SHGetSpecialFolderPath fails, no harm, no foul--not
1639 * every shell32 version supports CSIDL_WINDOWS.
1641 static void testWinDir(void)
1643 char windowsShellPath
[MAX_PATH
], windowsDir
[MAX_PATH
] = { 0 };
1645 if (!pSHGetSpecialFolderPathA
) return;
1647 if (pSHGetSpecialFolderPathA(NULL
, windowsShellPath
, CSIDL_WINDOWS
, FALSE
))
1649 myPathRemoveBackslashA(windowsShellPath
);
1650 GetWindowsDirectoryA(windowsDir
, sizeof(windowsDir
));
1651 myPathRemoveBackslashA(windowsDir
);
1652 ok(!lstrcmpiA(windowsDir
, windowsShellPath
),
1653 "GetWindowsDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1654 windowsDir
, windowsShellPath
);
1658 /* Verifies the shell path for CSIDL_SYSTEM matches the return from
1659 * GetSystemDirectory. If SHGetSpecialFolderPath fails, no harm,
1660 * no foul--not every shell32 version supports CSIDL_SYSTEM.
1662 static void testSystemDir(void)
1664 char systemShellPath
[MAX_PATH
], systemDir
[MAX_PATH
], systemDirx86
[MAX_PATH
];
1666 if (!pSHGetSpecialFolderPathA
) return;
1668 GetSystemDirectoryA(systemDir
, sizeof(systemDir
));
1669 myPathRemoveBackslashA(systemDir
);
1670 if (pSHGetSpecialFolderPathA(NULL
, systemShellPath
, CSIDL_SYSTEM
, FALSE
))
1672 myPathRemoveBackslashA(systemShellPath
);
1673 ok(!lstrcmpiA(systemDir
, systemShellPath
),
1674 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1675 systemDir
, systemShellPath
);
1678 if (!pGetSystemWow64DirectoryA
|| !pGetSystemWow64DirectoryA(systemDirx86
, sizeof(systemDirx86
)))
1679 GetSystemDirectoryA(systemDirx86
, sizeof(systemDirx86
));
1680 myPathRemoveBackslashA(systemDirx86
);
1681 if (pSHGetSpecialFolderPathA(NULL
, systemShellPath
, CSIDL_SYSTEMX86
, FALSE
))
1683 myPathRemoveBackslashA(systemShellPath
);
1684 ok(!lstrcmpiA(systemDirx86
, systemShellPath
) || broken(!lstrcmpiA(systemDir
, systemShellPath
)),
1685 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1686 systemDir
, systemShellPath
);
1690 /* Globals used by subprocesses */
1692 static char **myARGV
;
1693 static char base
[MAX_PATH
];
1694 static char selfname
[MAX_PATH
];
1696 static BOOL
init(void)
1698 myARGC
= winetest_get_mainargs(&myARGV
);
1699 if (!GetCurrentDirectoryA(sizeof(base
), base
)) return FALSE
;
1700 strcpy(selfname
, myARGV
[0]);
1704 static void doChild(const char *arg
)
1706 char path
[MAX_PATH
];
1714 /* test what happens when CSIDL_FAVORITES is set to a nonexistent directory */
1716 /* test some failure cases first: */
1717 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
, NULL
, SHGFP_TYPE_CURRENT
, path
);
1718 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
1719 "SHGetFolderPath returned 0x%08x, expected 0x80070002\n", hr
);
1722 hr
= SHGetFolderLocation(NULL
, CSIDL_FAVORITES
, NULL
, 0, &pidl
);
1723 ok(hr
== E_FAIL
|| hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
1724 "SHGetFolderLocation returned 0x%08x\n", hr
);
1726 ok(!pSHGetSpecialFolderPathA(NULL
, path
, CSIDL_FAVORITES
, FALSE
),
1727 "SHGetSpecialFolderPath succeeded, expected failure\n");
1730 hr
= pSHGetSpecialFolderLocation(NULL
, CSIDL_FAVORITES
, &pidl
);
1731 ok(hr
== E_FAIL
|| hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
),
1732 "SHGetFolderLocation returned 0x%08x\n", hr
);
1734 /* now test success: */
1735 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
| CSIDL_FLAG_CREATE
, NULL
,
1736 SHGFP_TYPE_CURRENT
, path
);
1737 ok (hr
== S_OK
, "got 0x%08x\n", hr
);
1742 trace("CSIDL_FAVORITES was changed to %s\n", path
);
1743 ret
= CreateDirectoryA(path
, NULL
);
1744 ok(!ret
, "expected failure with ERROR_ALREADY_EXISTS\n");
1746 ok(GetLastError() == ERROR_ALREADY_EXISTS
,
1747 "got %d, expected ERROR_ALREADY_EXISTS\n", GetLastError());
1749 p
= path
+ strlen(path
);
1750 strcpy(p
, "\\desktop.ini");
1753 SetFileAttributesA( path
, FILE_ATTRIBUTE_NORMAL
);
1754 ret
= RemoveDirectoryA(path
);
1755 ok( ret
, "failed to remove %s error %u\n", path
, GetLastError() );
1758 else if (arg
[0] == '2')
1760 /* make sure SHGetFolderPath still succeeds when the
1761 original value of CSIDL_FAVORITES is restored. */
1762 hr
= pSHGetFolderPathA(NULL
, CSIDL_FAVORITES
| CSIDL_FLAG_CREATE
, NULL
,
1763 SHGFP_TYPE_CURRENT
, path
);
1764 ok(hr
== S_OK
, "SHGetFolderPath failed: 0x%08x\n", hr
);
1768 /* Tests the return values from the various shell functions both with and
1769 * without the use of the CSIDL_FLAG_CREATE flag. This flag only appeared in
1770 * version 5 of the shell, so don't test unless it's at least version 5.
1771 * The test reads a value from the registry, modifies it, calls
1772 * SHGetFolderPath once with the CSIDL_FLAG_CREATE flag, and immediately
1773 * afterward without it. Then it restores the registry and deletes the folder
1775 * One oddity with respect to restoration: shell32 caches somehow, so it needs
1776 * to be reloaded in order to see the correct (restored) value.
1777 * Some APIs unrelated to the ones under test may fail, but I expect they're
1778 * covered by other unit tests; I just print out something about failure to
1779 * help trace what's going on.
1781 static void test_NonExistentPath(void)
1783 static const char userShellFolders
[] =
1784 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
1785 char originalPath
[MAX_PATH
], modifiedPath
[MAX_PATH
];
1788 if (!pSHGetFolderPathA
) return;
1789 if (!pSHGetSpecialFolderPathA
) return;
1790 if (!pSHGetSpecialFolderLocation
) return;
1791 if (!pSHFileOperationA
) return;
1792 if (shellVersion
.dwMajorVersion
< 5) return;
1794 if (!RegOpenKeyExA(HKEY_CURRENT_USER
, userShellFolders
, 0, KEY_ALL_ACCESS
,
1799 len
= sizeof(originalPath
);
1800 if (!RegQueryValueExA(key
, "Favorites", NULL
, &type
,
1801 (LPBYTE
)&originalPath
, &len
))
1803 size_t len
= strlen(originalPath
);
1805 memcpy(modifiedPath
, originalPath
, len
);
1806 modifiedPath
[len
++] = '2';
1807 modifiedPath
[len
++] = '\0';
1808 trace("Changing CSIDL_FAVORITES to %s\n", modifiedPath
);
1809 if (!RegSetValueExA(key
, "Favorites", 0, type
,
1810 (LPBYTE
)modifiedPath
, len
))
1812 char buffer
[MAX_PATH
+20];
1813 STARTUPINFOA startup
;
1814 PROCESS_INFORMATION info
;
1816 sprintf(buffer
, "%s shellpath 1", selfname
);
1817 memset(&startup
, 0, sizeof(startup
));
1818 startup
.cb
= sizeof(startup
);
1819 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
1820 startup
.wShowWindow
= SW_SHOWNORMAL
;
1821 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
,
1823 wait_child_process( info
.hProcess
);
1825 /* restore original values: */
1826 trace("Restoring CSIDL_FAVORITES to %s\n", originalPath
);
1827 RegSetValueExA(key
, "Favorites", 0, type
, (LPBYTE
) originalPath
,
1828 strlen(originalPath
) + 1);
1831 sprintf(buffer
, "%s shellpath 2", selfname
);
1832 memset(&startup
, 0, sizeof(startup
));
1833 startup
.cb
= sizeof(startup
);
1834 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
1835 startup
.wShowWindow
= SW_SHOWNORMAL
;
1836 CreateProcessA(NULL
, buffer
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
,
1838 ok(WaitForSingleObject(info
.hProcess
, 30000) == WAIT_OBJECT_0
,
1839 "child process termination\n");
1842 else skip("RegQueryValueExA(key, Favorites, ...) failed\n");
1846 else skip("RegOpenKeyExA(HKEY_CURRENT_USER, %s, ...) failed\n", userShellFolders
);
1849 static void test_SHGetFolderPathEx(void)
1851 WCHAR buffer
[MAX_PATH
], *path
, *path2
;
1856 if (!pSHGetKnownFolderPath
|| !pSHGetFolderPathEx
)
1858 win_skip("SHGetKnownFolderPath or SHGetFolderPathEx not available\n");
1862 if (0) { /* crashes */
1863 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, 0, NULL
, NULL
);
1864 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
1866 /* non-existent folder id */
1867 path
= (void *)0xdeadbeef;
1868 hr
= pSHGetKnownFolderPath(&IID_IOleObject
, 0, NULL
, &path
);
1869 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
1870 ok(path
== NULL
, "got %p\n", path
);
1873 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, KF_FLAG_DEFAULT_PATH
, NULL
, &path
);
1874 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1875 ok(path
!= NULL
, "expected path != NULL\n");
1876 CoTaskMemFree(path
);
1878 for (i
= 0; i
< ARRAY_SIZE(known_folders
); ++i
)
1880 const KNOWNFOLDERID
*folder_id
= known_folders
[i
].folderId
;
1883 hr
= pSHGetKnownFolderPath(folder_id
, KF_FLAG_DEFAULT
, NULL
, &path
);
1886 ok(path
== NULL
, "expected path == NULL\n");
1889 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1890 ok(path
!= NULL
, "expected path != NULL\n");
1893 hr
= pSHGetKnownFolderPath(folder_id
, KF_FLAG_SIMPLE_IDLIST
, NULL
, &path2
);
1894 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1895 ok(path2
!= NULL
, "expected path != NULL\n");
1896 ok(!lstrcmpiW(path
, path2
), "expected equal paths: %s, %s\n", wine_dbgstr_w(path
), wine_dbgstr_w(path2
));
1897 CoTaskMemFree(path2
);
1900 hr
= pSHGetKnownFolderPath(folder_id
, KF_FLAG_DONT_UNEXPAND
, NULL
, &path2
);
1901 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1902 ok(path2
!= NULL
, "expected path != NULL\n");
1903 ok(!lstrcmpiW(path
, path2
), "expected equal paths: %s, %s\n", wine_dbgstr_w(path
), wine_dbgstr_w(path2
));
1904 CoTaskMemFree(path2
);
1907 hr
= pSHGetKnownFolderPath(folder_id
, KF_FLAG_SIMPLE_IDLIST
| KF_FLAG_DONT_UNEXPAND
, NULL
, &path2
);
1908 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1909 ok(path2
!= NULL
, "expected path != NULL\n");
1910 ok(!lstrcmpiW(path
, path2
), "expected equal paths: %s, %s\n", wine_dbgstr_w(path
), wine_dbgstr_w(path2
));
1911 CoTaskMemFree(path2
);
1913 hr
= pSHGetKnownFolderPath(folder_id
, KF_FLAG_DEFAULT_PATH
, NULL
, &path2
);
1914 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1915 ok(path2
!= NULL
, "expected path != NULL\n");
1916 CoTaskMemFree(path2
);
1918 hr
= pSHGetKnownFolderPath(folder_id
, KF_FLAG_NOT_PARENT_RELATIVE
, NULL
, &path2
);
1919 ok(hr
== E_INVALIDARG
, "expected S_OK, got 0x%08x\n", hr
);
1921 hr
= pSHGetKnownFolderPath(folder_id
, KF_FLAG_DEFAULT_PATH
| KF_FLAG_NOT_PARENT_RELATIVE
, NULL
, &path2
);
1922 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1923 ok(path2
!= NULL
, "expected path != NULL\n");
1924 CoTaskMemFree(path2
);
1926 CoTaskMemFree(path
);
1930 hr
= pSHGetKnownFolderPath(&FOLDERID_Desktop
, 0, NULL
, &path
);
1931 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1932 ok(path
!= NULL
, "expected path != NULL\n");
1934 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, MAX_PATH
);
1935 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1936 ok(!lstrcmpiW(path
, buffer
), "expected equal paths\n");
1937 len
= lstrlenW(buffer
);
1938 CoTaskMemFree(path
);
1940 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, 0);
1941 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
1943 if (0) { /* crashes */
1944 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, NULL
, len
+ 1);
1945 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
1947 hr
= pSHGetFolderPathEx(NULL
, 0, NULL
, buffer
, MAX_PATH
);
1948 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got 0x%08x\n", hr
);
1950 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
);
1951 ok(hr
== E_NOT_SUFFICIENT_BUFFER
, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr
);
1953 hr
= pSHGetFolderPathEx(&FOLDERID_Desktop
, 0, NULL
, buffer
, len
+ 1);
1954 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1957 hr
= pSHGetKnownFolderPath(&FOLDERID_ProgramFilesX64
, 0, NULL
, &path
);
1959 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1960 ok(path
!= NULL
, "path not set\n");
1961 CoTaskMemFree(path
);
1963 todo_wine
ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
1964 ok(path
== NULL
, "path set\n");
1968 hr
= pSHGetKnownFolderPath(&FOLDERID_ProgramFilesCommonX64
, 0, NULL
, &path
);
1970 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1971 ok(path
!= NULL
, "path not set\n");
1972 CoTaskMemFree(path
);
1974 todo_wine
ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
1975 ok(path
== NULL
, "path set\n");
1979 static BOOL
is_in_strarray(const WCHAR
*needle
, const char *hay
)
1981 WCHAR wstr
[MAX_PATH
];
1990 if(strcmp(hay
, "(null)") == 0 && !needle
)
1993 ret
= MultiByteToWideChar(CP_ACP
, 0, hay
, -1, wstr
, ARRAY_SIZE(wstr
));
1996 ok(0, "Failed to convert string\n");
2000 if(lstrcmpW(wstr
, needle
) == 0)
2003 hay
+= strlen(hay
) + 1;
2009 static void check_known_folder(IKnownFolderManager
*mgr
, KNOWNFOLDERID
*folderId
)
2012 int csidl
, expectedCsidl
, ret
;
2013 KNOWNFOLDER_DEFINITION kfd
;
2014 IKnownFolder
*folder
, *kf_parent
;
2018 WCHAR
*ikf_path
, *gkfp_path
, *ikf_parent_path
;
2020 for (i
= 0; i
< ARRAY_SIZE(known_folders
); ++i
)
2022 const struct knownFolderDef
*known_folder
= &known_folders
[i
];
2024 if(IsEqualGUID(known_folder
->folderId
, folderId
))
2026 known_folder_found
[i
] = TRUE
;
2029 if(!(known_folder
->csidl
& NO_CSIDL
))
2031 /* mask off winetest flags */
2032 expectedCsidl
= known_folder
->csidl
& 0xFFFF;
2034 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, folderId
, &csidl
);
2035 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot retrieve CSIDL for folder %s\n", known_folder
->sFolderId
);
2037 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
);
2040 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
2041 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder for %s\n", known_folder
->sFolderId
);
2044 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
2045 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "cannot get known folder definition for %s\n", known_folder
->sFolderId
);
2048 ret
= MultiByteToWideChar(CP_ACP
, 0, known_folder
->sName
, -1, sName
, ARRAY_SIZE(sName
));
2049 ok_(__FILE__
, known_folder
->line
)(ret
!= 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder
->sName
);
2051 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
));
2053 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
);
2055 ok_(__FILE__
, known_folder
->line
)(IsEqualGUID(known_folder
->fidParents
[0], &kfd
.fidParent
) ||
2056 IsEqualGUID(known_folder
->fidParents
[1], &kfd
.fidParent
),
2057 "invalid known folder parent for %s: %s retrieved\n",
2058 known_folder
->sFolderId
, wine_dbgstr_guid(&kfd
.fidParent
));
2060 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
));
2062 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
));
2064 ok_(__FILE__
, known_folder
->line
)(known_folder
->attributes
== kfd
.dwAttributes
||
2065 (known_folder
->csidl
& WINE_ATTRIBUTES_OPTIONAL
&& kfd
.dwAttributes
== 0),
2066 "invalid known folder attributes for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder
->sFolderId
, known_folder
->attributes
, kfd
.dwAttributes
);
2068 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
);
2071 hr
= pSHGetKnownFolderPath(folderId
, KF_FLAG_DEFAULT
, NULL
, &gkfp_path
);
2075 hr
= IKnownFolder_GetPath(folder
, KF_FLAG_DEFAULT
, &ikf_path
);
2076 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "IKnownFolder::GetPath failed: 0x%08x\n", hr
);
2077 ok_(__FILE__
, known_folder
->line
)(ikf_path
!= NULL
, "SHGetKnownFolderPath gave NULL path\n");
2079 /* IKnownFolder::GetPath and SHGetKnownFolderPath should be the same */
2080 ok_(__FILE__
, known_folder
->line
)(lstrcmpW(gkfp_path
, ikf_path
) == 0, "Got different paths: %s vs %s\n",
2081 debugstr_w(gkfp_path
), debugstr_w(ikf_path
));
2083 if(kfd
.pszRelativePath
)
2085 /* RelativePath should be a substring of the path */
2086 ok_(__FILE__
, known_folder
->line
)(wcscasestr(ikf_path
, kfd
.pszRelativePath
) != NULL
,
2087 "KNOWNFOLDER_DEFINITION.pszRelativePath %s is not a substring of full path %s\n",
2088 debugstr_w(kfd
.pszRelativePath
), debugstr_w(ikf_path
));
2090 hr
= IKnownFolderManager_GetFolder(mgr
, &kfd
.fidParent
, &kf_parent
);
2091 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "IKnownFolderManager::GetFolder(parent) failed: 0x%08x\n", hr
);
2095 ikf_parent_path
= NULL
;
2096 hr
= IKnownFolder_GetPath(kf_parent
, KF_FLAG_DEFAULT
, &ikf_parent_path
);
2097 ok_(__FILE__
, known_folder
->line
)(hr
== S_OK
, "IKnownFolder::GetPath(parent) failed: 0x%08x\n", hr
);
2099 /* Parent path + pszRelativePath should give the full path */
2100 ok_(__FILE__
, known_folder
->line
)(memcmp(ikf_parent_path
, ikf_path
, lstrlenW(ikf_parent_path
) * sizeof(WCHAR
)) == 0,
2101 "Full path %s does not start with parent path %s\n",
2102 debugstr_w(ikf_path
), debugstr_w(ikf_parent_path
));
2103 ok_(__FILE__
, known_folder
->line
)(*(ikf_path
+ lstrlenW(ikf_parent_path
)) == '\\',
2105 ok_(__FILE__
, known_folder
->line
)(
2106 wcsicmp(kfd
.pszRelativePath
, ikf_path
+ lstrlenW(ikf_parent_path
) + 1) == 0 ||
2107 /* With multiple drives, there are multiple CD-burning folders */
2108 (IsEqualGUID(folderId
, &FOLDERID_CDBurning
) &&
2109 wcsnicmp(kfd
.pszRelativePath
, ikf_path
+ lstrlenW(ikf_parent_path
) + 1, wcslen(kfd
.pszRelativePath
)) == 0),
2110 "Full path %s does not end with relative path %s\n",
2111 debugstr_w(ikf_path
), debugstr_w(kfd
.pszRelativePath
));
2113 CoTaskMemFree(ikf_parent_path
);
2114 IKnownFolder_Release(kf_parent
);
2118 CoTaskMemFree(ikf_path
);
2119 CoTaskMemFree(gkfp_path
);
2121 FreeKnownFolderDefinitionFields(&kfd
);
2124 IKnownFolder_Release(folder
);
2133 trace("unknown known folder found: %s\n", wine_dbgstr_guid(folderId
));
2135 hr
= IKnownFolderManager_GetFolder(mgr
, folderId
, &folder
);
2136 ok(hr
== S_OK
, "cannot get known folder for %s\n", wine_dbgstr_guid(folderId
));
2139 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfd
);
2141 ok(hr
== S_OK
, "cannot get known folder definition for %s\n", wine_dbgstr_guid(folderId
));
2144 trace(" category: %d\n", kfd
.category
);
2145 trace(" name: %s\n", wine_dbgstr_w(kfd
.pszName
));
2146 trace(" description: %s\n", wine_dbgstr_w(kfd
.pszDescription
));
2147 trace(" parent: %s\n", wine_dbgstr_guid(&kfd
.fidParent
));
2148 trace(" relative path: %s\n", wine_dbgstr_w(kfd
.pszRelativePath
));
2149 trace(" parsing name: %s\n", wine_dbgstr_w(kfd
.pszParsingName
));
2150 trace(" tooltip: %s\n", wine_dbgstr_w(kfd
.pszTooltip
));
2151 trace(" localized name: %s\n", wine_dbgstr_w(kfd
.pszLocalizedName
));
2152 trace(" icon: %s\n", wine_dbgstr_w(kfd
.pszIcon
));
2153 trace(" security: %s\n", wine_dbgstr_w(kfd
.pszSecurity
));
2154 trace(" attributes: 0x%08x\n", kfd
.dwAttributes
);
2155 trace(" flags: 0x%08x\n", kfd
.kfdFlags
);
2156 trace(" type: %s\n", wine_dbgstr_guid(&kfd
.ftidType
));
2157 FreeKnownFolderDefinitionFields(&kfd
);
2160 IKnownFolder_Release(folder
);
2166 static void test_knownFolders(void)
2168 static const WCHAR sWindows
[] = {'W','i','n','d','o','w','s',0};
2169 static const WCHAR sWindows2
[] = {'w','i','n','d','o','w','s',0};
2170 static const WCHAR sExample
[] = {'E','x','a','m','p','l','e',0};
2171 static const WCHAR sExample2
[] = {'E','x','a','m','p','l','e','2',0};
2172 static const WCHAR sSubFolder
[] = {'S','u','b','F','o','l','d','e','r',0};
2173 static const WCHAR sNoSuch
[] = {'N','o','S','u','c','h',0};
2174 static const WCHAR sBackslash
[] = {'\\',0};
2175 static const KNOWNFOLDERID newFolderId
= {0x01234567, 0x89AB, 0xCDEF, {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x01} };
2176 static const KNOWNFOLDERID subFolderId
= {0xFEDCBA98, 0x7654, 0x3210, {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF} };
2178 IKnownFolderManager
*mgr
= NULL
;
2179 IKnownFolder
*folder
= NULL
, *subFolder
= NULL
;
2180 KNOWNFOLDERID folderId
, *folders
;
2181 KF_CATEGORY cat
= 0;
2182 KNOWNFOLDER_DEFINITION kfDefinition
, kfSubDefinition
;
2185 LPWSTR folderPath
, errorMsg
;
2186 KF_REDIRECTION_CAPABILITIES redirectionCapabilities
= 1;
2187 WCHAR sWinDir
[MAX_PATH
], sExamplePath
[MAX_PATH
], sExample2Path
[MAX_PATH
], sSubFolderPath
[MAX_PATH
], sSubFolder2Path
[MAX_PATH
];
2191 GetWindowsDirectoryW( sWinDir
, MAX_PATH
);
2193 GetTempPathW(ARRAY_SIZE(sExamplePath
), sExamplePath
);
2194 lstrcatW(sExamplePath
, sExample
);
2196 GetTempPathW(ARRAY_SIZE(sExample2Path
), sExample2Path
);
2197 lstrcatW(sExample2Path
, sExample2
);
2199 lstrcpyW(sSubFolderPath
, sExamplePath
);
2200 lstrcatW(sSubFolderPath
, sBackslash
);
2201 lstrcatW(sSubFolderPath
, sSubFolder
);
2203 lstrcpyW(sSubFolder2Path
, sExample2Path
);
2204 lstrcatW(sSubFolder2Path
, sBackslash
);
2205 lstrcatW(sSubFolder2Path
, sSubFolder
);
2209 hr
= CoCreateInstance(&CLSID_KnownFolderManager
, NULL
, CLSCTX_INPROC_SERVER
,
2210 &IID_IKnownFolderManager
, (LPVOID
*)&mgr
);
2211 if(hr
== REGDB_E_CLASSNOTREG
)
2212 win_skip("IKnownFolderManager unavailable\n");
2217 ok(hr
== S_OK
, "failed to create KnownFolderManager instance: 0x%08x\n", hr
);
2219 hr
= IKnownFolderManager_QueryInterface(mgr
, &IID_IMarshal
, (void**)&unk
);
2220 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2222 hr
= IKnownFolderManager_FolderIdFromCsidl(mgr
, CSIDL_WINDOWS
, &folderId
);
2223 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2224 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2226 hr
= IKnownFolderManager_FolderIdToCsidl(mgr
, &FOLDERID_Windows
, &csidl
);
2227 ok(hr
== S_OK
, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr
);
2228 ok(csidl
== CSIDL_WINDOWS
, "invalid CSIDL returned\n");
2230 hr
= IKnownFolderManager_GetFolder(mgr
, &FOLDERID_Windows
, &folder
);
2231 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2234 hr
= IKnownFolder_QueryInterface(folder
, &IID_IMarshal
, (void**)&unk
);
2235 ok(hr
== E_NOINTERFACE
, "got 0x%08x\n", hr
);
2237 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2238 ok(hr
== S_OK
, "failed to get folder category: 0x%08x\n", hr
);
2239 ok(cat
==KF_CATEGORY_FIXED
, "invalid folder category: %d\n", cat
);
2241 hr
= IKnownFolder_GetId(folder
, &folderId
);
2242 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2243 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2245 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2246 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2247 ok(lstrcmpiW(sWinDir
, folderPath
)==0, "invalid path returned: \"%s\", expected: \"%s\"\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sWinDir
));
2248 CoTaskMemFree(folderPath
);
2250 hr
= IKnownFolder_GetRedirectionCapabilities(folder
, &redirectionCapabilities
);
2251 ok(hr
== S_OK
, "failed to get redirection capabilities: 0x%08x\n", hr
);
2253 ok(redirectionCapabilities
==0, "invalid redirection capabilities returned: %d\n", redirectionCapabilities
);
2255 hr
= IKnownFolder_SetPath(folder
, 0, sWinDir
);
2257 ok(hr
== E_INVALIDARG
, "unexpected value from SetPath: 0x%08x\n", hr
);
2259 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfDefinition
);
2260 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2263 ok(kfDefinition
.category
==KF_CATEGORY_FIXED
, "invalid folder category: 0x%08x\n", kfDefinition
.category
);
2264 ok(lstrcmpW(kfDefinition
.pszName
, sWindows
)==0, "invalid folder name: %s\n", wine_dbgstr_w(kfDefinition
.pszName
));
2265 ok(kfDefinition
.dwAttributes
==0, "invalid folder attributes: %d\n", kfDefinition
.dwAttributes
);
2266 FreeKnownFolderDefinitionFields(&kfDefinition
);
2269 hr
= IKnownFolder_Release(folder
);
2270 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2273 hr
= IKnownFolderManager_GetFolderByName(mgr
, sWindows
, &folder
);
2274 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2277 hr
= IKnownFolder_GetId(folder
, &folderId
);
2278 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2279 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2281 hr
= IKnownFolder_Release(folder
);
2282 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2285 hr
= IKnownFolderManager_GetFolderByName(mgr
, sWindows2
, &folder
);
2286 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2289 hr
= IKnownFolder_GetId(folder
, &folderId
);
2290 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2291 ok(IsEqualGUID(&folderId
, &FOLDERID_Windows
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2293 hr
= IKnownFolder_Release(folder
);
2294 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2297 folder
= (IKnownFolder
*)0xdeadbeef;
2298 hr
= IKnownFolderManager_GetFolderByName(mgr
, sNoSuch
, &folder
);
2299 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
2300 ok(folder
== NULL
, "got %p\n", folder
);
2302 for(i
=0; i
< ARRAY_SIZE(known_folder_found
); ++i
)
2303 known_folder_found
[i
] = FALSE
;
2305 hr
= IKnownFolderManager_GetFolderIds(mgr
, &folders
, &nCount
);
2306 ok(hr
== S_OK
, "failed to get known folders: 0x%08x\n", hr
);
2307 for(i
=0;i
<nCount
;++i
)
2308 check_known_folder(mgr
, &folders
[i
]);
2310 for(i
=0; i
< ARRAY_SIZE(known_folder_found
); ++i
)
2311 if(!known_folder_found
[i
])
2312 trace("Known folder %s not found on current platform\n", known_folders
[i
].sFolderId
);
2314 CoTaskMemFree(folders
);
2316 /* test of registering new known folders */
2317 bRes
= CreateDirectoryW(sExamplePath
, NULL
);
2318 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExamplePath
));
2319 bRes
= CreateDirectoryW(sExample2Path
, NULL
);
2320 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sExample2Path
));
2321 bRes
= CreateDirectoryW(sSubFolderPath
, NULL
);
2322 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolderPath
));
2324 ZeroMemory(&kfDefinition
, sizeof(kfDefinition
));
2325 kfDefinition
.category
= KF_CATEGORY_PERUSER
;
2326 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample
));
2327 lstrcpyW(kfDefinition
.pszName
, sExample
);
2328 kfDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sExample
));
2329 lstrcpyW(kfDefinition
.pszDescription
, sExample
);
2330 kfDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sExamplePath
));
2331 lstrcpyW(kfDefinition
.pszRelativePath
, sExamplePath
);
2333 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2334 if(hr
== HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED
))
2335 win_skip("No permissions required to register custom known folder\n");
2338 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2341 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2342 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2345 hr
= IKnownFolder_GetCategory(folder
, &cat
);
2346 ok(hr
== S_OK
, "failed to get folder category: hr=0x%0x\n", hr
);
2347 ok(cat
== KF_CATEGORY_PERUSER
, "invalid category returned: %d, while %d (KF_CATEGORY_PERUSER) expected\n", cat
, KF_CATEGORY_PERUSER
);
2349 hr
= IKnownFolder_GetId(folder
, &folderId
);
2350 ok(hr
== S_OK
, "failed to get folder id: 0x%08x\n", hr
);
2351 ok(IsEqualGUID(&folderId
, &newFolderId
)==TRUE
, "invalid KNOWNFOLDERID returned\n");
2353 /* current path should be Temp\Example */
2354 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2355 ok(hr
== S_OK
, "failed to get path from known folder: 0x%08x\n", hr
);
2356 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2357 CoTaskMemFree(folderPath
);
2359 /* register sub-folder and mark it as child of Example folder */
2360 ZeroMemory(&kfSubDefinition
, sizeof(kfSubDefinition
));
2361 kfSubDefinition
.category
= KF_CATEGORY_PERUSER
;
2362 kfSubDefinition
.pszName
= CoTaskMemAlloc(sizeof(sSubFolder
));
2363 lstrcpyW(kfSubDefinition
.pszName
, sSubFolder
);
2364 kfSubDefinition
.pszDescription
= CoTaskMemAlloc(sizeof(sSubFolder
));
2365 lstrcpyW(kfSubDefinition
.pszDescription
, sSubFolder
);
2366 kfSubDefinition
.pszRelativePath
= CoTaskMemAlloc(sizeof(sSubFolder
));
2367 lstrcpyW(kfSubDefinition
.pszRelativePath
, sSubFolder
);
2368 kfSubDefinition
.fidParent
= newFolderId
;
2370 hr
= IKnownFolderManager_RegisterFolder(mgr
, &subFolderId
, &kfSubDefinition
);
2371 ok(hr
== S_OK
, "failed to register known folder: 0x%08x\n", hr
);
2375 hr
= IKnownFolderManager_GetFolder(mgr
, &subFolderId
, &subFolder
);
2376 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2379 /* check sub folder path */
2380 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2381 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2382 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2383 CoTaskMemFree(folderPath
);
2386 /* try to redirect Example to Temp\Example2 */
2387 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2388 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2391 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2392 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2393 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2394 CoTaskMemFree(folderPath
);
2396 /* verify sub folder - it should fail now, as we redirected its parent folder, but we have no sub folder in new location */
2397 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2398 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "unexpected value from GetPath(): 0x%08x\n", hr
);
2399 ok(folderPath
==NULL
, "invalid known folder path retrieved: \"%s\" when NULL pointer was expected\n", wine_dbgstr_w(folderPath
));
2400 CoTaskMemFree(folderPath
);
2403 /* set Example path to original. Using SetPath() is valid here, as it also uses redirection internally */
2404 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2405 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2408 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2409 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2410 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2411 CoTaskMemFree(folderPath
);
2414 /* create sub folder in Temp\Example2 */
2415 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2416 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2418 /* again perform that same redirection */
2419 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 0, NULL
, &errorMsg
);
2420 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2422 /* verify sub folder. It should succeed now, as the required sub folder exists */
2423 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2424 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2425 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2426 CoTaskMemFree(folderPath
);
2428 /* remove newly created directory */
2429 RemoveDirectoryW(sSubFolder2Path
);
2431 /* verify subfolder. It still succeeds, so Windows does not check folder presence each time */
2432 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2434 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2436 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2437 CoTaskMemFree(folderPath
);
2440 /* set Example path to original */
2441 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2442 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2445 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2446 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2447 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2448 CoTaskMemFree(folderPath
);
2450 /* verify sub folder */
2451 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2452 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2453 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2454 CoTaskMemFree(folderPath
);
2457 /* create sub folder in Temp\Example2 */
2458 bRes
= CreateDirectoryW(sSubFolder2Path
, NULL
);
2459 ok(bRes
, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path
));
2461 /* do that same redirection, but try to exclude sub-folder */
2462 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, 0, sExample2Path
, 1, &subFolderId
, &errorMsg
);
2463 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2466 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2467 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2468 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2469 CoTaskMemFree(folderPath
);
2471 /* 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 */
2472 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2473 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2474 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2475 CoTaskMemFree(folderPath
);
2477 /* remove newly created directory */
2478 RemoveDirectoryW(sSubFolder2Path
);
2481 /* set Example path to original */
2482 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2483 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2486 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2487 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2488 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2489 CoTaskMemFree(folderPath
);
2491 /* verify sub folder */
2492 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2493 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2494 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2495 CoTaskMemFree(folderPath
);
2498 /* do that same redirection again, but set it to copy content. It should also copy the sub folder, so checking it would succeed now */
2499 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2500 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2503 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2504 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2505 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2506 CoTaskMemFree(folderPath
);
2508 /* verify sub folder */
2509 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2510 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2511 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2512 CoTaskMemFree(folderPath
);
2514 /* remove copied directory */
2515 RemoveDirectoryW(sSubFolder2Path
);
2518 /* set Example path to original */
2519 hr
= IKnownFolder_SetPath(folder
, 0, sExamplePath
);
2520 ok(hr
== S_OK
, "SetPath() failed: 0x%08x\n", hr
);
2523 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2524 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2525 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2526 CoTaskMemFree(folderPath
);
2528 /* verify sub folder */
2529 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2530 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2531 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2532 CoTaskMemFree(folderPath
);
2535 /* redirect again, set it to copy content and remove originals */
2536 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
| KF_REDIRECT_DEL_SOURCE_CONTENTS
, sExample2Path
, 0, NULL
, &errorMsg
);
2537 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2540 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2541 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2542 ok(lstrcmpiW(folderPath
, sExample2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExample2Path
));
2543 CoTaskMemFree(folderPath
);
2545 /* verify sub folder */
2546 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2547 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2548 ok(lstrcmpiW(folderPath
, sSubFolder2Path
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolder2Path
));
2549 CoTaskMemFree(folderPath
);
2551 /* check if original directory was really removed */
2552 dwAttributes
= GetFileAttributesW(sExamplePath
);
2553 ok(dwAttributes
==INVALID_FILE_ATTRIBUTES
, "directory should not exist, but has attributes: 0x%08x\n", dwAttributes
);
2556 /* redirect (with copy) to original path */
2557 hr
= IKnownFolderManager_Redirect(mgr
, &newFolderId
, NULL
, KF_REDIRECT_COPY_CONTENTS
, sExamplePath
, 0, NULL
, &errorMsg
);
2558 ok(hr
== S_OK
, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr
, wine_dbgstr_w(errorMsg
));
2561 hr
= IKnownFolder_GetPath(folder
, 0, &folderPath
);
2562 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2563 ok(lstrcmpiW(folderPath
, sExamplePath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sExamplePath
));
2564 CoTaskMemFree(folderPath
);
2566 /* verify sub folder */
2567 hr
= IKnownFolder_GetPath(subFolder
, 0, &folderPath
);
2568 ok(hr
== S_OK
, "failed to get known folder path: 0x%08x\n", hr
);
2569 ok(lstrcmpiW(folderPath
, sSubFolderPath
)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath
), wine_dbgstr_w(sSubFolderPath
));
2570 CoTaskMemFree(folderPath
);
2572 /* check shell utility functions */
2573 if(!pSHGetKnownFolderPath
|| !pSHSetKnownFolderPath
)
2575 win_skip("cannot get SHGet/SetKnownFolderPath routines\n");
2578 /* try to get current known folder path */
2579 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2581 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2583 ok(lstrcmpW(folderPath
, sExamplePath
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2585 /* set it to new value */
2586 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExample2Path
);
2588 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2590 /* check if it changed */
2591 hr
= pSHGetKnownFolderPath(&newFolderId
, 0, NULL
, &folderPath
);
2593 ok(hr
==S_OK
, "cannot get known folder path: hr=0x%0x\n", hr
);
2595 ok(lstrcmpW(folderPath
, sExample2Path
)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath
));
2598 hr
= pSHSetKnownFolderPath(&newFolderId
, 0, NULL
, sExamplePath
);
2600 ok(hr
==S_OK
, "cannot set known folder path: hr=0x%0x\n", hr
);
2603 IKnownFolder_Release(subFolder
);
2606 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &subFolderId
);
2607 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2610 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2612 hr
= IKnownFolder_Release(folder
);
2613 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2615 /* update the folder */
2616 CoTaskMemFree(kfDefinition
.pszName
);
2617 kfDefinition
.pszName
= CoTaskMemAlloc(sizeof(sExample2
));
2618 lstrcpyW(kfDefinition
.pszName
, sExample2
);
2619 hr
= IKnownFolderManager_RegisterFolder(mgr
, &newFolderId
, &kfDefinition
);
2620 ok(hr
== S_OK
, "failed to re-register known folder: 0x%08x\n", hr
);
2622 hr
= IKnownFolderManager_GetFolder(mgr
, &newFolderId
, &folder
);
2623 ok(hr
== S_OK
, "failed to get known folder: 0x%08x\n", hr
);
2625 hr
= IKnownFolder_GetFolderDefinition(folder
, &kfSubDefinition
);
2626 ok(hr
== S_OK
, "failed to get folder definition: 0x%08x\n", hr
);
2627 ok(!memcmp(kfDefinition
.pszName
, kfSubDefinition
.pszName
, sizeof(sExample2
)),
2628 "Got wrong updated name: %s\n", wine_dbgstr_w(kfSubDefinition
.pszName
));
2630 FreeKnownFolderDefinitionFields(&kfSubDefinition
);
2632 hr
= IKnownFolder_Release(folder
);
2633 ok(hr
== S_OK
, "failed to release KnownFolder instance: 0x%08x\n", hr
);
2636 hr
= IKnownFolderManager_UnregisterFolder(mgr
, &newFolderId
);
2637 ok(hr
== S_OK
, "failed to unregister folder: 0x%08x\n", hr
);
2640 FreeKnownFolderDefinitionFields(&kfDefinition
);
2642 RemoveDirectoryW(sSubFolder2Path
);
2643 RemoveDirectoryW(sSubFolderPath
);
2644 RemoveDirectoryW(sExamplePath
);
2645 RemoveDirectoryW(sExample2Path
);
2647 hr
= IKnownFolderManager_Release(mgr
);
2648 ok(hr
== S_OK
, "failed to release KnownFolderManager instance: 0x%08x\n", hr
);
2654 static void test_DoEnvironmentSubst(void)
2656 WCHAR expectedW
[MAX_PATH
];
2657 WCHAR bufferW
[MAX_PATH
];
2658 CHAR expectedA
[MAX_PATH
];
2659 CHAR bufferA
[MAX_PATH
];
2664 static const WCHAR does_not_existW
[] = {'%','D','O','E','S','_','N','O','T','_','E','X','I','S','T','%',0};
2665 static const CHAR does_not_existA
[] = "%DOES_NOT_EXIST%";
2666 static const CHAR
*names
[] = {
2667 /* interactive apps and services (works on all windows versions) */
2668 "%ALLUSERSPROFILE%", "%APPDATA%", "%LOCALAPPDATA%",
2669 "%NUMBER_OF_PROCESSORS%", "%OS%", "%PROCESSOR_ARCHITECTURE%",
2670 "%PROCESSOR_IDENTIFIER%", "%PROCESSOR_LEVEL%", "%PROCESSOR_REVISION%",
2671 "%ProgramFiles%", "%SystemDrive%",
2672 "%SystemRoot%", "%USERPROFILE%", "%windir%",
2673 /* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
2675 /* replace more than one var is allowed */
2676 "%HOMEDRIVE%%HOMEPATH%",
2677 "%OS% %windir%"}; /* always the last entry in the table */
2679 for (i
= 0; i
< ARRAY_SIZE(names
); i
++)
2681 winetest_push_context("%d", i
);
2682 memset(bufferA
, '#', MAX_PATH
- 1);
2683 bufferA
[MAX_PATH
- 1] = 0;
2684 lstrcpyA(bufferA
, names
[i
]);
2685 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2687 res2
= ExpandEnvironmentStringsA(names
[i
], expectedA
, MAX_PATH
);
2688 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2690 /* is the space for the terminating 0 included? */
2691 if (!i
&& HIWORD(res
) && (LOWORD(res
) == (lstrlenA(bufferA
))))
2693 win_skip("DoEnvironmentSubstA/W are broken on NT 4\n");
2694 winetest_pop_context();
2697 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2698 "got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2699 ok(!lstrcmpA(bufferA
, expectedA
),
2700 "got %s (expected %s)\n", bufferA
, expectedA
);
2702 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2703 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2704 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2705 "got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2706 ok(!lstrcmpW(bufferW
, expectedW
),
2707 "got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2708 winetest_pop_context();
2711 i
--; /* reuse data in the last table entry */
2712 len
= LOWORD(res
); /* needed length */
2714 /* one character extra is fine */
2715 memset(bufferA
, '#', MAX_PATH
- 1);
2716 bufferA
[len
+ 2] = 0;
2717 lstrcpyA(bufferA
, names
[i
]);
2718 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2720 res2
= ExpandEnvironmentStringsA(bufferA
, expectedA
, MAX_PATH
);
2721 res
= DoEnvironmentSubstA(bufferA
, len
+ 1);
2722 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2723 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2724 ok(!lstrcmpA(bufferA
, expectedA
),
2725 "+1: got %s (expected %s)\n", bufferA
, expectedA
);
2727 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2728 res
= DoEnvironmentSubstW(bufferW
, len
+ 1);
2729 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2730 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2731 ok(!lstrcmpW(bufferW
, expectedW
),
2732 "+1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2735 /* minimal buffer length (result string and terminating 0) */
2736 memset(bufferA
, '#', MAX_PATH
- 1);
2737 bufferA
[len
+ 2] = 0;
2738 lstrcpyA(bufferA
, names
[i
]);
2739 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2741 /* ANSI version failed without an extra byte, as documented on msdn */
2742 res
= DoEnvironmentSubstA(bufferA
, len
);
2743 ok(!HIWORD(res
) && (LOWORD(res
) == len
),
2744 " 0: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
);
2745 ok(!lstrcmpA(bufferA
, names
[i
]),
2746 " 0: got %s (expected %s)\n", bufferA
, names
[i
]);
2748 /* DoEnvironmentSubstW works as expected */
2749 res2
= ExpandEnvironmentStringsW(bufferW
, expectedW
, MAX_PATH
);
2750 res
= DoEnvironmentSubstW(bufferW
, len
);
2751 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2752 " 0: got %d/%d (expected TRUE/%d)\n", HIWORD(res
), LOWORD(res
), res2
);
2753 ok(!lstrcmpW(bufferW
, expectedW
),
2754 " 0: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2757 /* Buffer too small */
2758 /* result: FALSE / provided buffer length / the buffer is untouched */
2759 memset(bufferA
, '#', MAX_PATH
- 1);
2760 bufferA
[len
+ 2] = 0;
2761 lstrcpyA(bufferA
, names
[i
]);
2762 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2764 res
= DoEnvironmentSubstA(bufferA
, len
- 1);
2765 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2766 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2767 ok(!lstrcmpA(bufferA
, names
[i
]),
2768 "-1: got %s (expected %s)\n", bufferA
, names
[i
]);
2770 lstrcpyW(expectedW
, bufferW
);
2771 res
= DoEnvironmentSubstW(bufferW
, len
- 1);
2772 ok(!HIWORD(res
) && (LOWORD(res
) == (len
- 1)),
2773 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res
), LOWORD(res
), len
- 1);
2774 ok(!lstrcmpW(bufferW
, expectedW
),
2775 "-1: got %s (expected %s)\n", wine_dbgstr_w(bufferW
), wine_dbgstr_w(expectedW
));
2778 /* unknown variable */
2779 /* result: TRUE / string length including terminating 0 / the buffer is untouched */
2780 memset(bufferA
, '#', MAX_PATH
- 1);
2781 bufferA
[MAX_PATH
- 1] = 0;
2782 lstrcpyA(bufferA
, does_not_existA
);
2783 MultiByteToWideChar(CP_ACP
, 0, bufferA
, MAX_PATH
, bufferW
, ARRAY_SIZE(bufferW
));
2785 res2
= lstrlenA(does_not_existA
) + 1;
2786 res
= DoEnvironmentSubstA(bufferA
, MAX_PATH
);
2787 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2788 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2789 ok(!lstrcmpA(bufferA
, does_not_existA
),
2790 "%d: got %s (expected %s)\n", i
, bufferA
, does_not_existA
);
2792 res
= DoEnvironmentSubstW(bufferW
, MAX_PATH
);
2793 ok(HIWORD(res
) && (LOWORD(res
) == res2
),
2794 "%d: got %d/%d (expected TRUE/%d)\n", i
, HIWORD(res
), LOWORD(res
), res2
);
2795 ok(!lstrcmpW(bufferW
, does_not_existW
),
2796 "%d: got %s (expected %s)\n", i
, wine_dbgstr_w(bufferW
), wine_dbgstr_w(does_not_existW
));
2801 /* NULL crashes on windows */
2802 res
= DoEnvironmentSubstA(NULL
, MAX_PATH
);
2803 res
= DoEnvironmentSubstW(NULL
, MAX_PATH
);
2807 static void test_PathYetAnotherMakeUniqueName(void)
2809 static const WCHAR shortW
[] = {'f','i','l','e','.','t','s','t',0};
2810 static const WCHAR short2W
[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
2811 static const WCHAR tmpW
[] = {'t','m','p',0};
2812 static const WCHAR longW
[] = {'n','a','m','e',0};
2813 static const WCHAR long2W
[] = {'n','a','m','e',' ','(','2',')',0};
2814 WCHAR nameW
[MAX_PATH
], buffW
[MAX_PATH
], pathW
[MAX_PATH
];
2818 if (!pPathYetAnotherMakeUniqueName
)
2820 win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
2826 /* crashes on Windows */
2827 ret
= pPathYetAnotherMakeUniqueName(NULL
, NULL
, NULL
, NULL
);
2828 ok(!ret
, "got %d\n", ret
);
2830 ret
= pPathYetAnotherMakeUniqueName(nameW
, NULL
, NULL
, NULL
);
2831 ok(!ret
, "got %d\n", ret
);
2834 GetTempPathW(ARRAY_SIZE(pathW
), pathW
);
2836 /* Using short name only first */
2838 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2839 ok(ret
, "got %d\n", ret
);
2840 lstrcpyW(buffW
, pathW
);
2841 lstrcatW(buffW
, shortW
);
2842 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2844 /* now create a file with this name and get next name */
2845 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2846 ok(file
!= NULL
, "got %p\n", file
);
2849 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, shortW
, NULL
);
2850 ok(ret
, "got %d\n", ret
);
2851 lstrcpyW(buffW
, pathW
);
2852 lstrcatW(buffW
, short2W
);
2853 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2857 /* Using short and long */
2859 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2860 ok(ret
, "got %d\n", ret
);
2861 lstrcpyW(buffW
, pathW
);
2862 lstrcatW(buffW
, longW
);
2863 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2865 file
= CreateFileW(nameW
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
2866 ok(file
!= NULL
, "got %p\n", file
);
2869 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, tmpW
, longW
);
2870 ok(ret
, "got %d\n", ret
);
2871 lstrcpyW(buffW
, pathW
);
2872 lstrcatW(buffW
, long2W
);
2873 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2877 /* Using long only */
2879 ret
= pPathYetAnotherMakeUniqueName(nameW
, pathW
, NULL
, longW
);
2880 ok(ret
, "got %d\n", ret
);
2881 lstrcpyW(buffW
, pathW
);
2882 lstrcatW(buffW
, longW
);
2883 ok(!lstrcmpW(nameW
, buffW
), "got %s, expected %s\n", wine_dbgstr_w(nameW
), wine_dbgstr_w(buffW
));
2886 static void test_SHGetKnownFolderIDList(void)
2888 PIDLIST_ABSOLUTE pidl
;
2891 if (!pSHGetKnownFolderIDList
)
2893 win_skip("SHGetKnownFolderIDList is not available.\n");
2897 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, NULL
);
2898 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2900 if (0) { /* crashes on native */
2901 pidl
= (void*)0xdeadbeef;
2902 hr
= pSHGetKnownFolderIDList(NULL
, 0, NULL
, &pidl
);
2904 /* not a known folder */
2905 pidl
= (void*)0xdeadbeef;
2906 hr
= pSHGetKnownFolderIDList(&IID_IUnknown
, 0, NULL
, &pidl
);
2907 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
2908 ok(pidl
== NULL
, "got %p\n", pidl
);
2910 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, NULL
);
2911 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
2913 pidl
= (void*)0xdeadbeef;
2914 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, 0, NULL
, &pidl
);
2915 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2916 ok(ILIsEmpty(pidl
), "pidl should be empty.\n");
2917 ok(pidl
->mkid
.cb
== 0, "get wrong value: %d\n", pidl
->mkid
.cb
);
2920 pidl
= (void*)0xdeadbeef;
2921 hr
= pSHGetKnownFolderIDList(&FOLDERID_Desktop
, KF_FLAG_NO_ALIAS
, NULL
, &pidl
);
2922 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2923 todo_wine
ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2924 todo_wine
ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2927 pidl
= (void*)0xdeadbeef;
2928 hr
= pSHGetKnownFolderIDList(&FOLDERID_Documents
, 0, NULL
, &pidl
);
2929 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2930 ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2931 ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2934 pidl
= (void*)0xdeadbeef;
2935 hr
= pSHGetKnownFolderIDList(&FOLDERID_Documents
, KF_FLAG_NO_ALIAS
, NULL
, &pidl
);
2936 ok(hr
== S_OK
, "SHGetKnownFolderIDList failed: 0x%08x\n", hr
);
2937 ok(!ILIsEmpty(pidl
), "pidl should not be empty.\n");
2938 ok(pidl
->mkid
.cb
== 20, "get wrong value: %d\n", pidl
->mkid
.cb
);
2942 static void test_PathResolve(void)
2944 WCHAR testfile
[MAX_PATH
], testfile_lnk
[MAX_PATH
], regedit_in_testdir
[MAX_PATH
], regedit_cmd
[MAX_PATH
];
2945 WCHAR tempdir
[MAX_PATH
], path
[MAX_PATH
];
2946 const WCHAR
*dirs
[2] = { tempdir
, NULL
};
2954 const WCHAR
*expected_path
;
2957 { L
"test", 0, FALSE
, L
"test" },
2958 { L
"C:\\test", 0, TRUE
, L
"C:\\test" },
2959 { L
"regedit", 0, FALSE
, L
"regedit" },
2960 { testfile
, 0, TRUE
, testfile
},
2962 /* PRF_VERIFYEXISTS */
2963 { L
"test", PRF_VERIFYEXISTS
, TRUE
, testfile_lnk
},
2964 { L
"C:\\test", PRF_VERIFYEXISTS
, FALSE
, L
"C:\\test" },
2965 /* common extensions are tried even if PRF_TRYPROGRAMEXTENSIONS isn't passed */
2966 /* directories in dirs parameter are always searched first even if PRF_FIRSTDIRDEF isn't passed */
2967 { L
"regedit", PRF_VERIFYEXISTS
, TRUE
, regedit_cmd
},
2968 /* .dll is not tried */
2969 { L
"bcrypt", PRF_VERIFYEXISTS
, FALSE
, L
"bcrypt" },
2970 { testfile
, PRF_VERIFYEXISTS
, TRUE
, testfile_lnk
},
2971 { regedit_in_testdir
, PRF_VERIFYEXISTS
, TRUE
, regedit_cmd
},
2973 /* PRF_FIRSTDIRDEF */
2974 { L
"regedit", PRF_FIRSTDIRDEF
, FALSE
, L
"regedit" },
2976 /* RF_VERIFYEXISTS | PRF_FIRSTDIRDEF */
2977 { L
"regedit", PRF_VERIFYEXISTS
| PRF_FIRSTDIRDEF
, TRUE
, regedit_cmd
},
2979 /* PRF_DONTFINDLNK */
2980 { testfile
, PRF_DONTFINDLNK
, TRUE
, testfile
},
2981 { regedit_in_testdir
, PRF_DONTFINDLNK
, TRUE
, regedit_in_testdir
},
2983 /* RF_VERIFYEXISTS | PRF_DONTFINDLNK */
2984 { testfile
, PRF_VERIFYEXISTS
| PRF_DONTFINDLNK
, FALSE
, testfile
},
2985 /* cmd is also ignored when passing PRF_VERIFYEXISTS | PRF_DONTFINDLNK */
2986 { regedit_in_testdir
, PRF_VERIFYEXISTS
| PRF_DONTFINDLNK
, FALSE
, regedit_in_testdir
},
2988 /* PRF_VERIFYEXISTS | PRF_REQUIREABSOLUTE */
2989 /* only PRF_VERIFYEXISTS matters*/
2990 { L
"test", PRF_VERIFYEXISTS
| PRF_REQUIREABSOLUTE
, TRUE
, testfile_lnk
},
2991 { L
"C:\\test", PRF_VERIFYEXISTS
| PRF_REQUIREABSOLUTE
, FALSE
, L
"C:\\test" },
2992 { L
"regedit", PRF_VERIFYEXISTS
| PRF_REQUIREABSOLUTE
, TRUE
, regedit_cmd
},
2993 { testfile
, PRF_VERIFYEXISTS
| PRF_REQUIREABSOLUTE
, TRUE
, testfile_lnk
},
2995 /* PRF_TRYPROGRAMEXTENSIONS */
2996 { L
"test", PRF_TRYPROGRAMEXTENSIONS
, TRUE
, testfile_lnk
},
2997 { L
"C:\\test", PRF_TRYPROGRAMEXTENSIONS
, FALSE
, L
"C:\\test" },
2998 { L
"regedit", PRF_TRYPROGRAMEXTENSIONS
, TRUE
, regedit_cmd
},
2999 /* .dll is not tried */
3000 { L
"bcrypt", PRF_TRYPROGRAMEXTENSIONS
, FALSE
, L
"bcrypt" },
3001 { testfile
, PRF_TRYPROGRAMEXTENSIONS
, TRUE
, testfile_lnk
},
3002 { regedit_in_testdir
, PRF_TRYPROGRAMEXTENSIONS
, TRUE
, regedit_cmd
},
3004 /* PRF_TRYPROGRAMEXTENSIONS | PRF_DONTFINDLNK */
3005 { testfile
, PRF_TRYPROGRAMEXTENSIONS
| PRF_DONTFINDLNK
, FALSE
, testfile
},
3006 /* cmd is also ignored when passing PRF_TRYPROGRAMEXTENSIONS | PRF_DONTFINDLNK */
3007 { regedit_in_testdir
, PRF_TRYPROGRAMEXTENSIONS
| PRF_DONTFINDLNK
, FALSE
, regedit_in_testdir
}
3012 win_skip("PathResolve not available\n");
3016 GetTempPathW(MAX_PATH
, tempdir
);
3018 lstrcpyW(testfile
, tempdir
);
3019 lstrcatW(testfile
, L
"test");
3020 lstrcpyW(testfile_lnk
, testfile
);
3021 lstrcatW(testfile_lnk
, L
".lnk");
3023 file
= CreateFileW(testfile_lnk
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
3024 ok(file
!= INVALID_HANDLE_VALUE
, "got %p\n", file
);
3026 lstrcpyW(regedit_in_testdir
, tempdir
);
3027 lstrcatW(regedit_in_testdir
, L
"regedit");
3028 lstrcpyW(regedit_cmd
, regedit_in_testdir
);
3029 lstrcatW(regedit_cmd
, L
".cmd");
3031 file2
= CreateFileW(regedit_cmd
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_FLAG_DELETE_ON_CLOSE
, NULL
);
3032 ok(file2
!= INVALID_HANDLE_VALUE
, "got %p\n", file
);
3034 /* show that resolving regedit with NULL dirs returns regedit.exe */
3035 lstrcpyW(path
, L
"regedit");
3036 ret
= pPathResolve(path
, NULL
, PRF_VERIFYEXISTS
);
3037 ok(ret
, "resolving regedit failed unexpectedly\n");
3038 ok(!lstrcmpiW(path
, L
"C:\\windows\\regedit.exe") || !lstrcmpiW(path
, L
"C:\\windows\\system32\\regedit.exe"),
3039 "unexpected path %s\n", wine_dbgstr_w(path
));
3041 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++)
3043 winetest_push_context("test %d", i
);
3044 lstrcpyW(path
, tests
[i
].path
);
3046 if (!tests
[i
].expected
) SetLastError(0xdeadbeef);
3047 ret
= pPathResolve(path
, dirs
, tests
[i
].flags
);
3048 ok(ret
== tests
[i
].expected
, "expected %d, got %d\n", tests
[i
].expected
, ret
);
3049 ok(!lstrcmpiW(path
, tests
[i
].expected_path
),
3050 "expected %s, got %s\n", wine_dbgstr_w(tests
[i
].expected_path
), wine_dbgstr_w(path
));
3051 if (!tests
[i
].expected
)
3052 ok(GetLastError() == ERROR_FILE_NOT_FOUND
||
3053 broken(GetLastError() == ERROR_PATH_NOT_FOUND
/* some win 8.1 & 10 */),
3054 "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
3055 winetest_pop_context();
3062 START_TEST(shellpath
)
3064 if (!init()) return;
3067 pGetSystemWow64DirectoryA
= (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
3068 "GetSystemWow64DirectoryA" );
3073 /* first test various combinations of parameters: */
3076 /* check known values: */
3082 test_NonExistentPath();
3083 test_SHGetFolderPathEx();
3084 test_knownFolders();
3085 test_DoEnvironmentSubst();
3086 test_PathYetAnotherMakeUniqueName();
3087 test_SHGetKnownFolderIDList();