ReactOS 0.4.17-dev-470-gf9e3448
shellpath.c
Go to the documentation of this file.
1/*
2 * Unit tests for shell32 SHGet{Special}Folder{Path|Location} functions.
3 *
4 * Copyright 2004 Juan Lang
5 *
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.
10 *
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.
15 *
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).
22 */
23
24#define COBJMACROS
25
26#include <stdarg.h>
27#include <stdio.h>
28#include "windef.h"
29#include "winbase.h"
30#include "shlguid.h"
31#include "shlobj.h"
32#include "shlwapi.h"
33#include "knownfolders.h"
34#include "shellapi.h"
35#include "wine/test.h"
36
37#include "initguid.h"
38
39/* CSIDL_MYDOCUMENTS is now the same as CSIDL_PERSONAL, but what we want
40 * here is its original value.
41 */
42#define OLD_CSIDL_MYDOCUMENTS 0x000c
43
44DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
45
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 */
49#endif
50#ifndef PT_GUID
51#define PT_GUID 0x1f /* no path */
52#endif
53#ifndef PT_DRIVE
54#define PT_DRIVE 0x23 /* has path */
55#endif
56#ifndef PT_DRIVE2
57#define PT_DRIVE2 0x25 /* has path */
58#endif
59#ifndef PT_SHELLEXT
60#define PT_SHELLEXT 0x2e /* no path */
61#endif
62#ifndef PT_FOLDER
63#define PT_FOLDER 0x31 /* has path */
64#endif
65#ifndef PT_FOLDERW
66#define PT_FOLDERW 0x35 /* has path */
67#endif
68#ifndef PT_WORKGRP
69#define PT_WORKGRP 0x41 /* no path */
70#endif
71#ifndef PT_YAGUID
72#define PT_YAGUID 0x70 /* no path */
73#endif
74/* FIXME: this is used for history/favorites folders; what's a better name? */
75#ifndef PT_IESPECIAL2
76#define PT_IESPECIAL2 0xb1 /* has path */
77#endif
78
79static GUID CLSID_CommonDocuments = { 0x0000000c, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x1a } };
80
82 int folder;
84 const BYTE *types;
85};
86
87static HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO *);
88static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
89static HRESULT (WINAPI *pSHGetFolderLocation)(HWND, int, HANDLE, DWORD,
90 LPITEMIDLIST *);
91static BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL);
92static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *);
93static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
94static int (WINAPI *pSHFileOperationA)(LPSHFILEOPSTRUCTA);
95static HRESULT (WINAPI *pSHGetMalloc)(LPMALLOC *);
96static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR,UINT);
97static HRESULT (WINAPI *pSHGetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *);
98static HRESULT (WINAPI *pSHSetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR);
99static HRESULT (WINAPI *pSHGetFolderPathEx)(REFKNOWNFOLDERID, DWORD, HANDLE, LPWSTR, DWORD);
100static BOOL (WINAPI *pPathYetAnotherMakeUniqueName)(PWSTR, PCWSTR, PCWSTR, PCWSTR);
101static HRESULT (WINAPI *pSHGetKnownFolderIDList)(REFKNOWNFOLDERID, DWORD, HANDLE, PIDLIST_ABSOLUTE*);
102
105static const BYTE guidType[] = { PT_GUID };
107static const BYTE folderType[] = { PT_FOLDER, PT_FOLDERW };
108static const BYTE favoritesType[] = { PT_FOLDER, PT_FOLDERW, 0, PT_IESPECIAL2 /* Win98 */ };
110static const BYTE personalType[] = { PT_FOLDER, PT_GUID, PT_DRIVE, 0xff /* Win9x */,
111 PT_IESPECIAL2 /* Win98 */, 0 /* Vista */, PT_SHELLEXT /* win8 */ };
112/* FIXME: don't know the type of 0x71 returned by Vista/2008 for printers */
113static const BYTE printersType[] = { PT_YAGUID, PT_SHELLEXT, 0x71 };
114static const BYTE ieSpecialType[] = { PT_IESPECIAL2 };
115static const BYTE shellExtType[] = { PT_SHELLEXT };
116static const BYTE workgroupType[] = { PT_WORKGRP };
117#define DECLARE_TYPE(x, y) { x, ARRAY_SIZE(y), y }
126/* FIXME: the following fails in Wine, returns type PT_FOLDER
127 DECLARE_TYPE(CSIDL_HISTORY, ieSpecialType),
128 */
141};
143/* FIXME: the following only semi-succeed; they return NULL PIDLs on XP.. hmm.
144 DECLARE_TYPE(CSIDL_ALTSTARTUP, folderType),
145 DECLARE_TYPE(CSIDL_COMMON_ALTSTARTUP, folderType),
146 DECLARE_TYPE(CSIDL_COMMON_OEM_LINKS, folderType),
147 */
148/* Windows NT-only: */
156/* first appearing in shell32 version 4.71: */
158/* first appearing in shell32 version 4.72: */
160/* first appearing in shell32 version 5.0: */
175/* first appearing in shell32 6.0: */
183};
184#undef DECLARE_TYPE
185
186static void loadShell32(void)
187{
188 HMODULE hShell32 = GetModuleHandleA("shell32");
189
190#define GET_PROC(func) \
191 p ## func = (void*)GetProcAddress(hShell32, #func); \
192 if(!p ## func) \
193 trace("GetProcAddress(%s) failed\n", #func);
194
197 GET_PROC(SHGetFolderPathEx)
199 GET_PROC(SHGetKnownFolderPath)
200 GET_PROC(SHSetKnownFolderPath)
204 if (!pILFindLastID)
205 pILFindLastID = (void *)GetProcAddress(hShell32, (LPCSTR)16);
209 GET_PROC(SHGetKnownFolderIDList)
210
211 ok(pSHGetMalloc != NULL, "shell32 is missing SHGetMalloc\n");
212 if (pSHGetMalloc)
213 {
214 HRESULT hr = pSHGetMalloc(&pMalloc);
215
216 ok(hr == S_OK, "SHGetMalloc failed: 0x%08x\n", hr);
217 ok(pMalloc != NULL, "SHGetMalloc returned a NULL IMalloc\n");
218 }
219
220 if (pDllGetVersion)
221 {
222 shellVersion.cbSize = sizeof(shellVersion);
223 pDllGetVersion(&shellVersion);
224 trace("shell32 version is %d.%d\n",
225 shellVersion.dwMajorVersion, shellVersion.dwMinorVersion);
226 }
227#undef GET_PROC
228}
229
230#ifndef CSIDL_PROFILES
231#define CSIDL_PROFILES 0x003e
232#endif
233
234/* A couple utility printing functions */
235static const char *getFolderName(int folder)
236{
237 static char unknown[32];
238
239#define CSIDL_TO_STR(x) case x: return#x;
240 switch (folder)
241 {
300#undef CSIDL_TO_STR
301 default:
302 sprintf(unknown, "unknown (0x%04x)", folder);
303 return unknown;
304 }
305}
306
307/* Standard CSIDL values (and their flags) uses only two less-significant bytes */
308#define NO_CSIDL 0x10000
309#define WINE_ATTRIBUTES_OPTIONAL 0x20000
310#define KNOWN_FOLDER(id, csidl, name, category, parent1, parent2, relative_path, parsing_name, attributes, definitionFlags) \
311 { &id, # id, csidl, # csidl, name, category, {&parent1, &parent2}, relative_path, parsing_name, attributes, definitionFlags, __LINE__ }
312
313/* non-published known folders test */
314static const GUID _FOLDERID_CryptoKeys = {0xB88F4DAA, 0xE7BD, 0x49A9, {0xB7, 0x4D, 0x02, 0x88, 0x5A, 0x5D, 0xC7, 0x65} };
315static const GUID _FOLDERID_DpapiKeys = {0x10C07CD0, 0xEF91, 0x4567, {0xB8, 0x50, 0x44, 0x8B, 0x77, 0xCB, 0x37, 0xF9} };
316static const GUID _FOLDERID_SystemCertificates = {0x54EED2E0, 0xE7CA, 0x4FDB, {0x91, 0x48, 0x0F, 0x42, 0x47, 0x29, 0x1C, 0xFA} };
317static const GUID _FOLDERID_CredentialManager = {0x915221FB, 0x9EFE, 0x4BDA, {0x8F, 0xD7, 0xF7, 0x8D, 0xCA, 0x77, 0x4F, 0x87} };
318
321 const char *sFolderId;
322 const int csidl;
323 const char *sCsidl;
324 const char *sName;
325 const KF_CATEGORY category;
327 const char *sRelativePath;
328 const char *sParsingName;
331 const int line;
332};
333
334/* Note: content of parsing name may vary between Windows versions.
335 * As a base, values from 6.0 (Vista) were used. Some entries may contain
336 * alternative values. In that case, Windows version where the value was
337 * found is noted.
338 *
339 * The list of values for parsing name was encoded as a number of null-
340 * terminated strings placed one by one (separated by null byte only).
341 * End of list is marked by two consecutive null bytes.
342 */
343static const struct knownFolderDef known_folders[] = {
344 KNOWN_FOLDER(FOLDERID_AddNewPrograms,
345 NO_CSIDL,
346 "AddNewProgramsFolder",
347 KF_CATEGORY_VIRTUAL,
349 NULL,
350 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0"
351 "shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{15eae92e-f17a-4431-9f28-805e482dafd4}\0\0" /* 6.1 */,
352 0,
353 0),
354 KNOWN_FOLDER(FOLDERID_AdminTools,
356 "Administrative Tools",
357 KF_CATEGORY_PERUSER,
358 FOLDERID_Programs, GUID_NULL,
359 "Administrative Tools",
360 NULL,
363 KNOWN_FOLDER(FOLDERID_AppUpdates,
364 NO_CSIDL,
365 "AppUpdatesFolder",
366 KF_CATEGORY_VIRTUAL,
368 NULL,
369 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0"
370 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\\::{d450a8a1-9568-45c7-9c0e-b4f9fb4537bd}\0\0" /* 6.1 */,
371 0,
372 0),
373 KNOWN_FOLDER(FOLDERID_CDBurning,
375 "CD Burning",
376 KF_CATEGORY_PERUSER,
377 FOLDERID_LocalAppData, GUID_NULL,
378 "Microsoft\\Windows\\Burn\\Burn",
379 NULL,
382 KNOWN_FOLDER(FOLDERID_ChangeRemovePrograms,
383 NO_CSIDL,
384 "ChangeRemoveProgramsFolder",
385 KF_CATEGORY_VIRTUAL,
387 NULL,
388 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0"
389 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}\0\0" /* 6.1 */,
390 0,
391 0),
392 KNOWN_FOLDER(FOLDERID_CommonAdminTools,
394 "Common Administrative Tools",
395 KF_CATEGORY_COMMON,
396 FOLDERID_CommonPrograms, GUID_NULL,
397 "Administrative Tools",
398 NULL,
401 KNOWN_FOLDER(FOLDERID_CommonOEMLinks,
403 "OEM Links",
404 KF_CATEGORY_COMMON,
405 FOLDERID_ProgramData, GUID_NULL,
406 "OEM Links",
407 NULL,
408 0,
409 0),
410 KNOWN_FOLDER(FOLDERID_CommonPrograms,
412 "Common Programs",
413 KF_CATEGORY_COMMON,
414 FOLDERID_CommonStartMenu, GUID_NULL,
415 "Programs",
416 NULL,
419 KNOWN_FOLDER(FOLDERID_CommonStartMenu,
421 "Common Start Menu",
422 KF_CATEGORY_COMMON,
423 FOLDERID_ProgramData, GUID_NULL,
424 "Microsoft\\Windows\\Start Menu\0",
425 NULL,
428#ifndef __REACTOS__
429 KNOWN_FOLDER(FOLDERID_CommonStartup,
431 "Common Startup",
432 KF_CATEGORY_COMMON,
433 FOLDERID_CommonPrograms, GUID_NULL,
434 "StartUp",
435 NULL,
438#else // s/StartUp/Startup/
439 KNOWN_FOLDER(FOLDERID_CommonStartup,
441 "Common Startup",
442 KF_CATEGORY_COMMON,
443 FOLDERID_CommonPrograms, GUID_NULL,
444 "Startup",
445 NULL,
448#endif
449 KNOWN_FOLDER(FOLDERID_CommonTemplates,
451 "Common Templates",
452 KF_CATEGORY_COMMON,
453 FOLDERID_ProgramData, GUID_NULL,
454 "Microsoft\\Windows\\Templates\0",
455 NULL,
456 0,
457 0),
458 KNOWN_FOLDER(FOLDERID_ComputerFolder,
460 "MyComputerFolder",
461 KF_CATEGORY_VIRTUAL,
463 NULL,
464 "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\0\0",
465 0,
466 0),
467 KNOWN_FOLDER(FOLDERID_ConflictFolder,
468 NO_CSIDL,
469 "ConflictFolder",
470 KF_CATEGORY_VIRTUAL,
472 NULL,
473 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0"
474 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{E413D040-6788-4C22-957E-175D1C513A34},\0\0" /* 6.1 */,
475 0,
476 0),
477 KNOWN_FOLDER(FOLDERID_ConnectionsFolder,
479 "ConnectionsFolder",
480 KF_CATEGORY_VIRTUAL,
482 NULL,
483 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0"
484 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\0\0" /* 6.1 */,
485 0,
486 0),
487 KNOWN_FOLDER(FOLDERID_Contacts,
488 NO_CSIDL,
489 "Contacts",
490 KF_CATEGORY_PERUSER,
491 FOLDERID_Profile, GUID_NULL,
492 "Contacts",
493 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{56784854-C6CB-462B-8169-88E350ACB882}\0\0",
496 KNOWN_FOLDER(FOLDERID_ControlPanelFolder,
498 "ControlPanelFolder",
499 KF_CATEGORY_VIRTUAL,
501 NULL,
502 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\0"
503 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\0\0" /* 6.1 */,
504 0,
505 0),
506 KNOWN_FOLDER(FOLDERID_Cookies,
508 "Cookies",
509 KF_CATEGORY_PERUSER,
510 FOLDERID_RoamingAppData, FOLDERID_LocalAppData,
511 "Microsoft\\Windows\\Cookies\0Microsoft\\Windows\\INetCookies\0" /* win8 */,
512 NULL,
513 0,
514 0),
515 KNOWN_FOLDER(FOLDERID_Desktop,
517 "Desktop",
518 KF_CATEGORY_PERUSER,
519 FOLDERID_Profile, GUID_NULL,
520 "Desktop",
521 NULL,
524 KNOWN_FOLDER(FOLDERID_DeviceMetadataStore,
525 NO_CSIDL,
526 "Device Metadata Store",
527 KF_CATEGORY_COMMON,
528 FOLDERID_ProgramData, GUID_NULL,
529 "Microsoft\\Windows\\DeviceMetadataStore\0",
530 NULL,
531 0,
532 0),
533 KNOWN_FOLDER(FOLDERID_Documents,
535 "Personal",
536 KF_CATEGORY_PERUSER,
537 FOLDERID_Profile, GUID_NULL,
538 "Documents\0",
539 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{FDD39AD0-238F-46AF-ADB4-6C85480369C7}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}\0\0", /* win8 */
542 KNOWN_FOLDER(FOLDERID_DocumentsLibrary,
543 NO_CSIDL,
544 "DocumentsLibrary",
545 KF_CATEGORY_PERUSER,
546 FOLDERID_Libraries, GUID_NULL,
547 "Documents.library-ms\0",
548 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{7b0db17d-9cd2-4a93-9733-46cc89022e7c}\0\0",
549 0,
551 KNOWN_FOLDER(FOLDERID_Downloads,
552 NO_CSIDL,
553 "Downloads",
554 KF_CATEGORY_PERUSER,
555 FOLDERID_Profile, GUID_NULL,
556 "Downloads\0",
557 "(null)\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{374DE290-123F-4565-9164-39C4925E467B}\0\0", /* win8 */
560 KNOWN_FOLDER(FOLDERID_Favorites,
562 "Favorites",
563 KF_CATEGORY_PERUSER,
564 FOLDERID_Profile, GUID_NULL,
565 "Favorites\0",
566 NULL,
569 KNOWN_FOLDER(FOLDERID_Fonts,
571 "Fonts",
572 KF_CATEGORY_FIXED,
573 FOLDERID_Windows, GUID_NULL,
574 NULL,
575 NULL,
576 0,
577 0),
578 KNOWN_FOLDER(FOLDERID_Games,
579 NO_CSIDL,
580 "Games",
581 KF_CATEGORY_VIRTUAL,
583 NULL,
584 "::{ED228FDF-9EA8-4870-83b1-96b02CFE0D52}\0\0",
585 0,
586 0),
587 KNOWN_FOLDER(FOLDERID_GameTasks,
588 NO_CSIDL,
589 "GameTasks",
590 KF_CATEGORY_PERUSER,
591 FOLDERID_LocalAppData, GUID_NULL,
592 "Microsoft\\Windows\\GameExplorer\0",
593 NULL,
594 0,
596 KNOWN_FOLDER(FOLDERID_History,
598 "History",
599 KF_CATEGORY_PERUSER,
600 FOLDERID_LocalAppData, GUID_NULL,
601 "Microsoft\\Windows\\History\0",
602 NULL,
603 0,
605 KNOWN_FOLDER(FOLDERID_HomeGroup,
606 NO_CSIDL,
607 "HomeGroupFolder",
608 KF_CATEGORY_VIRTUAL,
610 NULL,
611 "::{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\0\0",
612 0,
613 0),
614 KNOWN_FOLDER(FOLDERID_ImplicitAppShortcuts,
615 NO_CSIDL,
616 "ImplicitAppShortcuts",
617 KF_CATEGORY_PERUSER,
618 FOLDERID_UserPinned, GUID_NULL,
619 "ImplicitAppShortcuts\0",
620 NULL,
621 0,
623 KNOWN_FOLDER(FOLDERID_InternetCache,
625 "Cache",
626 KF_CATEGORY_PERUSER,
627 FOLDERID_LocalAppData, GUID_NULL,
628 "Microsoft\\Windows\\Temporary Internet Files\0Microsoft\\Windows\\INetCache\0\0", /* win8 */
629 NULL,
630 0,
632 KNOWN_FOLDER(FOLDERID_InternetFolder,
634 "InternetFolder",
635 KF_CATEGORY_VIRTUAL,
637 NULL,
638 "::{871C5380-42A0-1069-A2EA-08002B30309D}\0\0",
639 0,
640 0),
641 KNOWN_FOLDER(FOLDERID_Libraries,
642 NO_CSIDL,
643 "Libraries",
644 KF_CATEGORY_PERUSER,
645 FOLDERID_RoamingAppData, GUID_NULL,
646 "Microsoft\\Windows\\Libraries\0",
647 NULL,
648 0,
650 KNOWN_FOLDER(FOLDERID_Links,
651 NO_CSIDL,
652 "Links",
653 KF_CATEGORY_PERUSER,
654 FOLDERID_Profile, GUID_NULL,
655 "Links\0",
656 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}\0\0",
659 KNOWN_FOLDER(FOLDERID_LocalAppData,
661 "Local AppData",
662 KF_CATEGORY_PERUSER,
663 FOLDERID_Profile, GUID_NULL,
664 "AppData\\Local\0",
665 NULL,
666 0,
668 KNOWN_FOLDER(FOLDERID_LocalAppDataLow,
669 NO_CSIDL,
670 "LocalAppDataLow",
671 KF_CATEGORY_PERUSER,
672 FOLDERID_Profile, GUID_NULL,
673 "AppData\\LocalLow\0",
674 NULL,
677 KNOWN_FOLDER(FOLDERID_LocalizedResourcesDir,
679 "LocalizedResourcesDir",
680 KF_CATEGORY_FIXED,
682 NULL,
683 NULL,
684 0,
685 0),
686 KNOWN_FOLDER(FOLDERID_Music,
688 "My Music",
689 KF_CATEGORY_PERUSER,
690 FOLDERID_Profile, GUID_NULL,
691 "Music\0",
692 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4BD8D571-6D19-48D3-BE97-422220080E43}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{1CF1260C-4DD0-4EBB-811F-33C572699FDE}\0\0", /* win8 */
695 KNOWN_FOLDER(FOLDERID_MusicLibrary,
696 NO_CSIDL,
697 "MusicLibrary",
698 KF_CATEGORY_PERUSER,
699 FOLDERID_Libraries, GUID_NULL,
700 "Music.library-ms\0",
701 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{2112AB0A-C86A-4ffe-A368-0DE96E47012E}\0\0",
702 0,
704 KNOWN_FOLDER(FOLDERID_NetHood,
706 "NetHood",
707 KF_CATEGORY_PERUSER,
708 FOLDERID_RoamingAppData, GUID_NULL,
709 "Microsoft\\Windows\\Network Shortcuts\0",
710 NULL,
711 0,
712 0),
713 KNOWN_FOLDER(FOLDERID_NetworkFolder,
715 "NetworkPlacesFolder",
716 KF_CATEGORY_VIRTUAL,
718 NULL,
719 "::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\0\0",
720 0,
721 0),
722 KNOWN_FOLDER(FOLDERID_OriginalImages,
723 NO_CSIDL,
724 "Original Images",
725 KF_CATEGORY_PERUSER,
726 FOLDERID_LocalAppData, GUID_NULL,
727 "Microsoft\\Windows Photo Gallery\\Original Images\0",
728 NULL,
729 0,
730 0),
731 KNOWN_FOLDER(FOLDERID_PhotoAlbums,
732 NO_CSIDL,
733 "PhotoAlbums",
734 KF_CATEGORY_PERUSER,
735 FOLDERID_Pictures, GUID_NULL,
736 "Slide Shows\0",
737 NULL,
739 0),
740 KNOWN_FOLDER(FOLDERID_Pictures,
742 "My Pictures",
743 KF_CATEGORY_PERUSER,
744 FOLDERID_Profile, GUID_NULL,
745 "Pictures\0",
746 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{33E28130-4E1E-4676-835A-98395C3BC3BB}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{3ADD1653-EB32-4CB0-BBD7-DFA0ABB5ACCA}\0\0", /* win8 */
749 KNOWN_FOLDER(FOLDERID_PicturesLibrary,
750 NO_CSIDL,
751 "PicturesLibrary",
752 KF_CATEGORY_PERUSER,
753 FOLDERID_Libraries, GUID_NULL,
754 "Pictures.library-ms\0",
755 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{A990AE9F-A03B-4e80-94BC-9912D7504104}\0\0",
756 0,
758 KNOWN_FOLDER(FOLDERID_Playlists,
759 NO_CSIDL,
760 "Playlists",
761 KF_CATEGORY_PERUSER,
762 FOLDERID_Music, GUID_NULL,
763 "Playlists\0",
764 NULL,
766 0),
767 KNOWN_FOLDER(FOLDERID_PrintersFolder,
769 "PrintersFolder",
770 KF_CATEGORY_VIRTUAL,
772 NULL,
773 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}\0\0",
774 0,
775 0),
776 KNOWN_FOLDER(FOLDERID_PrintHood,
778 "PrintHood",
779 KF_CATEGORY_PERUSER,
780 FOLDERID_RoamingAppData, GUID_NULL,
781 "Microsoft\\Windows\\Printer Shortcuts\0",
782 NULL,
783 0,
784 0),
785 KNOWN_FOLDER(FOLDERID_Profile,
787 "Profile",
788 KF_CATEGORY_FIXED,
790 NULL,
791 NULL,
792 0,
793 0),
794 KNOWN_FOLDER(FOLDERID_ProgramData,
796 "Common AppData",
797 KF_CATEGORY_FIXED,
799 NULL,
800 NULL,
801 0,
802 0),
803 KNOWN_FOLDER(FOLDERID_ProgramFiles,
805 "ProgramFiles",
806 KF_CATEGORY_FIXED,
808 NULL,
809 NULL,
812 ),
813 KNOWN_FOLDER(FOLDERID_ProgramFilesCommon,
815 "ProgramFilesCommon",
816 KF_CATEGORY_FIXED,
818 NULL,
819 NULL,
820 0,
821 0),
822 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX64,
823 NO_CSIDL,
824 "ProgramFilesCommonX64",
825 KF_CATEGORY_FIXED,
827 NULL,
828 NULL,
829 0,
830 0),
831 KNOWN_FOLDER(FOLDERID_ProgramFilesCommonX86,
832 NO_CSIDL,
833 "ProgramFilesCommonX86",
834 KF_CATEGORY_FIXED,
836 NULL,
837 NULL,
838 0,
839 0),
840 KNOWN_FOLDER(FOLDERID_ProgramFilesX64,
841 NO_CSIDL,
842 "ProgramFilesX64",
843 KF_CATEGORY_FIXED,
845 NULL,
846 NULL,
847 0,
848 0),
849 KNOWN_FOLDER(FOLDERID_ProgramFilesX86,
851 "ProgramFilesX86",
852 KF_CATEGORY_FIXED,
854 NULL,
855 NULL,
858 KNOWN_FOLDER(FOLDERID_Programs,
860 "Programs",
861 KF_CATEGORY_PERUSER,
862 FOLDERID_StartMenu, GUID_NULL,
863 "Programs\0",
864 NULL,
867 KNOWN_FOLDER(FOLDERID_Public,
868 NO_CSIDL,
869 "Public",
870 KF_CATEGORY_FIXED,
872 NULL,
873 "::{4336a54d-038b-4685-ab02-99bb52d3fb8b}\0"
874 "(null)\0\0" /* 6.1 */,
877 KNOWN_FOLDER(FOLDERID_PublicDesktop,
879 "Common Desktop",
880 KF_CATEGORY_COMMON,
881 FOLDERID_Public, GUID_NULL,
882 "Desktop\0",
883 NULL,
886 KNOWN_FOLDER(FOLDERID_PublicDocuments,
888 "Common Documents",
889 KF_CATEGORY_COMMON,
890 FOLDERID_Public, GUID_NULL,
891 "Documents\0",
892 NULL,
895 KNOWN_FOLDER(FOLDERID_PublicDownloads,
896 NO_CSIDL,
897 "CommonDownloads",
898 KF_CATEGORY_COMMON,
899 FOLDERID_Public, GUID_NULL,
900 "Downloads\0",
901 NULL,
904 KNOWN_FOLDER(FOLDERID_PublicGameTasks,
905 NO_CSIDL,
906 "PublicGameTasks",
907 KF_CATEGORY_COMMON,
908 FOLDERID_ProgramData, GUID_NULL,
909 "Microsoft\\Windows\\GameExplorer\0",
910 NULL,
911 0,
913 KNOWN_FOLDER(FOLDERID_PublicLibraries,
914 NO_CSIDL,
915 "PublicLibraries",
916 KF_CATEGORY_COMMON,
917 FOLDERID_Public, GUID_NULL,
918 "Libraries\0",
919 NULL,
922 KNOWN_FOLDER(FOLDERID_PublicMusic,
924 "CommonMusic",
925 KF_CATEGORY_COMMON,
926 FOLDERID_Public, GUID_NULL,
927 "Music\0",
928 NULL,
931 KNOWN_FOLDER(FOLDERID_PublicPictures,
933 "CommonPictures",
934 KF_CATEGORY_COMMON,
935 FOLDERID_Public, GUID_NULL,
936 "Pictures\0",
937 NULL,
940 KNOWN_FOLDER(FOLDERID_PublicRingtones,
941 NO_CSIDL,
942 "CommonRingtones",
943 KF_CATEGORY_COMMON,
944 FOLDERID_ProgramData, GUID_NULL,
945 "Microsoft\\Windows\\Ringtones\0",
946 NULL,
947 0,
949 KNOWN_FOLDER(FOLDERID_PublicVideos,
951 "CommonVideo",
952 KF_CATEGORY_COMMON,
953 FOLDERID_Public, GUID_NULL,
954 "Videos\0",
955 NULL,
958 KNOWN_FOLDER(FOLDERID_QuickLaunch,
959 NO_CSIDL,
960 "Quick Launch",
961 KF_CATEGORY_PERUSER,
962 FOLDERID_RoamingAppData, GUID_NULL,
963 "Microsoft\\Internet Explorer\\Quick Launch\0",
964 NULL,
965 0,
966 0),
967 KNOWN_FOLDER(FOLDERID_Recent,
969 "Recent",
970 KF_CATEGORY_PERUSER,
971 FOLDERID_RoamingAppData, GUID_NULL,
972 "Microsoft\\Windows\\Recent\0",
973 NULL,
976 KNOWN_FOLDER(FOLDERID_RecordedTVLibrary,
977 NO_CSIDL,
978 "RecordedTVLibrary",
979 KF_CATEGORY_COMMON,
980 FOLDERID_PublicLibraries, GUID_NULL,
981 "RecordedTV.library-ms\0",
982 NULL,
983 0,
985 KNOWN_FOLDER(FOLDERID_RecycleBinFolder,
987 "RecycleBinFolder",
988 KF_CATEGORY_VIRTUAL,
990 NULL,
991 "::{645FF040-5081-101B-9F08-00AA002F954E}\0\0",
992 0,
993 0),
994 KNOWN_FOLDER(FOLDERID_ResourceDir,
996 "ResourceDir",
997 KF_CATEGORY_FIXED,
999 NULL,
1000 NULL,
1001 0,
1002 0),
1003 KNOWN_FOLDER(FOLDERID_Ringtones,
1004 NO_CSIDL,
1005 "Ringtones",
1006 KF_CATEGORY_PERUSER,
1007 FOLDERID_LocalAppData, GUID_NULL,
1008 "Microsoft\\Windows\\Ringtones\0",
1009 NULL,
1010 0,
1012 KNOWN_FOLDER(FOLDERID_RoamingAppData,
1014 "AppData",
1015 KF_CATEGORY_PERUSER,
1016 FOLDERID_Profile, GUID_NULL,
1017 "AppData\\Roaming\0",
1018 NULL,
1019 0,
1020 0),
1021 KNOWN_FOLDER(FOLDERID_SampleMusic,
1023 "SampleMusic",
1024 KF_CATEGORY_COMMON,
1025 FOLDERID_PublicMusic, GUID_NULL,
1026 "Sample Music\0",
1027 NULL,
1030 KNOWN_FOLDER(FOLDERID_SamplePictures,
1032 "SamplePictures",
1033 KF_CATEGORY_COMMON,
1034 FOLDERID_PublicPictures, GUID_NULL,
1035 "Sample Pictures\0",
1036 NULL,
1039 KNOWN_FOLDER(FOLDERID_SamplePlaylists,
1040 NO_CSIDL,
1041 "SamplePlaylists",
1042 KF_CATEGORY_COMMON,
1043 FOLDERID_PublicMusic, GUID_NULL,
1044 "Sample Playlists\0",
1045 NULL,
1047 0),
1048 KNOWN_FOLDER(FOLDERID_SampleVideos,
1050 "SampleVideos",
1051 KF_CATEGORY_COMMON,
1052 FOLDERID_PublicVideos, GUID_NULL,
1053 "Sample Videos\0",
1054 NULL,
1057 KNOWN_FOLDER(FOLDERID_SavedGames,
1058 NO_CSIDL,
1059 "SavedGames",
1060 KF_CATEGORY_PERUSER,
1061 FOLDERID_Profile, GUID_NULL,
1062 "Saved Games\0",
1063 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}\0\0",
1066 KNOWN_FOLDER(FOLDERID_SavedSearches,
1067 NO_CSIDL,
1068 "Searches",
1069 KF_CATEGORY_PERUSER,
1070 FOLDERID_Profile, GUID_NULL,
1071 "Searches\0",
1072 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{7d1d3a04-debb-4115-95cf-2f29da2920da}\0\0",
1075 KNOWN_FOLDER(FOLDERID_SEARCH_CSC,
1076 NO_CSIDL,
1077 "CSCFolder",
1078 KF_CATEGORY_VIRTUAL,
1080 NULL,
1081 "shell:::{BD7A2E7B-21CB-41b2-A086-B309680C6B7E}\\*\0\0",
1082 0,
1083 0),
1084 KNOWN_FOLDER(FOLDERID_SearchHome,
1085 NO_CSIDL,
1086 "SearchHomeFolder",
1087 KF_CATEGORY_VIRTUAL,
1089 NULL,
1090 "::{9343812e-1c37-4a49-a12e-4b2d810d956b}\0\0",
1091 0,
1092 0),
1093 KNOWN_FOLDER(FOLDERID_SEARCH_MAPI,
1094 NO_CSIDL,
1095 "MAPIFolder",
1096 KF_CATEGORY_VIRTUAL,
1098 NULL,
1099 "shell:::{89D83576-6BD1-4C86-9454-BEB04E94C819}\\*\0\0",
1100 0,
1101 0),
1102 KNOWN_FOLDER(FOLDERID_SendTo,
1104 "SendTo",
1105 KF_CATEGORY_PERUSER,
1106 FOLDERID_RoamingAppData, GUID_NULL,
1107 "Microsoft\\Windows\\SendTo\0",
1108 NULL,
1109 0,
1110 0),
1111 KNOWN_FOLDER(FOLDERID_SidebarDefaultParts,
1112 NO_CSIDL,
1113 "Default Gadgets",
1114 KF_CATEGORY_COMMON,
1115 FOLDERID_ProgramFiles, GUID_NULL,
1116 "Windows Sidebar\\Gadgets\0",
1117 NULL,
1118 0,
1119 0),
1120 KNOWN_FOLDER(FOLDERID_SidebarParts,
1121 NO_CSIDL,
1122 "Gadgets",
1123 KF_CATEGORY_PERUSER,
1124 FOLDERID_LocalAppData, GUID_NULL,
1125 "Microsoft\\Windows Sidebar\\Gadgets\0",
1126 NULL,
1127 0,
1128 0),
1129 KNOWN_FOLDER(FOLDERID_StartMenu,
1131 "Start Menu",
1132 KF_CATEGORY_PERUSER,
1133 FOLDERID_RoamingAppData, GUID_NULL,
1134 "Microsoft\\Windows\\Start Menu\0",
1135 NULL,
1138#ifndef __REACTOS__
1139 KNOWN_FOLDER(FOLDERID_Startup,
1141 "Startup",
1142 KF_CATEGORY_PERUSER,
1143 FOLDERID_Programs, GUID_NULL,
1144 "StartUp\0",
1145 NULL,
1148#else // s/StartUp/Startup/
1149 KNOWN_FOLDER(FOLDERID_Startup,
1151 "Startup",
1152 KF_CATEGORY_PERUSER,
1153 FOLDERID_Programs, GUID_NULL,
1154 "Startup\0",
1155 NULL,
1158#endif
1159 KNOWN_FOLDER(FOLDERID_SyncManagerFolder,
1160 NO_CSIDL,
1161 "SyncCenterFolder",
1162 KF_CATEGORY_VIRTUAL,
1164 NULL,
1165 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0"
1166 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\0\0" /* 6.1 */,
1167 0,
1168 0),
1169 KNOWN_FOLDER(FOLDERID_SyncResultsFolder,
1170 NO_CSIDL,
1171 "SyncResultsFolder",
1172 KF_CATEGORY_VIRTUAL,
1174 NULL,
1175 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0"
1176 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{BC48B32F-5910-47F5-8570-5074A8A5636A},\0\0",
1177 0,
1178 0),
1179 KNOWN_FOLDER(FOLDERID_SyncSetupFolder,
1180 NO_CSIDL,
1181 "SyncSetupFolder",
1182 KF_CATEGORY_VIRTUAL,
1184 NULL,
1185 "::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0"
1186 "::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF}\\::{F1390A9A-A3F4-4E5D-9C5F-98F3BD8D935C},\0\0" /* 6.1 */,
1187 0,
1188 0),
1189 KNOWN_FOLDER(FOLDERID_System,
1191 "System",
1192 KF_CATEGORY_FIXED,
1194 NULL,
1195 NULL,
1196 0,
1197 0),
1198 KNOWN_FOLDER(FOLDERID_SystemX86,
1200 "SystemX86",
1201 KF_CATEGORY_FIXED,
1203 NULL,
1204 NULL,
1205 0,
1206 0),
1207 KNOWN_FOLDER(FOLDERID_Templates,
1209 "Templates",
1210 KF_CATEGORY_PERUSER,
1211 FOLDERID_RoamingAppData, GUID_NULL,
1212 "Microsoft\\Windows\\Templates\0",
1213 NULL,
1214 0,
1215 0),
1216 KNOWN_FOLDER(FOLDERID_UserPinned,
1217 NO_CSIDL,
1218 "User Pinned",
1219 KF_CATEGORY_PERUSER,
1220 FOLDERID_QuickLaunch, GUID_NULL,
1221 "User Pinned\0",
1222 NULL,
1225 KNOWN_FOLDER(FOLDERID_UserProfiles,
1226 NO_CSIDL,
1227 "UserProfiles",
1228 KF_CATEGORY_FIXED,
1230 NULL,
1231 NULL,
1234 KNOWN_FOLDER(FOLDERID_UserProgramFiles,
1235 NO_CSIDL,
1236 "UserProgramFiles",
1237 KF_CATEGORY_PERUSER,
1238 FOLDERID_LocalAppData, GUID_NULL,
1239 "Programs\0",
1240 NULL,
1241 0,
1242 0),
1243 KNOWN_FOLDER(FOLDERID_UserProgramFilesCommon,
1244 NO_CSIDL,
1245 "UserProgramFilesCommon",
1246 KF_CATEGORY_PERUSER,
1247 FOLDERID_UserProgramFiles, GUID_NULL,
1248 "Common\0",
1249 NULL,
1250 0,
1251 0),
1252 KNOWN_FOLDER(FOLDERID_UsersFiles,
1253 NO_CSIDL,
1254 "UsersFilesFolder",
1255 KF_CATEGORY_VIRTUAL,
1257 NULL,
1258 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\0\0",
1259 0,
1260 0),
1261 KNOWN_FOLDER(FOLDERID_UsersLibraries,
1262 NO_CSIDL,
1263 "UsersLibrariesFolder",
1264 KF_CATEGORY_VIRTUAL,
1266 NULL,
1267 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\0\0",
1268 0,
1269 0),
1270 KNOWN_FOLDER(FOLDERID_Videos,
1272 "My Video",
1273 KF_CATEGORY_PERUSER,
1274 FOLDERID_Profile, GUID_NULL,
1275 "Videos\0",
1276 "::{59031a47-3f72-44a7-89c5-5595fe6b30ee}\\{18989B1D-99B5-455B-841C-AB7C74E4DDFC}\0shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{A0953C92-50DC-43BF-BE83-3742FED03C9C}\0\0", /* win8 */
1279 KNOWN_FOLDER(FOLDERID_VideosLibrary,
1280 NO_CSIDL,
1281 "VideosLibrary",
1282 KF_CATEGORY_PERUSER,
1283 FOLDERID_Libraries, GUID_NULL,
1284 "Videos.library-ms\0",
1285 "::{031E4825-7B94-4dc3-B131-E946B44C8DD5}\\{491E922F-5643-4af4-A7EB-4E7A138D8174}\0\0",
1286 0,
1288 KNOWN_FOLDER(FOLDERID_Windows,
1290 "Windows",
1291 KF_CATEGORY_FIXED,
1293 NULL,
1294 NULL,
1295 0,
1296 0),
1298 NO_CSIDL,
1299 "CredentialManager",
1300 KF_CATEGORY_FIXED,
1302 NULL,
1303 NULL,
1304 0,
1305 0),
1307 NO_CSIDL,
1308 "CryptoKeys",
1309 KF_CATEGORY_FIXED,
1311 NULL,
1312 NULL,
1313 0,
1314 0),
1316 NO_CSIDL,
1317 "DpapiKeys",
1318 KF_CATEGORY_FIXED,
1320 NULL,
1321 NULL,
1322 0,
1323 0),
1325 NO_CSIDL,
1326 "SystemCertificates",
1327 KF_CATEGORY_FIXED,
1329 NULL,
1330 NULL,
1331 0,
1332 0),
1333};
1334#undef KNOWN_FOLDER
1336
1337static void test_parameters(void)
1338{
1339 LPITEMIDLIST pidl = NULL;
1340 char path[MAX_PATH];
1341 HRESULT hr;
1342
1343 if (pSHGetFolderLocation)
1344 {
1345 /* check a bogus CSIDL: */
1346 pidl = NULL;
1347 hr = pSHGetFolderLocation(NULL, 0xeeee, NULL, 0, &pidl);
1348 ok(hr == E_INVALIDARG, "got 0x%08x, expected E_INVALIDARG\n", hr);
1349 if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
1350
1351 /* check a bogus user token: */
1352 pidl = NULL;
1353 hr = pSHGetFolderLocation(NULL, CSIDL_FAVORITES, (HANDLE)2, 0, &pidl);
1354 ok(hr == E_FAIL || hr == E_HANDLE, "got 0x%08x, expected E_FAIL or E_HANDLE\n", hr);
1355 if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
1356
1357 /* a NULL pidl pointer crashes, so don't test it */
1358 }
1359
1360 if (pSHGetSpecialFolderLocation)
1361 {
1362 if (0)
1363 /* crashes */
1365
1366 hr = pSHGetSpecialFolderLocation(NULL, 0xeeee, &pidl);
1367 ok(hr == E_INVALIDARG, "got returned 0x%08x\n", hr);
1368 }
1369
1370 if (pSHGetFolderPathA)
1371 {
1372 /* expect 2's a bogus handle, especially since we didn't open it */
1373 hr = pSHGetFolderPathA(NULL, CSIDL_DESKTOP, (HANDLE)2, SHGFP_TYPE_DEFAULT, path);
1374 ok(hr == E_FAIL || hr == E_HANDLE || /* Vista and 2k8 */
1375 broken(hr == S_OK), /* W2k and Me */ "got 0x%08x, expected E_FAIL\n", hr);
1376
1377 hr = pSHGetFolderPathA(NULL, 0xeeee, NULL, SHGFP_TYPE_DEFAULT, path);
1378 ok(hr == E_INVALIDARG, "got 0x%08x, expected E_INVALIDARG\n", hr);
1379 }
1380
1381 if (pSHGetSpecialFolderPathA)
1382 {
1383 BOOL ret;
1384
1385 if (0)
1386 pSHGetSpecialFolderPathA(NULL, NULL, CSIDL_BITBUCKET, FALSE);
1387
1388 /* odd but true: calling with a NULL path still succeeds if it's a real
1389 * dir (on some windows platform). on winME it generates exception.
1390 */
1391 ret = pSHGetSpecialFolderPathA(NULL, path, CSIDL_PROGRAMS, FALSE);
1392 ok(ret, "got %d\n", ret);
1393
1394 ret = pSHGetSpecialFolderPathA(NULL, path, 0xeeee, FALSE);
1395 ok(!ret, "got %d\n", ret);
1396 }
1397}
1398
1399/* Returns the folder's PIDL type, or 0xff if one can't be found. */
1401{
1402 LPITEMIDLIST pidl;
1403 HRESULT hr;
1404 BYTE ret = 0xff;
1405
1406 /* treat absence of function as success */
1407 if (!pSHGetFolderLocation) return TRUE;
1408
1409 pidl = NULL;
1410 hr = pSHGetFolderLocation(NULL, folder, NULL, 0, &pidl);
1411 if (hr == S_OK)
1412 {
1413 if (pidl)
1414 {
1415 LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1416
1417 ok(pidlLast != NULL, "%s: ILFindLastID failed\n",
1419 if (pidlLast)
1420 ret = pidlLast->mkid.abID[0];
1421 IMalloc_Free(pMalloc, pidl);
1422 }
1423 }
1424 return ret;
1425}
1426
1427/* Returns the folder's PIDL type, or 0xff if one can't be found. */
1429{
1430 LPITEMIDLIST pidl;
1431 HRESULT hr;
1432 BYTE ret = 0xff;
1433
1434 /* treat absence of function as success */
1435 if (!pSHGetSpecialFolderLocation) return TRUE;
1436
1437 pidl = NULL;
1438 hr = pSHGetSpecialFolderLocation(NULL, folder, &pidl);
1439 if (hr == S_OK)
1440 {
1441 if (pidl)
1442 {
1443 LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1444
1445 ok(pidlLast != NULL,
1446 "%s: ILFindLastID failed\n", getFolderName(folder));
1447 if (pidlLast)
1448 ret = pidlLast->mkid.abID[0];
1449 IMalloc_Free(pMalloc, pidl);
1450 }
1451 }
1452 return ret;
1453}
1454
1456{
1457 char path[MAX_PATH];
1458 HRESULT hr;
1459
1460 if (!pSHGetFolderPathA) return;
1461
1462 hr = pSHGetFolderPathA(NULL, folder, NULL, SHGFP_TYPE_CURRENT, path);
1463 ok(hr == S_OK || optional,
1464 "SHGetFolderPathA(NULL, %s, NULL, SHGFP_TYPE_CURRENT, path) failed: 0x%08x\n", getFolderName(folder), hr);
1465}
1466
1468{
1469 char path[MAX_PATH];
1470 BOOL ret;
1471
1472 if (!pSHGetSpecialFolderPathA) return;
1473
1474 ret = pSHGetSpecialFolderPathA(NULL, path, folder, FALSE);
1476 printf("%s: %s\n", getFolderName(folder), path);
1477 ok(ret || optional,
1478 "SHGetSpecialFolderPathA(NULL, path, %s, FALSE) failed\n",
1480}
1481
1482static void test_ShellValues(const struct shellExpectedValues testEntries[],
1483 int numEntries, BOOL optional)
1484{
1485 int i;
1486
1487 for (i = 0; i < numEntries; i++)
1488 {
1489 BYTE type;
1490 int j;
1491 BOOL foundTypeMatch = FALSE;
1492
1493 if (pSHGetFolderLocation)
1494 {
1495 type = testSHGetFolderLocation(testEntries[i].folder);
1496 for (j = 0; !foundTypeMatch && j < testEntries[i].numTypes; j++)
1497 if (testEntries[i].types[j] == type)
1498 foundTypeMatch = TRUE;
1499 ok(foundTypeMatch || optional || broken(type == 0xff) /* Win9x */,
1500 "%s has unexpected type %d (0x%02x)\n",
1501 getFolderName(testEntries[i].folder), type, type);
1502 }
1504 for (j = 0, foundTypeMatch = FALSE; !foundTypeMatch &&
1505 j < testEntries[i].numTypes; j++)
1506 if (testEntries[i].types[j] == type)
1507 foundTypeMatch = TRUE;
1508 ok(foundTypeMatch || optional || broken(type == 0xff) /* Win9x */,
1509 "%s has unexpected type %d (0x%02x)\n",
1510 getFolderName(testEntries[i].folder), type, type);
1511 switch (type)
1512 {
1513 case PT_FOLDER:
1514 case PT_DRIVE:
1515 case PT_DRIVE2:
1516 case PT_IESPECIAL2:
1517 test_SHGetFolderPath(optional, testEntries[i].folder);
1519 break;
1520 }
1521 }
1522}
1523
1524/* Attempts to verify that the folder path corresponding to the folder CSIDL
1525 * value has the same value as the environment variable with name envVar.
1526 * Doesn't mind if SHGetSpecialFolderPath fails for folder or if envVar isn't
1527 * set in this environment; different OS and shell version behave differently.
1528 * However, if both are present, fails if envVar's value is not the same
1529 * (byte-for-byte) as what SHGetSpecialFolderPath returns.
1530 */
1531static void matchSpecialFolderPathToEnv(int folder, const char *envVar)
1532{
1533 char path[MAX_PATH];
1534
1535 if (!pSHGetSpecialFolderPathA) return;
1536
1537 if (pSHGetSpecialFolderPathA(NULL, path, folder, FALSE))
1538 {
1539 char *envVal = getenv(envVar);
1540
1541 ok(!envVal || !lstrcmpiA(envVal, path),
1542 "%%%s%% does not match SHGetSpecialFolderPath:\n"
1543 "%%%s%% is %s\nSHGetSpecialFolderPath returns %s\n",
1544 envVar, envVar, envVal, path);
1545 }
1546}
1547
1548/* Attempts to match the GUID returned by SHGetFolderLocation for folder with
1549 * GUID. Assumes the type of the returned PIDL is in fact a GUID, but doesn't
1550 * fail if it isn't--that check should already have been done.
1551 * Fails if the returned PIDL is a GUID whose value does not match guid.
1552 */
1553static void matchGUID(int folder, const GUID *guid, const GUID *guid_alt)
1554{
1555 LPITEMIDLIST pidl;
1556 HRESULT hr;
1557
1558 if (!pSHGetFolderLocation) return;
1559 if (!guid) return;
1560
1561 pidl = NULL;
1562 hr = pSHGetFolderLocation(NULL, folder, NULL, 0, &pidl);
1563 if (hr == S_OK)
1564 {
1565 LPITEMIDLIST pidlLast = pILFindLastID(pidl);
1566
1567 if (pidlLast && (pidlLast->mkid.abID[0] == PT_SHELLEXT ||
1568 pidlLast->mkid.abID[0] == PT_GUID))
1569 {
1570 GUID *shellGuid = (GUID *)(pidlLast->mkid.abID + 2);
1571
1572 if (!guid_alt)
1573 ok(IsEqualIID(shellGuid, guid),
1574 "%s: got GUID %s, expected %s\n", getFolderName(folder),
1576 else
1577 ok(IsEqualIID(shellGuid, guid) ||
1578 IsEqualIID(shellGuid, guid_alt),
1579 "%s: got GUID %s, expected %s or %s\n", getFolderName(folder),
1580 wine_dbgstr_guid(shellGuid), wine_dbgstr_guid(guid), wine_dbgstr_guid(guid_alt));
1581 }
1582 IMalloc_Free(pMalloc, pidl);
1583 }
1584}
1585
1586/* Checks the PIDL type of all the known values. */
1587static void test_PidlTypes(void)
1588{
1589 /* Desktop */
1592
1595}
1596
1597/* FIXME: Should be in shobjidl.idl */
1598DEFINE_GUID(CLSID_NetworkExplorerFolder, 0xF02C1A0D, 0xBE21, 0x4350, 0x88, 0xB0, 0x73, 0x67, 0xFC, 0x96, 0xEF, 0x3C);
1599DEFINE_GUID(_CLSID_Documents, 0xA8CDFF1C, 0x4878, 0x43be, 0xB5, 0xFD, 0xF8, 0x09, 0x1C, 0x1C, 0x60, 0xD0);
1600
1601/* Verifies various shell virtual folders have the correct well-known GUIDs. */
1602static void test_GUIDs(void)
1603{
1604 matchGUID(CSIDL_BITBUCKET, &CLSID_RecycleBin, NULL);
1605 matchGUID(CSIDL_CONTROLS, &CLSID_ControlPanel, NULL);
1606 matchGUID(CSIDL_DRIVES, &CLSID_MyComputer, NULL);
1607 matchGUID(CSIDL_INTERNET, &CLSID_Internet, NULL);
1608 matchGUID(CSIDL_NETWORK, &CLSID_NetworkPlaces, &CLSID_NetworkExplorerFolder); /* Vista and higher */
1609 matchGUID(CSIDL_PERSONAL, &CLSID_MyDocuments, &_CLSID_Documents /* win8 */);
1611 matchGUID(CSIDL_PRINTERS, &CLSID_Printers, NULL);
1612}
1613
1614/* Verifies various shell paths match the environment variables to which they
1615 * correspond.
1616 */
1617static void test_EnvVars(void)
1618{
1625 /* this is only set on Wine, but can't hurt to verify it: */
1627}
1628
1629/* Loosely based on PathRemoveBackslashA from dlls/shlwapi/path.c */
1630static BOOL myPathIsRootA(LPCSTR lpszPath)
1631{
1632 if (lpszPath && *lpszPath &&
1633 lpszPath[1] == ':' && lpszPath[2] == '\\' && lpszPath[3] == '\0')
1634 return TRUE; /* X:\ */
1635 return FALSE;
1636}
1638{
1639 LPSTR szTemp = NULL;
1640
1641 if(lpszPath)
1642 {
1643 szTemp = CharPrevA(lpszPath, lpszPath + strlen(lpszPath));
1644 if (!myPathIsRootA(lpszPath) && *szTemp == '\\')
1645 *szTemp = '\0';
1646 }
1647 return szTemp;
1648}
1649
1650/* Verifies the shell path for CSIDL_WINDOWS matches the return from
1651 * GetWindowsDirectory. If SHGetSpecialFolderPath fails, no harm, no foul--not
1652 * every shell32 version supports CSIDL_WINDOWS.
1653 */
1654static void testWinDir(void)
1655{
1656 char windowsShellPath[MAX_PATH], windowsDir[MAX_PATH] = { 0 };
1657
1658 if (!pSHGetSpecialFolderPathA) return;
1659
1660 if (pSHGetSpecialFolderPathA(NULL, windowsShellPath, CSIDL_WINDOWS, FALSE))
1661 {
1662 myPathRemoveBackslashA(windowsShellPath);
1663 GetWindowsDirectoryA(windowsDir, sizeof(windowsDir));
1664 myPathRemoveBackslashA(windowsDir);
1665 ok(!lstrcmpiA(windowsDir, windowsShellPath),
1666 "GetWindowsDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1667 windowsDir, windowsShellPath);
1668 }
1669}
1670
1671/* Verifies the shell path for CSIDL_SYSTEM matches the return from
1672 * GetSystemDirectory. If SHGetSpecialFolderPath fails, no harm,
1673 * no foul--not every shell32 version supports CSIDL_SYSTEM.
1674 */
1675static void testSystemDir(void)
1676{
1677 char systemShellPath[MAX_PATH], systemDir[MAX_PATH], systemDirx86[MAX_PATH];
1678
1679 if (!pSHGetSpecialFolderPathA) return;
1680
1681 GetSystemDirectoryA(systemDir, sizeof(systemDir));
1682 myPathRemoveBackslashA(systemDir);
1683 if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEM, FALSE))
1684 {
1685 myPathRemoveBackslashA(systemShellPath);
1686 ok(!lstrcmpiA(systemDir, systemShellPath),
1687 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1688 systemDir, systemShellPath);
1689 }
1690
1691 if (!pGetSystemWow64DirectoryA || !pGetSystemWow64DirectoryA(systemDirx86, sizeof(systemDirx86)))
1692 GetSystemDirectoryA(systemDirx86, sizeof(systemDirx86));
1693 myPathRemoveBackslashA(systemDirx86);
1694 if (pSHGetSpecialFolderPathA(NULL, systemShellPath, CSIDL_SYSTEMX86, FALSE))
1695 {
1696 myPathRemoveBackslashA(systemShellPath);
1697 ok(!lstrcmpiA(systemDirx86, systemShellPath) || broken(!lstrcmpiA(systemDir, systemShellPath)),
1698 "GetSystemDirectory returns %s SHGetSpecialFolderPath returns %s\n",
1699 systemDir, systemShellPath);
1700 }
1701}
1702
1703/* Globals used by subprocesses */
1704static int myARGC;
1705static char **myARGV;
1706static char base[MAX_PATH];
1707static char selfname[MAX_PATH];
1708
1709static BOOL init(void)
1710{
1712 if (!GetCurrentDirectoryA(sizeof(base), base)) return FALSE;
1713 strcpy(selfname, myARGV[0]);
1714 return TRUE;
1715}
1716
1717static void doChild(const char *arg)
1718{
1719 char path[MAX_PATH];
1720 HRESULT hr;
1721
1722 if (arg[0] == '1')
1723 {
1724 LPITEMIDLIST pidl;
1725 char *p;
1726
1727 /* test what happens when CSIDL_FAVORITES is set to a nonexistent directory */
1728
1729 /* test some failure cases first: */
1730 hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES, NULL, SHGFP_TYPE_CURRENT, path);
1732 "SHGetFolderPath returned 0x%08x, expected 0x80070002\n", hr);
1733
1734 pidl = NULL;
1735 hr = pSHGetFolderLocation(NULL, CSIDL_FAVORITES, NULL, 0, &pidl);
1737 "SHGetFolderLocation returned 0x%08x\n", hr);
1738 if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
1739
1740 ok(!pSHGetSpecialFolderPathA(NULL, path, CSIDL_FAVORITES, FALSE),
1741 "SHGetSpecialFolderPath succeeded, expected failure\n");
1742
1743 pidl = NULL;
1744 hr = pSHGetSpecialFolderLocation(NULL, CSIDL_FAVORITES, &pidl);
1746 "SHGetFolderLocation returned 0x%08x\n", hr);
1747
1748 if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
1749
1750 /* now test success: */
1751 hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES | CSIDL_FLAG_CREATE, NULL,
1753 ok (hr == S_OK, "got 0x%08x\n", hr);
1754 if (hr == S_OK)
1755 {
1756 BOOL ret;
1757
1758 trace("CSIDL_FAVORITES was changed to %s\n", path);
1760 ok(!ret, "expected failure with ERROR_ALREADY_EXISTS\n");
1761 if (!ret)
1763 "got %d, expected ERROR_ALREADY_EXISTS\n", GetLastError());
1764
1765 p = path + strlen(path);
1766 strcpy(p, "\\desktop.ini");
1768 *p = 0;
1771 ok( ret, "failed to remove %s error %u\n", path, GetLastError() );
1772 }
1773 }
1774 else if (arg[0] == '2')
1775 {
1776 /* make sure SHGetFolderPath still succeeds when the
1777 original value of CSIDL_FAVORITES is restored. */
1778 hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES | CSIDL_FLAG_CREATE, NULL,
1780 ok(hr == S_OK, "SHGetFolderPath failed: 0x%08x\n", hr);
1781 }
1782}
1783
1784/* Tests the return values from the various shell functions both with and
1785 * without the use of the CSIDL_FLAG_CREATE flag. This flag only appeared in
1786 * version 5 of the shell, so don't test unless it's at least version 5.
1787 * The test reads a value from the registry, modifies it, calls
1788 * SHGetFolderPath once with the CSIDL_FLAG_CREATE flag, and immediately
1789 * afterward without it. Then it restores the registry and deletes the folder
1790 * that was created.
1791 * One oddity with respect to restoration: shell32 caches somehow, so it needs
1792 * to be reloaded in order to see the correct (restored) value.
1793 * Some APIs unrelated to the ones under test may fail, but I expect they're
1794 * covered by other unit tests; I just print out something about failure to
1795 * help trace what's going on.
1796 */
1797static void test_NonExistentPath(void)
1798{
1799 static const char userShellFolders[] =
1800 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
1801 char originalPath[MAX_PATH], modifiedPath[MAX_PATH];
1802 HKEY key;
1803
1804 if (!pSHGetFolderPathA) return;
1805 if (!pSHGetFolderLocation) return;
1806 if (!pSHGetSpecialFolderPathA) return;
1807 if (!pSHGetSpecialFolderLocation) return;
1808 if (!pSHFileOperationA) return;
1809 if (shellVersion.dwMajorVersion < 5) return;
1810
1811 if (!RegOpenKeyExA(HKEY_CURRENT_USER, userShellFolders, 0, KEY_ALL_ACCESS,
1812 &key))
1813 {
1814 DWORD len, type;
1815
1816 len = sizeof(originalPath);
1817 if (!RegQueryValueExA(key, "Favorites", NULL, &type,
1818 (LPBYTE)&originalPath, &len))
1819 {
1820 size_t len = strlen(originalPath);
1821
1822 memcpy(modifiedPath, originalPath, len);
1823 modifiedPath[len++] = '2';
1824 modifiedPath[len++] = '\0';
1825 trace("Changing CSIDL_FAVORITES to %s\n", modifiedPath);
1826 if (!RegSetValueExA(key, "Favorites", 0, type,
1827 (LPBYTE)modifiedPath, len))
1828 {
1829 char buffer[MAX_PATH+20];
1832
1833 sprintf(buffer, "%s tests/shellpath.c 1", selfname);
1834 memset(&startup, 0, sizeof(startup));
1835 startup.cb = sizeof(startup);
1836 startup.dwFlags = STARTF_USESHOWWINDOW;
1837 startup.wShowWindow = SW_SHOWNORMAL;
1839 &startup, &info);
1841
1842 /* restore original values: */
1843 trace("Restoring CSIDL_FAVORITES to %s\n", originalPath);
1844 RegSetValueExA(key, "Favorites", 0, type, (LPBYTE) originalPath,
1845 strlen(originalPath) + 1);
1847
1848 sprintf(buffer, "%s tests/shellpath.c 2", selfname);
1849 memset(&startup, 0, sizeof(startup));
1850 startup.cb = sizeof(startup);
1851 startup.dwFlags = STARTF_USESHOWWINDOW;
1852 startup.wShowWindow = SW_SHOWNORMAL;
1854 &startup, &info);
1855 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0,
1856 "child process termination\n");
1857 }
1858 }
1859 else skip("RegQueryValueExA(key, Favorites, ...) failed\n");
1860 if (key)
1862 }
1863 else skip("RegOpenKeyExA(HKEY_CURRENT_USER, %s, ...) failed\n", userShellFolders);
1864}
1865
1866static void test_SHGetFolderPathEx(void)
1867{
1869 unsigned int i;
1870 HRESULT hr;
1871 DWORD len;
1872
1873 if (!pSHGetKnownFolderPath || !pSHGetFolderPathEx)
1874 {
1875 win_skip("SHGetKnownFolderPath or SHGetFolderPathEx not available\n");
1876 return;
1877 }
1878
1879if (0) { /* crashes */
1880 hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, NULL);
1881 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1882}
1883 /* non-existent folder id */
1884 path = (void *)0xdeadbeef;
1885 hr = pSHGetKnownFolderPath(&IID_IOleObject, 0, NULL, &path);
1886 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
1887 ok(path == NULL, "got %p\n", path);
1888
1889 path = NULL;
1890 hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, KF_FLAG_DEFAULT_PATH, NULL, &path);
1891 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1892 ok(path != NULL, "expected path != NULL\n");
1894
1895 for (i = 0; i < ARRAY_SIZE(known_folders); ++i)
1896 {
1897 const KNOWNFOLDERID *folder_id = known_folders[i].folderId;
1898
1899 path = NULL;
1900 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_DEFAULT, NULL, &path);
1901 if (FAILED(hr))
1902 {
1903 ok(path == NULL, "expected path == NULL\n");
1904 continue;
1905 }
1906 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1907 ok(path != NULL, "expected path != NULL\n");
1908
1909 path2 = NULL;
1910 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_SIMPLE_IDLIST, NULL, &path2);
1911 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1912 ok(path2 != NULL, "expected path != NULL\n");
1913 ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1915
1916 path2 = NULL;
1917 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_DONT_UNEXPAND, NULL, &path2);
1918 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1919 ok(path2 != NULL, "expected path != NULL\n");
1920 ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1922
1923 path2 = NULL;
1924 hr = pSHGetKnownFolderPath(folder_id, KF_FLAG_SIMPLE_IDLIST | KF_FLAG_DONT_UNEXPAND, NULL, &path2);
1925 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1926 ok(path2 != NULL, "expected path != NULL\n");
1927 ok(!lstrcmpiW(path, path2), "expected equal paths: %s, %s\n", wine_dbgstr_w(path), wine_dbgstr_w(path2));
1929
1931 }
1932
1933 path = NULL;
1934 hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, &path);
1935 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1936 ok(path != NULL, "expected path != NULL\n");
1937
1938 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, MAX_PATH);
1939 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1940 ok(!lstrcmpiW(path, buffer), "expected equal paths\n");
1941 len = lstrlenW(buffer);
1943
1944 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, 0);
1945 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1946
1947if (0) { /* crashes */
1948 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, NULL, len + 1);
1949 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1950
1951 hr = pSHGetFolderPathEx(NULL, 0, NULL, buffer, MAX_PATH);
1952 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr);
1953}
1954 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len);
1955 ok(hr == E_NOT_SUFFICIENT_BUFFER, "expected E_NOT_SUFFICIENT_BUFFER, got 0x%08x\n", hr);
1956
1957 hr = pSHGetFolderPathEx(&FOLDERID_Desktop, 0, NULL, buffer, len + 1);
1958 ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);
1959}
1960
1961static BOOL is_in_strarray(const WCHAR *needle, const char *hay)
1962{
1963 WCHAR wstr[MAX_PATH];
1964
1965 if(!needle && !hay)
1966 return TRUE;
1967
1968 while(hay && *hay)
1969 {
1970 DWORD ret;
1971
1972 if(strcmp(hay, "(null)") == 0 && !needle)
1973 return TRUE;
1974
1975 ret = MultiByteToWideChar(CP_ACP, 0, hay, -1, wstr, ARRAY_SIZE(wstr));
1976 if(ret == 0)
1977 {
1978 ok(0, "Failed to convert string\n");
1979 return FALSE;
1980 }
1981
1982 if(lstrcmpW(wstr, needle) == 0)
1983 return TRUE;
1984
1985 hay += strlen(hay) + 1;
1986 }
1987
1988 return FALSE;
1989}
1990
1992{
1993 HRESULT hr;
1994 int csidl, expectedCsidl, ret;
1996 IKnownFolder *folder;
1997 WCHAR sName[1024];
1998 BOOL found = FALSE;
1999 unsigned int i;
2000
2001 for (i = 0; i < ARRAY_SIZE(known_folders); ++i)
2002 {
2003 const struct knownFolderDef *known_folder = &known_folders[i];
2004
2005 if(IsEqualGUID(known_folder->folderId, folderId))
2006 {
2008 found = TRUE;
2009 /* verify CSIDL */
2010 if(!(known_folder->csidl & NO_CSIDL))
2011 {
2012 /* mask off winetest flags */
2013 expectedCsidl = known_folder->csidl & 0xFFFF;
2014
2015 hr = IKnownFolderManager_FolderIdToCsidl(mgr, folderId, &csidl);
2016 ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot retrieve CSIDL for folder %s\n", known_folder->sFolderId);
2017
2018 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);
2019 }
2020
2021 hr = IKnownFolderManager_GetFolder(mgr, folderId, &folder);
2022 ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot get known folder for %s\n", known_folder->sFolderId);
2023 if(SUCCEEDED(hr))
2024 {
2025 hr = IKnownFolder_GetFolderDefinition(folder, &kfd);
2026 ok_(__FILE__, known_folder->line)(hr == S_OK, "cannot get known folder definition for %s\n", known_folder->sFolderId);
2027 if(SUCCEEDED(hr))
2028 {
2029 ret = MultiByteToWideChar(CP_ACP, 0, known_folder->sName, -1, sName, ARRAY_SIZE(sName));
2030 ok_(__FILE__, known_folder->line)(ret != 0, "cannot convert known folder name \"%s\" to wide characters\n", known_folder->sName);
2031
2032 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));
2033
2034 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);
2035
2036 ok_(__FILE__, known_folder->line)(IsEqualGUID(known_folder->fidParents[0], &kfd.fidParent) ||
2037 IsEqualGUID(known_folder->fidParents[1], &kfd.fidParent),
2038 "invalid known folder parent for %s: %s retrieved\n",
2039 known_folder->sFolderId, wine_dbgstr_guid(&kfd.fidParent));
2040
2041 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));
2042
2043 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));
2044
2045 ok_(__FILE__, known_folder->line)(known_folder->attributes == kfd.dwAttributes ||
2046 (known_folder->csidl & WINE_ATTRIBUTES_OPTIONAL && kfd.dwAttributes == 0),
2047 "invalid known folder attributes for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder->sFolderId, known_folder->attributes, kfd.dwAttributes);
2048
2049 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);
2050
2052 }
2053
2054 IKnownFolder_Release(folder);
2055 }
2056
2057 break;
2058 }
2059 }
2060
2061 if(!found)
2062 {
2063 trace("unknown known folder found: %s\n", wine_dbgstr_guid(folderId));
2064
2065 hr = IKnownFolderManager_GetFolder(mgr, folderId, &folder);
2066 ok(hr == S_OK, "cannot get known folder for %s\n", wine_dbgstr_guid(folderId));
2067 if(SUCCEEDED(hr))
2068 {
2069 hr = IKnownFolder_GetFolderDefinition(folder, &kfd);
2070 todo_wine
2071 ok(hr == S_OK, "cannot get known folder definition for %s\n", wine_dbgstr_guid(folderId));
2072 if(SUCCEEDED(hr))
2073 {
2074 trace(" category: %d\n", kfd.category);
2075 trace(" name: %s\n", wine_dbgstr_w(kfd.pszName));
2076 trace(" description: %s\n", wine_dbgstr_w(kfd.pszDescription));
2077 trace(" parent: %s\n", wine_dbgstr_guid(&kfd.fidParent));
2078 trace(" relative path: %s\n", wine_dbgstr_w(kfd.pszRelativePath));
2079 trace(" parsing name: %s\n", wine_dbgstr_w(kfd.pszParsingName));
2080 trace(" tooltip: %s\n", wine_dbgstr_w(kfd.pszTooltip));
2081 trace(" localized name: %s\n", wine_dbgstr_w(kfd.pszLocalizedName));
2082 trace(" icon: %s\n", wine_dbgstr_w(kfd.pszIcon));
2083 trace(" security: %s\n", wine_dbgstr_w(kfd.pszSecurity));
2084 trace(" attributes: 0x%08x\n", kfd.dwAttributes);
2085 trace(" flags: 0x%08x\n", kfd.kfdFlags);
2086 trace(" type: %s\n", wine_dbgstr_guid(&kfd.ftidType));
2088 }
2089
2090 IKnownFolder_Release(folder);
2091 }
2092 }
2093}
2094#undef NO_CSIDL
2095
2096static void test_knownFolders(void)
2097{
2098 static const WCHAR sWindows[] = {'W','i','n','d','o','w','s',0};
2099 static const WCHAR sWindows2[] = {'w','i','n','d','o','w','s',0};
2100 static const WCHAR sExample[] = {'E','x','a','m','p','l','e',0};
2101 static const WCHAR sExample2[] = {'E','x','a','m','p','l','e','2',0};
2102 static const WCHAR sSubFolder[] = {'S','u','b','F','o','l','d','e','r',0};
2103 static const WCHAR sNoSuch[] = {'N','o','S','u','c','h',0};
2104 static const WCHAR sBackslash[] = {'\\',0};
2105 static const KNOWNFOLDERID newFolderId = {0x01234567, 0x89AB, 0xCDEF, {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x01} };
2106 static const KNOWNFOLDERID subFolderId = {0xFEDCBA98, 0x7654, 0x3210, {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF} };
2107 HRESULT hr;
2109 IKnownFolder *folder = NULL, *subFolder = NULL;
2110 KNOWNFOLDERID folderId, *folders;
2111 KF_CATEGORY cat = 0;
2112 KNOWNFOLDER_DEFINITION kfDefinition, kfSubDefinition;
2113 int csidl, i;
2114 UINT nCount = 0;
2115 LPWSTR folderPath, errorMsg;
2116 KF_REDIRECTION_CAPABILITIES redirectionCapabilities = 1;
2117 WCHAR sWinDir[MAX_PATH], sExamplePath[MAX_PATH], sExample2Path[MAX_PATH], sSubFolderPath[MAX_PATH], sSubFolder2Path[MAX_PATH];
2118 BOOL bRes;
2120
2121 GetWindowsDirectoryW( sWinDir, MAX_PATH );
2122
2123 GetTempPathW(ARRAY_SIZE(sExamplePath), sExamplePath);
2124 lstrcatW(sExamplePath, sExample);
2125
2126 GetTempPathW(ARRAY_SIZE(sExample2Path), sExample2Path);
2127 lstrcatW(sExample2Path, sExample2);
2128
2129 lstrcpyW(sSubFolderPath, sExamplePath);
2130 lstrcatW(sSubFolderPath, sBackslash);
2131 lstrcatW(sSubFolderPath, sSubFolder);
2132
2133 lstrcpyW(sSubFolder2Path, sExample2Path);
2134 lstrcatW(sSubFolder2Path, sBackslash);
2135 lstrcatW(sSubFolder2Path, sSubFolder);
2136
2138
2139 hr = CoCreateInstance(&CLSID_KnownFolderManager, NULL, CLSCTX_INPROC_SERVER,
2140 &IID_IKnownFolderManager, (LPVOID*)&mgr);
2141 if(hr == REGDB_E_CLASSNOTREG)
2142 win_skip("IKnownFolderManager unavailable\n");
2143 else
2144 {
2145 IUnknown *unk;
2146
2147 ok(hr == S_OK, "failed to create KnownFolderManager instance: 0x%08x\n", hr);
2148
2149 hr = IKnownFolderManager_QueryInterface(mgr, &IID_IMarshal, (void**)&unk);
2150 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
2151
2152 hr = IKnownFolderManager_FolderIdFromCsidl(mgr, CSIDL_WINDOWS, &folderId);
2153 ok(hr == S_OK, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr);
2154 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2155
2156 hr = IKnownFolderManager_FolderIdToCsidl(mgr, &FOLDERID_Windows, &csidl);
2157 ok(hr == S_OK, "failed to convert CSIDL to KNOWNFOLDERID: 0x%08x\n", hr);
2158 ok(csidl == CSIDL_WINDOWS, "invalid CSIDL returned\n");
2159
2160 hr = IKnownFolderManager_GetFolder(mgr, &FOLDERID_Windows, &folder);
2161 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2162 if(SUCCEEDED(hr))
2163 {
2164 hr = IKnownFolder_QueryInterface(folder, &IID_IMarshal, (void**)&unk);
2165 ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
2166
2167 hr = IKnownFolder_GetCategory(folder, &cat);
2168 ok(hr == S_OK, "failed to get folder category: 0x%08x\n", hr);
2169 ok(cat==KF_CATEGORY_FIXED, "invalid folder category: %d\n", cat);
2170
2171 hr = IKnownFolder_GetId(folder, &folderId);
2172 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2173 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2174
2175 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2176 ok(hr == S_OK, "failed to get path from known folder: 0x%08x\n", hr);
2177 ok(lstrcmpiW(sWinDir, folderPath)==0, "invalid path returned: \"%s\", expected: \"%s\"\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sWinDir));
2178 CoTaskMemFree(folderPath);
2179
2180 hr = IKnownFolder_GetRedirectionCapabilities(folder, &redirectionCapabilities);
2181 ok(hr == S_OK, "failed to get redirection capabilities: 0x%08x\n", hr);
2182 todo_wine
2183 ok(redirectionCapabilities==0, "invalid redirection capabilities returned: %d\n", redirectionCapabilities);
2184
2185 hr = IKnownFolder_SetPath(folder, 0, sWinDir);
2186 todo_wine
2187 ok(hr == E_INVALIDARG, "unexpected value from SetPath: 0x%08x\n", hr);
2188
2189 hr = IKnownFolder_GetFolderDefinition(folder, &kfDefinition);
2190 ok(hr == S_OK, "failed to get folder definition: 0x%08x\n", hr);
2191 if(SUCCEEDED(hr))
2192 {
2193 ok(kfDefinition.category==KF_CATEGORY_FIXED, "invalid folder category: 0x%08x\n", kfDefinition.category);
2194 ok(lstrcmpW(kfDefinition.pszName, sWindows)==0, "invalid folder name: %s\n", wine_dbgstr_w(kfDefinition.pszName));
2195 ok(kfDefinition.dwAttributes==0, "invalid folder attributes: %d\n", kfDefinition.dwAttributes);
2196 FreeKnownFolderDefinitionFields(&kfDefinition);
2197 }
2198
2199 hr = IKnownFolder_Release(folder);
2200 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2201 }
2202
2203 hr = IKnownFolderManager_GetFolderByName(mgr, sWindows, &folder);
2204 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2205 if(SUCCEEDED(hr))
2206 {
2207 hr = IKnownFolder_GetId(folder, &folderId);
2208 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2209 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2210
2211 hr = IKnownFolder_Release(folder);
2212 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2213 }
2214
2215 hr = IKnownFolderManager_GetFolderByName(mgr, sWindows2, &folder);
2216 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2217 if(SUCCEEDED(hr))
2218 {
2219 hr = IKnownFolder_GetId(folder, &folderId);
2220 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2221 ok(IsEqualGUID(&folderId, &FOLDERID_Windows)==TRUE, "invalid KNOWNFOLDERID returned\n");
2222
2223 hr = IKnownFolder_Release(folder);
2224 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2225 }
2226
2227 folder = (IKnownFolder *)0xdeadbeef;
2228 hr = IKnownFolderManager_GetFolderByName(mgr, sNoSuch, &folder);
2229 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
2230 ok(folder == NULL, "got %p\n", folder);
2231
2232 for(i=0; i < ARRAY_SIZE(known_folder_found); ++i)
2234
2235 hr = IKnownFolderManager_GetFolderIds(mgr, &folders, &nCount);
2236 ok(hr == S_OK, "failed to get known folders: 0x%08x\n", hr);
2237 for(i=0;i<nCount;++i)
2238 check_known_folder(mgr, &folders[i]);
2239
2240 for(i=0; i < ARRAY_SIZE(known_folder_found); ++i)
2241 if(!known_folder_found[i])
2242 trace("Known folder %s not found on current platform\n", known_folders[i].sFolderId);
2243
2244 CoTaskMemFree(folders);
2245
2246 /* test of registering new known folders */
2247 bRes = CreateDirectoryW(sExamplePath, NULL);
2248 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sExamplePath));
2249 bRes = CreateDirectoryW(sExample2Path, NULL);
2250 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sExample2Path));
2251 bRes = CreateDirectoryW(sSubFolderPath, NULL);
2252 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolderPath));
2253
2254 ZeroMemory(&kfDefinition, sizeof(kfDefinition));
2255 kfDefinition.category = KF_CATEGORY_PERUSER;
2256 kfDefinition.pszName = CoTaskMemAlloc(sizeof(sExample));
2257 lstrcpyW(kfDefinition.pszName, sExample);
2258 kfDefinition.pszDescription = CoTaskMemAlloc(sizeof(sExample));
2259 lstrcpyW(kfDefinition.pszDescription, sExample);
2260 kfDefinition.pszRelativePath = CoTaskMemAlloc(sizeof(sExamplePath));
2261 lstrcpyW(kfDefinition.pszRelativePath, sExamplePath);
2262
2263 hr = IKnownFolderManager_RegisterFolder(mgr, &newFolderId, &kfDefinition);
2265 win_skip("No permissions required to register custom known folder\n");
2266 else
2267 {
2268 ok(hr == S_OK, "failed to register known folder: 0x%08x\n", hr);
2269 if(SUCCEEDED(hr))
2270 {
2271 hr = IKnownFolderManager_GetFolder(mgr, &newFolderId, &folder);
2272 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2273 if(SUCCEEDED(hr))
2274 {
2275 hr = IKnownFolder_GetCategory(folder, &cat);
2276 ok(hr == S_OK, "failed to get folder category: hr=0x%0x\n", hr);
2277 ok(cat == KF_CATEGORY_PERUSER, "invalid category returned: %d, while %d (KF_CATEGORY_PERUSER) expected\n", cat, KF_CATEGORY_PERUSER);
2278
2279 hr = IKnownFolder_GetId(folder, &folderId);
2280 ok(hr == S_OK, "failed to get folder id: 0x%08x\n", hr);
2281 ok(IsEqualGUID(&folderId, &newFolderId)==TRUE, "invalid KNOWNFOLDERID returned\n");
2282
2283 /* current path should be Temp\Example */
2284 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2285 ok(hr == S_OK, "failed to get path from known folder: 0x%08x\n", hr);
2286 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2287 CoTaskMemFree(folderPath);
2288
2289 /* register sub-folder and mark it as child of Example folder */
2290 ZeroMemory(&kfSubDefinition, sizeof(kfSubDefinition));
2291 kfSubDefinition.category = KF_CATEGORY_PERUSER;
2292 kfSubDefinition.pszName = CoTaskMemAlloc(sizeof(sSubFolder));
2293 lstrcpyW(kfSubDefinition.pszName, sSubFolder);
2294 kfSubDefinition.pszDescription = CoTaskMemAlloc(sizeof(sSubFolder));
2295 lstrcpyW(kfSubDefinition.pszDescription, sSubFolder);
2296 kfSubDefinition.pszRelativePath = CoTaskMemAlloc(sizeof(sSubFolder));
2297 lstrcpyW(kfSubDefinition.pszRelativePath, sSubFolder);
2298 kfSubDefinition.fidParent = newFolderId;
2299
2300 hr = IKnownFolderManager_RegisterFolder(mgr, &subFolderId, &kfSubDefinition);
2301 ok(hr == S_OK, "failed to register known folder: 0x%08x\n", hr);
2302 if(SUCCEEDED(hr))
2303 {
2304
2305 hr = IKnownFolderManager_GetFolder(mgr, &subFolderId, &subFolder);
2306 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2307 if(SUCCEEDED(hr))
2308 {
2309 /* check sub folder path */
2310 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2311 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2312 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2313 CoTaskMemFree(folderPath);
2314
2315
2316 /* try to redirect Example to Temp\Example2 */
2317 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, 0, sExample2Path, 0, NULL, &errorMsg);
2318 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2319
2320 /* verify */
2321 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2322 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2323 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2324 CoTaskMemFree(folderPath);
2325
2326 /* verify sub folder - it should fail now, as we redirected its parent folder, but we have no sub folder in new location */
2327 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2328 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "unexpected value from GetPath(): 0x%08x\n", hr);
2329 ok(folderPath==NULL, "invalid known folder path retrieved: \"%s\" when NULL pointer was expected\n", wine_dbgstr_w(folderPath));
2330 CoTaskMemFree(folderPath);
2331
2332
2333 /* set Example path to original. Using SetPath() is valid here, as it also uses redirection internally */
2334 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2335 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2336
2337 /* verify */
2338 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2339 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2340 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2341 CoTaskMemFree(folderPath);
2342
2343
2344 /* create sub folder in Temp\Example2 */
2345 bRes = CreateDirectoryW(sSubFolder2Path, NULL);
2346 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path));
2347
2348 /* again perform that same redirection */
2349 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, 0, sExample2Path, 0, NULL, &errorMsg);
2350 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2351
2352 /* verify sub folder. It should succeed now, as the required sub folder exists */
2353 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2354 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2355 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2356 CoTaskMemFree(folderPath);
2357
2358 /* remove newly created directory */
2359 RemoveDirectoryW(sSubFolder2Path);
2360
2361 /* verify subfolder. It still succeeds, so Windows does not check folder presence each time */
2362 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2363 todo_wine
2364 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2365 todo_wine
2366 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2367 CoTaskMemFree(folderPath);
2368
2369
2370 /* set Example path to original */
2371 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2372 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2373
2374 /* verify */
2375 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2376 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2377 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2378 CoTaskMemFree(folderPath);
2379
2380 /* verify sub folder */
2381 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2382 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2383 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2384 CoTaskMemFree(folderPath);
2385
2386
2387 /* create sub folder in Temp\Example2 */
2388 bRes = CreateDirectoryW(sSubFolder2Path, NULL);
2389 ok(bRes, "cannot create example directory: %s\n", wine_dbgstr_w(sSubFolder2Path));
2390
2391 /* do that same redirection, but try to exclude sub-folder */
2392 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, 0, sExample2Path, 1, &subFolderId, &errorMsg);
2393 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2394
2395 /* verify */
2396 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2397 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2398 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2399 CoTaskMemFree(folderPath);
2400
2401 /* 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 */
2402 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2403 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2404 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2405 CoTaskMemFree(folderPath);
2406
2407 /* remove newly created directory */
2408 RemoveDirectoryW(sSubFolder2Path);
2409
2410
2411 /* set Example path to original */
2412 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2413 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2414
2415 /* verify */
2416 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2417 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2418 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2419 CoTaskMemFree(folderPath);
2420
2421 /* verify sub folder */
2422 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2423 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2424 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2425 CoTaskMemFree(folderPath);
2426
2427
2428 /* do that same redirection again, but set it to copy content. It should also copy the sub folder, so checking it would succeed now */
2429 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, KF_REDIRECT_COPY_CONTENTS, sExample2Path, 0, NULL, &errorMsg);
2430 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2431
2432 /* verify */
2433 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2434 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2435 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2436 CoTaskMemFree(folderPath);
2437
2438 /* verify sub folder */
2439 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2440 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2441 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2442 CoTaskMemFree(folderPath);
2443
2444 /* remove copied directory */
2445 RemoveDirectoryW(sSubFolder2Path);
2446
2447
2448 /* set Example path to original */
2449 hr = IKnownFolder_SetPath(folder, 0, sExamplePath);
2450 ok(hr == S_OK, "SetPath() failed: 0x%08x\n", hr);
2451
2452 /* verify */
2453 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2454 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2455 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2456 CoTaskMemFree(folderPath);
2457
2458 /* verify sub folder */
2459 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2460 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2461 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2462 CoTaskMemFree(folderPath);
2463
2464
2465 /* redirect again, set it to copy content and remove originals */
2466 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, KF_REDIRECT_COPY_CONTENTS | KF_REDIRECT_DEL_SOURCE_CONTENTS, sExample2Path, 0, NULL, &errorMsg);
2467 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2468
2469 /* verify */
2470 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2471 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2472 ok(lstrcmpiW(folderPath, sExample2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExample2Path));
2473 CoTaskMemFree(folderPath);
2474
2475 /* verify sub folder */
2476 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2477 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2478 ok(lstrcmpiW(folderPath, sSubFolder2Path)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolder2Path));
2479 CoTaskMemFree(folderPath);
2480
2481 /* check if original directory was really removed */
2482 dwAttributes = GetFileAttributesW(sExamplePath);
2483 ok(dwAttributes==INVALID_FILE_ATTRIBUTES, "directory should not exist, but has attributes: 0x%08x\n", dwAttributes );
2484
2485
2486 /* redirect (with copy) to original path */
2487 hr = IKnownFolderManager_Redirect(mgr, &newFolderId, NULL, KF_REDIRECT_COPY_CONTENTS, sExamplePath, 0, NULL, &errorMsg);
2488 ok(hr == S_OK, "failed to redirect known folder: 0x%08x, errorMsg: %s\n", hr, wine_dbgstr_w(errorMsg));
2489
2490 /* verify */
2491 hr = IKnownFolder_GetPath(folder, 0, &folderPath);
2492 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2493 ok(lstrcmpiW(folderPath, sExamplePath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sExamplePath));
2494 CoTaskMemFree(folderPath);
2495
2496 /* verify sub folder */
2497 hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
2498 ok(hr == S_OK, "failed to get known folder path: 0x%08x\n", hr);
2499 ok(lstrcmpiW(folderPath, sSubFolderPath)==0, "invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n", wine_dbgstr_w(folderPath), wine_dbgstr_w(sSubFolderPath));
2500 CoTaskMemFree(folderPath);
2501
2502 /* check shell utility functions */
2503 if(!pSHGetKnownFolderPath || !pSHSetKnownFolderPath)
2504 todo_wine
2505 win_skip("cannot get SHGet/SetKnownFolderPath routines\n");
2506 else
2507 {
2508 /* try to get current known folder path */
2509 hr = pSHGetKnownFolderPath(&newFolderId, 0, NULL, &folderPath);
2510 todo_wine
2511 ok(hr==S_OK, "cannot get known folder path: hr=0x%0x\n", hr);
2512 todo_wine
2513 ok(lstrcmpW(folderPath, sExamplePath)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath));
2514
2515 /* set it to new value */
2516 hr = pSHSetKnownFolderPath(&newFolderId, 0, NULL, sExample2Path);
2517 todo_wine
2518 ok(hr==S_OK, "cannot set known folder path: hr=0x%0x\n", hr);
2519
2520 /* check if it changed */
2521 hr = pSHGetKnownFolderPath(&newFolderId, 0, NULL, &folderPath);
2522 todo_wine
2523 ok(hr==S_OK, "cannot get known folder path: hr=0x%0x\n", hr);
2524 todo_wine
2525 ok(lstrcmpW(folderPath, sExample2Path)==0, "invalid path returned: %s\n", wine_dbgstr_w(folderPath));
2526
2527 /* set it back */
2528 hr = pSHSetKnownFolderPath(&newFolderId, 0, NULL, sExamplePath);
2529 todo_wine
2530 ok(hr==S_OK, "cannot set known folder path: hr=0x%0x\n", hr);
2531 }
2532
2533 IKnownFolder_Release(subFolder);
2534 }
2535
2536 hr = IKnownFolderManager_UnregisterFolder(mgr, &subFolderId);
2537 ok(hr == S_OK, "failed to unregister folder: 0x%08x\n", hr);
2538 }
2539
2540 FreeKnownFolderDefinitionFields(&kfSubDefinition);
2541
2542 hr = IKnownFolder_Release(folder);
2543 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2544
2545 /* update the folder */
2546 CoTaskMemFree(kfDefinition.pszName);
2547 kfDefinition.pszName = CoTaskMemAlloc(sizeof(sExample2));
2548 lstrcpyW(kfDefinition.pszName, sExample2);
2549 hr = IKnownFolderManager_RegisterFolder(mgr, &newFolderId, &kfDefinition);
2550 ok(hr == S_OK, "failed to re-register known folder: 0x%08x\n", hr);
2551
2552 hr = IKnownFolderManager_GetFolder(mgr, &newFolderId, &folder);
2553 ok(hr == S_OK, "failed to get known folder: 0x%08x\n", hr);
2554
2555 hr = IKnownFolder_GetFolderDefinition(folder, &kfSubDefinition);
2556 ok(hr == S_OK, "failed to get folder definition: 0x%08x\n", hr);
2557 ok(!memcmp(kfDefinition.pszName, kfSubDefinition.pszName, sizeof(sExample2)),
2558 "Got wrong updated name: %s\n", wine_dbgstr_w(kfSubDefinition.pszName));
2559
2560 FreeKnownFolderDefinitionFields(&kfSubDefinition);
2561
2562 hr = IKnownFolder_Release(folder);
2563 ok(hr == S_OK, "failed to release KnownFolder instance: 0x%08x\n", hr);
2564 }
2565
2566 hr = IKnownFolderManager_UnregisterFolder(mgr, &newFolderId);
2567 ok(hr == S_OK, "failed to unregister folder: 0x%08x\n", hr);
2568 }
2569 }
2570 FreeKnownFolderDefinitionFields(&kfDefinition);
2571
2572 RemoveDirectoryW(sSubFolder2Path);
2573 RemoveDirectoryW(sSubFolderPath);
2574 RemoveDirectoryW(sExamplePath);
2575 RemoveDirectoryW(sExample2Path);
2576
2577 hr = IKnownFolderManager_Release(mgr);
2578 ok(hr == S_OK, "failed to release KnownFolderManager instance: 0x%08x\n", hr);
2579 }
2581}
2582
2583
2585{
2586 WCHAR expectedW[MAX_PATH];
2587 WCHAR bufferW[MAX_PATH];
2588 CHAR expectedA[MAX_PATH];
2589 CHAR bufferA[MAX_PATH];
2590 DWORD res;
2591 DWORD res2;
2592 DWORD len;
2593 INT i;
2594 static const WCHAR does_not_existW[] = {'%','D','O','E','S','_','N','O','T','_','E','X','I','S','T','%',0};
2595 static const CHAR does_not_existA[] = "%DOES_NOT_EXIST%";
2596 static const CHAR *names[] = {
2597 /* interactive apps and services (works on all windows versions) */
2598 "%ALLUSERSPROFILE%", "%APPDATA%", "%LOCALAPPDATA%",
2599 "%NUMBER_OF_PROCESSORS%", "%OS%", "%PROCESSOR_ARCHITECTURE%",
2600 "%PROCESSOR_IDENTIFIER%", "%PROCESSOR_LEVEL%", "%PROCESSOR_REVISION%",
2601 "%ProgramFiles%", "%SystemDrive%",
2602 "%SystemRoot%", "%USERPROFILE%", "%windir%",
2603 /* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
2604
2605 /* replace more than one var is allowed */
2606 "%HOMEDRIVE%%HOMEPATH%",
2607 "%OS% %windir%"}; /* always the last entry in the table */
2608
2609 for (i = 0; i < (ARRAY_SIZE(names)); i++)
2610 {
2611 memset(bufferA, '#', MAX_PATH - 1);
2612 bufferA[MAX_PATH - 1] = 0;
2613 lstrcpyA(bufferA, names[i]);
2614 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2615
2616 res2 = ExpandEnvironmentStringsA(names[i], expectedA, MAX_PATH);
2617 res = DoEnvironmentSubstA(bufferA, MAX_PATH);
2618
2619 /* is the space for the terminating 0 included? */
2620 if (!i && HIWORD(res) && (LOWORD(res) == (lstrlenA(bufferA))))
2621 {
2622 win_skip("DoEnvironmentSubstA/W are broken on NT 4\n");
2623 return;
2624 }
2625 ok(HIWORD(res) && (LOWORD(res) == res2),
2626 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2627 ok(!lstrcmpA(bufferA, expectedA),
2628 "%d: got %s (expected %s)\n", i, bufferA, expectedA);
2629
2630 res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2631 res = DoEnvironmentSubstW(bufferW, MAX_PATH);
2632 ok(HIWORD(res) && (LOWORD(res) == res2),
2633 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2634 ok(!lstrcmpW(bufferW, expectedW),
2635 "%d: got %s (expected %s)\n", i, wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2636 }
2637
2638 i--; /* reuse data in the last table entry */
2639 len = LOWORD(res); /* needed length */
2640
2641 /* one character extra is fine */
2642 memset(bufferA, '#', MAX_PATH - 1);
2643 bufferA[len + 2] = 0;
2644 lstrcpyA(bufferA, names[i]);
2645 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2646
2647 res2 = ExpandEnvironmentStringsA(bufferA, expectedA, MAX_PATH);
2648 res = DoEnvironmentSubstA(bufferA, len + 1);
2649 ok(HIWORD(res) && (LOWORD(res) == res2),
2650 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2651 ok(!lstrcmpA(bufferA, expectedA),
2652 "+1: got %s (expected %s)\n", bufferA, expectedA);
2653
2654 res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2655 res = DoEnvironmentSubstW(bufferW, len + 1);
2656 ok(HIWORD(res) && (LOWORD(res) == res2),
2657 "+1: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2658 ok(!lstrcmpW(bufferW, expectedW),
2659 "+1: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2660
2661
2662 /* minimal buffer length (result string and terminating 0) */
2663 memset(bufferA, '#', MAX_PATH - 1);
2664 bufferA[len + 2] = 0;
2665 lstrcpyA(bufferA, names[i]);
2666 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2667
2668 /* ANSI version failed without an extra byte, as documented on msdn */
2669 res = DoEnvironmentSubstA(bufferA, len);
2670 ok(!HIWORD(res) && (LOWORD(res) == len),
2671 " 0: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len);
2672 ok(!lstrcmpA(bufferA, names[i]),
2673 " 0: got %s (expected %s)\n", bufferA, names[i]);
2674
2675 /* DoEnvironmentSubstW works as expected */
2676 res2 = ExpandEnvironmentStringsW(bufferW, expectedW, MAX_PATH);
2677 res = DoEnvironmentSubstW(bufferW, len);
2678 ok(HIWORD(res) && (LOWORD(res) == res2),
2679 " 0: got %d/%d (expected TRUE/%d)\n", HIWORD(res), LOWORD(res), res2);
2680 ok(!lstrcmpW(bufferW, expectedW),
2681 " 0: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2682
2683
2684 /* Buffer too small */
2685 /* result: FALSE / provided buffer length / the buffer is untouched */
2686 memset(bufferA, '#', MAX_PATH - 1);
2687 bufferA[len + 2] = 0;
2688 lstrcpyA(bufferA, names[i]);
2689 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2690
2691 res = DoEnvironmentSubstA(bufferA, len - 1);
2692 ok(!HIWORD(res) && (LOWORD(res) == (len - 1)),
2693 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len - 1);
2694 ok(!lstrcmpA(bufferA, names[i]),
2695 "-1: got %s (expected %s)\n", bufferA, names[i]);
2696
2697 lstrcpyW(expectedW, bufferW);
2698 res = DoEnvironmentSubstW(bufferW, len - 1);
2699 ok(!HIWORD(res) && (LOWORD(res) == (len - 1)),
2700 "-1: got %d/%d (expected FALSE/%d)\n", HIWORD(res), LOWORD(res), len - 1);
2701 ok(!lstrcmpW(bufferW, expectedW),
2702 "-1: got %s (expected %s)\n", wine_dbgstr_w(bufferW), wine_dbgstr_w(expectedW));
2703
2704
2705 /* unknown variable */
2706 /* result: TRUE / string length including terminating 0 / the buffer is untouched */
2707 memset(bufferA, '#', MAX_PATH - 1);
2708 bufferA[MAX_PATH - 1] = 0;
2709 lstrcpyA(bufferA, does_not_existA);
2710 MultiByteToWideChar(CP_ACP, 0, bufferA, MAX_PATH, bufferW, ARRAY_SIZE(bufferW));
2711
2712 res2 = lstrlenA(does_not_existA) + 1;
2713 res = DoEnvironmentSubstA(bufferA, MAX_PATH);
2714 ok(HIWORD(res) && (LOWORD(res) == res2),
2715 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2716 ok(!lstrcmpA(bufferA, does_not_existA),
2717 "%d: got %s (expected %s)\n", i, bufferA, does_not_existA);
2718
2719 res = DoEnvironmentSubstW(bufferW, MAX_PATH);
2720 ok(HIWORD(res) && (LOWORD(res) == res2),
2721 "%d: got %d/%d (expected TRUE/%d)\n", i, HIWORD(res), LOWORD(res), res2);
2722 ok(!lstrcmpW(bufferW, does_not_existW),
2723 "%d: got %s (expected %s)\n", i, wine_dbgstr_w(bufferW), wine_dbgstr_w(does_not_existW));
2724
2725
2726 if (0)
2727 {
2728 /* NULL crashes on windows */
2731 }
2732}
2733
2735{
2736 static const WCHAR shortW[] = {'f','i','l','e','.','t','s','t',0};
2737 static const WCHAR short2W[] = {'f','i','l','e',' ','(','2',')','.','t','s','t',0};
2738 static const WCHAR tmpW[] = {'t','m','p',0};
2739 static const WCHAR longW[] = {'n','a','m','e',0};
2740 static const WCHAR long2W[] = {'n','a','m','e',' ','(','2',')',0};
2742 HANDLE file;
2743 BOOL ret;
2744
2745 if (!pPathYetAnotherMakeUniqueName)
2746 {
2747 win_skip("PathYetAnotherMakeUniqueName() is not available.\n");
2748 return;
2749 }
2750
2751if (0)
2752{
2753 /* crashes on Windows */
2754 ret = pPathYetAnotherMakeUniqueName(NULL, NULL, NULL, NULL);
2755 ok(!ret, "got %d\n", ret);
2756
2757 ret = pPathYetAnotherMakeUniqueName(nameW, NULL, NULL, NULL);
2758 ok(!ret, "got %d\n", ret);
2759}
2760
2762
2763 /* Using short name only first */
2764 nameW[0] = 0;
2765 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
2766 ok(ret, "got %d\n", ret);
2767 lstrcpyW(buffW, pathW);
2768 lstrcatW(buffW, shortW);
2769 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2770
2771 /* now create a file with this name and get next name */
2773 ok(file != NULL, "got %p\n", file);
2774
2775 nameW[0] = 0;
2776 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, shortW, NULL);
2777 ok(ret, "got %d\n", ret);
2778 lstrcpyW(buffW, pathW);
2779 lstrcatW(buffW, short2W);
2780 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2781
2783
2784 /* Using short and long */
2785 nameW[0] = 0;
2786 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
2787 ok(ret, "got %d\n", ret);
2788 lstrcpyW(buffW, pathW);
2789 lstrcatW(buffW, longW);
2790 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2791
2793 ok(file != NULL, "got %p\n", file);
2794
2795 nameW[0] = 0;
2796 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, tmpW, longW);
2797 ok(ret, "got %d\n", ret);
2798 lstrcpyW(buffW, pathW);
2799 lstrcatW(buffW, long2W);
2800 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2801
2803
2804 /* Using long only */
2805 nameW[0] = 0;
2806 ret = pPathYetAnotherMakeUniqueName(nameW, pathW, NULL, longW);
2807 ok(ret, "got %d\n", ret);
2808 lstrcpyW(buffW, pathW);
2809 lstrcatW(buffW, longW);
2810 ok(!lstrcmpW(nameW, buffW), "got %s, expected %s\n", wine_dbgstr_w(nameW), wine_dbgstr_w(buffW));
2811}
2812
2814{
2815 PIDLIST_ABSOLUTE pidl;
2816 HRESULT hr;
2817
2818 if (!pSHGetKnownFolderIDList)
2819 {
2820 win_skip("SHGetKnownFolderIDList is not available.\n");
2821 return;
2822 }
2823
2824 hr = pSHGetKnownFolderIDList(NULL, 0, NULL, NULL);
2825 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2826
2827if (0) { /* crashes on native */
2828 pidl = (void*)0xdeadbeef;
2829 hr = pSHGetKnownFolderIDList(NULL, 0, NULL, &pidl);
2830}
2831 /* not a known folder */
2832 pidl = (void*)0xdeadbeef;
2833 hr = pSHGetKnownFolderIDList(&IID_IUnknown, 0, NULL, &pidl);
2834 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
2835 ok(pidl == NULL, "got %p\n", pidl);
2836
2837 hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, NULL);
2838 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
2839
2840 pidl = (void*)0xdeadbeef;
2841 hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, 0, NULL, &pidl);
2842 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2843 ok(ILIsEmpty(pidl), "pidl should be empty.\n");
2844 ok(pidl->mkid.cb == 0, "get wrong value: %d\n", pidl->mkid.cb);
2845 ILFree(pidl);
2846
2847 pidl = (void*)0xdeadbeef;
2848 hr = pSHGetKnownFolderIDList(&FOLDERID_Desktop, KF_FLAG_NO_ALIAS, NULL, &pidl);
2849 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2850 todo_wine ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2851 todo_wine ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2852 ILFree(pidl);
2853
2854 pidl = (void*)0xdeadbeef;
2855 hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, 0, NULL, &pidl);
2856 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2857 ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2858 ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2859 ILFree(pidl);
2860
2861 pidl = (void*)0xdeadbeef;
2862 hr = pSHGetKnownFolderIDList(&FOLDERID_Documents, KF_FLAG_NO_ALIAS, NULL, &pidl);
2863 ok(hr == S_OK, "SHGetKnownFolderIDList failed: 0x%08x\n", hr);
2864 ok(!ILIsEmpty(pidl), "pidl should not be empty.\n");
2865 ok(pidl->mkid.cb == 20, "get wrong value: %d\n", pidl->mkid.cb);
2866 ILFree(pidl);
2867}
2868
2869START_TEST(shellpath)
2870{
2871 if (!init()) return;
2872
2873 loadShell32();
2874 pGetSystemWow64DirectoryA = (void *)GetProcAddress( GetModuleHandleA("kernel32.dll"),
2875 "GetSystemWow64DirectoryA" );
2876 if (myARGC >= 3)
2877 doChild(myARGV[2]);
2878 else
2879 {
2880 /* Report missing functions once */
2881 if (!pSHGetFolderLocation)
2882 win_skip("SHGetFolderLocation is not available\n");
2883
2884 /* first test various combinations of parameters: */
2886
2887 /* check known values: */
2889 test_GUIDs();
2890 test_EnvVars();
2891 testWinDir();
2892 testSystemDir();
2899 }
2900}
@ optional
Definition: SystemMenu.c:34
static void startup(void)
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
static const WCHAR nameW[]
Definition: main.c:49
#define ARRAY_SIZE(A)
Definition: main.h:20
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
STDAPI DllGetVersion(DLLVERSIONINFO *info)
Definition: browseui.cpp:221
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2951
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define GetProcAddress(x, y)
Definition: compat.h:753
HANDLE HWND
Definition: compat.h:19
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
Definition: environ.c:372
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:682
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:700
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:760
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2065
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:1999
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2256
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2271
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2202
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
Definition: process.c:686
LPSTR WINAPI CharPrevA(const char *start, const char *ptr)
Definition: string.c:1172
GUID guid
Definition: version.c:147
char *CDECL getenv(const char *name)
Definition: environ.c:227
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
HRESULT WINAPI SHGetMalloc(LPMALLOC *lpmal)
Definition: shellole.c:329
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3384
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3277
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3206
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2963
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:848
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:103
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
GLuint GLuint * names
Definition: glext.h:11545
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
unsigned int UINT
Definition: sysinfo.c:13
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
#define GUID_NULL
Definition: ks.h:106
static WCHAR does_not_existW[]
Definition: localmon.c:90
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define win_skip
Definition: minitest.h:67
int winetest_interactive
#define todo_wine
Definition: minitest.h:80
#define ZeroMemory
Definition: minwinbase.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CREATE_ALWAYS
Definition: disk.h:72
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define FILE_FLAG_DELETE_ON_CLOSE
Definition: disk.h:42
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define sprintf
Definition: sprintf.c:45
static const WCHAR pathW[]
Definition: path.c:2368
static LPSTR myPathRemoveBackslashA(LPSTR lpszPath)
Definition: shellpath.c:1637
static PCWSTR
Definition: shellpath.c:100
static const BYTE folderOrSpecialType[]
Definition: shellpath.c:109
static void test_SHGetKnownFolderIDList(void)
Definition: shellpath.c:2813
static void testSystemDir(void)
Definition: shellpath.c:1675
static const BYTE workgroupType[]
Definition: shellpath.c:116
static void matchGUID(int folder, const GUID *guid, const GUID *guid_alt)
Definition: shellpath.c:1553
#define PT_CPL
Definition: shellpath.c:48
#define PT_WORKGRP
Definition: shellpath.c:69
static void test_SHGetSpecialFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1467
#define PT_FOLDER
Definition: shellpath.c:63
static void test_PidlTypes(void)
Definition: shellpath.c:1587
static const BYTE folderType[]
Definition: shellpath.c:107
static const BYTE guidType[]
Definition: shellpath.c:105
static void test_DoEnvironmentSubst(void)
Definition: shellpath.c:2584
static PWSTR *static PWSTR
Definition: shellpath.c:98
static const BYTE favoritesType[]
Definition: shellpath.c:108
static const BYTE printersType[]
Definition: shellpath.c:113
static void test_NonExistentPath(void)
Definition: shellpath.c:1797
static void test_SHGetFolderPathEx(void)
Definition: shellpath.c:1866
static void test_EnvVars(void)
Definition: shellpath.c:1617
static void test_SHGetFolderPath(BOOL optional, int folder)
Definition: shellpath.c:1455
static BYTE testSHGetFolderLocation(int folder)
Definition: shellpath.c:1400
#define NO_CSIDL
Definition: shellpath.c:308
static BOOL init(void)
Definition: shellpath.c:1709
static BOOL is_in_strarray(const WCHAR *needle, const char *hay)
Definition: shellpath.c:1961
static const char * getFolderName(int folder)
Definition: shellpath.c:235
#define PT_DRIVE
Definition: shellpath.c:54
static void test_PathYetAnotherMakeUniqueName(void)
Definition: shellpath.c:2734
static const struct shellExpectedValues optionalShellValues[]
Definition: shellpath.c:142
static int myARGC
Definition: shellpath.c:1704
static int
Definition: shellpath.c:88
static const GUID _FOLDERID_SystemCertificates
Definition: shellpath.c:316
#define OLD_CSIDL_MYDOCUMENTS
Definition: shellpath.c:42
static const BYTE personalType[]
Definition: shellpath.c:110
static void test_parameters(void)
Definition: shellpath.c:1337
#define CSIDL_PROFILES
Definition: shellpath.c:231
#define PT_DRIVE2
Definition: shellpath.c:57
static PIDLIST_ABSOLUTE *static DLLVERSIONINFO shellVersion
Definition: shellpath.c:103
static void loadShell32(void)
Definition: shellpath.c:186
#define CSIDL_TO_STR(x)
static const BYTE ieSpecialType[]
Definition: shellpath.c:114
static DWORD
Definition: shellpath.c:88
static const BYTE shellExtType[]
Definition: shellpath.c:115
static void test_knownFolders(void)
Definition: shellpath.c:2096
static void doChild(const char *arg)
Definition: shellpath.c:1717
static void test_GUIDs(void)
Definition: shellpath.c:1602
#define PT_GUID
Definition: shellpath.c:51
static LPMALLOC pMalloc
Definition: shellpath.c:104
static char ** myARGV
Definition: shellpath.c:1705
static GUID CLSID_CommonDocuments
Definition: shellpath.c:79
#define GET_PROC(func)
static const GUID _FOLDERID_DpapiKeys
Definition: shellpath.c:315
static void matchSpecialFolderPathToEnv(int folder, const char *envVar)
Definition: shellpath.c:1531
static void test_ShellValues(const struct shellExpectedValues testEntries[], int numEntries, BOOL optional)
Definition: shellpath.c:1482
BOOL known_folder_found[ARRAY_SIZE(known_folders)]
Definition: shellpath.c:1335
static const BYTE controlPanelType[]
Definition: shellpath.c:106
static const struct shellExpectedValues requiredShellValues[]
Definition: shellpath.c:118
static const GUID _FOLDERID_CryptoKeys
Definition: shellpath.c:314
static BOOL myPathIsRootA(LPCSTR lpszPath)
Definition: shellpath.c:1630
#define WINE_ATTRIBUTES_OPTIONAL
Definition: shellpath.c:309
static void check_known_folder(IKnownFolderManager *mgr, KNOWNFOLDERID *folderId)
Definition: shellpath.c:1991
static void testWinDir(void)
Definition: shellpath.c:1654
static BYTE testSHGetSpecialFolderLocation(int folder)
Definition: shellpath.c:1428
#define DECLARE_TYPE(x, y)
Definition: shellpath.c:117
static const GUID _FOLDERID_CredentialManager
Definition: shellpath.c:317
#define KNOWN_FOLDER(id, csidl, name, category, parent1, parent2, relative_path, parsing_name, attributes, definitionFlags)
Definition: shellpath.c:310
static LPITEMIDLIST *static BOOL
Definition: shellpath.c:91
static char selfname[MAX_PATH]
Definition: shellpath.c:1707
static const struct knownFolderDef known_folders[]
Definition: shellpath.c:343
#define PT_YAGUID
Definition: shellpath.c:72
#define PT_FOLDERW
Definition: shellpath.c:66
#define PT_SHELLEXT
Definition: shellpath.c:60
#define PT_IESPECIAL2
Definition: shellpath.c:76
static UINT
Definition: shellpath.c:96
static HMODULE hShell32
Definition: string.c:34
static const WCHAR path2[]
Definition: path.c:29
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define GENERIC_WRITE
Definition: nt_native.h:90
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
Definition: ntifs_ex.h:384
interface IMalloc * LPMALLOC
Definition: objfwd.h:12
const GUID IID_IOleObject
#define LOWORD(l)
Definition: pedump.c:82
short WCHAR
Definition: pedump.c:58
char CHAR
Definition: pedump.c:57
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:199
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
strcpy
Definition: string.h:131
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:171
int winetest_get_mainargs(char ***pargv)
void winetest_wait_child_process(HANDLE process)
#define memset(x, y, z)
Definition: compat.h:39
struct _SHFILEOPSTRUCTA * LPSHFILEOPSTRUCTA
DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
Definition: shellord.c:2073
DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
Definition: shellord.c:2028
int WINAPI SHFileOperationA(LPSHFILEOPSTRUCTA lpFileOp)
Definition: shlfileop.cpp:1160
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2234
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2214
#define CSIDL_TEMPLATES
Definition: shlobj.h:2210
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2227
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2221
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2205
#define CSIDL_SENDTO
Definition: shlobj.h:2199
#define CSIDL_RECENT
Definition: shlobj.h:2198
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2202
#define CSIDL_ADMINTOOLS
Definition: shlobj.h:2237
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2211
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2167
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2166
#define CSIDL_CDBURN_AREA
Definition: shlobj.h:2245
#define CSIDL_COMMON_ALTSTARTUP
Definition: shlobj.h:2219
#define CSIDL_FONTS
Definition: shlobj.h:2209
#define CSIDL_PERSONAL
Definition: shlobj.h:2195
#define CSIDL_FAVORITES
Definition: shlobj.h:2196
#define CSIDL_FLAG_CREATE
Definition: shlobj.h:2252
#define CSIDL_COMMON_APPDATA
Definition: shlobj.h:2224
#define CSIDL_CONNECTIONS
Definition: shlobj.h:2238
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2212
#define CSIDL_COMPUTERSNEARME
Definition: shlobj.h:2246
#define CSIDL_MYPICTURES
Definition: shlobj.h:2228
#define CSIDL_COOKIES
Definition: shlobj.h:2222
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2220
#define CSIDL_PRINTERS
Definition: shlobj.h:2194
@ KF_FLAG_NO_ALIAS
Definition: shlobj.h:103
@ KF_FLAG_SIMPLE_IDLIST
Definition: shlobj.h:99
@ KF_FLAG_DONT_UNEXPAND
Definition: shlobj.h:104
@ KF_FLAG_DEFAULT
Definition: shlobj.h:98
#define CSIDL_RESOURCES
Definition: shlobj.h:2242
#define CSIDL_SYSTEM
Definition: shlobj.h:2226
#define CSIDL_HISTORY
Definition: shlobj.h:2223
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2217
#define CSIDL_PROFILE
Definition: shlobj.h:2229
#define CSIDL_PROGRAM_FILES_COMMONX86
Definition: shlobj.h:2233
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2232
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2239
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2241
#define CSIDL_DESKTOP
Definition: shlobj.h:2190
#define CSIDL_NETWORK
Definition: shlobj.h:2207
#define CSIDL_STARTMENU
Definition: shlobj.h:2201
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2231
static BOOL ILIsEmpty(_In_opt_ PCUIDLIST_RELATIVE pidl)
Definition: shlobj.h:2536
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2240
#define CSIDL_PROGRAMS
Definition: shlobj.h:2192
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2213
#define CSIDL_APPDATA
Definition: shlobj.h:2215
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2216
#define CSIDL_ALTSTARTUP
Definition: shlobj.h:2218
#define CSIDL_SYSTEMX86
Definition: shlobj.h:2230
#define KF_FLAG_DEFAULT_PATH
Definition: shlobj.h:325
#define CSIDL_STARTUP
Definition: shlobj.h:2197
#define CSIDL_WINDOWS
Definition: shlobj.h:2225
#define CSIDL_DRIVES
Definition: shlobj.h:2206
#define CSIDL_MYMUSIC
Definition: shlobj.h:2203
#define CSIDL_INTERNET
Definition: shlobj.h:2191
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2235
#define CSIDL_CONTROLS
Definition: shlobj.h:2193
#define CSIDL_BITBUCKET
Definition: shlobj.h:2200
#define CSIDL_NETHOOD
Definition: shlobj.h:2208
#define CSIDL_COMMON_OEM_LINKS
Definition: shlobj.h:2244
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2236
#define CSIDL_MYVIDEO
Definition: shlobj.h:2204
#define CSIDL_RESOURCES_LOCALIZED
Definition: shlobj.h:2243
enum tagKF_DEFINITION_FLAGS KF_DEFINITION_FLAGS
static void FreeKnownFolderDefinitionFields(KNOWNFOLDER_DEFINITION *pKFD)
Definition: shobjidl.idl:4182
@ KFDF_PUBLISHEXPANDEDPATH
Definition: shobjidl.idl:4047
@ KFDF_LOCAL_REDIRECT_ONLY
Definition: shobjidl.idl:4043
@ KFDF_ROAMABLE
Definition: shobjidl.idl:4044
@ KFDF_PRECREATE
Definition: shobjidl.idl:4045
@ KFDF_STREAM
Definition: shobjidl.idl:4046
pointer_default(unique)] interface IFileDialogCustomize enum tagKF_REDIRECTION_CAPABILITIES KF_REDIRECTION_CAPABILITIES
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
KNOWNFOLDERID * REFKNOWNFOLDERID
Definition: shtypes.idl:147
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
WORD cb
Definition: shtypes.idl:27
SHITEMID mkid
Definition: shtypes.idl:34
Definition: fci.c:127
Definition: fci.c:116
Definition: copy.c:22
const DWORD attributes
Definition: shellpath.c:329
const char * sRelativePath
Definition: shellpath.c:327
const KF_CATEGORY category
Definition: shellpath.c:325
const int csidl
Definition: shellpath.c:322
const KNOWNFOLDERID * folderId
Definition: shellpath.c:320
const char * sFolderId
Definition: shellpath.c:321
const char * sName
Definition: shellpath.c:324
const KF_DEFINITION_FLAGS definitionFlags
Definition: shellpath.c:330
const char * sCsidl
Definition: shellpath.c:323
const int line
Definition: shellpath.c:331
const KNOWNFOLDERID * fidParents[2]
Definition: shellpath.c:326
const char * sParsingName
Definition: shellpath.c:328
const BYTE * types
Definition: shellpath.c:84
KF_DEFINITION_FLAGS kfdFlags
Definition: shobjidl.idl:4063
Definition: cmds.c:130
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
uint16_t * PWSTR
Definition: typedefs.h:56
const char * LPCSTR
Definition: typedefs.h:52
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
PVOID HANDLE
Definition: typedefs.h:73
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
DWORD dwAttributes
Definition: vdmdbg.h:34
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define STARTF_USESHOWWINDOW
Definition: winbase.h:468
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:3801
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_HANDLE
Definition: winerror.h:4117
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SW_SHOWNORMAL
Definition: winuser.h:781
unsigned char BYTE
Definition: xxhash.c:193