shell32: Accept more flags in SHGetKnownFolderPath().
[wine.git] / dlls / shell32 / shellpath.c
blobde4bf7d566c1ccd50446b9ca9b784e52a61342bb
1 /*
2 * Path Functions
4 * Copyright 1998, 1999, 2000 Juergen Schmied
5 * Copyright 2004 Juan Lang
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * NOTES:
23 * Many of these functions are in SHLWAPI.DLL also
27 #define COBJMACROS
29 #include "config.h"
30 #include "wine/port.h"
32 #include <stdio.h>
33 #include <stdarg.h>
34 #include <string.h>
35 #include <ctype.h>
36 #include "wine/debug.h"
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winnls.h"
40 #include "winreg.h"
41 #include "wingdi.h"
42 #include "winuser.h"
44 #include "shlobj.h"
45 #include "shtypes.h"
46 #include "shresdef.h"
47 #include "shell32_main.h"
48 #include "undocshell.h"
49 #include "pidl.h"
50 #include "wine/unicode.h"
51 #include "shlwapi.h"
52 #include "xdg.h"
53 #include "sddl.h"
54 #include "knownfolders.h"
55 #include "initguid.h"
56 #include "shobjidl.h"
58 WINE_DEFAULT_DEBUG_CHANNEL(shell);
60 static const BOOL is_win64 = sizeof(void *) > sizeof(int);
63 ########## Combining and Constructing paths ##########
66 /*************************************************************************
67 * PathAppend [SHELL32.36]
69 BOOL WINAPI PathAppendAW(
70 LPVOID lpszPath1,
71 LPCVOID lpszPath2)
73 if (SHELL_OsIsUnicode())
74 return PathAppendW(lpszPath1, lpszPath2);
75 return PathAppendA(lpszPath1, lpszPath2);
78 /*************************************************************************
79 * PathCombine [SHELL32.37]
81 LPVOID WINAPI PathCombineAW(
82 LPVOID szDest,
83 LPCVOID lpszDir,
84 LPCVOID lpszFile)
86 if (SHELL_OsIsUnicode())
87 return PathCombineW( szDest, lpszDir, lpszFile );
88 return PathCombineA( szDest, lpszDir, lpszFile );
91 /*************************************************************************
92 * PathAddBackslash [SHELL32.32]
94 LPVOID WINAPI PathAddBackslashAW(LPVOID lpszPath)
96 if(SHELL_OsIsUnicode())
97 return PathAddBackslashW(lpszPath);
98 return PathAddBackslashA(lpszPath);
101 /*************************************************************************
102 * PathBuildRoot [SHELL32.30]
104 LPVOID WINAPI PathBuildRootAW(LPVOID lpszPath, int drive)
106 if(SHELL_OsIsUnicode())
107 return PathBuildRootW(lpszPath, drive);
108 return PathBuildRootA(lpszPath, drive);
112 Extracting Component Parts
115 /*************************************************************************
116 * PathFindFileName [SHELL32.34]
118 LPVOID WINAPI PathFindFileNameAW(LPCVOID lpszPath)
120 if(SHELL_OsIsUnicode())
121 return PathFindFileNameW(lpszPath);
122 return PathFindFileNameA(lpszPath);
125 /*************************************************************************
126 * PathFindExtension [SHELL32.31]
128 LPVOID WINAPI PathFindExtensionAW(LPCVOID lpszPath)
130 if (SHELL_OsIsUnicode())
131 return PathFindExtensionW(lpszPath);
132 return PathFindExtensionA(lpszPath);
136 /*************************************************************************
137 * PathGetExtensionA [internal]
139 * NOTES
140 * exported by ordinal
141 * return value points to the first char after the dot
143 static LPSTR PathGetExtensionA(LPCSTR lpszPath)
145 TRACE("(%s)\n",lpszPath);
147 lpszPath = PathFindExtensionA(lpszPath);
148 return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath);
151 /*************************************************************************
152 * PathGetExtensionW [internal]
154 static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
156 TRACE("(%s)\n",debugstr_w(lpszPath));
158 lpszPath = PathFindExtensionW(lpszPath);
159 return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath);
162 /*************************************************************************
163 * PathGetExtension [SHELL32.158]
165 LPVOID WINAPI PathGetExtensionAW(LPCVOID lpszPath,DWORD void1, DWORD void2)
167 if (SHELL_OsIsUnicode())
168 return PathGetExtensionW(lpszPath);
169 return PathGetExtensionA(lpszPath);
172 /*************************************************************************
173 * PathGetArgs [SHELL32.52]
175 LPVOID WINAPI PathGetArgsAW(LPVOID lpszPath)
177 if (SHELL_OsIsUnicode())
178 return PathGetArgsW(lpszPath);
179 return PathGetArgsA(lpszPath);
182 /*************************************************************************
183 * PathGetDriveNumber [SHELL32.57]
185 int WINAPI PathGetDriveNumberAW(LPVOID lpszPath)
187 if (SHELL_OsIsUnicode())
188 return PathGetDriveNumberW(lpszPath);
189 return PathGetDriveNumberA(lpszPath);
192 /*************************************************************************
193 * PathRemoveFileSpec [SHELL32.35]
195 BOOL WINAPI PathRemoveFileSpecAW(LPVOID lpszPath)
197 if (SHELL_OsIsUnicode())
198 return PathRemoveFileSpecW(lpszPath);
199 return PathRemoveFileSpecA(lpszPath);
202 /*************************************************************************
203 * PathStripPath [SHELL32.38]
205 void WINAPI PathStripPathAW(LPVOID lpszPath)
207 if (SHELL_OsIsUnicode())
208 PathStripPathW(lpszPath);
209 else
210 PathStripPathA(lpszPath);
213 /*************************************************************************
214 * PathStripToRoot [SHELL32.50]
216 BOOL WINAPI PathStripToRootAW(LPVOID lpszPath)
218 if (SHELL_OsIsUnicode())
219 return PathStripToRootW(lpszPath);
220 return PathStripToRootA(lpszPath);
223 /*************************************************************************
224 * PathRemoveArgs [SHELL32.251]
226 void WINAPI PathRemoveArgsAW(LPVOID lpszPath)
228 if (SHELL_OsIsUnicode())
229 PathRemoveArgsW(lpszPath);
230 else
231 PathRemoveArgsA(lpszPath);
234 /*************************************************************************
235 * PathRemoveExtension [SHELL32.250]
237 void WINAPI PathRemoveExtensionAW(LPVOID lpszPath)
239 if (SHELL_OsIsUnicode())
240 PathRemoveExtensionW(lpszPath);
241 else
242 PathRemoveExtensionA(lpszPath);
247 Path Manipulations
250 /*************************************************************************
251 * PathGetShortPathA [internal]
253 static void PathGetShortPathA(LPSTR pszPath)
255 CHAR path[MAX_PATH];
257 TRACE("%s\n", pszPath);
259 if (GetShortPathNameA(pszPath, path, MAX_PATH))
261 lstrcpyA(pszPath, path);
265 /*************************************************************************
266 * PathGetShortPathW [internal]
268 static void PathGetShortPathW(LPWSTR pszPath)
270 WCHAR path[MAX_PATH];
272 TRACE("%s\n", debugstr_w(pszPath));
274 if (GetShortPathNameW(pszPath, path, MAX_PATH))
276 lstrcpyW(pszPath, path);
280 /*************************************************************************
281 * PathGetShortPath [SHELL32.92]
283 VOID WINAPI PathGetShortPathAW(LPVOID pszPath)
285 if(SHELL_OsIsUnicode())
286 PathGetShortPathW(pszPath);
287 PathGetShortPathA(pszPath);
290 /*************************************************************************
291 * PathRemoveBlanks [SHELL32.33]
293 void WINAPI PathRemoveBlanksAW(LPVOID str)
295 if(SHELL_OsIsUnicode())
296 PathRemoveBlanksW(str);
297 else
298 PathRemoveBlanksA(str);
301 /*************************************************************************
302 * PathQuoteSpaces [SHELL32.55]
304 VOID WINAPI PathQuoteSpacesAW (LPVOID lpszPath)
306 if(SHELL_OsIsUnicode())
307 PathQuoteSpacesW(lpszPath);
308 else
309 PathQuoteSpacesA(lpszPath);
312 /*************************************************************************
313 * PathUnquoteSpaces [SHELL32.56]
315 VOID WINAPI PathUnquoteSpacesAW(LPVOID str)
317 if(SHELL_OsIsUnicode())
318 PathUnquoteSpacesW(str);
319 else
320 PathUnquoteSpacesA(str);
323 /*************************************************************************
324 * PathParseIconLocation [SHELL32.249]
326 int WINAPI PathParseIconLocationAW (LPVOID lpszPath)
328 if(SHELL_OsIsUnicode())
329 return PathParseIconLocationW(lpszPath);
330 return PathParseIconLocationA(lpszPath);
334 ########## Path Testing ##########
336 /*************************************************************************
337 * PathIsUNC [SHELL32.39]
339 BOOL WINAPI PathIsUNCAW (LPCVOID lpszPath)
341 if (SHELL_OsIsUnicode())
342 return PathIsUNCW( lpszPath );
343 return PathIsUNCA( lpszPath );
346 /*************************************************************************
347 * PathIsRelative [SHELL32.40]
349 BOOL WINAPI PathIsRelativeAW (LPCVOID lpszPath)
351 if (SHELL_OsIsUnicode())
352 return PathIsRelativeW( lpszPath );
353 return PathIsRelativeA( lpszPath );
356 /*************************************************************************
357 * PathIsRoot [SHELL32.29]
359 BOOL WINAPI PathIsRootAW(LPCVOID lpszPath)
361 if (SHELL_OsIsUnicode())
362 return PathIsRootW(lpszPath);
363 return PathIsRootA(lpszPath);
366 /*************************************************************************
367 * PathIsExeA [internal]
369 static BOOL PathIsExeA (LPCSTR lpszPath)
371 LPCSTR lpszExtension = PathGetExtensionA(lpszPath);
372 int i;
373 static const char * const lpszExtensions[] =
374 {"exe", "com", "pif", "cmd", "bat", "scf", "scr", NULL };
376 TRACE("path=%s\n",lpszPath);
378 for(i=0; lpszExtensions[i]; i++)
379 if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE;
381 return FALSE;
384 /*************************************************************************
385 * PathIsExeW [internal]
387 static BOOL PathIsExeW (LPCWSTR lpszPath)
389 LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
390 int i;
391 static const WCHAR lpszExtensions[][4] =
392 {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','f','\0'},
393 {'c','m','d','\0'}, {'b','a','t','\0'}, {'s','c','f','\0'},
394 {'s','c','r','\0'}, {'\0'} };
396 TRACE("path=%s\n",debugstr_w(lpszPath));
398 for(i=0; lpszExtensions[i][0]; i++)
399 if (!strcmpiW(lpszExtension,lpszExtensions[i])) return TRUE;
401 return FALSE;
404 /*************************************************************************
405 * PathIsExe [SHELL32.43]
407 BOOL WINAPI PathIsExeAW (LPCVOID path)
409 if (SHELL_OsIsUnicode())
410 return PathIsExeW (path);
411 return PathIsExeA(path);
414 /*************************************************************************
415 * PathIsDirectory [SHELL32.159]
417 BOOL WINAPI PathIsDirectoryAW (LPCVOID lpszPath)
419 if (SHELL_OsIsUnicode())
420 return PathIsDirectoryW (lpszPath);
421 return PathIsDirectoryA (lpszPath);
424 /*************************************************************************
425 * PathFileExists [SHELL32.45]
427 BOOL WINAPI PathFileExistsAW (LPCVOID lpszPath)
429 if (SHELL_OsIsUnicode())
430 return PathFileExistsW (lpszPath);
431 return PathFileExistsA (lpszPath);
434 /*************************************************************************
435 * PathMatchSpec [SHELL32.46]
437 BOOL WINAPI PathMatchSpecAW(LPVOID name, LPVOID mask)
439 if (SHELL_OsIsUnicode())
440 return PathMatchSpecW( name, mask );
441 return PathMatchSpecA( name, mask );
444 /*************************************************************************
445 * PathIsSameRoot [SHELL32.650]
447 BOOL WINAPI PathIsSameRootAW(LPCVOID lpszPath1, LPCVOID lpszPath2)
449 if (SHELL_OsIsUnicode())
450 return PathIsSameRootW(lpszPath1, lpszPath2);
451 return PathIsSameRootA(lpszPath1, lpszPath2);
454 /*************************************************************************
455 * IsLFNDriveA [SHELL32.41]
457 BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath)
459 DWORD fnlen;
461 if (!GetVolumeInformationA(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
462 return FALSE;
463 return fnlen > 12;
466 /*************************************************************************
467 * IsLFNDriveW [SHELL32.42]
469 BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
471 DWORD fnlen;
473 if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
474 return FALSE;
475 return fnlen > 12;
478 /*************************************************************************
479 * IsLFNDrive [SHELL32.119]
481 BOOL WINAPI IsLFNDriveAW(LPCVOID lpszPath)
483 if (SHELL_OsIsUnicode())
484 return IsLFNDriveW(lpszPath);
485 return IsLFNDriveA(lpszPath);
489 ########## Creating Something Unique ##########
491 /*************************************************************************
492 * PathMakeUniqueNameA [internal]
494 static BOOL PathMakeUniqueNameA(
495 LPSTR lpszBuffer,
496 DWORD dwBuffSize,
497 LPCSTR lpszShortName,
498 LPCSTR lpszLongName,
499 LPCSTR lpszPathName)
501 FIXME("%p %u %s %s %s stub\n",
502 lpszBuffer, dwBuffSize, debugstr_a(lpszShortName),
503 debugstr_a(lpszLongName), debugstr_a(lpszPathName));
504 return TRUE;
507 /*************************************************************************
508 * PathMakeUniqueNameW [internal]
510 static BOOL PathMakeUniqueNameW(
511 LPWSTR lpszBuffer,
512 DWORD dwBuffSize,
513 LPCWSTR lpszShortName,
514 LPCWSTR lpszLongName,
515 LPCWSTR lpszPathName)
517 FIXME("%p %u %s %s %s stub\n",
518 lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
519 debugstr_w(lpszLongName), debugstr_w(lpszPathName));
520 return TRUE;
523 /*************************************************************************
524 * PathMakeUniqueName [SHELL32.47]
526 BOOL WINAPI PathMakeUniqueNameAW(
527 LPVOID lpszBuffer,
528 DWORD dwBuffSize,
529 LPCVOID lpszShortName,
530 LPCVOID lpszLongName,
531 LPCVOID lpszPathName)
533 if (SHELL_OsIsUnicode())
534 return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
535 return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
538 /*************************************************************************
539 * PathYetAnotherMakeUniqueName [SHELL32.75]
541 BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
543 WCHAR pathW[MAX_PATH], retW[MAX_PATH];
544 const WCHAR *file, *ext;
545 int i = 2;
547 TRACE("(%p, %s, %s, %s)\n", buffer, debugstr_w(path), debugstr_w(shortname), debugstr_w(longname));
549 file = longname ? longname : shortname;
550 PathCombineW(pathW, path, file);
551 strcpyW(retW, pathW);
552 PathRemoveExtensionW(pathW);
554 ext = PathFindExtensionW(file);
556 /* now try to make it unique */
557 while (PathFileExistsW(retW))
559 static const WCHAR fmtW[] = {'%','s',' ','(','%','d',')','%','s',0};
561 sprintfW(retW, fmtW, pathW, i, ext);
562 i++;
565 strcpyW(buffer, retW);
566 TRACE("ret - %s\n", debugstr_w(buffer));
568 return TRUE;
572 ########## cleaning and resolving paths ##########
575 /*************************************************************************
576 * PathFindOnPath [SHELL32.145]
578 BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID *sOtherDirs)
580 if (SHELL_OsIsUnicode())
581 return PathFindOnPathW(sFile, (LPCWSTR *)sOtherDirs);
582 return PathFindOnPathA(sFile, (LPCSTR *)sOtherDirs);
585 /*************************************************************************
586 * PathCleanupSpec [SHELL32.171]
588 * lpszFile is changed in place.
590 int WINAPI PathCleanupSpec( LPCWSTR lpszPathW, LPWSTR lpszFileW )
592 int i = 0;
593 DWORD rc = 0;
594 int length = 0;
596 if (SHELL_OsIsUnicode())
598 LPWSTR p = lpszFileW;
600 TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
602 if (lpszPathW)
603 length = strlenW(lpszPathW);
605 while (*p)
607 int gct = PathGetCharTypeW(*p);
608 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
610 lpszFileW[i]='-';
611 rc |= PCS_REPLACEDCHAR;
613 else
614 lpszFileW[i]=*p;
615 i++;
616 p++;
617 if (length + i == MAX_PATH)
619 rc |= PCS_FATAL | PCS_PATHTOOLONG;
620 break;
623 lpszFileW[i]=0;
625 else
627 LPSTR lpszFileA = (LPSTR)lpszFileW;
628 LPCSTR lpszPathA = (LPCSTR)lpszPathW;
629 LPSTR p = lpszFileA;
631 TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
633 if (lpszPathA)
634 length = strlen(lpszPathA);
636 while (*p)
638 int gct = PathGetCharTypeA(*p);
639 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
641 lpszFileA[i]='-';
642 rc |= PCS_REPLACEDCHAR;
644 else
645 lpszFileA[i]=*p;
646 i++;
647 p++;
648 if (length + i == MAX_PATH)
650 rc |= PCS_FATAL | PCS_PATHTOOLONG;
651 break;
654 lpszFileA[i]=0;
656 return rc;
659 /*************************************************************************
660 * PathQualifyA [SHELL32]
662 static BOOL PathQualifyA(LPCSTR pszPath)
664 FIXME("%s\n",pszPath);
665 return FALSE;
668 /*************************************************************************
669 * PathQualifyW [SHELL32]
671 static BOOL PathQualifyW(LPCWSTR pszPath)
673 FIXME("%s\n",debugstr_w(pszPath));
674 return FALSE;
677 /*************************************************************************
678 * PathQualify [SHELL32.49]
680 BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
682 if (SHELL_OsIsUnicode())
683 return PathQualifyW(pszPath);
684 return PathQualifyA(pszPath);
687 static BOOL PathResolveA(LPSTR path, LPCSTR *paths, DWORD flags)
689 FIXME("(%s,%p,0x%08x),stub!\n", debugstr_a(path), paths, flags);
690 return FALSE;
693 static BOOL PathResolveW(LPWSTR path, LPCWSTR *paths, DWORD flags)
695 FIXME("(%s,%p,0x%08x),stub!\n", debugstr_w(path), paths, flags);
696 return FALSE;
699 /*************************************************************************
700 * PathResolve [SHELL32.51]
702 BOOL WINAPI PathResolveAW(LPVOID path, LPCVOID *paths, DWORD flags)
704 if (SHELL_OsIsUnicode())
705 return PathResolveW(path, (LPCWSTR*)paths, flags);
706 else
707 return PathResolveA(path, (LPCSTR*)paths, flags);
710 /*************************************************************************
711 * PathProcessCommandA
713 static LONG PathProcessCommandA (
714 LPCSTR lpszPath,
715 LPSTR lpszBuff,
716 DWORD dwBuffSize,
717 DWORD dwFlags)
719 FIXME("%s %p 0x%04x 0x%04x stub\n",
720 lpszPath, lpszBuff, dwBuffSize, dwFlags);
721 if(!lpszPath) return -1;
722 if(lpszBuff) strcpy(lpszBuff, lpszPath);
723 return strlen(lpszPath);
726 /*************************************************************************
727 * PathProcessCommandW
729 static LONG PathProcessCommandW (
730 LPCWSTR lpszPath,
731 LPWSTR lpszBuff,
732 DWORD dwBuffSize,
733 DWORD dwFlags)
735 FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
736 debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
737 if(!lpszPath) return -1;
738 if(lpszBuff) strcpyW(lpszBuff, lpszPath);
739 return strlenW(lpszPath);
742 /*************************************************************************
743 * PathProcessCommand (SHELL32.653)
745 LONG WINAPI PathProcessCommandAW (
746 LPCVOID lpszPath,
747 LPVOID lpszBuff,
748 DWORD dwBuffSize,
749 DWORD dwFlags)
751 if (SHELL_OsIsUnicode())
752 return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
753 return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
757 ########## special ##########
760 /*************************************************************************
761 * PathSetDlgItemPath (SHELL32.48)
763 VOID WINAPI PathSetDlgItemPathAW(HWND hDlg, int id, LPCVOID pszPath)
765 if (SHELL_OsIsUnicode())
766 PathSetDlgItemPathW(hDlg, id, pszPath);
767 else
768 PathSetDlgItemPathA(hDlg, id, pszPath);
771 static const WCHAR szCategory[] = {'C','a','t','e','g','o','r','y',0};
772 static const WCHAR szAttributes[] = {'A','t','t','r','i','b','u','t','e','s',0};
773 static const WCHAR szName[] = {'N','a','m','e',0};
774 static const WCHAR szParsingName[] = {'P','a','r','s','i','n','g','N','a','m','e',0};
775 static const WCHAR szRelativePath[] = {'R','e','l','a','t','i','v','e','P','a','t','h',0};
776 static const WCHAR szParentFolder[] = {'P','a','r','e','n','t','F','o','l','d','e','r',0};
778 static const WCHAR szCurrentVersion[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0'};
779 static const WCHAR AddNewProgramsFolderW[] = {'A','d','d','N','e','w','P','r','o','g','r','a','m','s','F','o','l','d','e','r',0};
780 static const WCHAR AppUpdatesFolderW[] = {'A','p','p','U','p','d','a','t','e','s','F','o','l','d','e','r',0};
781 static const WCHAR Administrative_ToolsW[] = {'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
782 static const WCHAR AppDataW[] = {'A','p','p','D','a','t','a','\0'};
783 static const WCHAR AppData_RoamingW[] = {'A','p','p','D','a','t','a','\\','R','o','a','m','i','n','g','\0'};
784 static const WCHAR AppData_LocalLowW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','L','o','w','\0'};
785 static const WCHAR AppData_LocalW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','\0'};
786 static const WCHAR Application_DataW[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
787 static const WCHAR CacheW[] = {'C','a','c','h','e','\0'};
788 static const WCHAR CD_BurningW[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
789 static const WCHAR ChangeRemoveProgramsFolderW[] = {'C','h','a','n','g','e','R','e','m','o','v','e','P','r','o','g','r','a','m','s','F','o','l','d','e','r',0};
790 static const WCHAR CommonW[] = {'C','o','m','m','o','n',0};
791 static const WCHAR Common_Administrative_ToolsW[] = {'C','o','m','m','o','n',' ','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
792 static const WCHAR Common_AppDataW[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'};
793 static const WCHAR Common_DesktopW[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'};
794 static const WCHAR Common_DocumentsW[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'};
795 static const WCHAR CommonDownloadsW[] = {'C','o','m','m','o','n','D','o','w','n','l','o','a','d','s',0};
796 static const WCHAR Common_FavoritesW[] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'};
797 static const WCHAR CommonFilesDirW[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'};
798 static const WCHAR CommonFilesDirX86W[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
799 static const WCHAR CommonMusicW[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'};
800 static const WCHAR CommonPicturesW[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'};
801 static const WCHAR Common_ProgramsW[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'};
802 static const WCHAR CommonRingtonesW[] = {'C','o','m','m','o','n','R','i','n','g','t','o','n','e','s',0};
803 static const WCHAR Common_StartUpW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'};
804 static const WCHAR Common_StartupW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','u','p','\0'};
805 static const WCHAR Common_Start_MenuW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'};
806 static const WCHAR Common_TemplatesW[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'};
807 static const WCHAR CommonVideoW[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
808 static const WCHAR ConflictFolderW[] = {'C','o','n','f','l','i','c','t','F','o','l','d','e','r',0};
809 static const WCHAR ConnectionsFolderW[] = {'C','o','n','n','e','c','t','i','o','n','s','F','o','l','d','e','r',0};
810 static const WCHAR ContactsW[] = {'C','o','n','t','a','c','t','s','\0'};
811 static const WCHAR ControlPanelFolderW[] = {'C','o','n','t','r','o','l','P','a','n','e','l','F','o','l','d','e','r',0};
812 static const WCHAR CookiesW[] = {'C','o','o','k','i','e','s','\0'};
813 static const WCHAR CSCFolderW[] = {'C','S','C','F','o','l','d','e','r',0};
814 static const WCHAR Default_GadgetsW[] = {'D','e','f','a','u','l','t',' ','G','a','d','g','e','t','s',0};
815 static const WCHAR DesktopW[] = {'D','e','s','k','t','o','p','\0'};
816 static const WCHAR Device_Metadata_StoreW[] = {'D','e','v','i','c','e',' ','M','e','t','a','d','a','t','a',' ','S','t','o','r','e',0};
817 static const WCHAR DocumentsW[] = {'D','o','c','u','m','e','n','t','s','\0'};
818 static const WCHAR DocumentsLibraryW[] = {'D','o','c','u','m','e','n','t','s','L','i','b','r','a','r','y','\0'};
819 static const WCHAR Documents_librarymsW[] = {'D','o','c','u','m','e','n','t','s','.','l','i','b','r','a','r','y','-','m','s',0};
820 static const WCHAR DownloadsW[] = {'D','o','w','n','l','o','a','d','s','\0'};
821 static const WCHAR FavoritesW[] = {'F','a','v','o','r','i','t','e','s','\0'};
822 static const WCHAR FontsW[] = {'F','o','n','t','s','\0'};
823 static const WCHAR GadgetsW[] = {'G','a','d','g','e','t','s',0};
824 static const WCHAR GamesW[] = {'G','a','m','e','s',0};
825 static const WCHAR GameTasksW[] = {'G','a','m','e','T','a','s','k','s',0};
826 static const WCHAR HistoryW[] = {'H','i','s','t','o','r','y','\0'};
827 static const WCHAR HomeGroupFolderW[] = {'H','o','m','e','G','r','o','u','p','F','o','l','d','e','r',0};
828 static const WCHAR ImplicitAppShortcutsW[] = {'I','m','p','l','i','c','i','t','A','p','p','S','h','o','r','t','c','u','t','s',0};
829 static const WCHAR InternetFolderW[] = {'I','n','t','e','r','n','e','t','F','o','l','d','e','r',0};
830 static const WCHAR LibrariesW[] = {'L','i','b','r','a','r','i','e','s',0};
831 static const WCHAR LinksW[] = {'L','i','n','k','s','\0'};
832 static const WCHAR Local_AppDataW[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
833 static const WCHAR Local_Settings_Application_DataW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
834 static const WCHAR Local_Settings_CD_BurningW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\\','M','i','c','r','o','s','o','f','t','\\','C','D',' ','B','u','r','n','i','n','g','\0'};
835 static const WCHAR Local_Settings_HistoryW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','H','i','s','t','o','r','y','\0'};
836 static const WCHAR Local_Settings_Temporary_Internet_FilesW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s','\0'};
837 static const WCHAR LocalAppDataLowW[] = {'L','o','c','a','l','A','p','p','D','a','t','a','L','o','w',0};
838 static const WCHAR LocalizedResourcesDirW[] = {'L','o','c','a','l','i','z','e','d','R','e','s','o','u','r','c','e','s','D','i','r',0};
839 static const WCHAR MAPIFolderW[] = {'M','A','P','I','F','o','l','d','e','r',0};
840 static const WCHAR Microsoft_Internet_Explorer_Quick_LaunchW[] = {'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\','Q','u','i','c','k',' ','L','a','u','n','c','h',0};
841 static const WCHAR Microsoft_Windows_Burn_BurnW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','B','u','r','n','\\','B','u','r','n',0};
842 static const WCHAR Microsoft_Windows_CookiesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','o','o','k','i','e','s',0};
843 static const WCHAR Microsoft_Windows_GameExplorerW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','G','a','m','e','E','x','p','l','o','r','e','r','\0'};
844 static const WCHAR Microsoft_Windows_DeviceMetadataStoreW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','D','e','v','i','c','e','M','e','t','a','d','a','t','a','S','t','o','r','e',0};
845 static const WCHAR Microsoft_Windows_HistoryW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','H','i','s','t','o','r','y',0};
846 static const WCHAR Microsoft_Windows_LibrariesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','L','i','b','r','a','r','i','e','s','\0'};
847 static const WCHAR Microsoft_Windows_Network_ShortcutsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','N','e','t','w','o','r','k',' ','S','h','o','r','t','c','u','t','s',0};
848 static const WCHAR Microsoft_Windows_Photo_Gallery_Original_ImagesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','P','h','o','t','o',' ','G','a','l','l','e','r','y','\\','O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
849 static const WCHAR Microsoft_Windows_Printer_ShortcutsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','P','r','i','n','t','e','r',' ','S','h','o','r','t','c','u','t','s',0};
850 static const WCHAR Microsoft_Windows_RecentW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','R','e','c','e','n','t','\0'};
851 static const WCHAR Microsoft_Windows_RingtonesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','R','i','n','g','t','o','n','e','s','\0'};
852 static const WCHAR Microsoft_Windows_SendToW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','e','n','d','T','o',0};
853 static const WCHAR Microsoft_Windows_Sidebar_GadgetsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','S','i','d','e','b','a','r','\\','G','a','d','g','e','t','s',0};
854 static const WCHAR Microsoft_Windows_Start_MenuW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u',0};
855 static const WCHAR Microsoft_Windows_Start_Menu_ProgramsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
856 static const WCHAR Microsoft_Windows_Start_Menu_Admin_ToolsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
857 static const WCHAR Microsoft_Windows_Start_Menu_StartupW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
858 static const WCHAR Microsoft_Windows_TemplatesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','l','a','t','e','s',0};
859 static const WCHAR Microsoft_Windows_Temporary_Internet_FilesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s',0};
860 static const WCHAR Microsoft_Windows_ThemesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','h','e','m','e','s',0};
861 static const WCHAR MoviesW[] = {'M','o','v','i','e','s','\0'};
862 static const WCHAR MusicW[] = {'M','u','s','i','c','\0'};
863 static const WCHAR MusicLibraryW[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
864 static const WCHAR Music_librarymsW[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
865 static const WCHAR Music_PlaylistsW[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
866 static const WCHAR Music_Sample_MusicW[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
867 static const WCHAR Music_Sample_PlaylistsW[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s','\0'};
868 static const WCHAR My_MusicW[] = {'M','y',' ','M','u','s','i','c','\0'};
869 static const WCHAR My_PicturesW[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
870 static const WCHAR My_VideosW[] = {'M','y',' ','V','i','d','e','o','s','\0'};
871 static const WCHAR My_VideoW[] = {'M','y',' ','V','i','d','e','o','\0'};
872 static const WCHAR MyComputerFolderW[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
873 static const WCHAR NetHoodW[] = {'N','e','t','H','o','o','d','\0'};
874 static const WCHAR NetworkPlacesFolderW[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
875 static const WCHAR OEM_LinksW[] = {'O','E','M',' ','L','i','n','k','s','\0'};
876 static const WCHAR Original_ImagesW[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
877 static const WCHAR PersonalW[] = {'P','e','r','s','o','n','a','l','\0'};
878 static const WCHAR PhotoAlbumsW[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
879 static const WCHAR PicturesW[] = {'P','i','c','t','u','r','e','s','\0'};
880 static const WCHAR PicturesLibraryW[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
881 static const WCHAR Pictures_librarymsW[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
882 static const WCHAR Pictures_Sample_PicturesW[] = {'P','i','c','t','u','r','e','s','\\','S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s','\0'};
883 static const WCHAR Pictures_Slide_ShowsW[] = {'P','i','c','t','u','r','e','s','\\','S','l','i','d','e',' ','S','h','o','w','s','\0'};
884 static const WCHAR PlaylistsW[] = {'P','l','a','y','l','i','s','t','s',0};
885 static const WCHAR PrintersFolderW[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
886 static const WCHAR PrintHoodW[] = {'P','r','i','n','t','H','o','o','d','\0'};
887 static const WCHAR ProfileW[] = {'P','r','o','f','i','l','e',0};
888 static const WCHAR ProgramDataW[] = {'P','r','o','g','r','a','m','D','a','t','a','\0'};
889 static const WCHAR Program_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
890 static const WCHAR ProgramFilesW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
891 static const WCHAR ProgramFilesX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
892 static const WCHAR ProgramFilesX64W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
893 static const WCHAR Program_Files_Common_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
894 static const WCHAR Program_Files_x86W[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
895 static const WCHAR Program_Files_x86_Common_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
896 static const WCHAR ProgramFilesCommonW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
897 static const WCHAR ProgramFilesCommonX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','8','6',0};
898 static const WCHAR ProgramFilesCommonX64W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','6','4',0};
899 static const WCHAR ProgramFilesDirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
900 static const WCHAR ProgramFilesDirX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
901 static const WCHAR ProgramsW[] = {'P','r','o','g','r','a','m','s','\0'};
902 static const WCHAR PublicW[] = {'P','u','b','l','i','c',0};
903 static const WCHAR PublicGameTasksW[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
904 static const WCHAR PublicLibrariesW[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
905 static const WCHAR Quick_LaunchW[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
906 static const WCHAR RecentW[] = {'R','e','c','e','n','t','\0'};
907 static const WCHAR RecordedTVLibraryW[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
908 static const WCHAR RecordedTV_librarymsW[] = {'R','e','c','o','r','d','e','d','T','V','.','l','i','b','r','a','r','y','-','m','s',0};
909 static const WCHAR RecycleBinFolderW[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
910 static const WCHAR ResourceDirW[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
911 static const WCHAR ResourcesW[] = {'R','e','s','o','u','r','c','e','s','\0'};
912 static const WCHAR RingtonesW[] = {'R','i','n','g','t','o','n','e','s',0};
913 static const WCHAR SampleMusicW[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
914 static const WCHAR Sample_MusicW[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
915 static const WCHAR SamplePicturesW[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
916 static const WCHAR Sample_PicturesW[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
917 static const WCHAR SamplePlaylistsW[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
918 static const WCHAR Sample_PlaylistsW[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
919 static const WCHAR Sample_VideosW[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
920 static const WCHAR SampleVideosW[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
921 static const WCHAR Saved_GamesW[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
922 static const WCHAR SavedGamesW[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
923 static const WCHAR SearchesW[] = {'S','e','a','r','c','h','e','s','\0'};
924 static const WCHAR SearchHomeFolderW[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
925 static const WCHAR SendToW[] = {'S','e','n','d','T','o','\0'};
926 static const WCHAR Slide_ShowsW[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
927 static const WCHAR StartUpW[] = {'S','t','a','r','t','U','p','\0'};
928 static const WCHAR StartupW[] = {'S','t','a','r','t','u','p','\0'};
929 static const WCHAR Start_MenuW[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
930 static const WCHAR Start_Menu_ProgramsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
931 static const WCHAR Start_Menu_Admin_ToolsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
932 static const WCHAR Start_Menu_StartupW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
933 static const WCHAR SyncCenterFolderW[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
934 static const WCHAR SyncResultsFolderW[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
935 static const WCHAR SyncSetupFolderW[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
936 static const WCHAR SystemW[] = {'S','y','s','t','e','m',0};
937 static const WCHAR SystemX86W[] = {'S','y','s','t','e','m','X','8','6',0};
938 static const WCHAR TemplatesW[] = {'T','e','m','p','l','a','t','e','s','\0'};
939 static const WCHAR User_PinnedW[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
940 static const WCHAR UsersW[] = {'U','s','e','r','s','\0'};
941 static const WCHAR UsersFilesFolderW[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
942 static const WCHAR UsersLibrariesFolderW[] = {'U','s','e','r','s','L','i','b','r','a','r','i','e','s','F','o','l','d','e','r',0};
943 static const WCHAR UserProfilesW[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
944 static const WCHAR UserProgramFilesW[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
945 static const WCHAR UserProgramFilesCommonW[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
946 static const WCHAR UsersPublicW[] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'};
947 static const WCHAR VideosW[] = {'V','i','d','e','o','s','\0'};
948 static const WCHAR VideosLibraryW[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
949 static const WCHAR Videos_librarymsW[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
950 static const WCHAR Videos_Sample_VideosW[] = {'V','i','d','e','o','s','\\','S','a','m','p','l','e',' ','V','i','d','e','o','s','\0'};
951 static const WCHAR WindowsW[] = {'W','i','n','d','o','w','s',0};
952 static const WCHAR Windows_Sidebar_GadgetsW[] = {'W','i','n','d','o','w','s',' ','S','i','d','e','b','a','r','\\','G','a','d','g','e','t','s',0};
953 static const WCHAR DefaultW[] = {'.','D','e','f','a','u','l','t','\0'};
954 static const WCHAR AllUsersProfileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
955 static const WCHAR UserProfileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
956 static const WCHAR ProgramDataVarW[] = {'%','P','r','o','g','r','a','m','D','a','t','a','%','\0'};
957 static const WCHAR SystemDriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
958 static const WCHAR ProfileListW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0};
959 static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
960 static const WCHAR AllUsersProfileValueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
961 static const WCHAR szSHFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
962 static const WCHAR szSHUserFolders[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
963 static const WCHAR szDefaultProfileDirW[] = {'u','s','e','r','s',0};
964 static const WCHAR szKnownFolderDescriptions[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','F','o','l','d','e','r','D','e','s','c','r','i','p','t','i','o','n','s','\0'};
965 static const WCHAR szKnownFolderRedirections[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s',0};
966 static const WCHAR AllUsersW[] = {'P','u','b','l','i','c',0};
968 #define CHANGEREMOVEPROGRAMS_PARSING_GUID '{','7','b','8','1','b','e','6','a','-','c','e','2','b','-','4','6','7','6','-','a','2','9','e','-','e','b','9','0','7','a','5','1','2','6','c','5','}'
969 #define SYNCMANAGER_PARSING_GUID '{','9','C','7','3','F','5','E','5','-','7','A','E','7','-','4','E','3','2','-','A','8','E','8','-','8','D','2','3','B','8','5','2','5','5','B','F','}'
970 #define SYSTEMFOLDERS_PARSING_GUID '{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}'
971 #define USERFOLDERS_PARSING_GUID '{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}'
972 #define USERSLIBRARIES_PARSING_GUID '{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}'
974 static const WCHAR ComputerFolderParsingNameW[] = {':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
975 static const WCHAR ControlPanelFolderParsingNameW[] = {':',':','{','2','6','E','E','0','6','6','8','-','A','0','0','A','-','4','4','D','7','-','9','3','7','1','-','B','E','B','0','6','4','C','9','8','6','8','3','}','\\','0',0};
976 static const WCHAR ControlPanelFolderRelativePathW[] = {':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
977 static const WCHAR GamesParsingNameW[] = {':',':','{','E','D','2','2','8','F','D','F','-','9','E','A','8','-','4','8','7','0','-','8','3','b','1','-','9','6','b','0','2','C','F','E','0','D','5','2','}',0};
978 static const WCHAR HomeGroupParsingNameW[] = {':',':','{','B','4','F','B','3','F','9','8','-','C','1','E','A','-','4','2','8','d','-','A','7','8','A','-','D','1','F','5','6','5','9','C','B','A','9','3','}',0};
979 static const WCHAR InternetFolderParsingNameW[] = {':',':','{','8','7','1','C','5','3','8','0','-','4','2','A','0','-','1','0','6','9','-','A','2','E','A','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
980 static const WCHAR NetworkFolderParsingNameW[] = {':',':','{','F','0','2','C','1','A','0','D','-','B','E','2','1','-','4','3','5','0','-','8','8','B','0','-','7','3','6','7','F','C','9','6','E','F','3','C','}',0};
981 static const WCHAR PublicParsingNameW[] = {':',':','{','4','3','3','6','a','5','4','d','-','0','3','8','b','-','4','6','8','5','-','a','b','0','2','-','9','9','b','b','5','2','d','3','f','b','8','b','}',0};
982 static const WCHAR RecycleBinFolderParsingNameW[] = {':',':','{','6','4','5','F','F','0','4','0','-','5','0','8','1','-','1','0','1','B','-','9','F','0','8','-','0','0','A','A','0','0','2','F','9','5','4','E','}',0};
983 static const WCHAR SearchHomeParsingNameW[] = {':',':','{','9','3','4','3','8','1','2','e','-','1','c','3','7','-','4','a','4','9','-','a','1','2','e','-','4','b','2','d','8','1','0','d','9','5','6','b','}',0};
984 static const WCHAR SEARCH_CSCParsingNameW[] = {'s','h','e','l','l',':',':',':','{','B','D','7','A','2','E','7','B','-','2','1','C','B','-','4','1','b','2','-','A','0','8','6','-','B','3','0','9','6','8','0','C','6','B','7','E','}','\\','*',0};
985 static const WCHAR SEARCH_MAPIParsingNameW[] = {'s','h','e','l','l',':',':',':','{','8','9','D','8','3','5','7','6','-','6','B','D','1','-','4','C','8','6','-','9','4','5','4','-','B','E','B','0','4','E','9','4','C','8','1','9','}','\\','*',0};
986 static const WCHAR UsersFilesParsingNameW[] = {':',':','{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}',0};
987 static const WCHAR UsersLibrariesParsingNameW[] = {':',':','{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}',0};
988 static const WCHAR AddNewProgramsParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':','{','1','5','e','a','e','9','2','e','-','f','1','7','a','-','4','4','3','1','-','9','f','2','8','-','8','0','5','e','4','8','2','d','a','f','d','4','}',0};
989 static const WCHAR ConnectionsFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':','{','7','0','0','7','A','C','C','7','-','3','2','0','2','-','1','1','D','1','-','A','A','D','2','-','0','0','8','0','5','F','C','1','2','7','0','E','}',0};
990 static const WCHAR PrintersFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':','{','2','2','2','7','A','2','8','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','E','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
991 static const WCHAR ChangeRemoveProgramsParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID, 0};
992 static const WCHAR AppUpdatesParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID, '\\',':',':','{','d','4','5','0','a','8','a','1','-','9','5','6','8','-','4','5','c','7','-','9','c','0','e','-','b','4','f','9','f','b','4','5','3','7','b','d','}',0};
993 static const WCHAR SyncManagerFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', SYNCMANAGER_PARSING_GUID, 0};
994 static const WCHAR ConflictFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', SYNCMANAGER_PARSING_GUID, '\\',':',':','{','E','4','1','3','D','0','4','0','-','6','7','8','8','-','4','C','2','2','-','9','5','7','E','-','1','7','5','D','1','C','5','1','3','A','3','4','}',',',0};
995 static const WCHAR SyncResultsFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', SYNCMANAGER_PARSING_GUID, '\\',':',':','{','B','C','4','8','B','3','2','F','-','5','9','1','0','-','4','7','F','5','-','8','5','7','0','-','5','0','7','4','A','8','A','5','6','3','6','A','}',',',0};
996 static const WCHAR SyncSetupFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', SYNCMANAGER_PARSING_GUID, '\\',':',':','{','F','1','3','9','0','A','9','A','-','A','3','F','4','-','4','E','5','D','-','9','C','5','F','-','9','8','F','3','B','D','8','D','9','3','5','C','}',',',0};
997 static const WCHAR ContactsParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','5','6','7','8','4','8','5','4','-','C','6','C','B','-','4','6','2','B','-','8','1','6','9','-','8','8','E','3','5','0','A','C','B','8','8','2','}',0};
998 static const WCHAR DocumentsParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','F','D','D','3','9','A','D','0','-','2','3','8','F','-','4','6','A','F','-','A','D','B','4','-','6','C','8','5','4','8','0','3','6','9','C','7','}',0};
999 static const WCHAR LinksParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','b','f','b','9','d','5','e','0','-','c','6','a','9','-','4','0','4','c','-','b','2','b','2','-','a','e','6','d','b','6','a','f','4','9','6','8','}',0};
1000 static const WCHAR MusicParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','4','B','D','8','D','5','7','1','-','6','D','1','9','-','4','8','D','3','-','B','E','9','7','-','4','2','2','2','2','0','0','8','0','E','4','3','}',0};
1001 static const WCHAR PicturesParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','3','3','E','2','8','1','3','0','-','4','E','1','E','-','4','6','7','6','-','8','3','5','A','-','9','8','3','9','5','C','3','B','C','3','B','B','}',0};
1002 static const WCHAR SavedGamesParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','4','C','5','C','3','2','F','F','-','B','B','9','D','-','4','3','b','0','-','B','5','B','4','-','2','D','7','2','E','5','4','E','A','A','A','4','}',0};
1003 static const WCHAR SavedSearchesParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','7','d','1','d','3','a','0','4','-','d','e','b','b','-','4','1','1','5','-','9','5','c','f','-','2','f','2','9','d','a','2','9','2','0','d','a','}',0};
1004 static const WCHAR VideosParsingNameW[] = {':',':', USERFOLDERS_PARSING_GUID, '\\','{','1','8','9','8','9','B','1','D','-','9','9','B','5','-','4','5','5','B','-','8','4','1','C','-','A','B','7','C','7','4','E','4','D','D','F','C','}',0};
1005 static const WCHAR DocumentsLibraryParsingNameW[] = {':',':', USERSLIBRARIES_PARSING_GUID, '\\','{','7','b','0','d','b','1','7','d','-','9','c','d','2','-','4','a','9','3','-','9','7','3','3','-','4','6','c','c','8','9','0','2','2','e','7','c','}',0};
1006 static const WCHAR MusicLibraryParsingNameW[] = {':',':', USERSLIBRARIES_PARSING_GUID, '\\','{','2','1','1','2','A','B','0','A','-','C','8','6','A','-','4','f','f','e','-','A','3','6','8','-','0','D','E','9','6','E','4','7','0','1','2','E','}',0};
1007 static const WCHAR PicturesLibraryParsingNameW[] = {':',':', USERSLIBRARIES_PARSING_GUID, '\\','{','A','9','9','0','A','E','9','F','-','A','0','3','B','-','4','e','8','0','-','9','4','B','C','-','9','9','1','2','D','7','5','0','4','1','0','4','}',0};
1008 static const WCHAR VideosLibraryParsingNameW[] = {':',':', USERSLIBRARIES_PARSING_GUID, '\\','{','4','9','1','E','9','2','2','F','-','5','6','4','3','-','4','a','f','4','-','A','7','E','B','-','4','E','7','A','1','3','8','D','8','1','7','4','}',0};
1010 typedef enum _CSIDL_Type {
1011 CSIDL_Type_User,
1012 CSIDL_Type_AllUsers,
1013 CSIDL_Type_CurrVer,
1014 CSIDL_Type_Disallowed,
1015 CSIDL_Type_NonExistent,
1016 CSIDL_Type_WindowsPath,
1017 CSIDL_Type_SystemPath,
1018 CSIDL_Type_SystemX86Path,
1019 CSIDL_Type_ProgramData,
1020 } CSIDL_Type;
1022 #define CSIDL_CONTACTS 0x0043
1023 #define CSIDL_DOWNLOADS 0x0047
1024 #define CSIDL_LINKS 0x004d
1025 #define CSIDL_APPDATA_LOCALLOW 0x004e
1026 #define CSIDL_SAVED_GAMES 0x0062
1027 #define CSIDL_SEARCHES 0x0063
1029 typedef struct
1031 IApplicationDestinations IApplicationDestinations_iface;
1032 LONG ref;
1033 } IApplicationDestinationsImpl;
1035 static inline IApplicationDestinationsImpl *impl_from_IApplicationDestinations( IApplicationDestinations *iface )
1037 return CONTAINING_RECORD(iface, IApplicationDestinationsImpl, IApplicationDestinations_iface);
1040 static HRESULT WINAPI ApplicationDestinations_QueryInterface(IApplicationDestinations *iface, REFIID riid,
1041 LPVOID *ppv)
1043 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1045 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppv);
1047 if (ppv == NULL)
1048 return E_POINTER;
1050 if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IApplicationDestinations, riid))
1052 *ppv = &This->IApplicationDestinations_iface;
1053 IUnknown_AddRef((IUnknown*)*ppv);
1055 TRACE("Returning IApplicationDestinations: %p\n", *ppv);
1056 return S_OK;
1059 *ppv = NULL;
1060 FIXME("(%p)->(%s, %p) interface not supported.\n", This, debugstr_guid(riid), ppv);
1062 return E_NOINTERFACE;
1065 static ULONG WINAPI ApplicationDestinations_AddRef(IApplicationDestinations *iface)
1067 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1068 ULONG ref = InterlockedIncrement(&This->ref);
1070 TRACE("(%p), new refcount=%i\n", This, ref);
1072 return ref;
1075 static ULONG WINAPI ApplicationDestinations_Release(IApplicationDestinations *iface)
1077 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1078 ULONG ref = InterlockedDecrement(&This->ref);
1080 TRACE("(%p), new refcount=%i\n", This, ref);
1082 if (ref == 0)
1083 heap_free(This);
1085 return ref;
1088 static HRESULT WINAPI ApplicationDestinations_SetAppID(IApplicationDestinations *iface, const WCHAR *appid)
1090 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1092 FIXME("(%p, %s) stub!\n", This, debugstr_w(appid));
1094 return E_NOTIMPL;
1097 static HRESULT WINAPI ApplicationDestinations_RemoveDestination(IApplicationDestinations *iface, IUnknown *punk)
1099 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1101 FIXME("(%p, %p) stub!\n", This, punk);
1103 return E_NOTIMPL;
1106 static HRESULT WINAPI ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations *iface)
1108 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1110 FIXME("(%p) stub!\n", This);
1112 return E_NOTIMPL;
1115 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl =
1117 ApplicationDestinations_QueryInterface,
1118 ApplicationDestinations_AddRef,
1119 ApplicationDestinations_Release,
1120 ApplicationDestinations_SetAppID,
1121 ApplicationDestinations_RemoveDestination,
1122 ApplicationDestinations_RemoveAllDestinations
1125 HRESULT WINAPI ApplicationDestinations_Constructor(IUnknown *outer, REFIID riid, LPVOID *ppv)
1127 IApplicationDestinationsImpl *This;
1128 HRESULT hr;
1130 TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);
1132 if (outer)
1133 return CLASS_E_NOAGGREGATION;
1135 if (!(This = SHAlloc(sizeof(*This))))
1136 return E_OUTOFMEMORY;
1138 This->IApplicationDestinations_iface.lpVtbl = &ApplicationDestinationsVtbl;
1139 This->ref = 0;
1141 hr = IUnknown_QueryInterface(&This->IApplicationDestinations_iface, riid, ppv);
1142 if (FAILED(hr))
1143 SHFree(This);
1145 return hr;
1148 typedef struct
1150 const KNOWNFOLDERID *id;
1151 CSIDL_Type type;
1152 LPCWSTR szValueName;
1153 LPCWSTR szDefaultPath; /* fallback string or resource ID */
1155 /* KNOWNFOLDER_DEFINITION fields */
1156 KF_CATEGORY category;
1157 const WCHAR *pszName;
1158 const WCHAR *pszDescription;
1159 const KNOWNFOLDERID *fidParent;
1160 const WCHAR *pszRelativePath;
1161 const WCHAR *pszParsingName;
1162 const WCHAR *pszTooltip;
1163 const WCHAR *pszLocalizedName;
1164 const WCHAR *pszIcon;
1165 const WCHAR *pszSecurity;
1166 DWORD dwAttributes;
1167 KF_DEFINITION_FLAGS kfdFlags;
1168 const FOLDERTYPEID *ftidType;
1169 } CSIDL_DATA;
1171 static const CSIDL_DATA CSIDL_Data[] =
1173 { /* 0x00 - CSIDL_DESKTOP */
1174 &FOLDERID_Desktop,
1175 CSIDL_Type_User,
1176 DesktopW,
1177 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1179 KF_CATEGORY_PERUSER, /* category */
1180 DesktopW, /* name */
1181 NULL, /* description */
1182 &GUID_NULL, /* parent */
1183 DesktopW, /* relative path */
1184 NULL, /* parsing */
1185 NULL, /* tooltip */
1186 NULL, /* localized */
1187 NULL, /* icon */
1188 NULL, /* security */
1189 FILE_ATTRIBUTE_READONLY, /* attributes */
1190 0, /* flags */
1191 &GUID_NULL /* typeid */
1193 { /* 0x01 - CSIDL_INTERNET */
1194 &FOLDERID_InternetFolder,
1195 CSIDL_Type_Disallowed,
1196 NULL,
1197 NULL,
1199 KF_CATEGORY_VIRTUAL, /* category */
1200 InternetFolderW, /* name */
1201 NULL, /* description */
1202 &GUID_NULL, /* parent */
1203 NULL, /* relative path */
1204 InternetFolderParsingNameW, /* parsing */
1205 NULL, /* tooltip */
1206 NULL, /* localized */
1207 NULL, /* icon */
1208 NULL, /* security */
1209 0, /* attributes */
1210 0, /* flags */
1211 &GUID_NULL /* typeid */
1213 { /* 0x02 - CSIDL_PROGRAMS */
1214 &FOLDERID_Programs,
1215 CSIDL_Type_User,
1216 ProgramsW,
1217 Start_Menu_ProgramsW,
1219 KF_CATEGORY_PERUSER, /* category */
1220 ProgramsW, /* name */
1221 NULL, /* description */
1222 &GUID_NULL, /* parent */
1223 ProgramsW, /* relative path */
1224 NULL, /* parsing */
1225 NULL, /* tooltip */
1226 NULL, /* localized */
1227 NULL, /* icon */
1228 NULL, /* security */
1229 FILE_ATTRIBUTE_READONLY, /* attributes */
1230 0, /* flags */
1231 &GUID_NULL /* typeid */
1233 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1234 &FOLDERID_ControlPanelFolder,
1235 CSIDL_Type_SystemPath,
1236 NULL,
1237 NULL,
1239 KF_CATEGORY_VIRTUAL, /* category */
1240 ControlPanelFolderW, /* name */
1241 NULL, /* description */
1242 &GUID_NULL, /* parent */
1243 ControlPanelFolderRelativePathW, /* relative path */
1244 ControlPanelFolderParsingNameW, /* parsing */
1245 NULL, /* tooltip */
1246 NULL, /* localized */
1247 NULL, /* icon */
1248 NULL, /* security */
1249 0, /* attributes */
1250 0, /* flags */
1251 &GUID_NULL /* typeid */
1253 { /* 0x04 - CSIDL_PRINTERS */
1254 &FOLDERID_PrintersFolder,
1255 CSIDL_Type_SystemPath,
1256 NULL,
1257 NULL,
1259 KF_CATEGORY_VIRTUAL, /* category */
1260 PrintersFolderW, /* name */
1261 NULL, /* description */
1262 &GUID_NULL, /* parent */
1263 NULL, /* relative path */
1264 PrintersFolderParsingNameW, /* parsing */
1265 NULL, /* tooltip */
1266 NULL, /* localized */
1267 NULL, /* icon */
1268 NULL, /* security */
1269 0, /* attributes */
1270 0, /* flags */
1271 &GUID_NULL /* typeid */
1273 { /* 0x05 - CSIDL_PERSONAL */
1274 &FOLDERID_Documents,
1275 CSIDL_Type_User,
1276 PersonalW,
1277 MAKEINTRESOURCEW(IDS_PERSONAL),
1279 KF_CATEGORY_PERUSER, /* category */
1280 PersonalW, /* name */
1281 NULL, /* description */
1282 &GUID_NULL, /* parent */
1283 DocumentsW, /* relative path */
1284 DocumentsParsingNameW, /* parsing */
1285 NULL, /* tooltip */
1286 NULL, /* localized */
1287 NULL, /* icon */
1288 NULL, /* security */
1289 FILE_ATTRIBUTE_READONLY, /* attributes */
1290 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1291 &GUID_NULL /* typeid */
1293 { /* 0x06 - CSIDL_FAVORITES */
1294 &FOLDERID_Favorites,
1295 CSIDL_Type_User,
1296 FavoritesW,
1297 FavoritesW,
1299 KF_CATEGORY_PERUSER, /* category */
1300 FavoritesW, /* name */
1301 NULL, /* description */
1302 &GUID_NULL, /* parent */
1303 FavoritesW, /* relative path */
1304 NULL, /* parsing */
1305 NULL, /* tooltip */
1306 NULL, /* localized */
1307 NULL, /* icon */
1308 NULL, /* security */
1309 FILE_ATTRIBUTE_READONLY, /* attributes */
1310 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1311 &GUID_NULL /* typeid */
1313 { /* 0x07 - CSIDL_STARTUP */
1314 &FOLDERID_Startup,
1315 CSIDL_Type_User,
1316 StartUpW,
1317 Start_Menu_StartupW,
1319 KF_CATEGORY_PERUSER, /* category */
1320 StartupW, /* name */
1321 NULL, /* description */
1322 &GUID_NULL, /* parent */
1323 StartUpW, /* relative path */
1324 NULL, /* parsing */
1325 NULL, /* tooltip */
1326 NULL, /* localized */
1327 NULL, /* icon */
1328 NULL, /* security */
1329 FILE_ATTRIBUTE_READONLY, /* attributes */
1330 KFDF_PRECREATE, /* flags */
1331 &GUID_NULL /* typeid */
1333 { /* 0x08 - CSIDL_RECENT */
1334 &FOLDERID_Recent,
1335 CSIDL_Type_User,
1336 RecentW,
1337 RecentW,
1339 KF_CATEGORY_PERUSER, /* category */
1340 RecentW, /* name */
1341 NULL, /* description */
1342 &FOLDERID_RoamingAppData, /* parent */
1343 Microsoft_Windows_RecentW, /* relative path */
1344 NULL, /* parsing */
1345 NULL, /* tooltip */
1346 NULL, /* localized */
1347 NULL, /* icon */
1348 NULL, /* security */
1349 FILE_ATTRIBUTE_READONLY, /* attributes */
1350 KFDF_PRECREATE, /* flags */
1351 &GUID_NULL /* typeid */
1353 { /* 0x09 - CSIDL_SENDTO */
1354 &FOLDERID_SendTo,
1355 CSIDL_Type_User,
1356 SendToW,
1357 SendToW,
1359 KF_CATEGORY_PERUSER, /* category */
1360 SendToW, /* name */
1361 NULL, /* description */
1362 &FOLDERID_RoamingAppData, /* parent */
1363 Microsoft_Windows_SendToW, /* relative path */
1364 NULL, /* parsing */
1365 NULL, /* tooltip */
1366 NULL, /* localized */
1367 NULL, /* icon */
1368 NULL, /* security */
1369 0, /* attributes */
1370 KFDF_PRECREATE, /* flags */
1371 &GUID_NULL /* typeid */
1373 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1374 &FOLDERID_RecycleBinFolder,
1375 CSIDL_Type_Disallowed,
1376 NULL,
1377 NULL,
1379 KF_CATEGORY_VIRTUAL, /* category */
1380 RecycleBinFolderW, /* name */
1381 NULL, /* description */
1382 &GUID_NULL, /* parent */
1383 NULL, /* relative path */
1384 RecycleBinFolderParsingNameW, /* parsing */
1385 NULL, /* tooltip */
1386 NULL, /* localized */
1387 NULL, /* icon */
1388 NULL, /* security */
1389 0, /* attributes */
1390 0, /* flags */
1391 &GUID_NULL /* typeid */
1393 { /* 0x0b - CSIDL_STARTMENU */
1394 &FOLDERID_StartMenu,
1395 CSIDL_Type_User,
1396 Start_MenuW,
1397 Start_MenuW,
1399 KF_CATEGORY_PERUSER, /* category */
1400 Start_MenuW, /* name */
1401 NULL, /* description */
1402 &FOLDERID_RoamingAppData, /* parent */
1403 Microsoft_Windows_Start_MenuW, /* relative path */
1404 NULL, /* parsing */
1405 NULL, /* tooltip */
1406 NULL, /* localized */
1407 NULL, /* icon */
1408 NULL, /* security */
1409 FILE_ATTRIBUTE_READONLY, /* attributes */
1410 KFDF_PRECREATE, /* flags */
1411 &GUID_NULL /* typeid */
1413 { /* 0x0c - CSIDL_MYDOCUMENTS */
1414 &GUID_NULL,
1415 CSIDL_Type_Disallowed, /* matches WinXP--can't get its path */
1416 NULL,
1417 NULL
1419 { /* 0x0d - CSIDL_MYMUSIC */
1420 &FOLDERID_Music,
1421 CSIDL_Type_User,
1422 My_MusicW,
1423 MAKEINTRESOURCEW(IDS_MYMUSIC),
1425 KF_CATEGORY_PERUSER, /* category */
1426 My_MusicW, /* name */
1427 NULL, /* description */
1428 &FOLDERID_Profile, /* parent */
1429 MusicW, /* relative path */
1430 MusicParsingNameW, /* parsing */
1431 NULL, /* tooltip */
1432 NULL, /* localized */
1433 NULL, /* icon */
1434 NULL, /* security */
1435 FILE_ATTRIBUTE_READONLY, /* attributes */
1436 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1437 &GUID_NULL /* typeid */
1439 { /* 0x0e - CSIDL_MYVIDEO */
1440 &FOLDERID_Videos,
1441 CSIDL_Type_User,
1442 My_VideosW,
1443 MAKEINTRESOURCEW(IDS_MYVIDEOS),
1445 KF_CATEGORY_PERUSER, /* category */
1446 My_VideoW, /* name */
1447 NULL, /* description */
1448 &FOLDERID_Profile, /* parent */
1449 VideosW, /* relative path */
1450 VideosParsingNameW, /* parsing */
1451 NULL, /* tooltip */
1452 NULL, /* localized */
1453 NULL, /* icon */
1454 NULL, /* security */
1455 FILE_ATTRIBUTE_READONLY, /* attributes */
1456 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1457 &GUID_NULL /* typeid */
1459 { /* 0x0f - unassigned */
1460 &GUID_NULL,
1461 CSIDL_Type_Disallowed,
1462 NULL,
1463 NULL,
1465 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1466 &FOLDERID_Desktop,
1467 CSIDL_Type_User,
1468 DesktopW,
1469 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1471 KF_CATEGORY_PERUSER, /* category */
1472 DesktopW, /* name */
1473 NULL, /* description */
1474 &FOLDERID_Profile, /* parent */
1475 DesktopW, /* relative path */
1476 NULL, /* parsing */
1477 NULL, /* tooltip */
1478 NULL, /* localized */
1479 NULL, /* icon */
1480 NULL, /* security */
1481 FILE_ATTRIBUTE_READONLY, /* attributes */
1482 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1483 &GUID_NULL /* typeid */
1485 { /* 0x11 - CSIDL_DRIVES */
1486 &FOLDERID_ComputerFolder,
1487 CSIDL_Type_Disallowed,
1488 NULL,
1489 NULL,
1491 KF_CATEGORY_VIRTUAL, /* category */
1492 MyComputerFolderW, /* name */
1493 NULL, /* description */
1494 &GUID_NULL, /* parent */
1495 NULL, /* relative path */
1496 ComputerFolderParsingNameW, /* parsing */
1497 NULL, /* tooltip */
1498 NULL, /* localized */
1499 NULL, /* icon */
1500 NULL, /* security */
1501 0, /* attributes */
1502 0, /* flags */
1503 &GUID_NULL /* typeid */
1505 { /* 0x12 - CSIDL_NETWORK */
1506 &FOLDERID_NetworkFolder,
1507 CSIDL_Type_Disallowed,
1508 NULL,
1509 NULL,
1511 KF_CATEGORY_VIRTUAL, /* category */
1512 NetworkPlacesFolderW, /* name */
1513 NULL, /* description */
1514 &GUID_NULL, /* parent */
1515 NULL, /* relative path */
1516 NetworkFolderParsingNameW, /* parsing */
1517 NULL, /* tooltip */
1518 NULL, /* localized */
1519 NULL, /* icon */
1520 NULL, /* security */
1521 0, /* attributes */
1522 0, /* flags */
1523 &GUID_NULL /* typeid */
1525 { /* 0x13 - CSIDL_NETHOOD */
1526 &FOLDERID_NetHood,
1527 CSIDL_Type_User,
1528 NetHoodW,
1529 NetHoodW,
1531 KF_CATEGORY_PERUSER, /* category */
1532 NetHoodW, /* name */
1533 NULL, /* description */
1534 &FOLDERID_RoamingAppData, /* parent */
1535 Microsoft_Windows_Network_ShortcutsW, /* relative path */
1536 NULL, /* parsing */
1537 NULL, /* tooltip */
1538 NULL, /* localized */
1539 NULL, /* icon */
1540 NULL, /* security */
1541 0, /* attributes */
1542 0, /* flags */
1543 &GUID_NULL /* typeid */
1545 { /* 0x14 - CSIDL_FONTS */
1546 &FOLDERID_Fonts,
1547 CSIDL_Type_WindowsPath,
1548 FontsW,
1549 FontsW,
1551 KF_CATEGORY_FIXED, /* category */
1552 FontsW, /* name */
1553 NULL, /* description */
1554 &GUID_NULL, /* parent */
1555 NULL, /* relative path */
1556 NULL, /* parsing */
1557 NULL, /* tooltip */
1558 NULL, /* localized */
1559 NULL, /* icon */
1560 NULL, /* security */
1561 0, /* attributes */
1562 0, /* flags */
1563 &FOLDERID_Windows/* typeid */
1565 { /* 0x15 - CSIDL_TEMPLATES */
1566 &FOLDERID_Templates,
1567 CSIDL_Type_User,
1568 TemplatesW,
1569 TemplatesW,
1571 KF_CATEGORY_PERUSER, /* category */
1572 TemplatesW, /* name */
1573 NULL, /* description */
1574 &FOLDERID_RoamingAppData, /* parent */
1575 Microsoft_Windows_TemplatesW, /* relative path */
1576 NULL, /* parsing */
1577 NULL, /* tooltip */
1578 NULL, /* localized */
1579 NULL, /* icon */
1580 NULL, /* security */
1581 0, /* attributes */
1582 0, /* flags */
1583 &GUID_NULL /* typeid */
1585 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1586 &FOLDERID_CommonStartMenu,
1587 CSIDL_Type_ProgramData,
1588 Common_Start_MenuW,
1589 Microsoft_Windows_Start_MenuW,
1591 KF_CATEGORY_COMMON, /* category */
1592 Common_Start_MenuW, /* name */
1593 NULL, /* description */
1594 &FOLDERID_ProgramData, /* parent */
1595 Microsoft_Windows_Start_MenuW, /* relative path */
1596 NULL, /* parsing */
1597 NULL, /* tooltip */
1598 NULL, /* localized */
1599 NULL, /* icon */
1600 NULL, /* security */
1601 FILE_ATTRIBUTE_READONLY, /* attributes */
1602 0, /* flags */
1603 &GUID_NULL /* typeid */
1605 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1606 &FOLDERID_CommonPrograms,
1607 CSIDL_Type_ProgramData,
1608 Common_ProgramsW,
1609 Microsoft_Windows_Start_Menu_ProgramsW,
1611 KF_CATEGORY_COMMON, /* category */
1612 Common_ProgramsW, /* name */
1613 NULL, /* description */
1614 &FOLDERID_CommonStartMenu, /* parent */
1615 ProgramsW, /* relative path */
1616 NULL, /* parsing */
1617 NULL, /* tooltip */
1618 NULL, /* localized */
1619 NULL, /* icon */
1620 NULL, /* security */
1621 FILE_ATTRIBUTE_READONLY, /* attributes */
1622 0, /* flags */
1623 &GUID_NULL /* typeid */
1625 { /* 0x18 - CSIDL_COMMON_STARTUP */
1626 &FOLDERID_CommonStartup,
1627 CSIDL_Type_ProgramData,
1628 Common_StartUpW,
1629 Microsoft_Windows_Start_Menu_StartupW,
1631 KF_CATEGORY_COMMON, /* category */
1632 Common_StartupW, /* name */
1633 NULL, /* description */
1634 &FOLDERID_CommonPrograms, /* parent */
1635 StartUpW, /* relative path */
1636 NULL, /* parsing */
1637 NULL, /* tooltip */
1638 NULL, /* localized */
1639 NULL, /* icon */
1640 NULL, /* security */
1641 FILE_ATTRIBUTE_READONLY, /* attributes */
1642 KFDF_PRECREATE, /* flags */
1643 &GUID_NULL /* typeid */
1645 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1646 &FOLDERID_PublicDesktop,
1647 CSIDL_Type_AllUsers,
1648 Common_DesktopW,
1649 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1651 KF_CATEGORY_COMMON, /* category */
1652 Common_DesktopW, /* name */
1653 NULL, /* description */
1654 &FOLDERID_Public, /* parent */
1655 DesktopW, /* relative path */
1656 NULL, /* parsing */
1657 NULL, /* tooltip */
1658 NULL, /* localized */
1659 NULL, /* icon */
1660 NULL, /* security */
1661 FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN, /* attributes */
1662 KFDF_PRECREATE, /* flags */
1663 &GUID_NULL /* typeid */
1665 { /* 0x1a - CSIDL_APPDATA */
1666 &FOLDERID_RoamingAppData,
1667 CSIDL_Type_User,
1668 AppDataW,
1669 Application_DataW,
1671 KF_CATEGORY_PERUSER, /* category */
1672 AppDataW, /* name */
1673 NULL, /* description */
1674 &FOLDERID_Profile, /* parent */
1675 AppData_RoamingW, /* relative path */
1676 NULL, /* parsing */
1677 NULL, /* tooltip */
1678 NULL, /* localized */
1679 NULL, /* icon */
1680 NULL, /* security */
1681 0, /* attributes */
1682 0, /* flags */
1683 &GUID_NULL /* typeid */
1685 { /* 0x1b - CSIDL_PRINTHOOD */
1686 &FOLDERID_PrintHood,
1687 CSIDL_Type_User,
1688 PrintHoodW,
1689 PrintHoodW,
1691 KF_CATEGORY_PERUSER, /* category */
1692 PrintHoodW, /* name */
1693 NULL, /* description */
1694 &FOLDERID_RoamingAppData, /* parent */
1695 Microsoft_Windows_Printer_ShortcutsW, /* relative path */
1696 NULL, /* parsing */
1697 NULL, /* tooltip */
1698 NULL, /* localized */
1699 NULL, /* icon */
1700 NULL, /* security */
1701 0, /* attributes */
1702 0, /* flags */
1703 &GUID_NULL /* typeid */
1705 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1706 &FOLDERID_LocalAppData,
1707 CSIDL_Type_User,
1708 Local_AppDataW,
1709 Local_Settings_Application_DataW,
1711 KF_CATEGORY_PERUSER, /* category */
1712 Local_AppDataW, /* name */
1713 NULL, /* description */
1714 &FOLDERID_Profile, /* parent */
1715 AppData_LocalW, /* relative path */
1716 NULL, /* parsing */
1717 NULL, /* tooltip */
1718 NULL, /* localized */
1719 NULL, /* icon */
1720 NULL, /* security */
1721 0, /* attributes */
1722 KFDF_LOCAL_REDIRECT_ONLY | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1723 &GUID_NULL /* typeid */
1725 { /* 0x1d - CSIDL_ALTSTARTUP */
1726 &GUID_NULL,
1727 CSIDL_Type_NonExistent,
1728 NULL,
1729 NULL
1731 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1732 &GUID_NULL,
1733 CSIDL_Type_NonExistent,
1734 NULL,
1735 NULL
1737 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1738 &FOLDERID_Favorites,
1739 CSIDL_Type_AllUsers,
1740 Common_FavoritesW,
1741 FavoritesW,
1743 KF_CATEGORY_PERUSER, /* category */
1744 FavoritesW, /* name */
1745 NULL, /* description */
1746 &FOLDERID_Profile, /* parent */
1747 FavoritesW, /* relative path */
1748 NULL, /* parsing */
1749 NULL, /* tooltip */
1750 NULL, /* localized */
1751 NULL, /* icon */
1752 NULL, /* security */
1753 FILE_ATTRIBUTE_READONLY, /* attributes */
1754 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1755 &GUID_NULL /* typeid */
1757 { /* 0x20 - CSIDL_INTERNET_CACHE */
1758 &FOLDERID_InternetCache,
1759 CSIDL_Type_User,
1760 CacheW,
1761 Local_Settings_Temporary_Internet_FilesW,
1763 KF_CATEGORY_PERUSER, /* category */
1764 CacheW, /* name */
1765 NULL, /* description */
1766 &FOLDERID_LocalAppData, /* parent */
1767 Microsoft_Windows_Temporary_Internet_FilesW, /* relative path */
1768 NULL, /* parsing */
1769 NULL, /* tooltip */
1770 NULL, /* localized */
1771 NULL, /* icon */
1772 NULL, /* security */
1773 0, /* attributes */
1774 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
1775 &GUID_NULL /* typeid */
1777 { /* 0x21 - CSIDL_COOKIES */
1778 &FOLDERID_Cookies,
1779 CSIDL_Type_User,
1780 CookiesW,
1781 CookiesW,
1783 KF_CATEGORY_PERUSER, /* category */
1784 CookiesW, /* name */
1785 NULL, /* description */
1786 &FOLDERID_RoamingAppData, /* parent */
1787 Microsoft_Windows_CookiesW, /* relative path */
1788 NULL, /* parsing */
1789 NULL, /* tooltip */
1790 NULL, /* localized */
1791 NULL, /* icon */
1792 NULL, /* security */
1793 0, /* attributes */
1794 0, /* flags */
1795 &GUID_NULL /* typeid */
1797 { /* 0x22 - CSIDL_HISTORY */
1798 &FOLDERID_History,
1799 CSIDL_Type_User,
1800 HistoryW,
1801 Local_Settings_HistoryW,
1803 KF_CATEGORY_PERUSER, /* category */
1804 HistoryW, /* name */
1805 NULL, /* description */
1806 &FOLDERID_LocalAppData, /* parent */
1807 Microsoft_Windows_HistoryW, /* relative path */
1808 NULL, /* parsing */
1809 NULL, /* tooltip */
1810 NULL, /* localized */
1811 NULL, /* icon */
1812 NULL, /* security */
1813 0, /* attributes */
1814 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
1815 &GUID_NULL /* typeid */
1817 { /* 0x23 - CSIDL_COMMON_APPDATA */
1818 &FOLDERID_ProgramData,
1819 CSIDL_Type_ProgramData,
1820 Common_AppDataW,
1821 NULL,
1823 KF_CATEGORY_FIXED, /* category */
1824 Common_AppDataW, /* name */
1825 NULL, /* description */
1826 &GUID_NULL, /* parent */
1827 NULL, /* relative path */
1828 NULL, /* parsing */
1829 NULL, /* tooltip */
1830 NULL, /* localized */
1831 NULL, /* icon */
1832 NULL, /* security */
1833 0, /* attributes */
1834 0, /* flags */
1835 &GUID_NULL /* typeid */
1837 { /* 0x24 - CSIDL_WINDOWS */
1838 &FOLDERID_Windows,
1839 CSIDL_Type_WindowsPath,
1840 NULL,
1841 NULL,
1843 KF_CATEGORY_FIXED, /* category */
1844 WindowsW, /* name */
1845 NULL, /* description */
1846 &GUID_NULL, /* parent */
1847 NULL, /* relative path */
1848 NULL, /* parsing */
1849 NULL, /* tooltip */
1850 NULL, /* localized */
1851 NULL, /* icon */
1852 NULL, /* security */
1853 0, /* attributes */
1854 0, /* flags */
1855 &GUID_NULL /* typeid */
1857 { /* 0x25 - CSIDL_SYSTEM */
1858 &FOLDERID_System,
1859 CSIDL_Type_SystemPath,
1860 NULL,
1861 NULL,
1863 KF_CATEGORY_FIXED, /* category */
1864 SystemW, /* name */
1865 NULL, /* description */
1866 &GUID_NULL, /* parent */
1867 NULL, /* relative path */
1868 NULL, /* parsing */
1869 NULL, /* tooltip */
1870 NULL, /* localized */
1871 NULL, /* icon */
1872 NULL, /* security */
1873 0, /* attributes */
1874 0, /* flags */
1875 &GUID_NULL /* typeid */
1877 { /* 0x26 - CSIDL_PROGRAM_FILES */
1878 &FOLDERID_ProgramFiles,
1879 CSIDL_Type_CurrVer,
1880 ProgramFilesDirW,
1881 Program_FilesW,
1883 KF_CATEGORY_FIXED, /* category */
1884 ProgramFilesW, /* name */
1885 NULL, /* description */
1886 &GUID_NULL, /* parent */
1887 NULL, /* relative path */
1888 NULL, /* parsing */
1889 NULL, /* tooltip */
1890 NULL, /* localized */
1891 NULL, /* icon */
1892 NULL, /* security */
1893 FILE_ATTRIBUTE_READONLY, /* attributes */
1894 0, /* flags */
1895 &GUID_NULL /* typeid */
1897 { /* 0x27 - CSIDL_MYPICTURES */
1898 &FOLDERID_Pictures,
1899 CSIDL_Type_User,
1900 My_PicturesW,
1901 MAKEINTRESOURCEW(IDS_MYPICTURES),
1903 KF_CATEGORY_PERUSER, /* category */
1904 My_PicturesW, /* name */
1905 NULL, /* description */
1906 &FOLDERID_Profile, /* parent */
1907 PicturesW, /* relative path */
1908 PicturesParsingNameW, /* parsing */
1909 NULL, /* tooltip */
1910 NULL, /* localized */
1911 NULL, /* icon */
1912 NULL, /* security */
1913 FILE_ATTRIBUTE_READONLY, /* attributes */
1914 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1915 &GUID_NULL /* typeid */
1917 { /* 0x28 - CSIDL_PROFILE */
1918 &FOLDERID_Profile,
1919 CSIDL_Type_User,
1920 NULL,
1921 NULL,
1923 KF_CATEGORY_FIXED, /* category */
1924 ProfileW, /* name */
1925 NULL, /* description */
1926 &GUID_NULL, /* parent */
1927 NULL, /* relative path */
1928 NULL, /* parsing */
1929 NULL, /* tooltip */
1930 NULL, /* localized */
1931 NULL, /* icon */
1932 NULL, /* security */
1933 0, /* attributes */
1934 0, /* flags */
1935 &GUID_NULL /* typeid */
1937 { /* 0x29 - CSIDL_SYSTEMX86 */
1938 &FOLDERID_SystemX86,
1939 CSIDL_Type_SystemX86Path,
1940 NULL,
1941 NULL,
1943 KF_CATEGORY_FIXED, /* category */
1944 SystemX86W, /* name */
1945 NULL, /* description */
1946 &GUID_NULL, /* parent */
1947 NULL, /* relative path */
1948 NULL, /* parsing */
1949 NULL, /* tooltip */
1950 NULL, /* localized */
1951 NULL, /* icon */
1952 NULL, /* security */
1953 0, /* attributes */
1954 0, /* flags */
1955 &GUID_NULL /* typeid */
1957 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
1958 &FOLDERID_ProgramFilesX86,
1959 CSIDL_Type_CurrVer,
1960 ProgramFilesDirX86W,
1961 Program_Files_x86W,
1963 KF_CATEGORY_FIXED, /* category */
1964 ProgramFilesX86W, /* name */
1965 NULL, /* description */
1966 &GUID_NULL, /* parent */
1967 NULL, /* relative path */
1968 NULL, /* parsing */
1969 NULL, /* tooltip */
1970 NULL, /* localized */
1971 NULL, /* icon */
1972 NULL, /* security */
1973 FILE_ATTRIBUTE_READONLY, /* attributes */
1974 0, /* flags */
1975 &GUID_NULL /* typeid */
1977 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
1978 &FOLDERID_ProgramFilesCommon,
1979 CSIDL_Type_CurrVer,
1980 CommonFilesDirW,
1981 Program_Files_Common_FilesW,
1983 KF_CATEGORY_FIXED, /* category */
1984 ProgramFilesCommonW, /* name */
1985 NULL, /* description */
1986 &GUID_NULL, /* parent */
1987 NULL, /* relative path */
1988 NULL, /* parsing */
1989 NULL, /* tooltip */
1990 NULL, /* localized */
1991 NULL, /* icon */
1992 NULL, /* security */
1993 0, /* attributes */
1994 0, /* flags */
1995 &GUID_NULL /* typeid */
1997 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
1998 &FOLDERID_ProgramFilesCommonX86,
1999 CSIDL_Type_CurrVer,
2000 CommonFilesDirX86W,
2001 Program_Files_x86_Common_FilesW,
2003 KF_CATEGORY_FIXED, /* category */
2004 ProgramFilesCommonX86W, /* name */
2005 NULL, /* description */
2006 &GUID_NULL, /* parent */
2007 NULL, /* relative path */
2008 NULL, /* parsing */
2009 NULL, /* tooltip */
2010 NULL, /* localized */
2011 NULL, /* icon */
2012 NULL, /* security */
2013 0, /* attributes */
2014 0, /* flags */
2015 &GUID_NULL /* typeid */
2017 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2018 &FOLDERID_CommonTemplates,
2019 CSIDL_Type_ProgramData,
2020 Common_TemplatesW,
2021 Microsoft_Windows_TemplatesW,
2023 KF_CATEGORY_COMMON, /* category */
2024 Common_TemplatesW, /* name */
2025 NULL, /* description */
2026 &FOLDERID_ProgramData, /* parent */
2027 Microsoft_Windows_TemplatesW, /* relative path */
2028 NULL, /* parsing */
2029 NULL, /* tooltip */
2030 NULL, /* localized */
2031 NULL, /* icon */
2032 NULL, /* security */
2033 0, /* attributes */
2034 0, /* flags */
2035 &GUID_NULL /* typeid */
2037 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2038 &FOLDERID_PublicDocuments,
2039 CSIDL_Type_AllUsers,
2040 Common_DocumentsW,
2041 DocumentsW,
2043 KF_CATEGORY_COMMON, /* category */
2044 Common_DocumentsW, /* name */
2045 NULL, /* description */
2046 &FOLDERID_Public, /* parent */
2047 DocumentsW, /* relative path */
2048 NULL, /* parsing */
2049 NULL, /* tooltip */
2050 NULL, /* localized */
2051 NULL, /* icon */
2052 NULL, /* security */
2053 FILE_ATTRIBUTE_READONLY, /* attributes */
2054 KFDF_PRECREATE, /* flags */
2055 &GUID_NULL /* typeid */
2057 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2058 &FOLDERID_CommonAdminTools,
2059 CSIDL_Type_ProgramData,
2060 Common_Administrative_ToolsW,
2061 Microsoft_Windows_Start_Menu_Admin_ToolsW,
2063 KF_CATEGORY_COMMON, /* category */
2064 Common_Administrative_ToolsW, /* name */
2065 NULL, /* description */
2066 &FOLDERID_CommonPrograms, /* parent */
2067 Administrative_ToolsW, /* relative path */
2068 NULL, /* parsing */
2069 NULL, /* tooltip */
2070 NULL, /* localized */
2071 NULL, /* icon */
2072 NULL, /* security */
2073 FILE_ATTRIBUTE_READONLY, /* attributes */
2074 KFDF_PRECREATE, /* flags */
2075 &GUID_NULL /* typeid */
2077 { /* 0x30 - CSIDL_ADMINTOOLS */
2078 &FOLDERID_AdminTools,
2079 CSIDL_Type_User,
2080 Administrative_ToolsW,
2081 Start_Menu_Admin_ToolsW,
2083 KF_CATEGORY_PERUSER, /* category */
2084 Administrative_ToolsW, /* name */
2085 NULL, /* description */
2086 &FOLDERID_Programs, /* parent */
2087 Administrative_ToolsW, /* relative path */
2088 NULL, /* parsing */
2089 NULL, /* tooltip */
2090 NULL, /* localized */
2091 NULL, /* icon */
2092 NULL, /* security */
2093 FILE_ATTRIBUTE_READONLY, /* attributes */
2094 KFDF_PRECREATE, /* flags */
2095 &GUID_NULL /* typeid */
2097 { /* 0x31 - CSIDL_CONNECTIONS */
2098 &FOLDERID_ConnectionsFolder,
2099 CSIDL_Type_Disallowed,
2100 NULL,
2101 NULL,
2103 KF_CATEGORY_VIRTUAL, /* category */
2104 ConnectionsFolderW, /* name */
2105 NULL, /* description */
2106 &GUID_NULL, /* parent */
2107 Administrative_ToolsW, /* relative path */
2108 ConnectionsFolderParsingNameW, /* parsing */
2109 NULL, /* tooltip */
2110 NULL, /* localized */
2111 NULL, /* icon */
2112 NULL, /* security */
2113 0, /* attributes */
2114 0, /* flags */
2115 &GUID_NULL /* typeid */
2117 { /* 0x32 - unassigned */
2118 &GUID_NULL,
2119 CSIDL_Type_Disallowed,
2120 NULL,
2121 NULL
2123 { /* 0x33 - unassigned */
2124 &GUID_NULL,
2125 CSIDL_Type_Disallowed,
2126 NULL,
2127 NULL
2129 { /* 0x34 - unassigned */
2130 &GUID_NULL,
2131 CSIDL_Type_Disallowed,
2132 NULL,
2133 NULL
2135 { /* 0x35 - CSIDL_COMMON_MUSIC */
2136 &FOLDERID_PublicMusic,
2137 CSIDL_Type_AllUsers,
2138 CommonMusicW,
2139 MusicW,
2141 KF_CATEGORY_COMMON, /* category */
2142 CommonMusicW, /* name */
2143 NULL, /* description */
2144 &FOLDERID_Public, /* parent */
2145 MusicW, /* relative path */
2146 NULL, /* parsing */
2147 NULL, /* tooltip */
2148 NULL, /* localized */
2149 NULL, /* icon */
2150 NULL, /* security */
2151 FILE_ATTRIBUTE_READONLY, /* attributes */
2152 KFDF_PRECREATE, /* flags */
2153 &GUID_NULL /* typeid */
2155 { /* 0x36 - CSIDL_COMMON_PICTURES */
2156 &FOLDERID_PublicPictures,
2157 CSIDL_Type_AllUsers,
2158 CommonPicturesW,
2159 PicturesW,
2161 KF_CATEGORY_COMMON, /* category */
2162 CommonPicturesW, /* name */
2163 NULL, /* description */
2164 &FOLDERID_Public, /* parent */
2165 PicturesW, /* relative path */
2166 NULL, /* parsing */
2167 NULL, /* tooltip */
2168 NULL, /* localized */
2169 NULL, /* icon */
2170 NULL, /* security */
2171 FILE_ATTRIBUTE_READONLY, /* attributes */
2172 KFDF_PRECREATE, /* flags */
2173 &GUID_NULL /* typeid */
2175 { /* 0x37 - CSIDL_COMMON_VIDEO */
2176 &FOLDERID_PublicVideos,
2177 CSIDL_Type_AllUsers,
2178 CommonVideoW,
2179 VideosW,
2181 KF_CATEGORY_COMMON, /* category */
2182 CommonVideoW, /* name */
2183 NULL, /* description */
2184 &FOLDERID_Public, /* parent */
2185 VideosW, /* relative path */
2186 NULL, /* parsing */
2187 NULL, /* tooltip */
2188 NULL, /* localized */
2189 NULL, /* icon */
2190 NULL, /* security */
2191 FILE_ATTRIBUTE_READONLY, /* attributes */
2192 KFDF_PRECREATE, /* flags */
2193 &GUID_NULL /* typeid */
2195 { /* 0x38 - CSIDL_RESOURCES */
2196 &FOLDERID_ResourceDir,
2197 CSIDL_Type_WindowsPath,
2198 NULL,
2199 ResourcesW,
2201 KF_CATEGORY_FIXED, /* category */
2202 ResourceDirW, /* name */
2203 NULL, /* description */
2204 &GUID_NULL, /* parent */
2205 NULL, /* relative path */
2206 NULL, /* parsing */
2207 NULL, /* tooltip */
2208 NULL, /* localized */
2209 NULL, /* icon */
2210 NULL, /* security */
2211 0, /* attributes */
2212 0, /* flags */
2213 &GUID_NULL /* typeid */
2215 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2216 &FOLDERID_LocalizedResourcesDir,
2217 CSIDL_Type_NonExistent,
2218 NULL,
2219 NULL,
2221 KF_CATEGORY_FIXED, /* category */
2222 LocalizedResourcesDirW, /* name */
2223 NULL, /* description */
2224 &GUID_NULL, /* parent */
2225 NULL, /* relative path */
2226 NULL, /* parsing */
2227 NULL, /* tooltip */
2228 NULL, /* localized */
2229 NULL, /* icon */
2230 NULL, /* security */
2231 0, /* attributes */
2232 0, /* flags */
2233 &GUID_NULL /* typeid */
2235 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2236 &FOLDERID_CommonOEMLinks,
2237 CSIDL_Type_ProgramData,
2238 NULL,
2239 OEM_LinksW,
2241 KF_CATEGORY_COMMON, /* category */
2242 OEM_LinksW, /* name */
2243 NULL, /* description */
2244 &FOLDERID_ProgramData, /* parent */
2245 OEM_LinksW, /* relative path */
2246 NULL, /* parsing */
2247 NULL, /* tooltip */
2248 NULL, /* localized */
2249 NULL, /* icon */
2250 NULL, /* security */
2251 0, /* attributes */
2252 0, /* flags */
2253 &GUID_NULL /* typeid */
2255 { /* 0x3b - CSIDL_CDBURN_AREA */
2256 &FOLDERID_CDBurning,
2257 CSIDL_Type_User,
2258 CD_BurningW,
2259 Local_Settings_CD_BurningW,
2261 KF_CATEGORY_PERUSER, /* category */
2262 CD_BurningW, /* name */
2263 NULL, /* description */
2264 &FOLDERID_LocalAppData, /* parent */
2265 Microsoft_Windows_Burn_BurnW, /* relative path */
2266 NULL, /* parsing */
2267 NULL, /* tooltip */
2268 NULL, /* localized */
2269 NULL, /* icon */
2270 NULL, /* security */
2271 FILE_ATTRIBUTE_READONLY, /* attributes */
2272 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2273 &GUID_NULL /* typeid */
2275 { /* 0x3c unassigned */
2276 &GUID_NULL,
2277 CSIDL_Type_Disallowed,
2278 NULL,
2279 NULL
2281 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2282 &GUID_NULL,
2283 CSIDL_Type_Disallowed, /* FIXME */
2284 NULL,
2285 NULL
2287 { /* 0x3e - CSIDL_PROFILES */
2288 &GUID_NULL,
2289 CSIDL_Type_Disallowed, /* oddly, this matches WinXP */
2290 NULL,
2291 NULL
2293 { /* 0x3f */
2294 &FOLDERID_AddNewPrograms,
2295 CSIDL_Type_Disallowed,
2296 NULL,
2297 NULL,
2299 KF_CATEGORY_VIRTUAL, /* category */
2300 AddNewProgramsFolderW, /* name */
2301 NULL, /* description */
2302 &GUID_NULL, /* parent */
2303 NULL, /* relative path */
2304 AddNewProgramsParsingNameW, /* parsing */
2305 NULL, /* tooltip */
2306 NULL, /* localized */
2307 NULL, /* icon */
2308 NULL, /* security */
2309 0, /* attributes */
2310 0, /* flags */
2311 &GUID_NULL /* typeid */
2313 { /* 0x40 */
2314 &FOLDERID_AppUpdates,
2315 CSIDL_Type_Disallowed,
2316 NULL,
2317 NULL,
2319 KF_CATEGORY_VIRTUAL, /* category */
2320 AppUpdatesFolderW, /* name */
2321 NULL, /* description */
2322 &GUID_NULL, /* parent */
2323 NULL, /* relative path */
2324 AppUpdatesParsingNameW, /* parsing */
2325 NULL, /* tooltip */
2326 NULL, /* localized */
2327 NULL, /* icon */
2328 NULL, /* security */
2329 0, /* attributes */
2330 0, /* flags */
2331 &GUID_NULL /* typeid */
2333 { /* 0x41 */
2334 &FOLDERID_ChangeRemovePrograms,
2335 CSIDL_Type_Disallowed,
2336 NULL,
2337 NULL,
2339 KF_CATEGORY_VIRTUAL, /* category */
2340 ChangeRemoveProgramsFolderW, /* name */
2341 NULL, /* description */
2342 &GUID_NULL, /* parent */
2343 NULL, /* relative path */
2344 ChangeRemoveProgramsParsingNameW, /* parsing */
2345 NULL, /* tooltip */
2346 NULL, /* localized */
2347 NULL, /* icon */
2348 NULL, /* security */
2349 0, /* attributes */
2350 0, /* flags */
2351 &GUID_NULL /* typeid */
2353 { /* 0x42 */
2354 &FOLDERID_ConflictFolder,
2355 CSIDL_Type_Disallowed,
2356 NULL,
2357 NULL,
2359 KF_CATEGORY_VIRTUAL, /* category */
2360 ConflictFolderW, /* name */
2361 NULL, /* description */
2362 &GUID_NULL, /* parent */
2363 NULL, /* relative path */
2364 ConflictFolderParsingNameW, /* parsing */
2365 NULL, /* tooltip */
2366 NULL, /* localized */
2367 NULL, /* icon */
2368 NULL, /* security */
2369 0, /* attributes */
2370 0, /* flags */
2371 &GUID_NULL /* typeid */
2373 { /* 0x43 - CSIDL_CONTACTS */
2374 &FOLDERID_Contacts,
2375 CSIDL_Type_User,
2376 NULL,
2377 ContactsW,
2379 KF_CATEGORY_PERUSER, /* category */
2380 ContactsW, /* name */
2381 NULL, /* description */
2382 &FOLDERID_Profile, /* parent */
2383 ContactsW, /* relative path */
2384 ContactsParsingNameW, /* parsing */
2385 NULL, /* tooltip */
2386 NULL, /* localized */
2387 NULL, /* icon */
2388 NULL, /* security */
2389 FILE_ATTRIBUTE_READONLY, /* attributes */
2390 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2391 &GUID_NULL /* typeid */
2393 { /* 0x44 */
2394 &FOLDERID_DeviceMetadataStore,
2395 CSIDL_Type_Disallowed, /* FIXME */
2396 NULL,
2397 NULL,
2399 KF_CATEGORY_COMMON, /* category */
2400 Device_Metadata_StoreW, /* name */
2401 NULL, /* description */
2402 &FOLDERID_ProgramData, /* parent */
2403 Microsoft_Windows_DeviceMetadataStoreW, /* relative path */
2404 NULL, /* parsing */
2405 NULL, /* tooltip */
2406 NULL, /* localized */
2407 NULL, /* icon */
2408 NULL, /* security */
2409 0, /* attributes */
2410 0, /* flags */
2411 &GUID_NULL /* typeid */
2413 { /* 0x45 */
2414 &GUID_NULL,
2415 CSIDL_Type_User,
2416 NULL,
2417 DocumentsW
2419 { /* 0x46 */
2420 &FOLDERID_DocumentsLibrary,
2421 CSIDL_Type_Disallowed, /* FIXME */
2422 NULL,
2423 NULL,
2425 KF_CATEGORY_PERUSER, /* category */
2426 DocumentsLibraryW, /* name */
2427 NULL, /* description */
2428 &FOLDERID_Libraries, /* parent */
2429 Documents_librarymsW, /* relative path */
2430 DocumentsLibraryParsingNameW, /* parsing */
2431 NULL, /* tooltip */
2432 NULL, /* localized */
2433 NULL, /* icon */
2434 NULL, /* security */
2435 0, /* attributes */
2436 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2437 &GUID_NULL /* typeid */
2439 { /* 0x47 - CSIDL_DOWNLOADS */
2440 &FOLDERID_Downloads,
2441 CSIDL_Type_User,
2442 NULL,
2443 DownloadsW,
2445 KF_CATEGORY_PERUSER, /* category */
2446 DownloadsW, /* name */
2447 NULL, /* description */
2448 &FOLDERID_Profile, /* parent */
2449 DownloadsW, /* relative path */
2450 NULL, /* parsing */
2451 NULL, /* tooltip */
2452 NULL, /* localized */
2453 NULL, /* icon */
2454 NULL, /* security */
2455 FILE_ATTRIBUTE_READONLY, /* attributes */
2456 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2457 &GUID_NULL /* typeid */
2459 { /* 0x48 */
2460 &FOLDERID_Games,
2461 CSIDL_Type_Disallowed,
2462 NULL,
2463 NULL,
2465 KF_CATEGORY_VIRTUAL, /* category */
2466 GamesW, /* name */
2467 NULL, /* description */
2468 &GUID_NULL, /* parent */
2469 NULL, /* relative path */
2470 GamesParsingNameW, /* parsing */
2471 NULL, /* tooltip */
2472 NULL, /* localized */
2473 NULL, /* icon */
2474 NULL, /* security */
2475 0, /* attributes */
2476 0, /* flags */
2477 &GUID_NULL /* typeid */
2479 { /* 0x49 */
2480 &FOLDERID_GameTasks,
2481 CSIDL_Type_Disallowed, /* FIXME */
2482 NULL,
2483 NULL,
2485 KF_CATEGORY_PERUSER, /* category */
2486 GameTasksW, /* name */
2487 NULL, /* description */
2488 &FOLDERID_LocalAppData, /* parent */
2489 Microsoft_Windows_GameExplorerW, /* relative path */
2490 NULL, /* parsing */
2491 NULL, /* tooltip */
2492 NULL, /* localized */
2493 NULL, /* icon */
2494 NULL, /* security */
2495 0, /* attributes */
2496 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2497 &GUID_NULL /* typeid */
2499 { /* 0x4a */
2500 &FOLDERID_HomeGroup,
2501 CSIDL_Type_Disallowed,
2502 NULL,
2503 NULL,
2505 KF_CATEGORY_VIRTUAL, /* category */
2506 HomeGroupFolderW, /* name */
2507 NULL, /* description */
2508 &GUID_NULL, /* parent */
2509 NULL, /* relative path */
2510 HomeGroupParsingNameW, /* parsing */
2511 NULL, /* tooltip */
2512 NULL, /* localized */
2513 NULL, /* icon */
2514 NULL, /* security */
2515 0, /* attributes */
2516 0, /* flags */
2517 &GUID_NULL /* typeid */
2519 { /* 0x4b */
2520 &FOLDERID_ImplicitAppShortcuts,
2521 CSIDL_Type_Disallowed, /* FIXME */
2522 NULL,
2523 NULL,
2525 KF_CATEGORY_PERUSER, /* category */
2526 ImplicitAppShortcutsW, /* name */
2527 NULL, /* description */
2528 &FOLDERID_UserPinned, /* parent */
2529 ImplicitAppShortcutsW, /* relative path */
2530 NULL, /* parsing */
2531 NULL, /* tooltip */
2532 NULL, /* localized */
2533 NULL, /* icon */
2534 NULL, /* security */
2535 0, /* attributes */
2536 KFDF_PRECREATE, /* flags */
2537 &GUID_NULL /* typeid */
2539 { /* 0x4c */
2540 &FOLDERID_Libraries,
2541 CSIDL_Type_Disallowed, /* FIXME */
2542 NULL,
2543 NULL,
2545 KF_CATEGORY_PERUSER, /* category */
2546 LibrariesW, /* name */
2547 NULL, /* description */
2548 &FOLDERID_RoamingAppData, /* parent */
2549 Microsoft_Windows_LibrariesW, /* relative path */
2550 NULL, /* parsing */
2551 NULL, /* tooltip */
2552 NULL, /* localized */
2553 NULL, /* icon */
2554 NULL, /* security */
2555 0, /* attributes */
2556 KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2557 &GUID_NULL /* typeid */
2559 { /* 0x4d - CSIDL_LINKS */
2560 &FOLDERID_Links,
2561 CSIDL_Type_User,
2562 NULL,
2563 LinksW,
2565 KF_CATEGORY_PERUSER, /* category */
2566 LinksW, /* name */
2567 NULL, /* description */
2568 &FOLDERID_Profile, /* parent */
2569 LinksW, /* relative path */
2570 LinksParsingNameW, /* parsing */
2571 NULL, /* tooltip */
2572 NULL, /* localized */
2573 NULL, /* icon */
2574 NULL, /* security */
2575 FILE_ATTRIBUTE_READONLY, /* attributes */
2576 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2577 &GUID_NULL /* typeid */
2579 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2580 &FOLDERID_LocalAppDataLow,
2581 CSIDL_Type_User,
2582 NULL,
2583 AppData_LocalLowW,
2585 KF_CATEGORY_PERUSER, /* category */
2586 LocalAppDataLowW, /* name */
2587 NULL, /* description */
2588 &FOLDERID_Profile, /* parent */
2589 AppData_LocalLowW, /* relative path */
2590 NULL, /* parsing */
2591 NULL, /* tooltip */
2592 NULL, /* localized */
2593 NULL, /* icon */
2594 NULL, /* security */
2595 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, /* attributes */
2596 KFDF_LOCAL_REDIRECT_ONLY | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2597 &GUID_NULL /* typeid */
2599 { /* 0x4f */
2600 &FOLDERID_MusicLibrary,
2601 CSIDL_Type_Disallowed, /* FIXME */
2602 NULL,
2603 NULL,
2605 KF_CATEGORY_PERUSER, /* category */
2606 MusicLibraryW, /* name */
2607 NULL, /* description */
2608 &FOLDERID_Libraries, /* parent */
2609 Music_librarymsW, /* relative path */
2610 MusicLibraryParsingNameW, /* parsing */
2611 NULL, /* tooltip */
2612 NULL, /* localized */
2613 NULL, /* icon */
2614 NULL, /* security */
2615 0, /* attributes */
2616 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2617 &GUID_NULL /* typeid */
2619 { /* 0x50 */
2620 &FOLDERID_OriginalImages,
2621 CSIDL_Type_Disallowed, /* FIXME */
2622 NULL,
2623 NULL,
2625 KF_CATEGORY_PERUSER, /* category */
2626 Original_ImagesW, /* name */
2627 NULL, /* description */
2628 &FOLDERID_LocalAppData, /* parent */
2629 Microsoft_Windows_Photo_Gallery_Original_ImagesW, /* relative path */
2630 NULL, /* parsing */
2631 NULL, /* tooltip */
2632 NULL, /* localized */
2633 NULL, /* icon */
2634 NULL, /* security */
2635 0, /* attributes */
2636 0, /* flags */
2637 &GUID_NULL /* typeid */
2639 { /* 0x51 */
2640 &FOLDERID_PhotoAlbums,
2641 CSIDL_Type_User,
2642 NULL,
2643 Pictures_Slide_ShowsW,
2645 KF_CATEGORY_PERUSER, /* category */
2646 PhotoAlbumsW, /* name */
2647 NULL, /* description */
2648 &FOLDERID_Pictures, /* parent */
2649 Slide_ShowsW, /* relative path */
2650 NULL, /* parsing */
2651 NULL, /* tooltip */
2652 NULL, /* localized */
2653 NULL, /* icon */
2654 NULL, /* security */
2655 FILE_ATTRIBUTE_READONLY, /* attributes */
2656 0, /* flags */
2657 &GUID_NULL /* typeid */
2659 { /* 0x52 */
2660 &FOLDERID_PicturesLibrary,
2661 CSIDL_Type_Disallowed, /* FIXME */
2662 NULL,
2663 NULL,
2665 KF_CATEGORY_PERUSER, /* category */
2666 PicturesLibraryW, /* name */
2667 NULL, /* description */
2668 &FOLDERID_Libraries, /* parent */
2669 Pictures_librarymsW, /* relative path */
2670 PicturesLibraryParsingNameW, /* parsing */
2671 NULL, /* tooltip */
2672 NULL, /* localized */
2673 NULL, /* icon */
2674 NULL, /* security */
2675 0, /* attributes */
2676 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2677 &GUID_NULL /* typeid */
2679 { /* 0x53 */
2680 &FOLDERID_Playlists,
2681 CSIDL_Type_User,
2682 NULL,
2683 Music_PlaylistsW,
2685 KF_CATEGORY_PERUSER, /* category */
2686 PlaylistsW, /* name */
2687 NULL, /* description */
2688 &FOLDERID_Music, /* parent */
2689 PlaylistsW, /* relative path */
2690 NULL, /* parsing */
2691 NULL, /* tooltip */
2692 NULL, /* localized */
2693 NULL, /* icon */
2694 NULL, /* security */
2695 FILE_ATTRIBUTE_READONLY, /* attributes */
2696 0, /* flags */
2697 &GUID_NULL /* typeid */
2699 { /* 0x54 */
2700 &FOLDERID_ProgramFilesX64,
2701 CSIDL_Type_NonExistent,
2702 NULL,
2703 NULL,
2705 KF_CATEGORY_FIXED, /* category */
2706 ProgramFilesX64W, /* name */
2707 NULL, /* description */
2708 &GUID_NULL, /* parent */
2709 NULL, /* relative path */
2710 NULL, /* parsing */
2711 NULL, /* tooltip */
2712 NULL, /* localized */
2713 NULL, /* icon */
2714 NULL, /* security */
2715 0, /* attributes */
2716 0, /* flags */
2717 &GUID_NULL /* typeid */
2719 { /* 0x55 */
2720 &FOLDERID_ProgramFilesCommonX64,
2721 CSIDL_Type_NonExistent,
2722 NULL,
2723 NULL,
2725 KF_CATEGORY_FIXED, /* category */
2726 ProgramFilesCommonX64W, /* name */
2727 NULL, /* description */
2728 &GUID_NULL, /* parent */
2729 NULL, /* relative path */
2730 NULL, /* parsing */
2731 NULL, /* tooltip */
2732 NULL, /* localized */
2733 NULL, /* icon */
2734 NULL, /* security */
2735 0, /* attributes */
2736 0, /* flags */
2737 &GUID_NULL /* typeid */
2739 { /* 0x56 */
2740 &FOLDERID_Public,
2741 CSIDL_Type_CurrVer, /* FIXME */
2742 NULL,
2743 UsersPublicW,
2745 KF_CATEGORY_FIXED, /* category */
2746 PublicW, /* name */
2747 NULL, /* description */
2748 &GUID_NULL, /* parent */
2749 NULL, /* relative path */
2750 PublicParsingNameW, /* parsing */
2751 NULL, /* tooltip */
2752 NULL, /* localized */
2753 NULL, /* icon */
2754 NULL, /* security */
2755 FILE_ATTRIBUTE_READONLY, /* attributes */
2756 KFDF_PRECREATE, /* flags */
2757 &GUID_NULL /* typeid */
2759 { /* 0x57 */
2760 &FOLDERID_PublicDownloads,
2761 CSIDL_Type_AllUsers,
2762 NULL,
2763 DownloadsW,
2765 KF_CATEGORY_COMMON, /* category */
2766 CommonDownloadsW, /* name */
2767 NULL, /* description */
2768 &FOLDERID_Public, /* parent */
2769 DownloadsW, /* relative path */
2770 NULL, /* parsing */
2771 NULL, /* tooltip */
2772 NULL, /* localized */
2773 NULL, /* icon */
2774 NULL, /* security */
2775 FILE_ATTRIBUTE_READONLY, /* attributes */
2776 KFDF_PRECREATE, /* flags */
2777 &GUID_NULL /* typeid */
2779 { /* 0x58 */
2780 &FOLDERID_PublicGameTasks,
2781 CSIDL_Type_ProgramData,
2782 NULL,
2783 Microsoft_Windows_GameExplorerW,
2785 KF_CATEGORY_COMMON, /* category */
2786 PublicGameTasksW, /* name */
2787 NULL, /* description */
2788 &FOLDERID_ProgramData, /* parent */
2789 Microsoft_Windows_GameExplorerW, /* relative path */
2790 NULL, /* parsing */
2791 NULL, /* tooltip */
2792 NULL, /* localized */
2793 NULL, /* icon */
2794 NULL, /* security */
2795 0, /* attributes */
2796 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2797 &GUID_NULL /* typeid */
2799 { /* 0x59 */
2800 &FOLDERID_PublicLibraries,
2801 CSIDL_Type_AllUsers,
2802 NULL,
2803 Microsoft_Windows_LibrariesW,
2805 KF_CATEGORY_COMMON, /* category */
2806 PublicLibrariesW, /* name */
2807 NULL, /* description */
2808 &FOLDERID_Public, /* parent */
2809 LibrariesW, /* relative path */
2810 NULL, /* parsing */
2811 NULL, /* tooltip */
2812 NULL, /* localized */
2813 NULL, /* icon */
2814 NULL, /* security */
2815 FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN, /* attributes */
2816 KFDF_PRECREATE, /* flags */
2817 &GUID_NULL /* typeid */
2819 { /* 0x5a */
2820 &FOLDERID_PublicRingtones,
2821 CSIDL_Type_ProgramData,
2822 NULL,
2823 Microsoft_Windows_RingtonesW,
2825 KF_CATEGORY_COMMON, /* category */
2826 CommonRingtonesW, /* name */
2827 NULL, /* description */
2828 &FOLDERID_ProgramData, /* parent */
2829 Microsoft_Windows_RingtonesW, /* relative path */
2830 NULL, /* parsing */
2831 NULL, /* tooltip */
2832 NULL, /* localized */
2833 NULL, /* icon */
2834 NULL, /* security */
2835 0, /* attributes */
2836 KFDF_PRECREATE, /* flags */
2837 &GUID_NULL /* typeid */
2839 { /* 0x5b */
2840 &FOLDERID_QuickLaunch,
2841 CSIDL_Type_Disallowed, /* FIXME */
2842 NULL,
2843 NULL,
2845 KF_CATEGORY_PERUSER, /* category */
2846 Quick_LaunchW, /* name */
2847 NULL, /* description */
2848 &FOLDERID_RoamingAppData, /* parent */
2849 Microsoft_Internet_Explorer_Quick_LaunchW, /* relative path */
2850 NULL, /* parsing */
2851 NULL, /* tooltip */
2852 NULL, /* localized */
2853 NULL, /* icon */
2854 NULL, /* security */
2855 0, /* attributes */
2856 0, /* flags */
2857 &GUID_NULL /* typeid */
2859 { /* 0x5c */
2860 &FOLDERID_RecordedTVLibrary,
2861 CSIDL_Type_Disallowed, /* FIXME */
2862 NULL,
2863 NULL,
2865 KF_CATEGORY_COMMON, /* category */
2866 RecordedTVLibraryW, /* name */
2867 NULL, /* description */
2868 &FOLDERID_PublicLibraries, /* parent */
2869 RecordedTV_librarymsW, /* relative path */
2870 NULL, /* parsing */
2871 NULL, /* tooltip */
2872 NULL, /* localized */
2873 NULL, /* icon */
2874 NULL, /* security */
2875 0, /* attributes */
2876 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2877 &GUID_NULL /* typeid */
2879 { /* 0x5d */
2880 &FOLDERID_Ringtones,
2881 CSIDL_Type_Disallowed, /* FIXME */
2882 NULL,
2883 NULL,
2885 KF_CATEGORY_PERUSER, /* category */
2886 RingtonesW, /* name */
2887 NULL, /* description */
2888 &FOLDERID_LocalAppData, /* parent */
2889 Microsoft_Windows_RingtonesW, /* relative path */
2890 NULL, /* parsing */
2891 NULL, /* tooltip */
2892 NULL, /* localized */
2893 NULL, /* icon */
2894 NULL, /* security */
2895 0, /* attributes */
2896 KFDF_PRECREATE, /* flags */
2897 &GUID_NULL /* typeid */
2899 { /* 0x5e */
2900 &FOLDERID_SampleMusic,
2901 CSIDL_Type_AllUsers,
2902 NULL,
2903 Music_Sample_MusicW,
2905 KF_CATEGORY_COMMON, /* category */
2906 SampleMusicW, /* name */
2907 NULL, /* description */
2908 &FOLDERID_PublicMusic, /* parent */
2909 Sample_MusicW, /* relative path */
2910 NULL, /* parsing */
2911 NULL, /* tooltip */
2912 NULL, /* localized */
2913 NULL, /* icon */
2914 NULL, /* security */
2915 FILE_ATTRIBUTE_READONLY, /* attributes */
2916 KFDF_PRECREATE, /* flags */
2917 &GUID_NULL /* typeid */
2919 { /* 0x5f */
2920 &FOLDERID_SamplePictures,
2921 CSIDL_Type_AllUsers,
2922 NULL,
2923 Pictures_Sample_PicturesW,
2925 KF_CATEGORY_COMMON, /* category */
2926 SamplePicturesW, /* name */
2927 NULL, /* description */
2928 &FOLDERID_PublicPictures, /* parent */
2929 Sample_PicturesW, /* relative path */
2930 NULL, /* parsing */
2931 NULL, /* tooltip */
2932 NULL, /* localized */
2933 NULL, /* icon */
2934 NULL, /* security */
2935 FILE_ATTRIBUTE_READONLY, /* attributes */
2936 KFDF_PRECREATE, /* flags */
2937 &GUID_NULL /* typeid */
2939 { /* 0x60 */
2940 &FOLDERID_SamplePlaylists,
2941 CSIDL_Type_AllUsers,
2942 NULL,
2943 Music_Sample_PlaylistsW,
2945 KF_CATEGORY_COMMON, /* category */
2946 SamplePlaylistsW, /* name */
2947 NULL, /* description */
2948 &FOLDERID_PublicMusic, /* parent */
2949 Sample_PlaylistsW, /* relative path */
2950 NULL, /* parsing */
2951 NULL, /* tooltip */
2952 NULL, /* localized */
2953 NULL, /* icon */
2954 NULL, /* security */
2955 FILE_ATTRIBUTE_READONLY, /* attributes */
2956 KFDF_PRECREATE, /* flags */
2957 &GUID_NULL /* typeid */
2959 { /* 0x61 */
2960 &FOLDERID_SampleVideos,
2961 CSIDL_Type_AllUsers,
2962 NULL,
2963 Videos_Sample_VideosW,
2965 KF_CATEGORY_COMMON, /* category */
2966 SampleVideosW, /* name */
2967 NULL, /* description */
2968 &FOLDERID_PublicVideos, /* parent */
2969 Sample_VideosW, /* relative path */
2970 NULL, /* parsing */
2971 NULL, /* tooltip */
2972 NULL, /* localized */
2973 NULL, /* icon */
2974 NULL, /* security */
2975 FILE_ATTRIBUTE_READONLY, /* attributes */
2976 KFDF_PRECREATE, /* flags */
2977 &GUID_NULL /* typeid */
2979 { /* 0x62 - CSIDL_SAVED_GAMES */
2980 &FOLDERID_SavedGames,
2981 CSIDL_Type_User,
2982 NULL,
2983 Saved_GamesW,
2985 KF_CATEGORY_PERUSER, /* category */
2986 SavedGamesW, /* name */
2987 NULL, /* description */
2988 &FOLDERID_Profile, /* parent */
2989 Saved_GamesW, /* relative path */
2990 SavedGamesParsingNameW, /* parsing */
2991 NULL, /* tooltip */
2992 NULL, /* localized */
2993 NULL, /* icon */
2994 NULL, /* security */
2995 FILE_ATTRIBUTE_READONLY, /* attributes */
2996 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2997 &GUID_NULL /* typeid */
2999 { /* 0x63 - CSIDL_SEARCHES */
3000 &FOLDERID_SavedSearches,
3001 CSIDL_Type_User,
3002 NULL,
3003 SearchesW,
3005 KF_CATEGORY_PERUSER, /* category */
3006 SearchesW, /* name */
3007 NULL, /* description */
3008 &FOLDERID_Profile, /* parent */
3009 SearchesW, /* relative path */
3010 SavedSearchesParsingNameW, /* parsing */
3011 NULL, /* tooltip */
3012 NULL, /* localized */
3013 NULL, /* icon */
3014 NULL, /* security */
3015 FILE_ATTRIBUTE_READONLY, /* attributes */
3016 KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
3017 &GUID_NULL /* typeid */
3019 { /* 0x64 */
3020 &FOLDERID_SEARCH_CSC,
3021 CSIDL_Type_Disallowed,
3022 NULL,
3023 NULL,
3025 KF_CATEGORY_VIRTUAL, /* category */
3026 CSCFolderW, /* name */
3027 NULL, /* description */
3028 &GUID_NULL, /* parent */
3029 NULL, /* relative path */
3030 SEARCH_CSCParsingNameW, /* parsing */
3031 NULL, /* tooltip */
3032 NULL, /* localized */
3033 NULL, /* icon */
3034 NULL, /* security */
3035 0, /* attributes */
3036 0, /* flags */
3037 &GUID_NULL /* typeid */
3039 { /* 0x65 */
3040 &FOLDERID_SEARCH_MAPI,
3041 CSIDL_Type_Disallowed,
3042 NULL,
3043 NULL,
3045 KF_CATEGORY_VIRTUAL, /* category */
3046 MAPIFolderW, /* name */
3047 NULL, /* description */
3048 &GUID_NULL, /* parent */
3049 NULL, /* relative path */
3050 SEARCH_MAPIParsingNameW, /* parsing */
3051 NULL, /* tooltip */
3052 NULL, /* localized */
3053 NULL, /* icon */
3054 NULL, /* security */
3055 0, /* attributes */
3056 0, /* flags */
3057 &GUID_NULL /* typeid */
3059 { /* 0x66 */
3060 &FOLDERID_SearchHome,
3061 CSIDL_Type_Disallowed,
3062 NULL,
3063 NULL,
3065 KF_CATEGORY_VIRTUAL, /* category */
3066 SearchHomeFolderW, /* name */
3067 NULL, /* description */
3068 &GUID_NULL, /* parent */
3069 NULL, /* relative path */
3070 SearchHomeParsingNameW, /* parsing */
3071 NULL, /* tooltip */
3072 NULL, /* localized */
3073 NULL, /* icon */
3074 NULL, /* security */
3075 0, /* attributes */
3076 0, /* flags */
3077 &GUID_NULL /* typeid */
3079 { /* 0x67 */
3080 &FOLDERID_SidebarDefaultParts,
3081 CSIDL_Type_Disallowed, /* FIXME */
3082 NULL,
3083 NULL,
3085 KF_CATEGORY_COMMON, /* category */
3086 Default_GadgetsW, /* name */
3087 NULL, /* description */
3088 &FOLDERID_ProgramFiles, /* parent */
3089 Windows_Sidebar_GadgetsW, /* relative path */
3090 NULL, /* parsing */
3091 NULL, /* tooltip */
3092 NULL, /* localized */
3093 NULL, /* icon */
3094 NULL, /* security */
3095 0, /* attributes */
3096 0, /* flags */
3097 &GUID_NULL /* typeid */
3099 { /* 0x68 */
3100 &FOLDERID_SidebarParts,
3101 CSIDL_Type_Disallowed, /* FIXME */
3102 NULL,
3103 NULL,
3105 KF_CATEGORY_PERUSER, /* category */
3106 GadgetsW, /* name */
3107 NULL, /* description */
3108 &FOLDERID_LocalAppData, /* parent */
3109 Microsoft_Windows_Sidebar_GadgetsW, /* relative path */
3110 NULL, /* parsing */
3111 NULL, /* tooltip */
3112 NULL, /* localized */
3113 NULL, /* icon */
3114 NULL, /* security */
3115 0, /* attributes */
3116 0, /* flags */
3117 &GUID_NULL /* typeid */
3119 { /* 0x69 */
3120 &FOLDERID_SyncManagerFolder,
3121 CSIDL_Type_Disallowed,
3122 NULL,
3123 NULL,
3125 KF_CATEGORY_VIRTUAL, /* category */
3126 SyncCenterFolderW, /* name */
3127 NULL, /* description */
3128 &GUID_NULL, /* parent */
3129 NULL, /* relative path */
3130 SyncManagerFolderParsingNameW, /* parsing */
3131 NULL, /* tooltip */
3132 NULL, /* localized */
3133 NULL, /* icon */
3134 NULL, /* security */
3135 0, /* attributes */
3136 0, /* flags */
3137 &GUID_NULL /* typeid */
3139 { /* 0x6a */
3140 &FOLDERID_SyncResultsFolder,
3141 CSIDL_Type_Disallowed,
3142 NULL,
3143 NULL,
3145 KF_CATEGORY_VIRTUAL, /* category */
3146 SyncResultsFolderW, /* name */
3147 NULL, /* description */
3148 &GUID_NULL, /* parent */
3149 NULL, /* relative path */
3150 SyncResultsFolderParsingNameW, /* parsing */
3151 NULL, /* tooltip */
3152 NULL, /* localized */
3153 NULL, /* icon */
3154 NULL, /* security */
3155 0, /* attributes */
3156 0, /* flags */
3157 &GUID_NULL /* typeid */
3159 { /* 0x6b */
3160 &FOLDERID_SyncSetupFolder,
3161 CSIDL_Type_Disallowed,
3162 NULL,
3163 NULL,
3165 KF_CATEGORY_VIRTUAL, /* category */
3166 SyncSetupFolderW, /* name */
3167 NULL, /* description */
3168 &GUID_NULL, /* parent */
3169 NULL, /* relative path */
3170 SyncSetupFolderParsingNameW, /* parsing */
3171 NULL, /* tooltip */
3172 NULL, /* localized */
3173 NULL, /* icon */
3174 NULL, /* security */
3175 0, /* attributes */
3176 0, /* flags */
3177 &GUID_NULL /* typeid */
3179 { /* 0x6c */
3180 &FOLDERID_UserPinned,
3181 CSIDL_Type_Disallowed, /* FIXME */
3182 NULL,
3183 NULL,
3185 KF_CATEGORY_PERUSER, /* category */
3186 User_PinnedW, /* name */
3187 NULL, /* description */
3188 &FOLDERID_QuickLaunch, /* parent */
3189 User_PinnedW, /* relative path */
3190 NULL, /* parsing */
3191 NULL, /* tooltip */
3192 NULL, /* localized */
3193 NULL, /* icon */
3194 NULL, /* security */
3195 FILE_ATTRIBUTE_HIDDEN, /* attributes */
3196 KFDF_PRECREATE, /* flags */
3197 &GUID_NULL /* typeid */
3199 { /* 0x6d */
3200 &FOLDERID_UserProfiles,
3201 CSIDL_Type_CurrVer,
3202 UsersW,
3203 UsersW,
3205 KF_CATEGORY_FIXED, /* category */
3206 UserProfilesW, /* name */
3207 NULL, /* description */
3208 &GUID_NULL, /* parent */
3209 NULL, /* relative path */
3210 NULL, /* parsing */
3211 NULL, /* tooltip */
3212 NULL, /* localized */
3213 NULL, /* icon */
3214 NULL, /* security */
3215 FILE_ATTRIBUTE_READONLY, /* attributes */
3216 KFDF_PRECREATE, /* flags */
3217 &GUID_NULL /* typeid */
3219 { /* 0x6e */
3220 &FOLDERID_UserProgramFiles,
3221 CSIDL_Type_Disallowed, /* FIXME */
3222 NULL,
3223 NULL,
3225 KF_CATEGORY_PERUSER, /* category */
3226 UserProgramFilesW, /* name */
3227 NULL, /* description */
3228 &FOLDERID_LocalAppData, /* parent */
3229 ProgramsW, /* relative path */
3230 NULL, /* parsing */
3231 NULL, /* tooltip */
3232 NULL, /* localized */
3233 NULL, /* icon */
3234 NULL, /* security */
3235 0, /* attributes */
3236 0, /* flags */
3237 &GUID_NULL /* typeid */
3239 { /* 0x6f */
3240 &FOLDERID_UserProgramFilesCommon,
3241 CSIDL_Type_Disallowed, /* FIXME */
3242 NULL,
3243 NULL,
3245 KF_CATEGORY_PERUSER, /* category */
3246 UserProgramFilesCommonW, /* name */
3247 NULL, /* description */
3248 &FOLDERID_UserProgramFiles, /* parent */
3249 CommonW, /* relative path */
3250 NULL, /* parsing */
3251 NULL, /* tooltip */
3252 NULL, /* localized */
3253 NULL, /* icon */
3254 NULL, /* security */
3255 0, /* attributes */
3256 0, /* flags */
3257 &GUID_NULL /* typeid */
3259 { /* 0x70 */
3260 &FOLDERID_UsersFiles,
3261 CSIDL_Type_Disallowed,
3262 NULL,
3263 NULL,
3265 KF_CATEGORY_VIRTUAL, /* category */
3266 UsersFilesFolderW, /* name */
3267 NULL, /* description */
3268 &GUID_NULL, /* parent */
3269 NULL, /* relative path */
3270 UsersFilesParsingNameW, /* parsing */
3271 NULL, /* tooltip */
3272 NULL, /* localized */
3273 NULL, /* icon */
3274 NULL, /* security */
3275 0, /* attributes */
3276 0, /* flags */
3277 &GUID_NULL /* typeid */
3279 { /* 0x71 */
3280 &FOLDERID_UsersLibraries,
3281 CSIDL_Type_Disallowed,
3282 NULL,
3283 NULL,
3285 KF_CATEGORY_VIRTUAL, /* category */
3286 UsersLibrariesFolderW, /* name */
3287 NULL, /* description */
3288 &GUID_NULL, /* parent */
3289 NULL, /* relative path */
3290 UsersLibrariesParsingNameW, /* parsing */
3291 NULL, /* tooltip */
3292 NULL, /* localized */
3293 NULL, /* icon */
3294 NULL, /* security */
3295 0, /* attributes */
3296 0, /* flags */
3297 &GUID_NULL /* typeid */
3299 { /* 0x72 */
3300 &FOLDERID_VideosLibrary,
3301 CSIDL_Type_Disallowed, /* FIXME */
3302 NULL,
3303 NULL,
3305 KF_CATEGORY_PERUSER, /* category */
3306 VideosLibraryW, /* name */
3307 NULL, /* description */
3308 &GUID_NULL, /* parent */
3309 Videos_librarymsW, /* relative path */
3310 VideosLibraryParsingNameW, /* parsing */
3311 NULL, /* tooltip */
3312 NULL, /* localized */
3313 NULL, /* icon */
3314 NULL, /* security */
3315 0, /* attributes */
3316 0, /* flags */
3317 &GUID_NULL /* typeid */
3321 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest);
3323 /* Gets the value named value from the registry key
3324 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3325 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3326 * is assumed to be MAX_PATH WCHARs in length.
3327 * If it exists, expands the value and writes the expanded value to
3328 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3329 * Returns successful error code if the value was retrieved from the registry,
3330 * and a failure otherwise.
3332 static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
3333 LPCWSTR value, LPWSTR path)
3335 HRESULT hr;
3336 WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
3337 LPCWSTR pShellFolderPath, pUserShellFolderPath;
3338 HKEY userShellFolderKey, shellFolderKey;
3339 DWORD dwType, dwPathLen;
3341 TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
3342 path);
3344 if (userPrefix)
3346 strcpyW(shellFolderPath, userPrefix);
3347 PathAddBackslashW(shellFolderPath);
3348 strcatW(shellFolderPath, szSHFolders);
3349 pShellFolderPath = shellFolderPath;
3350 strcpyW(userShellFolderPath, userPrefix);
3351 PathAddBackslashW(userShellFolderPath);
3352 strcatW(userShellFolderPath, szSHUserFolders);
3353 pUserShellFolderPath = userShellFolderPath;
3355 else
3357 pUserShellFolderPath = szSHUserFolders;
3358 pShellFolderPath = szSHFolders;
3361 if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
3363 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
3364 return E_FAIL;
3366 if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
3368 TRACE("Failed to create %s\n",
3369 debugstr_w(pUserShellFolderPath));
3370 RegCloseKey(shellFolderKey);
3371 return E_FAIL;
3374 dwPathLen = MAX_PATH * sizeof(WCHAR);
3375 if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
3376 (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
3378 LONG ret;
3380 path[dwPathLen / sizeof(WCHAR)] = '\0';
3381 if (dwType == REG_EXPAND_SZ && path[0] == '%')
3383 WCHAR szTemp[MAX_PATH];
3385 _SHExpandEnvironmentStrings(path, szTemp);
3386 lstrcpynW(path, szTemp, MAX_PATH);
3388 ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
3389 (strlenW(path) + 1) * sizeof(WCHAR));
3390 if (ret != ERROR_SUCCESS)
3391 hr = HRESULT_FROM_WIN32(ret);
3392 else
3393 hr = S_OK;
3395 else
3396 hr = E_FAIL;
3397 RegCloseKey(shellFolderKey);
3398 RegCloseKey(userShellFolderKey);
3399 TRACE("returning 0x%08x\n", hr);
3400 return hr;
3403 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3404 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3405 * - The entry's szDefaultPath may be either a string value or an integer
3406 * resource identifier. In the latter case, the string value of the resource
3407 * is written.
3408 * - Depending on the entry's type, the path may begin with an (unexpanded)
3409 * environment variable name. The caller is responsible for expanding
3410 * environment strings if so desired.
3411 * The types that are prepended with environment variables are:
3412 * CSIDL_Type_User: %USERPROFILE%
3413 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3414 * CSIDL_Type_CurrVer: %SystemDrive%
3415 * (Others might make sense too, but as yet are unneeded.)
3417 static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
3419 HRESULT hr;
3420 WCHAR resourcePath[MAX_PATH];
3421 LPCWSTR pDefaultPath = NULL;
3423 TRACE("0x%02x,%p\n", folder, pszPath);
3425 if (folder >= ARRAY_SIZE(CSIDL_Data))
3426 return E_INVALIDARG;
3428 if (!pszPath)
3429 return E_INVALIDARG;
3431 if (!is_win64)
3433 BOOL is_wow64;
3435 switch (folder)
3437 case CSIDL_PROGRAM_FILES:
3438 case CSIDL_PROGRAM_FILESX86:
3439 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3440 folder = is_wow64 ? CSIDL_PROGRAM_FILESX86 : CSIDL_PROGRAM_FILES;
3441 break;
3442 case CSIDL_PROGRAM_FILES_COMMON:
3443 case CSIDL_PROGRAM_FILES_COMMONX86:
3444 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3445 folder = is_wow64 ? CSIDL_PROGRAM_FILES_COMMONX86 : CSIDL_PROGRAM_FILES_COMMON;
3446 break;
3450 if (CSIDL_Data[folder].szDefaultPath &&
3451 IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
3453 if (LoadStringW(shell32_hInstance,
3454 LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
3456 hr = S_OK;
3457 pDefaultPath = resourcePath;
3459 else
3461 FIXME("(%d,%s), LoadString failed, missing translation?\n", folder,
3462 debugstr_w(pszPath));
3463 hr = E_FAIL;
3466 else
3468 hr = S_OK;
3469 pDefaultPath = CSIDL_Data[folder].szDefaultPath;
3471 if (SUCCEEDED(hr))
3473 switch (CSIDL_Data[folder].type)
3475 case CSIDL_Type_User:
3476 strcpyW(pszPath, UserProfileW);
3477 break;
3478 case CSIDL_Type_AllUsers:
3479 strcpyW(pszPath, AllUsersProfileW);
3480 break;
3481 case CSIDL_Type_ProgramData:
3482 strcpyW(pszPath, ProgramDataVarW);
3483 break;
3484 case CSIDL_Type_CurrVer:
3485 strcpyW(pszPath, SystemDriveW);
3486 break;
3487 default:
3488 ; /* no corresponding env. var, do nothing */
3490 if (pDefaultPath)
3492 PathAddBackslashW(pszPath);
3493 strcatW(pszPath, pDefaultPath);
3496 TRACE("returning 0x%08x\n", hr);
3497 return hr;
3500 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3501 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3502 * can be overridden in the HKLM\\szCurrentVersion key.
3503 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3504 * the registry, uses _SHGetDefaultValue to get the value.
3506 static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder,
3507 LPWSTR pszPath)
3509 HRESULT hr;
3511 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
3513 if (folder >= ARRAY_SIZE(CSIDL_Data))
3514 return E_INVALIDARG;
3515 if (CSIDL_Data[folder].type != CSIDL_Type_CurrVer)
3516 return E_INVALIDARG;
3517 if (!pszPath)
3518 return E_INVALIDARG;
3520 if (dwFlags & SHGFP_TYPE_DEFAULT)
3521 hr = _SHGetDefaultValue(folder, pszPath);
3522 else
3524 HKEY hKey;
3526 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, szCurrentVersion, &hKey))
3527 hr = E_FAIL;
3528 else
3530 DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
3532 if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
3533 &dwType, (LPBYTE)pszPath, &dwPathLen) ||
3534 (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
3536 hr = _SHGetDefaultValue(folder, pszPath);
3537 dwType = REG_EXPAND_SZ;
3538 switch (folder)
3540 case CSIDL_PROGRAM_FILESX86:
3541 case CSIDL_PROGRAM_FILES_COMMONX86:
3542 /* these two should never be set on 32-bit setups */
3543 if (!is_win64)
3545 BOOL is_wow64;
3546 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3547 if (!is_wow64) break;
3549 /* fall through */
3550 default:
3551 RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
3552 (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
3555 else
3557 pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
3558 hr = S_OK;
3560 RegCloseKey(hKey);
3563 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3564 return hr;
3567 static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
3569 char InfoBuffer[64];
3570 PTOKEN_USER UserInfo;
3571 DWORD InfoSize;
3572 LPWSTR SidStr;
3574 UserInfo = (PTOKEN_USER) InfoBuffer;
3575 if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
3576 &InfoSize))
3578 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
3579 return NULL;
3580 UserInfo = heap_alloc(InfoSize);
3581 if (UserInfo == NULL)
3582 return NULL;
3583 if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
3584 &InfoSize))
3586 heap_free(UserInfo);
3587 return NULL;
3591 if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
3592 SidStr = NULL;
3594 if (UserInfo != (PTOKEN_USER) InfoBuffer)
3595 heap_free(UserInfo);
3597 return SidStr;
3600 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3601 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3602 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3603 * - if hToken is -1, looks in HKEY_USERS\.Default
3604 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3605 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3606 * calls _SHGetDefaultValue for it.
3608 static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder,
3609 LPWSTR pszPath)
3611 const WCHAR *szValueName;
3612 WCHAR buffer[40];
3613 HRESULT hr;
3615 TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
3617 if (folder >= ARRAY_SIZE(CSIDL_Data))
3618 return E_INVALIDARG;
3619 if (CSIDL_Data[folder].type != CSIDL_Type_User)
3620 return E_INVALIDARG;
3621 if (!pszPath)
3622 return E_INVALIDARG;
3624 if (dwFlags & SHGFP_TYPE_DEFAULT)
3626 if (hToken != NULL && hToken != (HANDLE)-1)
3628 FIXME("unsupported for user other than current or default\n");
3629 return E_FAIL;
3631 hr = _SHGetDefaultValue(folder, pszPath);
3633 else
3635 LPCWSTR userPrefix = NULL;
3636 HKEY hRootKey;
3638 if (hToken == (HANDLE)-1)
3640 hRootKey = HKEY_USERS;
3641 userPrefix = DefaultW;
3643 else if (hToken == NULL)
3644 hRootKey = HKEY_CURRENT_USER;
3645 else
3647 hRootKey = HKEY_USERS;
3648 userPrefix = _GetUserSidStringFromToken(hToken);
3649 if (userPrefix == NULL)
3651 hr = E_FAIL;
3652 goto error;
3656 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3657 szValueName = CSIDL_Data[folder].szValueName;
3658 if (!szValueName)
3660 StringFromGUID2( CSIDL_Data[folder].id, buffer, 39 );
3661 szValueName = &buffer[0];
3664 hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
3665 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
3666 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
3667 if (FAILED(hr))
3668 hr = _SHGetDefaultValue(folder, pszPath);
3669 if (userPrefix != NULL && userPrefix != DefaultW)
3670 LocalFree((HLOCAL) userPrefix);
3672 error:
3673 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3674 return hr;
3677 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3678 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3679 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3680 * If this fails, falls back to _SHGetDefaultValue.
3682 static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder,
3683 LPWSTR pszPath)
3685 HRESULT hr;
3687 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
3689 if (folder >= ARRAY_SIZE(CSIDL_Data))
3690 return E_INVALIDARG;
3691 if (CSIDL_Data[folder].type != CSIDL_Type_AllUsers && CSIDL_Data[folder].type != CSIDL_Type_ProgramData)
3692 return E_INVALIDARG;
3693 if (!pszPath)
3694 return E_INVALIDARG;
3696 if (dwFlags & SHGFP_TYPE_DEFAULT)
3697 hr = _SHGetDefaultValue(folder, pszPath);
3698 else
3700 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL,
3701 CSIDL_Data[folder].szValueName, pszPath);
3702 if (FAILED(hr))
3703 hr = _SHGetDefaultValue(folder, pszPath);
3705 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3706 return hr;
3709 static HRESULT _SHOpenProfilesKey(PHKEY pKey)
3711 LONG lRet;
3712 DWORD disp;
3714 lRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ProfileListW, 0, NULL, 0,
3715 KEY_ALL_ACCESS, NULL, pKey, &disp);
3716 return HRESULT_FROM_WIN32(lRet);
3719 /* Reads the value named szValueName from the key profilesKey (assumed to be
3720 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3721 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3722 * szDefault to the registry).
3724 static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName,
3725 LPWSTR szValue, LPCWSTR szDefault)
3727 HRESULT hr;
3728 DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
3729 LONG lRet;
3731 TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
3732 debugstr_w(szDefault));
3733 lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
3734 (LPBYTE)szValue, &dwPathLen);
3735 if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
3736 && *szValue)
3738 dwPathLen /= sizeof(WCHAR);
3739 szValue[dwPathLen] = '\0';
3740 hr = S_OK;
3742 else
3744 /* Missing or invalid value, set a default */
3745 lstrcpynW(szValue, szDefault, MAX_PATH);
3746 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
3747 debugstr_w(szValue));
3748 lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
3749 (LPBYTE)szValue,
3750 (strlenW(szValue) + 1) * sizeof(WCHAR));
3751 if (lRet)
3752 hr = HRESULT_FROM_WIN32(lRet);
3753 else
3754 hr = S_OK;
3756 TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
3757 return hr;
3760 /* Attempts to expand environment variables from szSrc into szDest, which is
3761 * assumed to be MAX_PATH characters in length. Before referring to the
3762 * environment, handles a few variables directly, because the environment
3763 * variables may not be set when this is called (as during Wine's installation
3764 * when default values are being written to the registry).
3765 * The directly handled environment variables, and their source, are:
3766 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3767 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3768 * path
3769 * If one of the directly handled environment variables is expanded, only
3770 * expands a single variable, and only in the beginning of szSrc.
3772 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
3774 HRESULT hr;
3775 WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
3776 HKEY key = NULL;
3778 TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
3780 if (!szSrc || !szDest) return E_INVALIDARG;
3782 /* short-circuit if there's nothing to expand */
3783 if (szSrc[0] != '%')
3785 strcpyW(szDest, szSrc);
3786 hr = S_OK;
3787 goto end;
3789 /* Get the profile prefix, we'll probably be needing it */
3790 hr = _SHOpenProfilesKey(&key);
3791 if (SUCCEEDED(hr))
3793 WCHAR def_val[MAX_PATH];
3795 /* get the system drive */
3796 GetSystemDirectoryW(def_val, MAX_PATH);
3797 if (def_val[1] == ':') strcpyW( def_val + 3, szDefaultProfileDirW );
3798 else FIXME("non-drive system paths unsupported\n");
3800 hr = _SHGetProfilesValue(key, ProfilesDirectoryW, szProfilesPrefix, def_val );
3803 *szDest = 0;
3804 strcpyW(szTemp, szSrc);
3805 while (SUCCEEDED(hr) && szTemp[0] == '%')
3807 if (!strncmpiW(szTemp, AllUsersProfileW, strlenW(AllUsersProfileW)))
3809 WCHAR szAllUsers[MAX_PATH];
3811 strcpyW(szDest, szProfilesPrefix);
3812 hr = _SHGetProfilesValue(key, AllUsersProfileValueW,
3813 szAllUsers, AllUsersW);
3814 PathAppendW(szDest, szAllUsers);
3815 PathAppendW(szDest, szTemp + strlenW(AllUsersProfileW));
3817 else if (!strncmpiW(szTemp, ProgramDataVarW, strlenW(ProgramDataVarW)))
3819 WCHAR szProgramData[MAX_PATH], def_val[MAX_PATH];
3820 HKEY shellFolderKey;
3821 DWORD dwType, dwPathLen = sizeof(def_val);
3822 BOOL in_registry = FALSE;
3824 if (!RegCreateKeyW(HKEY_LOCAL_MACHINE, szSHFolders, &shellFolderKey))
3826 if (!RegQueryValueExW(shellFolderKey, Common_AppDataW, NULL, &dwType,
3827 (LPBYTE)def_val, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
3828 in_registry = TRUE;
3830 RegCloseKey(shellFolderKey);
3833 if (!in_registry)
3835 GetSystemDirectoryW(def_val, MAX_PATH);
3836 if (def_val[1] == ':') strcpyW( def_val + 3, ProgramDataW );
3837 else FIXME("non-drive system paths unsupported\n");
3840 hr = _SHGetProfilesValue(key, ProgramDataW, szProgramData, def_val);
3841 PathAppendW(szDest, szProgramData);
3842 PathAppendW(szDest, szTemp + strlenW(ProgramDataVarW));
3844 else if (!strncmpiW(szTemp, UserProfileW, strlenW(UserProfileW)))
3846 WCHAR userName[MAX_PATH];
3847 DWORD userLen = MAX_PATH;
3849 strcpyW(szDest, szProfilesPrefix);
3850 GetUserNameW(userName, &userLen);
3851 PathAppendW(szDest, userName);
3852 PathAppendW(szDest, szTemp + strlenW(UserProfileW));
3854 else if (!strncmpiW(szTemp, SystemDriveW, strlenW(SystemDriveW)))
3856 GetSystemDirectoryW(szDest, MAX_PATH);
3857 if (szDest[1] != ':')
3859 FIXME("non-drive system paths unsupported\n");
3860 hr = E_FAIL;
3862 else
3864 strcpyW(szDest + 3, szTemp + strlenW(SystemDriveW) + 1);
3865 hr = S_OK;
3868 else
3870 DWORD ret = ExpandEnvironmentStringsW(szSrc, szDest, MAX_PATH);
3872 if (ret > MAX_PATH)
3873 hr = E_NOT_SUFFICIENT_BUFFER;
3874 else if (ret == 0)
3875 hr = HRESULT_FROM_WIN32(GetLastError());
3876 else
3877 hr = S_OK;
3879 if (SUCCEEDED(hr) && szDest[0] == '%')
3880 strcpyW(szTemp, szDest);
3881 else
3883 /* terminate loop */
3884 szTemp[0] = '\0';
3887 end:
3888 if (key)
3889 RegCloseKey(key);
3890 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
3891 debugstr_w(szSrc), debugstr_w(szDest));
3892 return hr;
3895 /*************************************************************************
3896 * SHGetFolderPathW [SHELL32.@]
3898 * Convert nFolder to path.
3900 * RETURNS
3901 * Success: S_OK
3902 * Failure: standard HRESULT error codes.
3904 * NOTES
3905 * Most values can be overridden in either
3906 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3907 * or in the same location in HKLM.
3908 * The "Shell Folders" registry key was used in NT4 and earlier systems.
3909 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
3910 * changes made to it are made to the former key too. This synchronization is
3911 * done on-demand: not until someone requests the value of one of these paths
3912 * (by calling one of the SHGet functions) is the value synchronized.
3913 * Furthermore, the HKCU paths take precedence over the HKLM paths.
3915 HRESULT WINAPI SHGetFolderPathW(
3916 HWND hwndOwner, /* [I] owner window */
3917 int nFolder, /* [I] CSIDL identifying the folder */
3918 HANDLE hToken, /* [I] access token */
3919 DWORD dwFlags, /* [I] which path to return */
3920 LPWSTR pszPath) /* [O] converted path */
3922 HRESULT hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, NULL, pszPath);
3923 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr)
3924 hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
3925 return hr;
3928 HRESULT WINAPI SHGetFolderPathAndSubDirA(
3929 HWND hwndOwner, /* [I] owner window */
3930 int nFolder, /* [I] CSIDL identifying the folder */
3931 HANDLE hToken, /* [I] access token */
3932 DWORD dwFlags, /* [I] which path to return */
3933 LPCSTR pszSubPath, /* [I] sub directory of the specified folder */
3934 LPSTR pszPath) /* [O] converted path */
3936 int length;
3937 HRESULT hr = S_OK;
3938 LPWSTR pszSubPathW = NULL;
3939 LPWSTR pszPathW = NULL;
3941 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
3943 if(pszPath) {
3944 pszPathW = heap_alloc(MAX_PATH * sizeof(WCHAR));
3945 if(!pszPathW) {
3946 hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
3947 goto cleanup;
3950 TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
3952 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
3953 * set (null), or an empty string.therefore call it without the parameter set
3954 * if pszSubPath is an empty string
3956 if (pszSubPath && pszSubPath[0]) {
3957 length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
3958 pszSubPathW = heap_alloc(length * sizeof(WCHAR));
3959 if(!pszSubPathW) {
3960 hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
3961 goto cleanup;
3963 MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
3966 hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
3968 if (SUCCEEDED(hr) && pszPath)
3969 WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
3971 cleanup:
3972 heap_free(pszPathW);
3973 heap_free(pszSubPathW);
3974 return hr;
3977 /*************************************************************************
3978 * SHGetFolderPathAndSubDirW [SHELL32.@]
3980 HRESULT WINAPI SHGetFolderPathAndSubDirW(
3981 HWND hwndOwner, /* [I] owner window */
3982 int nFolder, /* [I] CSIDL identifying the folder */
3983 HANDLE hToken, /* [I] access token */
3984 DWORD dwFlags, /* [I] which path to return */
3985 LPCWSTR pszSubPath,/* [I] sub directory of the specified folder */
3986 LPWSTR pszPath) /* [O] converted path */
3988 HRESULT hr;
3989 WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
3990 DWORD folder = nFolder & CSIDL_FOLDER_MASK;
3991 CSIDL_Type type;
3992 int ret;
3994 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
3996 /* Windows always NULL-terminates the resulting path regardless of success
3997 * or failure, so do so first
3999 if (pszPath)
4000 *pszPath = '\0';
4002 if (folder >= ARRAY_SIZE(CSIDL_Data))
4003 return E_INVALIDARG;
4004 if ((SHGFP_TYPE_CURRENT != dwFlags) && (SHGFP_TYPE_DEFAULT != dwFlags))
4005 return E_INVALIDARG;
4006 szTemp[0] = 0;
4007 type = CSIDL_Data[folder].type;
4008 switch (type)
4010 case CSIDL_Type_Disallowed:
4011 hr = E_INVALIDARG;
4012 break;
4013 case CSIDL_Type_NonExistent:
4014 hr = S_FALSE;
4015 break;
4016 case CSIDL_Type_WindowsPath:
4017 GetWindowsDirectoryW(szTemp, MAX_PATH);
4018 if (CSIDL_Data[folder].szDefaultPath &&
4019 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4020 *CSIDL_Data[folder].szDefaultPath)
4022 PathAddBackslashW(szTemp);
4023 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4025 hr = S_OK;
4026 break;
4027 case CSIDL_Type_SystemPath:
4028 GetSystemDirectoryW(szTemp, MAX_PATH);
4029 if (CSIDL_Data[folder].szDefaultPath &&
4030 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4031 *CSIDL_Data[folder].szDefaultPath)
4033 PathAddBackslashW(szTemp);
4034 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4036 hr = S_OK;
4037 break;
4038 case CSIDL_Type_SystemX86Path:
4039 if (!GetSystemWow64DirectoryW(szTemp, MAX_PATH)) GetSystemDirectoryW(szTemp, MAX_PATH);
4040 if (CSIDL_Data[folder].szDefaultPath &&
4041 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4042 *CSIDL_Data[folder].szDefaultPath)
4044 PathAddBackslashW(szTemp);
4045 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4047 hr = S_OK;
4048 break;
4049 case CSIDL_Type_CurrVer:
4050 hr = _SHGetCurrentVersionPath(dwFlags, folder, szTemp);
4051 break;
4052 case CSIDL_Type_User:
4053 hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
4054 break;
4055 case CSIDL_Type_AllUsers:
4056 case CSIDL_Type_ProgramData:
4057 hr = _SHGetAllUsersProfilePath(dwFlags, folder, szTemp);
4058 break;
4059 default:
4060 FIXME("bogus type %d, please fix\n", type);
4061 hr = E_INVALIDARG;
4062 break;
4065 /* Expand environment strings if necessary */
4066 if (*szTemp == '%')
4067 hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
4068 else
4069 strcpyW(szBuildPath, szTemp);
4071 if (FAILED(hr)) goto end;
4073 if(pszSubPath) {
4074 /* make sure the new path does not exceed the buffer length
4075 * and remember to backslash and terminate it */
4076 if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
4077 hr = HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE);
4078 goto end;
4080 PathAppendW(szBuildPath, pszSubPath);
4081 PathRemoveBackslashW(szBuildPath);
4083 /* Copy the path if it's available before we might return */
4084 if (SUCCEEDED(hr) && pszPath)
4085 strcpyW(pszPath, szBuildPath);
4087 /* if we don't care about existing directories we are ready */
4088 if(nFolder & CSIDL_FLAG_DONT_VERIFY) goto end;
4090 if (PathFileExistsW(szBuildPath)) goto end;
4092 /* not existing but we are not allowed to create it. The return value
4093 * is verified against shell32 version 6.0.
4095 if (!(nFolder & CSIDL_FLAG_CREATE))
4097 hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
4098 goto end;
4101 /* create directory/directories */
4102 ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
4103 if (ret && ret != ERROR_ALREADY_EXISTS)
4105 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
4106 hr = E_FAIL;
4107 goto end;
4110 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
4111 end:
4112 TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
4113 return hr;
4116 /*************************************************************************
4117 * SHGetFolderPathA [SHELL32.@]
4119 * See SHGetFolderPathW.
4121 HRESULT WINAPI SHGetFolderPathA(
4122 HWND hwndOwner,
4123 int nFolder,
4124 HANDLE hToken,
4125 DWORD dwFlags,
4126 LPSTR pszPath)
4128 WCHAR szTemp[MAX_PATH];
4129 HRESULT hr;
4131 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
4133 if (pszPath)
4134 *pszPath = '\0';
4135 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
4136 if (SUCCEEDED(hr) && pszPath)
4137 WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
4138 NULL);
4140 return hr;
4143 /* For each folder in folders, if its value has not been set in the registry,
4144 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4145 * folder's type) to get the unexpanded value first.
4146 * Writes the unexpanded value to User Shell Folders, and queries it with
4147 * SHGetFolderPathW to force the creation of the directory if it doesn't
4148 * already exist. SHGetFolderPathW also returns the expanded value, which
4149 * this then writes to Shell Folders.
4151 static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken,
4152 LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[],
4153 UINT foldersLen)
4155 const WCHAR *szValueName;
4156 WCHAR buffer[40];
4157 UINT i;
4158 WCHAR path[MAX_PATH];
4159 HRESULT hr = S_OK;
4160 HKEY hUserKey = NULL, hKey = NULL;
4161 DWORD dwType, dwPathLen;
4162 LONG ret;
4164 TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
4165 debugstr_w(szUserShellFolderPath), folders, foldersLen);
4167 ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
4168 if (ret)
4169 hr = HRESULT_FROM_WIN32(ret);
4170 else
4172 ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
4173 if (ret)
4174 hr = HRESULT_FROM_WIN32(ret);
4176 for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
4178 dwPathLen = MAX_PATH * sizeof(WCHAR);
4180 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4181 szValueName = CSIDL_Data[folders[i]].szValueName;
4182 if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
4184 StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
4185 szValueName = &buffer[0];
4188 if (RegQueryValueExW(hUserKey, szValueName, NULL,
4189 &dwType, (LPBYTE)path, &dwPathLen) || (dwType != REG_SZ &&
4190 dwType != REG_EXPAND_SZ))
4192 *path = '\0';
4193 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
4194 _SHGetUserProfilePath(hToken, SHGFP_TYPE_DEFAULT, folders[i],
4195 path);
4196 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers ||
4197 CSIDL_Data[folders[i]].type == CSIDL_Type_ProgramData)
4198 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT, folders[i], path);
4199 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
4201 GetWindowsDirectoryW(path, MAX_PATH);
4202 if (CSIDL_Data[folders[i]].szDefaultPath &&
4203 !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
4205 PathAddBackslashW(path);
4206 strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
4209 else
4210 hr = E_FAIL;
4211 if (*path)
4213 ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
4214 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
4215 if (ret)
4216 hr = HRESULT_FROM_WIN32(ret);
4217 else
4219 hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
4220 hToken, SHGFP_TYPE_DEFAULT, path);
4221 ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
4222 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
4223 if (ret)
4224 hr = HRESULT_FROM_WIN32(ret);
4229 if (hUserKey)
4230 RegCloseKey(hUserKey);
4231 if (hKey)
4232 RegCloseKey(hKey);
4234 TRACE("returning 0x%08x\n", hr);
4235 return hr;
4238 static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
4240 static const UINT folders[] = {
4241 CSIDL_PROGRAMS,
4242 CSIDL_PERSONAL,
4243 CSIDL_FAVORITES,
4244 CSIDL_APPDATA,
4245 CSIDL_STARTUP,
4246 CSIDL_RECENT,
4247 CSIDL_SENDTO,
4248 CSIDL_STARTMENU,
4249 CSIDL_MYMUSIC,
4250 CSIDL_MYVIDEO,
4251 CSIDL_DESKTOPDIRECTORY,
4252 CSIDL_NETHOOD,
4253 CSIDL_TEMPLATES,
4254 CSIDL_PRINTHOOD,
4255 CSIDL_LOCAL_APPDATA,
4256 CSIDL_INTERNET_CACHE,
4257 CSIDL_COOKIES,
4258 CSIDL_HISTORY,
4259 CSIDL_MYPICTURES,
4260 CSIDL_FONTS,
4261 CSIDL_ADMINTOOLS,
4262 CSIDL_CONTACTS,
4263 CSIDL_DOWNLOADS,
4264 CSIDL_LINKS,
4265 CSIDL_APPDATA_LOCALLOW,
4266 CSIDL_SAVED_GAMES,
4267 CSIDL_SEARCHES
4269 WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
4270 LPCWSTR pUserShellFolderPath, pShellFolderPath;
4271 HRESULT hr = S_OK;
4272 HKEY hRootKey;
4273 HANDLE hToken;
4275 TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
4276 if (bDefault)
4278 hToken = (HANDLE)-1;
4279 hRootKey = HKEY_USERS;
4280 strcpyW(userShellFolderPath, DefaultW);
4281 PathAddBackslashW(userShellFolderPath);
4282 strcatW(userShellFolderPath, szSHUserFolders);
4283 pUserShellFolderPath = userShellFolderPath;
4284 strcpyW(shellFolderPath, DefaultW);
4285 PathAddBackslashW(shellFolderPath);
4286 strcatW(shellFolderPath, szSHFolders);
4287 pShellFolderPath = shellFolderPath;
4289 else
4291 hToken = NULL;
4292 hRootKey = HKEY_CURRENT_USER;
4293 pUserShellFolderPath = szSHUserFolders;
4294 pShellFolderPath = szSHFolders;
4297 hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
4298 pShellFolderPath, folders, ARRAY_SIZE(folders));
4299 TRACE("returning 0x%08x\n", hr);
4300 return hr;
4303 static HRESULT _SHRegisterCommonShellFolders(void)
4305 static const UINT folders[] = {
4306 CSIDL_COMMON_STARTMENU,
4307 CSIDL_COMMON_PROGRAMS,
4308 CSIDL_COMMON_STARTUP,
4309 CSIDL_COMMON_DESKTOPDIRECTORY,
4310 CSIDL_COMMON_FAVORITES,
4311 CSIDL_COMMON_APPDATA,
4312 CSIDL_COMMON_TEMPLATES,
4313 CSIDL_COMMON_DOCUMENTS,
4314 CSIDL_COMMON_ADMINTOOLS,
4315 CSIDL_COMMON_MUSIC,
4316 CSIDL_COMMON_PICTURES,
4317 CSIDL_COMMON_VIDEO,
4319 HRESULT hr;
4321 TRACE("\n");
4322 hr = _SHRegisterFolders(HKEY_LOCAL_MACHINE, NULL, szSHUserFolders,
4323 szSHFolders, folders, ARRAY_SIZE(folders));
4324 TRACE("returning 0x%08x\n", hr);
4325 return hr;
4328 /******************************************************************************
4329 * _SHAppendToUnixPath [Internal]
4331 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
4332 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
4333 * and replaces backslashes with slashes.
4335 * PARAMS
4336 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
4337 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
4339 * RETURNS
4340 * Success: TRUE,
4341 * Failure: FALSE
4343 static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
4344 WCHAR wszSubPath[MAX_PATH];
4345 int cLen = strlen(szBasePath);
4346 char *pBackslash;
4348 if (IS_INTRESOURCE(pwszSubPath)) {
4349 if (!LoadStringW(shell32_hInstance, LOWORD(pwszSubPath), wszSubPath, MAX_PATH)) {
4350 /* Fall back to hard coded defaults. */
4351 switch (LOWORD(pwszSubPath)) {
4352 case IDS_PERSONAL:
4353 lstrcpyW(wszSubPath, DocumentsW);
4354 break;
4355 case IDS_MYMUSIC:
4356 lstrcpyW(wszSubPath, My_MusicW);
4357 break;
4358 case IDS_MYPICTURES:
4359 lstrcpyW(wszSubPath, My_PicturesW);
4360 break;
4361 case IDS_MYVIDEOS:
4362 lstrcpyW(wszSubPath, My_VideosW);
4363 break;
4364 default:
4365 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath));
4366 return FALSE;
4369 } else {
4370 lstrcpyW(wszSubPath, pwszSubPath);
4373 if (szBasePath[cLen-1] != '/') szBasePath[cLen++] = '/';
4375 if (!WideCharToMultiByte(CP_UNIXCP, 0, wszSubPath, -1, szBasePath + cLen,
4376 FILENAME_MAX - cLen, NULL, NULL))
4378 return FALSE;
4381 pBackslash = szBasePath + cLen;
4382 while ((pBackslash = strchr(pBackslash, '\\'))) *pBackslash = '/';
4384 return TRUE;
4387 /******************************************************************************
4388 * _SHCreateSymbolicLinks [Internal]
4390 * Sets up symbol links for various shell folders to point into the users home
4391 * directory. We do an educated guess about what the user would probably want:
4392 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4393 * wine's 'My Documents' to point there. Furthermore, we imply that the user
4394 * is a Windows lover and has no problem with wine creating 'My Pictures',
4395 * 'My Music' and 'My Videos' subfolders under '$HOME/My Documents', if those
4396 * do not already exits. We put appropriate symbolic links in place for those,
4397 * too.
4398 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4399 * point directly to $HOME. We assume the user to be a unix hacker who does not
4400 * want wine to create anything anywhere besides the .wine directory. So, if
4401 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4402 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4403 * directory, and try to link to that. If that fails, then we symlink to
4404 * $HOME directly. The same holds fo 'My Pictures' and 'My Videos'.
4405 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4406 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4407 * it alone.
4408 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4410 static void _SHCreateSymbolicLinks(void)
4412 UINT aidsMyStuff[] = { IDS_MYPICTURES, IDS_MYVIDEOS, IDS_MYMUSIC }, i;
4413 const WCHAR* MyOSXStuffW[] = { PicturesW, MoviesW, MusicW };
4414 int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC };
4415 static const char * const xdg_dirs[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" };
4416 static const unsigned int num = ARRAY_SIZE(xdg_dirs);
4417 WCHAR wszTempPath[MAX_PATH];
4418 char szPersonalTarget[FILENAME_MAX], *pszPersonal;
4419 char szMyStuffTarget[FILENAME_MAX], *pszMyStuff;
4420 char szDesktopTarget[FILENAME_MAX], *pszDesktop;
4421 struct stat statFolder;
4422 const char *pszHome;
4423 HRESULT hr;
4424 char ** xdg_results;
4425 char * xdg_desktop_dir;
4427 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4428 hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL,
4429 SHGFP_TYPE_DEFAULT, wszTempPath);
4430 if (FAILED(hr)) return;
4431 pszPersonal = wine_get_unix_file_name(wszTempPath);
4432 if (!pszPersonal) return;
4434 hr = XDG_UserDirLookup(xdg_dirs, num, &xdg_results);
4435 if (FAILED(hr)) xdg_results = NULL;
4437 pszHome = getenv("HOME");
4438 if (pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode))
4440 while (1)
4442 /* Check if there's already a Wine-specific 'My Documents' folder */
4443 strcpy(szPersonalTarget, pszHome);
4444 if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) &&
4445 !stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
4447 /* '$HOME/My Documents' exists. Create 'My Pictures',
4448 * 'My Videos' and 'My Music' subfolders or fail silently if
4449 * they already exist.
4451 for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++)
4453 strcpy(szMyStuffTarget, szPersonalTarget);
4454 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
4455 mkdir(szMyStuffTarget, 0777);
4457 break;
4460 /* Try to point to the XDG Documents folder */
4461 if (xdg_results && xdg_results[num-2] &&
4462 !stat(xdg_results[num-2], &statFolder) &&
4463 S_ISDIR(statFolder.st_mode))
4465 strcpy(szPersonalTarget, xdg_results[num-2]);
4466 break;
4469 /* Or the hardcoded / OS X Documents folder */
4470 strcpy(szPersonalTarget, pszHome);
4471 if (_SHAppendToUnixPath(szPersonalTarget, DocumentsW) &&
4472 !stat(szPersonalTarget, &statFolder) &&
4473 S_ISDIR(statFolder.st_mode))
4474 break;
4476 /* As a last resort point to $HOME. */
4477 strcpy(szPersonalTarget, pszHome);
4478 break;
4481 /* Replace 'My Documents' directory with a symlink or fail silently if not empty. */
4482 remove(pszPersonal);
4483 symlink(szPersonalTarget, pszPersonal);
4485 else
4487 /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs
4488 * in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */
4489 pszHome = NULL;
4490 strcpy(szPersonalTarget, pszPersonal);
4491 for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) {
4492 strcpy(szMyStuffTarget, szPersonalTarget);
4493 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
4494 mkdir(szMyStuffTarget, 0777);
4498 /* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
4499 for (i=0; i < ARRAY_SIZE(aidsMyStuff); i++)
4501 /* Create the current 'My Whatever' folder and get its unix path. */
4502 hr = SHGetFolderPathW(NULL, acsidlMyStuff[i]|CSIDL_FLAG_CREATE, NULL,
4503 SHGFP_TYPE_DEFAULT, wszTempPath);
4504 if (FAILED(hr)) continue;
4506 pszMyStuff = wine_get_unix_file_name(wszTempPath);
4507 if (!pszMyStuff) continue;
4509 while (1)
4511 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4512 strcpy(szMyStuffTarget, szPersonalTarget);
4513 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])) &&
4514 !stat(szMyStuffTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
4515 break;
4517 /* Try the XDG_XXX_DIR folder */
4518 if (xdg_results && xdg_results[i])
4520 strcpy(szMyStuffTarget, xdg_results[i]);
4521 break;
4524 /* Or the OS X folder (these are never localized) */
4525 if (pszHome)
4527 strcpy(szMyStuffTarget, pszHome);
4528 if (_SHAppendToUnixPath(szMyStuffTarget, MyOSXStuffW[i]) &&
4529 !stat(szMyStuffTarget, &statFolder) &&
4530 S_ISDIR(statFolder.st_mode))
4531 break;
4534 /* As a last resort point to the same location as 'My Documents' */
4535 strcpy(szMyStuffTarget, szPersonalTarget);
4536 break;
4538 remove(pszMyStuff);
4539 symlink(szMyStuffTarget, pszMyStuff);
4540 heap_free(pszMyStuff);
4543 /* Last but not least, the Desktop folder */
4544 if (pszHome)
4545 strcpy(szDesktopTarget, pszHome);
4546 else
4547 strcpy(szDesktopTarget, pszPersonal);
4548 heap_free(pszPersonal);
4550 xdg_desktop_dir = xdg_results ? xdg_results[num - 1] : NULL;
4551 if (xdg_desktop_dir ||
4552 (_SHAppendToUnixPath(szDesktopTarget, DesktopW) &&
4553 !stat(szDesktopTarget, &statFolder) && S_ISDIR(statFolder.st_mode)))
4555 hr = SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, NULL,
4556 SHGFP_TYPE_DEFAULT, wszTempPath);
4557 if (SUCCEEDED(hr) && (pszDesktop = wine_get_unix_file_name(wszTempPath)))
4559 remove(pszDesktop);
4560 if (xdg_desktop_dir)
4561 symlink(xdg_desktop_dir, pszDesktop);
4562 else
4563 symlink(szDesktopTarget, pszDesktop);
4564 heap_free(pszDesktop);
4568 /* Free resources allocated by XDG_UserDirLookup() */
4569 if (xdg_results)
4571 for (i = 0; i < num; i++)
4572 heap_free(xdg_results[i]);
4573 heap_free(xdg_results);
4577 /******************************************************************************
4578 * create_extra_folders [Internal]
4580 * Create some extra folders that don't have a standard CSIDL definition.
4582 static HRESULT create_extra_folders(void)
4584 static const WCHAR environW[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4585 static const WCHAR microsoftW[] = {'M','i','c','r','o','s','o','f','t',0};
4586 static const WCHAR TempW[] = {'T','e','m','p',0};
4587 static const WCHAR TEMPW[] = {'T','E','M','P',0};
4588 static const WCHAR TMPW[] = {'T','M','P',0};
4589 WCHAR path[MAX_PATH+5];
4590 HRESULT hr;
4591 HKEY hkey;
4592 DWORD type, size, ret;
4594 ret = RegCreateKeyW( HKEY_CURRENT_USER, environW, &hkey );
4595 if (ret) return HRESULT_FROM_WIN32( ret );
4597 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4598 hr = SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL,
4599 SHGFP_TYPE_DEFAULT, TempW, path );
4600 if (SUCCEEDED(hr))
4602 size = sizeof(path);
4603 if (RegQueryValueExW( hkey, TEMPW, NULL, &type, (LPBYTE)path, &size ))
4604 RegSetValueExW( hkey, TEMPW, 0, REG_SZ, (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR) );
4605 size = sizeof(path);
4606 if (RegQueryValueExW( hkey, TMPW, NULL, &type, (LPBYTE)path, &size ))
4607 RegSetValueExW( hkey, TMPW, 0, REG_SZ, (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR) );
4609 RegCloseKey( hkey );
4611 if (SUCCEEDED(hr))
4613 hr = SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL,
4614 SHGFP_TYPE_DEFAULT, microsoftW, path );
4616 if (SUCCEEDED(hr))
4618 hr = SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL,
4619 SHGFP_TYPE_DEFAULT, Microsoft_Windows_ThemesW, path);
4621 return hr;
4625 /******************************************************************************
4626 * set_folder_attributes
4628 * Set the various folder attributes registry keys.
4630 static HRESULT set_folder_attributes(void)
4632 static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0 };
4633 static const WCHAR shellfolderW[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4634 static const WCHAR wfparsingW[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4635 static const WCHAR wfdisplayW[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4636 static const WCHAR hideasdeleteW[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4637 static const WCHAR cfattributesW[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4638 static const WCHAR emptyW[] = {0};
4640 static const struct
4642 const CLSID *clsid;
4643 BOOL wfparsing : 1;
4644 BOOL wfdisplay : 1;
4645 BOOL hideasdel : 1;
4646 DWORD attr;
4647 DWORD call_for_attr;
4648 } folders[] =
4650 { &CLSID_UnixFolder, TRUE, FALSE, FALSE },
4651 { &CLSID_UnixDosFolder, TRUE, FALSE, FALSE,
4652 SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER, SFGAO_FILESYSTEM },
4653 { &CLSID_FolderShortcut, FALSE, FALSE, FALSE,
4654 SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_LINK,
4655 SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR },
4656 { &CLSID_MyDocuments, TRUE, FALSE, FALSE,
4657 SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER, SFGAO_FILESYSTEM },
4658 { &CLSID_RecycleBin, FALSE, FALSE, FALSE,
4659 SFGAO_FOLDER|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET },
4660 { &CLSID_ControlPanel, FALSE, TRUE, TRUE,
4661 SFGAO_FOLDER|SFGAO_HASSUBFOLDER }
4664 unsigned int i;
4665 WCHAR buffer[39 + ARRAY_SIZE(clsidW) + ARRAY_SIZE(shellfolderW)];
4666 LONG res;
4667 HKEY hkey;
4669 for (i = 0; i < ARRAY_SIZE(folders); i++)
4671 strcpyW( buffer, clsidW );
4672 StringFromGUID2( folders[i].clsid, buffer + strlenW(buffer), 39 );
4673 strcatW( buffer, shellfolderW );
4674 res = RegCreateKeyExW( HKEY_CLASSES_ROOT, buffer, 0, NULL, 0,
4675 KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
4676 if (res) return HRESULT_FROM_WIN32( res );
4677 if (folders[i].wfparsing)
4678 res = RegSetValueExW( hkey, wfparsingW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4679 if (folders[i].wfdisplay)
4680 res = RegSetValueExW( hkey, wfdisplayW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4681 if (folders[i].hideasdel)
4682 res = RegSetValueExW( hkey, hideasdeleteW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4683 if (folders[i].attr)
4684 res = RegSetValueExW( hkey, szAttributes, 0, REG_DWORD,
4685 (const BYTE *)&folders[i].attr, sizeof(DWORD));
4686 if (folders[i].call_for_attr)
4687 res = RegSetValueExW( hkey, cfattributesW, 0, REG_DWORD,
4688 (const BYTE *)&folders[i].call_for_attr, sizeof(DWORD));
4689 RegCloseKey( hkey );
4691 return S_OK;
4694 /*************************************************************************
4695 * SHGetSpecialFolderPathA [SHELL32.@]
4697 BOOL WINAPI SHGetSpecialFolderPathA (
4698 HWND hwndOwner,
4699 LPSTR szPath,
4700 int nFolder,
4701 BOOL bCreate)
4703 return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
4704 szPath) == S_OK;
4707 /*************************************************************************
4708 * SHGetSpecialFolderPathW
4710 BOOL WINAPI SHGetSpecialFolderPathW (
4711 HWND hwndOwner,
4712 LPWSTR szPath,
4713 int nFolder,
4714 BOOL bCreate)
4716 return SHGetFolderPathW(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
4717 szPath) == S_OK;
4720 /*************************************************************************
4721 * SHGetSpecialFolderPath (SHELL32.175)
4723 BOOL WINAPI SHGetSpecialFolderPathAW (
4724 HWND hwndOwner,
4725 LPVOID szPath,
4726 int nFolder,
4727 BOOL bCreate)
4730 if (SHELL_OsIsUnicode())
4731 return SHGetSpecialFolderPathW (hwndOwner, szPath, nFolder, bCreate);
4732 return SHGetSpecialFolderPathA (hwndOwner, szPath, nFolder, bCreate);
4735 /*************************************************************************
4736 * SHGetFolderLocation [SHELL32.@]
4738 * Gets the folder locations from the registry and creates a pidl.
4740 * PARAMS
4741 * hwndOwner [I]
4742 * nFolder [I] CSIDL_xxxxx
4743 * hToken [I] token representing user, or NULL for current user, or -1 for
4744 * default user
4745 * dwReserved [I] must be zero
4746 * ppidl [O] PIDL of a special folder
4748 * RETURNS
4749 * Success: S_OK
4750 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
4752 * NOTES
4753 * Creates missing reg keys and directories.
4754 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
4755 * virtual folders that are handled here.
4757 HRESULT WINAPI SHGetFolderLocation(
4758 HWND hwndOwner,
4759 int nFolder,
4760 HANDLE hToken,
4761 DWORD dwReserved,
4762 LPITEMIDLIST *ppidl)
4764 HRESULT hr = E_INVALIDARG;
4766 TRACE("%p 0x%08x %p 0x%08x %p\n",
4767 hwndOwner, nFolder, hToken, dwReserved, ppidl);
4769 if (!ppidl)
4770 return E_INVALIDARG;
4771 if (dwReserved)
4772 return E_INVALIDARG;
4774 /* The virtual folders' locations are not user-dependent */
4775 *ppidl = NULL;
4776 switch (nFolder & CSIDL_FOLDER_MASK)
4778 case CSIDL_DESKTOP:
4779 *ppidl = _ILCreateDesktop();
4780 break;
4782 case CSIDL_PERSONAL:
4783 *ppidl = _ILCreateMyDocuments();
4784 break;
4786 case CSIDL_INTERNET:
4787 *ppidl = _ILCreateIExplore();
4788 break;
4790 case CSIDL_CONTROLS:
4791 *ppidl = _ILCreateControlPanel();
4792 break;
4794 case CSIDL_PRINTERS:
4795 *ppidl = _ILCreatePrinters();
4796 break;
4798 case CSIDL_BITBUCKET:
4799 *ppidl = _ILCreateBitBucket();
4800 break;
4802 case CSIDL_DRIVES:
4803 *ppidl = _ILCreateMyComputer();
4804 break;
4806 case CSIDL_NETWORK:
4807 *ppidl = _ILCreateNetwork();
4808 break;
4810 default:
4812 WCHAR szPath[MAX_PATH];
4814 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
4815 SHGFP_TYPE_CURRENT, szPath);
4816 if (SUCCEEDED(hr))
4818 DWORD attributes=0;
4820 TRACE("Value=%s\n", debugstr_w(szPath));
4821 hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
4823 else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
4825 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
4826 * version 6.0 returns E_FAIL for nonexistent paths
4828 hr = E_FAIL;
4832 if(*ppidl)
4833 hr = S_OK;
4835 TRACE("-- (new pidl %p)\n",*ppidl);
4836 return hr;
4839 /*************************************************************************
4840 * SHGetSpecialFolderLocation [SHELL32.@]
4842 * NOTES
4843 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
4844 * directory.
4846 HRESULT WINAPI SHGetSpecialFolderLocation(
4847 HWND hwndOwner,
4848 INT nFolder,
4849 LPITEMIDLIST * ppidl)
4851 HRESULT hr = E_INVALIDARG;
4853 TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
4855 if (!ppidl)
4856 return E_INVALIDARG;
4858 hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
4859 return hr;
4862 static int csidl_from_id( const KNOWNFOLDERID *id )
4864 int i;
4865 for (i = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
4866 if (IsEqualGUID( CSIDL_Data[i].id, id )) return i;
4867 return -1;
4870 /*************************************************************************
4871 * SHGetKnownFolderPath [SHELL32.@]
4873 HRESULT WINAPI SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, WCHAR **ret_path)
4875 WCHAR pathW[MAX_PATH], tempW[MAX_PATH];
4876 HRESULT hr;
4877 CSIDL_Type type;
4878 int ret;
4879 int folder = csidl_from_id(rfid), shgfp_flags;
4881 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid), flags, token, ret_path);
4883 *ret_path = NULL;
4885 if (folder < 0)
4886 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
4888 if (flags & ~(KF_FLAG_CREATE|KF_FLAG_SIMPLE_IDLIST|KF_FLAG_DONT_UNEXPAND|
4889 KF_FLAG_DONT_VERIFY|KF_FLAG_NO_ALIAS|KF_FLAG_INIT|KF_FLAG_DEFAULT_PATH))
4891 FIXME("flags 0x%08x not supported\n", flags);
4892 return E_INVALIDARG;
4895 shgfp_flags = flags & KF_FLAG_DEFAULT_PATH ? SHGFP_TYPE_DEFAULT : SHGFP_TYPE_CURRENT;
4897 type = CSIDL_Data[folder].type;
4898 switch (type)
4900 case CSIDL_Type_Disallowed:
4901 hr = E_INVALIDARG;
4902 break;
4903 case CSIDL_Type_NonExistent:
4904 *tempW = 0;
4905 hr = S_FALSE;
4906 break;
4907 case CSIDL_Type_WindowsPath:
4908 GetWindowsDirectoryW(tempW, MAX_PATH);
4909 if (CSIDL_Data[folder].szDefaultPath &&
4910 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4911 *CSIDL_Data[folder].szDefaultPath)
4913 PathAddBackslashW(tempW);
4914 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
4916 hr = S_OK;
4917 break;
4918 case CSIDL_Type_SystemPath:
4919 GetSystemDirectoryW(tempW, MAX_PATH);
4920 if (CSIDL_Data[folder].szDefaultPath &&
4921 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4922 *CSIDL_Data[folder].szDefaultPath)
4924 PathAddBackslashW(tempW);
4925 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
4927 hr = S_OK;
4928 break;
4929 case CSIDL_Type_SystemX86Path:
4930 if (!GetSystemWow64DirectoryW(tempW, MAX_PATH)) GetSystemDirectoryW(tempW, MAX_PATH);
4931 if (CSIDL_Data[folder].szDefaultPath &&
4932 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4933 *CSIDL_Data[folder].szDefaultPath)
4935 PathAddBackslashW(tempW);
4936 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
4938 hr = S_OK;
4939 break;
4940 case CSIDL_Type_CurrVer:
4941 hr = _SHGetCurrentVersionPath(shgfp_flags, folder, tempW);
4942 break;
4943 case CSIDL_Type_User:
4944 hr = _SHGetUserProfilePath(token, shgfp_flags, folder, tempW);
4945 break;
4946 case CSIDL_Type_AllUsers:
4947 case CSIDL_Type_ProgramData:
4948 hr = _SHGetAllUsersProfilePath(shgfp_flags, folder, tempW);
4949 break;
4950 default:
4951 FIXME("bogus type %d, please fix\n", type);
4952 hr = E_INVALIDARG;
4953 break;
4956 if (FAILED(hr))
4957 goto failed;
4959 /* Expand environment strings if necessary */
4960 if (*tempW == '%')
4962 hr = _SHExpandEnvironmentStrings(tempW, pathW);
4963 if (FAILED(hr))
4964 goto failed;
4966 else
4967 strcpyW(pathW, tempW);
4969 /* if we don't care about existing directories we are ready */
4970 if (flags & KF_FLAG_DONT_VERIFY) goto done;
4972 if (PathFileExistsW(pathW)) goto done;
4974 /* Does not exist but we are not allowed to create it. The return value
4975 * is verified against shell32 version 6.0.
4977 if (!(flags & KF_FLAG_CREATE))
4979 hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
4980 goto done;
4983 /* create directory/directories */
4984 ret = SHCreateDirectoryExW(NULL, pathW, NULL);
4985 if (ret && ret != ERROR_ALREADY_EXISTS)
4987 ERR("Failed to create directory %s.\n", debugstr_w(pathW));
4988 hr = E_FAIL;
4989 goto failed;
4992 TRACE("Created missing system directory %s\n", debugstr_w(pathW));
4994 done:
4995 TRACE("Final path is %s, %#x\n", debugstr_w(pathW), hr);
4997 *ret_path = CoTaskMemAlloc((strlenW(pathW) + 1) * sizeof(WCHAR));
4998 if (!*ret_path)
4999 return E_OUTOFMEMORY;
5000 strcpyW(*ret_path, pathW);
5002 return hr;
5004 failed:
5005 TRACE("Failed to get folder path, %#x.\n", hr);
5007 return hr;
5010 /*************************************************************************
5011 * SHGetFolderPathEx [SHELL32.@]
5013 HRESULT WINAPI SHGetFolderPathEx(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, LPWSTR path, DWORD len)
5015 HRESULT hr;
5016 WCHAR *buffer;
5018 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid), flags, token, path, len);
5020 if (!path || !len) return E_INVALIDARG;
5022 hr = SHGetKnownFolderPath( rfid, flags, token, &buffer );
5023 if (SUCCEEDED( hr ))
5025 if (strlenW( buffer ) + 1 > len)
5027 CoTaskMemFree( buffer );
5028 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER );
5030 strcpyW( path, buffer );
5031 CoTaskMemFree( buffer );
5033 return hr;
5037 * Internal function to convert known folder identifier to path of registry key
5038 * associated with known folder.
5040 * Parameters:
5041 * rfid [I] pointer to known folder identifier (may be NULL)
5042 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
5043 * lpPath [O] place to store string address. String should be
5044 * later freed using HeapFree(GetProcessHeap(),0, ... )
5046 static HRESULT get_known_folder_registry_path(
5047 REFKNOWNFOLDERID rfid,
5048 LPWSTR lpStringGuid,
5049 LPWSTR *lpPath)
5051 static const WCHAR sBackslash[] = {'\\',0};
5052 HRESULT hr = S_OK;
5053 int length;
5054 WCHAR sGuid[50];
5056 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid), debugstr_w(lpStringGuid), lpPath);
5058 if(rfid)
5059 StringFromGUID2(rfid, sGuid, ARRAY_SIZE(sGuid));
5060 else
5061 lstrcpyW(sGuid, lpStringGuid);
5063 length = lstrlenW(szKnownFolderDescriptions)+51;
5064 *lpPath = heap_alloc(length*sizeof(WCHAR));
5065 if(!(*lpPath))
5066 hr = E_OUTOFMEMORY;
5068 if(SUCCEEDED(hr))
5070 lstrcpyW(*lpPath, szKnownFolderDescriptions);
5071 lstrcatW(*lpPath, sBackslash);
5072 lstrcatW(*lpPath, sGuid);
5075 return hr;
5078 static HRESULT get_known_folder_wstr(const WCHAR *regpath, const WCHAR *value, WCHAR **out)
5080 DWORD size = 0;
5081 HRESULT hr;
5083 size = 0;
5084 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, regpath, value, RRF_RT_REG_SZ, NULL, NULL, &size));
5085 if(FAILED(hr))
5086 return hr;
5088 *out = CoTaskMemAlloc(size);
5089 if(!*out)
5090 return E_OUTOFMEMORY;
5092 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, regpath, value, RRF_RT_REG_SZ, NULL, *out, &size));
5093 if(FAILED(hr)){
5094 CoTaskMemFree(*out);
5095 *out = NULL;
5098 return hr;
5101 static HRESULT get_known_folder_dword(const WCHAR *registryPath, const WCHAR *value, DWORD *out)
5103 DWORD dwSize = sizeof(DWORD);
5104 DWORD dwType;
5105 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, value, RRF_RT_DWORD, &dwType, out, &dwSize));
5109 * Internal function to get place where folder redirection information are stored.
5111 * Parameters:
5112 * rfid [I] pointer to known folder identifier (may be NULL)
5113 * rootKey [O] root key where the redirection information are stored
5114 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5115 * However, besides root key, path is always that same, and is stored
5116 * as "szKnownFolderRedirections" constant
5118 static HRESULT get_known_folder_redirection_place(
5119 REFKNOWNFOLDERID rfid,
5120 HKEY *rootKey)
5122 HRESULT hr;
5123 LPWSTR lpRegistryPath = NULL;
5124 KF_CATEGORY category;
5126 /* first, get known folder's category */
5127 hr = get_known_folder_registry_path(rfid, NULL, &lpRegistryPath);
5129 if(SUCCEEDED(hr))
5130 hr = get_known_folder_dword(lpRegistryPath, szCategory, &category);
5132 if(SUCCEEDED(hr))
5134 if(category == KF_CATEGORY_COMMON)
5136 *rootKey = HKEY_LOCAL_MACHINE;
5137 hr = S_OK;
5139 else if(category == KF_CATEGORY_PERUSER)
5141 *rootKey = HKEY_CURRENT_USER;
5142 hr = S_OK;
5144 else
5145 hr = E_FAIL;
5148 heap_free(lpRegistryPath);
5149 return hr;
5152 static HRESULT get_known_folder_path_by_id(REFKNOWNFOLDERID folderId, LPWSTR lpRegistryPath, DWORD dwFlags, LPWSTR *ppszPath);
5154 static HRESULT redirect_known_folder(
5155 REFKNOWNFOLDERID rfid,
5156 HWND hwnd,
5157 KF_REDIRECT_FLAGS flags,
5158 LPCWSTR pszTargetPath,
5159 UINT cFolders,
5160 KNOWNFOLDERID const *pExclusion,
5161 LPWSTR *ppszError)
5163 HRESULT hr;
5164 HKEY rootKey = HKEY_LOCAL_MACHINE, hKey;
5165 WCHAR sGuid[39];
5166 LPWSTR lpRegistryPath = NULL, lpSrcPath = NULL;
5167 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid), hwnd, flags, debugstr_w(pszTargetPath), cFolders, pExclusion, ppszError);
5169 if (ppszError) *ppszError = NULL;
5171 hr = get_known_folder_registry_path(rfid, NULL, &lpRegistryPath);
5173 if(SUCCEEDED(hr))
5174 hr = get_known_folder_path_by_id(rfid, lpRegistryPath, 0, &lpSrcPath);
5176 heap_free(lpRegistryPath);
5178 /* get path to redirection storage */
5179 if(SUCCEEDED(hr))
5180 hr = get_known_folder_redirection_place(rfid, &rootKey);
5182 /* write redirection information */
5183 if(SUCCEEDED(hr))
5184 hr = HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey, szKnownFolderRedirections, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL));
5186 if(SUCCEEDED(hr))
5188 StringFromGUID2(rfid, sGuid, ARRAY_SIZE(sGuid));
5190 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, sGuid, 0, REG_SZ, (LPBYTE)pszTargetPath, (lstrlenW(pszTargetPath)+1)*sizeof(WCHAR)));
5192 RegCloseKey(hKey);
5195 /* make sure destination path exists */
5196 SHCreateDirectory(NULL, pszTargetPath);
5198 /* copy content if required */
5199 if(SUCCEEDED(hr) && (flags & KF_REDIRECT_COPY_CONTENTS) )
5201 static const WCHAR sWildcard[] = {'\\','*',0};
5202 WCHAR srcPath[MAX_PATH+1], dstPath[MAX_PATH+1];
5203 SHFILEOPSTRUCTW fileOp;
5205 ZeroMemory(srcPath, sizeof(srcPath));
5206 lstrcpyW(srcPath, lpSrcPath);
5207 lstrcatW(srcPath, sWildcard);
5209 ZeroMemory(dstPath, sizeof(dstPath));
5210 lstrcpyW(dstPath, pszTargetPath);
5212 ZeroMemory(&fileOp, sizeof(fileOp));
5214 if(flags & KF_REDIRECT_DEL_SOURCE_CONTENTS)
5215 fileOp.wFunc = FO_MOVE;
5216 else
5217 fileOp.wFunc = FO_COPY;
5219 fileOp.pFrom = srcPath;
5220 fileOp.pTo = dstPath;
5221 fileOp.fFlags = FOF_NO_UI;
5223 hr = (SHFileOperationW(&fileOp)==0 ? S_OK : E_FAIL);
5225 if(flags & KF_REDIRECT_DEL_SOURCE_CONTENTS)
5227 ZeroMemory(srcPath, sizeof(srcPath));
5228 lstrcpyW(srcPath, lpSrcPath);
5230 ZeroMemory(&fileOp, sizeof(fileOp));
5231 fileOp.wFunc = FO_DELETE;
5232 fileOp.pFrom = srcPath;
5233 fileOp.fFlags = FOF_NO_UI;
5235 hr = (SHFileOperationW(&fileOp)==0 ? S_OK : E_FAIL);
5239 CoTaskMemFree(lpSrcPath);
5241 return hr;
5245 struct knownfolder
5247 IKnownFolder IKnownFolder_iface;
5248 LONG refs;
5249 KNOWNFOLDERID id;
5250 LPWSTR registryPath;
5253 static inline struct knownfolder *impl_from_IKnownFolder( IKnownFolder *iface )
5255 return CONTAINING_RECORD( iface, struct knownfolder, IKnownFolder_iface );
5258 static ULONG WINAPI knownfolder_AddRef(
5259 IKnownFolder *iface )
5261 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5262 return InterlockedIncrement( &knownfolder->refs );
5265 static ULONG WINAPI knownfolder_Release(
5266 IKnownFolder *iface )
5268 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5269 LONG refs = InterlockedDecrement( &knownfolder->refs );
5270 if (!refs)
5272 TRACE("destroying %p\n", knownfolder);
5273 heap_free( knownfolder->registryPath );
5274 heap_free( knownfolder );
5276 return refs;
5279 static HRESULT WINAPI knownfolder_QueryInterface(
5280 IKnownFolder *iface,
5281 REFIID riid,
5282 void **ppv )
5284 struct knownfolder *This = impl_from_IKnownFolder( iface );
5286 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
5288 *ppv = NULL;
5289 if ( IsEqualGUID( riid, &IID_IKnownFolder ) ||
5290 IsEqualGUID( riid, &IID_IUnknown ) )
5292 *ppv = iface;
5294 else if ( IsEqualGUID( riid, &IID_IMarshal ) )
5296 TRACE("IID_IMarshal returning NULL.\n");
5297 return E_NOINTERFACE;
5299 else
5301 FIXME("interface %s not implemented\n", debugstr_guid(riid));
5302 return E_NOINTERFACE;
5304 IKnownFolder_AddRef( iface );
5305 return S_OK;
5308 static HRESULT knownfolder_set_id(
5309 struct knownfolder *knownfolder,
5310 const KNOWNFOLDERID *kfid)
5312 HKEY hKey;
5313 HRESULT hr;
5315 TRACE("%s\n", debugstr_guid(kfid));
5317 knownfolder->id = *kfid;
5319 /* check is it registry-registered folder */
5320 hr = get_known_folder_registry_path(kfid, NULL, &knownfolder->registryPath);
5321 if(SUCCEEDED(hr))
5322 hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, knownfolder->registryPath, 0, 0, &hKey));
5324 if(SUCCEEDED(hr))
5326 hr = S_OK;
5327 RegCloseKey(hKey);
5329 else
5331 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5332 heap_free(knownfolder->registryPath);
5333 knownfolder->registryPath = NULL;
5334 hr = S_OK;
5337 return hr;
5340 static HRESULT WINAPI knownfolder_GetId(
5341 IKnownFolder *iface,
5342 KNOWNFOLDERID *pkfid)
5344 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5346 TRACE("%p\n", pkfid);
5348 *pkfid = knownfolder->id;
5349 return S_OK;
5352 static HRESULT WINAPI knownfolder_GetCategory(
5353 IKnownFolder *iface,
5354 KF_CATEGORY *pCategory)
5356 struct knownfolder *knownfolder = impl_from_IKnownFolder(iface);
5357 HRESULT hr = S_OK;
5359 TRACE("%p, %p\n", knownfolder, pCategory);
5361 /* we cannot get a category for a folder which is not registered */
5362 if(!knownfolder->registryPath)
5363 hr = E_FAIL;
5365 if(SUCCEEDED(hr))
5366 hr = get_known_folder_dword(knownfolder->registryPath, szCategory, pCategory);
5368 return hr;
5371 static HRESULT WINAPI knownfolder_GetShellItem(
5372 IKnownFolder *iface,
5373 DWORD flags,
5374 REFIID riid,
5375 void **ppv)
5377 struct knownfolder *knownfolder = impl_from_IKnownFolder(iface);
5378 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder, flags, debugstr_guid(riid), ppv);
5379 return SHGetKnownFolderItem(&knownfolder->id, flags, NULL, riid, ppv);
5382 static HRESULT get_known_folder_path(
5383 LPWSTR sFolderId,
5384 LPWSTR registryPath,
5385 LPWSTR *ppszPath)
5387 static const WCHAR sBackslash[] = {'\\',0};
5388 HRESULT hr;
5389 DWORD dwSize, dwType;
5390 WCHAR path[MAX_PATH] = {0};
5391 WCHAR parentGuid[39];
5392 KF_CATEGORY category;
5393 LPWSTR parentRegistryPath, parentPath;
5394 HKEY hRedirectionRootKey = NULL;
5396 TRACE("(%s, %p)\n", debugstr_w(registryPath), ppszPath);
5397 *ppszPath = NULL;
5399 /* check if folder has parent */
5400 dwSize = sizeof(parentGuid);
5401 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szParentFolder, RRF_RT_REG_SZ, &dwType, parentGuid, &dwSize));
5402 if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) hr = S_FALSE;
5404 if(hr == S_OK)
5406 /* get parent's known folder path (recursive) */
5407 hr = get_known_folder_registry_path(NULL, parentGuid, &parentRegistryPath);
5408 if(FAILED(hr)) return hr;
5410 hr = get_known_folder_path(parentGuid, parentRegistryPath, &parentPath);
5411 if(FAILED(hr)) {
5412 heap_free(parentRegistryPath);
5413 return hr;
5416 lstrcatW(path, parentPath);
5417 lstrcatW(path, sBackslash);
5419 heap_free(parentRegistryPath);
5420 heap_free(parentPath);
5423 /* check, if folder was redirected */
5424 if(SUCCEEDED(hr))
5425 hr = get_known_folder_dword(registryPath, szCategory, &category);
5427 if(SUCCEEDED(hr))
5429 if(category == KF_CATEGORY_COMMON)
5430 hRedirectionRootKey = HKEY_LOCAL_MACHINE;
5431 else if(category == KF_CATEGORY_PERUSER)
5432 hRedirectionRootKey = HKEY_CURRENT_USER;
5434 if(hRedirectionRootKey)
5436 hr = HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey, szKnownFolderRedirections, sFolderId, RRF_RT_REG_SZ, NULL, NULL, &dwSize));
5438 if(SUCCEEDED(hr))
5440 *ppszPath = CoTaskMemAlloc(dwSize+(lstrlenW(path)+1)*sizeof(WCHAR));
5441 if(!*ppszPath) hr = E_OUTOFMEMORY;
5444 if(SUCCEEDED(hr))
5446 lstrcpyW(*ppszPath, path);
5447 hr = HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey, szKnownFolderRedirections, sFolderId, RRF_RT_REG_SZ, NULL, *ppszPath + lstrlenW(path), &dwSize));
5451 if(!*ppszPath)
5453 /* no redirection, use previous way - read the relative path from folder definition */
5454 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szRelativePath, RRF_RT_REG_SZ, &dwType, NULL, &dwSize));
5456 if(SUCCEEDED(hr))
5458 *ppszPath = CoTaskMemAlloc(dwSize+(lstrlenW(path)+1)*sizeof(WCHAR));
5459 if(!*ppszPath) hr = E_OUTOFMEMORY;
5462 if(SUCCEEDED(hr))
5464 lstrcpyW(*ppszPath, path);
5465 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szRelativePath, RRF_RT_REG_SZ, &dwType, *ppszPath + lstrlenW(path), &dwSize));
5470 TRACE("returning path: %s\n", debugstr_w(*ppszPath));
5471 return hr;
5474 static HRESULT get_known_folder_path_by_id(
5475 REFKNOWNFOLDERID folderId,
5476 LPWSTR lpRegistryPath,
5477 DWORD dwFlags,
5478 LPWSTR *ppszPath)
5480 HRESULT hr = E_FAIL;
5481 WCHAR sGuid[39];
5482 DWORD dwAttributes;
5484 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId), debugstr_w(lpRegistryPath), dwFlags, ppszPath);
5486 /* if this is registry-registered known folder, get path from registry */
5487 if(lpRegistryPath)
5489 StringFromGUID2(folderId, sGuid, ARRAY_SIZE(sGuid));
5491 hr = get_known_folder_path(sGuid, lpRegistryPath, ppszPath);
5493 /* in other case, use older way */
5495 if(FAILED(hr))
5496 hr = SHGetKnownFolderPath( folderId, dwFlags, NULL, ppszPath );
5498 if (FAILED(hr)) return hr;
5500 /* check if known folder really exists */
5501 dwAttributes = GetFileAttributesW(*ppszPath);
5502 if(dwAttributes == INVALID_FILE_ATTRIBUTES || !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY) )
5504 TRACE("directory %s not found\n", debugstr_w(*ppszPath));
5505 CoTaskMemFree(*ppszPath);
5506 *ppszPath = NULL;
5507 hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
5510 return hr;
5513 static HRESULT WINAPI knownfolder_GetPath(
5514 IKnownFolder *iface,
5515 DWORD dwFlags,
5516 LPWSTR *ppszPath)
5518 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5519 TRACE("(%p, 0x%08x, %p)\n", knownfolder, dwFlags, ppszPath);
5521 return get_known_folder_path_by_id(&knownfolder->id, knownfolder->registryPath, dwFlags, ppszPath);
5524 static HRESULT WINAPI knownfolder_SetPath(
5525 IKnownFolder *iface,
5526 DWORD dwFlags,
5527 LPCWSTR pszPath)
5529 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5530 HRESULT hr = S_OK;
5532 TRACE("(%p, 0x%08x, %s)\n", knownfolder, dwFlags, debugstr_w(pszPath));
5534 /* check if the known folder is registered */
5535 if(!knownfolder->registryPath)
5536 hr = E_FAIL;
5538 if(SUCCEEDED(hr))
5539 hr = redirect_known_folder(&knownfolder->id, NULL, 0, pszPath, 0, NULL, NULL);
5541 return hr;
5544 static HRESULT WINAPI knownfolder_GetIDList(
5545 IKnownFolder *iface,
5546 DWORD flags,
5547 PIDLIST_ABSOLUTE *ppidl)
5549 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5550 TRACE("(%p, 0x%08x, %p)\n", knownfolder, flags, ppidl);
5551 return SHGetKnownFolderIDList(&knownfolder->id, flags, NULL, ppidl);
5554 static HRESULT WINAPI knownfolder_GetFolderType(
5555 IKnownFolder *iface,
5556 FOLDERTYPEID *pftid)
5558 FIXME("%p\n", pftid);
5559 return E_NOTIMPL;
5562 static HRESULT WINAPI knownfolder_GetRedirectionCapabilities(
5563 IKnownFolder *iface,
5564 KF_REDIRECTION_CAPABILITIES *pCapabilities)
5566 FIXME("%p stub\n", pCapabilities);
5567 if(!pCapabilities) return E_INVALIDARG;
5568 *pCapabilities = KF_REDIRECTION_CAPABILITIES_DENY_ALL;
5569 return S_OK;
5572 static HRESULT WINAPI knownfolder_GetFolderDefinition(
5573 IKnownFolder *iface,
5574 KNOWNFOLDER_DEFINITION *pKFD)
5576 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5577 HRESULT hr;
5578 DWORD dwSize;
5579 WCHAR parentGuid[39];
5580 TRACE("(%p, %p)\n", knownfolder, pKFD);
5582 if(!pKFD) return E_INVALIDARG;
5584 ZeroMemory(pKFD, sizeof(*pKFD));
5586 /* required fields */
5587 hr = get_known_folder_dword(knownfolder->registryPath, szCategory, &pKFD->category);
5588 if(FAILED(hr))
5589 return hr;
5591 hr = get_known_folder_wstr(knownfolder->registryPath, szName, &pKFD->pszName);
5592 if(FAILED(hr))
5593 return hr;
5595 /* optional fields */
5596 dwSize = sizeof(parentGuid);
5597 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, knownfolder->registryPath, szParentFolder,
5598 RRF_RT_REG_SZ, NULL, parentGuid, &dwSize));
5599 if(SUCCEEDED(hr))
5601 hr = IIDFromString(parentGuid, &pKFD->fidParent);
5602 if(FAILED(hr))
5603 return hr;
5606 get_known_folder_dword(knownfolder->registryPath, szAttributes, &pKFD->dwAttributes);
5608 get_known_folder_wstr(knownfolder->registryPath, szRelativePath, &pKFD->pszRelativePath);
5610 get_known_folder_wstr(knownfolder->registryPath, szParsingName, &pKFD->pszParsingName);
5612 return S_OK;
5615 static const struct IKnownFolderVtbl knownfolder_vtbl =
5617 knownfolder_QueryInterface,
5618 knownfolder_AddRef,
5619 knownfolder_Release,
5620 knownfolder_GetId,
5621 knownfolder_GetCategory,
5622 knownfolder_GetShellItem,
5623 knownfolder_GetPath,
5624 knownfolder_SetPath,
5625 knownfolder_GetIDList,
5626 knownfolder_GetFolderType,
5627 knownfolder_GetRedirectionCapabilities,
5628 knownfolder_GetFolderDefinition
5631 static HRESULT knownfolder_create( struct knownfolder **knownfolder )
5633 struct knownfolder *kf;
5635 kf = heap_alloc( sizeof(*kf) );
5636 if (!kf) return E_OUTOFMEMORY;
5638 kf->IKnownFolder_iface.lpVtbl = &knownfolder_vtbl;
5639 kf->refs = 1;
5640 memset( &kf->id, 0, sizeof(kf->id) );
5641 kf->registryPath = NULL;
5643 *knownfolder = kf;
5645 TRACE("returning iface %p\n", &kf->IKnownFolder_iface);
5646 return S_OK;
5649 struct foldermanager
5651 IKnownFolderManager IKnownFolderManager_iface;
5652 LONG refs;
5653 UINT num_ids;
5654 KNOWNFOLDERID *ids;
5657 static inline struct foldermanager *impl_from_IKnownFolderManager( IKnownFolderManager *iface )
5659 return CONTAINING_RECORD( iface, struct foldermanager, IKnownFolderManager_iface );
5662 static ULONG WINAPI foldermanager_AddRef(
5663 IKnownFolderManager *iface )
5665 struct foldermanager *foldermanager = impl_from_IKnownFolderManager( iface );
5666 return InterlockedIncrement( &foldermanager->refs );
5669 static ULONG WINAPI foldermanager_Release(
5670 IKnownFolderManager *iface )
5672 struct foldermanager *foldermanager = impl_from_IKnownFolderManager( iface );
5673 LONG refs = InterlockedDecrement( &foldermanager->refs );
5674 if (!refs)
5676 TRACE("destroying %p\n", foldermanager);
5677 heap_free( foldermanager->ids );
5678 heap_free( foldermanager );
5680 return refs;
5683 static HRESULT WINAPI foldermanager_QueryInterface(
5684 IKnownFolderManager *iface,
5685 REFIID riid,
5686 void **ppv )
5688 struct foldermanager *This = impl_from_IKnownFolderManager( iface );
5690 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
5692 *ppv = NULL;
5693 if ( IsEqualGUID( riid, &IID_IKnownFolderManager ) ||
5694 IsEqualGUID( riid, &IID_IUnknown ) )
5696 *ppv = iface;
5698 else if ( IsEqualGUID( riid, &IID_IMarshal ) )
5700 TRACE("IID_IMarshal returning NULL.\n");
5701 return E_NOINTERFACE;
5703 else
5705 FIXME("interface %s not implemented\n", debugstr_guid(riid));
5706 return E_NOINTERFACE;
5708 IKnownFolderManager_AddRef( iface );
5709 return S_OK;
5712 static HRESULT WINAPI foldermanager_FolderIdFromCsidl(
5713 IKnownFolderManager *iface,
5714 int nCsidl,
5715 KNOWNFOLDERID *pfid)
5717 TRACE("%d, %p\n", nCsidl, pfid);
5719 if (nCsidl >= ARRAY_SIZE(CSIDL_Data))
5720 return E_INVALIDARG;
5721 *pfid = *CSIDL_Data[nCsidl].id;
5722 return S_OK;
5725 static HRESULT WINAPI foldermanager_FolderIdToCsidl(
5726 IKnownFolderManager *iface,
5727 REFKNOWNFOLDERID rfid,
5728 int *pnCsidl)
5730 int csidl;
5732 TRACE("%s, %p\n", debugstr_guid(rfid), pnCsidl);
5734 csidl = csidl_from_id( rfid );
5735 if (csidl == -1) return E_INVALIDARG;
5736 *pnCsidl = csidl;
5737 return S_OK;
5740 static HRESULT WINAPI foldermanager_GetFolderIds(
5741 IKnownFolderManager *iface,
5742 KNOWNFOLDERID **ppKFId,
5743 UINT *pCount)
5745 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
5747 TRACE("%p, %p\n", ppKFId, pCount);
5749 *ppKFId = CoTaskMemAlloc(fm->num_ids * sizeof(KNOWNFOLDERID));
5750 memcpy(*ppKFId, fm->ids, fm->num_ids * sizeof(KNOWNFOLDERID));
5751 *pCount = fm->num_ids;
5752 return S_OK;
5755 static BOOL is_knownfolder( struct foldermanager *fm, const KNOWNFOLDERID *id )
5757 UINT i;
5758 HRESULT hr;
5759 LPWSTR registryPath = NULL;
5760 HKEY hKey;
5762 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
5763 for (i = 0; i < fm->num_ids; i++)
5764 if (IsEqualGUID( &fm->ids[i], id )) return TRUE;
5766 hr = get_known_folder_registry_path(id, NULL, &registryPath);
5767 if(SUCCEEDED(hr))
5769 hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryPath, 0, 0, &hKey));
5770 heap_free(registryPath);
5773 if(SUCCEEDED(hr))
5775 hr = S_OK;
5776 RegCloseKey(hKey);
5779 return hr == S_OK;
5782 static HRESULT WINAPI foldermanager_GetFolder(
5783 IKnownFolderManager *iface,
5784 REFKNOWNFOLDERID rfid,
5785 IKnownFolder **ppkf)
5787 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
5788 struct knownfolder *kf;
5789 HRESULT hr;
5791 TRACE("%s, %p\n", debugstr_guid(rfid), ppkf);
5793 if (!is_knownfolder( fm, rfid ))
5795 WARN("unknown folder\n");
5796 return E_INVALIDARG;
5798 hr = knownfolder_create( &kf );
5799 if (SUCCEEDED( hr ))
5801 hr = knownfolder_set_id( kf, rfid );
5802 *ppkf = &kf->IKnownFolder_iface;
5804 else
5805 *ppkf = NULL;
5807 return hr;
5810 static HRESULT WINAPI foldermanager_GetFolderByName(
5811 IKnownFolderManager *iface,
5812 LPCWSTR pszCanonicalName,
5813 IKnownFolder **ppkf)
5815 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
5816 struct knownfolder *kf;
5817 BOOL found = FALSE;
5818 HRESULT hr;
5819 UINT i;
5821 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName), ppkf );
5823 for (i = 0; i < fm->num_ids; i++)
5825 WCHAR *path, *name;
5826 hr = get_known_folder_registry_path( &fm->ids[i], NULL, &path );
5827 if (FAILED( hr )) return hr;
5829 hr = get_known_folder_wstr( path, szName, &name );
5830 heap_free( path );
5831 if (FAILED( hr )) return hr;
5833 found = !strcmpiW( pszCanonicalName, name );
5834 CoTaskMemFree( name );
5835 if (found) break;
5838 if (found)
5840 hr = knownfolder_create( &kf );
5841 if (FAILED( hr )) return hr;
5843 hr = knownfolder_set_id( kf, &fm->ids[i] );
5844 if (FAILED( hr ))
5846 IKnownFolder_Release( &kf->IKnownFolder_iface );
5847 return hr;
5849 *ppkf = &kf->IKnownFolder_iface;
5851 else
5853 hr = HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
5854 *ppkf = NULL;
5857 return hr;
5860 static HRESULT register_folder(const KNOWNFOLDERID *rfid, const KNOWNFOLDER_DEFINITION *pKFD)
5862 HRESULT hr;
5863 HKEY hKey = NULL;
5864 DWORD dwDisp;
5865 LPWSTR registryPath = NULL;
5867 hr = get_known_folder_registry_path(rfid, NULL, &registryPath);
5868 TRACE("registry path: %s\n", debugstr_w(registryPath));
5870 if(SUCCEEDED(hr))
5871 hr = HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE, registryPath, 0, NULL, 0, KEY_WRITE, 0, &hKey, &dwDisp));
5873 if(SUCCEEDED(hr))
5875 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szCategory, 0, REG_DWORD, (LPBYTE)&pKFD->category, sizeof(pKFD->category)));
5877 if(SUCCEEDED(hr) && pKFD->dwAttributes != 0)
5878 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szAttributes, 0, REG_DWORD, (LPBYTE)&pKFD->dwAttributes, sizeof(pKFD->dwAttributes)));
5880 if(SUCCEEDED(hr))
5881 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szName, 0, REG_SZ, (LPBYTE)pKFD->pszName, (lstrlenW(pKFD->pszName)+1)*sizeof(WCHAR) ));
5883 if(SUCCEEDED(hr) && pKFD->pszParsingName)
5884 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szParsingName, 0, REG_SZ, (LPBYTE)pKFD->pszParsingName, (lstrlenW(pKFD->pszParsingName)+1)*sizeof(WCHAR) ));
5886 if(SUCCEEDED(hr) && !IsEqualGUID(&pKFD->fidParent, &GUID_NULL))
5888 WCHAR sParentGuid[39];
5889 StringFromGUID2(&pKFD->fidParent, sParentGuid, ARRAY_SIZE(sParentGuid));
5891 /* this known folder has parent folder */
5892 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szParentFolder, 0, REG_SZ, (LPBYTE)sParentGuid, sizeof(sParentGuid)));
5895 if(SUCCEEDED(hr) && pKFD->category != KF_CATEGORY_VIRTUAL && pKFD->pszRelativePath)
5896 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szRelativePath, 0, REG_SZ, (LPBYTE)pKFD->pszRelativePath, (lstrlenW(pKFD->pszRelativePath)+1)*sizeof(WCHAR) ));
5898 RegCloseKey(hKey);
5900 if(FAILED(hr))
5901 SHDeleteKeyW(HKEY_LOCAL_MACHINE, registryPath);
5904 heap_free(registryPath);
5905 return hr;
5908 static HRESULT WINAPI foldermanager_RegisterFolder(
5909 IKnownFolderManager *iface,
5910 REFKNOWNFOLDERID rfid,
5911 KNOWNFOLDER_DEFINITION const *pKFD)
5913 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(rfid), pKFD);
5914 return register_folder(rfid, pKFD);
5917 static HRESULT WINAPI foldermanager_UnregisterFolder(
5918 IKnownFolderManager *iface,
5919 REFKNOWNFOLDERID rfid)
5921 HRESULT hr;
5922 LPWSTR registryPath = NULL;
5923 TRACE("(%p, %s)\n", iface, debugstr_guid(rfid));
5925 hr = get_known_folder_registry_path(rfid, NULL, &registryPath);
5927 if(SUCCEEDED(hr))
5928 hr = HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE, registryPath));
5930 heap_free(registryPath);
5931 return hr;
5934 static HRESULT WINAPI foldermanager_FindFolderFromPath(
5935 IKnownFolderManager *iface,
5936 LPCWSTR pszPath,
5937 FFFP_MODE mode,
5938 IKnownFolder **ppkf)
5940 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath), mode, ppkf);
5941 return E_NOTIMPL;
5944 static HRESULT WINAPI foldermanager_FindFolderFromIDList(
5945 IKnownFolderManager *iface,
5946 PCIDLIST_ABSOLUTE pidl,
5947 IKnownFolder **ppkf)
5949 FIXME("%p, %p\n", pidl, ppkf);
5950 return E_NOTIMPL;
5953 static HRESULT WINAPI foldermanager_Redirect(
5954 IKnownFolderManager *iface,
5955 REFKNOWNFOLDERID rfid,
5956 HWND hwnd,
5957 KF_REDIRECT_FLAGS flags,
5958 LPCWSTR pszTargetPath,
5959 UINT cFolders,
5960 KNOWNFOLDERID const *pExclusion,
5961 LPWSTR *ppszError)
5963 return redirect_known_folder(rfid, hwnd, flags, pszTargetPath, cFolders, pExclusion, ppszError);
5966 static const struct IKnownFolderManagerVtbl foldermanager_vtbl =
5968 foldermanager_QueryInterface,
5969 foldermanager_AddRef,
5970 foldermanager_Release,
5971 foldermanager_FolderIdFromCsidl,
5972 foldermanager_FolderIdToCsidl,
5973 foldermanager_GetFolderIds,
5974 foldermanager_GetFolder,
5975 foldermanager_GetFolderByName,
5976 foldermanager_RegisterFolder,
5977 foldermanager_UnregisterFolder,
5978 foldermanager_FindFolderFromPath,
5979 foldermanager_FindFolderFromIDList,
5980 foldermanager_Redirect
5983 static HRESULT foldermanager_create( void **ppv )
5985 UINT i, j;
5986 struct foldermanager *fm;
5988 fm = heap_alloc( sizeof(*fm) );
5989 if (!fm) return E_OUTOFMEMORY;
5991 fm->IKnownFolderManager_iface.lpVtbl = &foldermanager_vtbl;
5992 fm->refs = 1;
5993 fm->num_ids = 0;
5995 for (i = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
5997 if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL )) fm->num_ids++;
5999 fm->ids = heap_alloc( fm->num_ids * sizeof(KNOWNFOLDERID) );
6000 if (!fm->ids)
6002 heap_free( fm );
6003 return E_OUTOFMEMORY;
6005 for (i = j = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
6007 if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL ))
6009 fm->ids[j] = *CSIDL_Data[i].id;
6010 j++;
6013 TRACE("found %u known folders\n", fm->num_ids);
6014 *ppv = &fm->IKnownFolderManager_iface;
6016 TRACE("returning iface %p\n", *ppv);
6017 return S_OK;
6020 HRESULT WINAPI KnownFolderManager_Constructor( IUnknown *punk, REFIID riid, void **ppv )
6022 TRACE("%p, %s, %p\n", punk, debugstr_guid(riid), ppv);
6024 if (!ppv)
6025 return E_POINTER;
6026 if (punk)
6027 return CLASS_E_NOAGGREGATION;
6029 return foldermanager_create( ppv );
6032 HRESULT WINAPI SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, PIDLIST_ABSOLUTE *pidl)
6034 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid), flags, token, pidl);
6036 if (!pidl)
6037 return E_INVALIDARG;
6039 if (flags)
6040 FIXME("unsupported flags: 0x%08x\n", flags);
6042 if (token)
6043 FIXME("user token is not used.\n");
6045 *pidl = NULL;
6046 if (IsEqualIID(rfid, &FOLDERID_Desktop))
6047 *pidl = _ILCreateDesktop();
6048 else if (IsEqualIID(rfid, &FOLDERID_RecycleBinFolder))
6049 *pidl = _ILCreateBitBucket();
6050 else if (IsEqualIID(rfid, &FOLDERID_ComputerFolder))
6051 *pidl = _ILCreateMyComputer();
6052 else if (IsEqualIID(rfid, &FOLDERID_PrintersFolder))
6053 *pidl = _ILCreatePrinters();
6054 else if (IsEqualIID(rfid, &FOLDERID_ControlPanelFolder))
6055 *pidl = _ILCreateControlPanel();
6056 else if (IsEqualIID(rfid, &FOLDERID_NetworkFolder))
6057 *pidl = _ILCreateNetwork();
6058 else if (IsEqualIID(rfid, &FOLDERID_Documents))
6059 *pidl = _ILCreateMyDocuments();
6060 else
6062 DWORD attributes = 0;
6063 WCHAR *pathW;
6064 HRESULT hr;
6066 hr = SHGetKnownFolderPath(rfid, flags, token, &pathW);
6067 if (FAILED(hr))
6068 return hr;
6070 hr = SHILCreateFromPathW(pathW, pidl, &attributes);
6071 CoTaskMemFree(pathW);
6072 return hr;
6075 return *pidl ? S_OK : E_FAIL;
6078 HRESULT WINAPI SHGetKnownFolderItem(REFKNOWNFOLDERID rfid, KNOWN_FOLDER_FLAG flags, HANDLE hToken,
6079 REFIID riid, void **ppv)
6081 PIDLIST_ABSOLUTE pidl;
6082 HRESULT hr;
6084 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid), flags, hToken, debugstr_guid(riid), ppv);
6086 hr = SHGetKnownFolderIDList(rfid, flags, hToken, &pidl);
6087 if (FAILED(hr))
6089 *ppv = NULL;
6090 return hr;
6093 hr = SHCreateItemFromIDList(pidl, riid, ppv);
6094 CoTaskMemFree(pidl);
6095 return hr;
6098 static void register_system_knownfolders(void)
6100 int i;
6102 for (i = 0; i < ARRAY_SIZE(CSIDL_Data); ++i)
6104 const CSIDL_DATA *folder = &CSIDL_Data[i];
6105 if(folder->pszName){
6106 KNOWNFOLDER_DEFINITION kfd;
6108 /* register_folder won't modify kfd, so cast away const instead of
6109 * reallocating */
6110 kfd.category = folder->category;
6111 kfd.pszName = (WCHAR*)folder->pszName;
6112 kfd.pszDescription = (WCHAR*)folder->pszDescription;
6113 memcpy(&kfd.fidParent, folder->fidParent, sizeof(KNOWNFOLDERID));
6114 kfd.pszRelativePath = (WCHAR*)folder->pszRelativePath;
6115 kfd.pszParsingName = (WCHAR*)folder->pszParsingName;
6116 kfd.pszTooltip = (WCHAR*)folder->pszTooltip;
6117 kfd.pszLocalizedName = (WCHAR*)folder->pszLocalizedName;
6118 kfd.pszIcon = (WCHAR*)folder->pszIcon;
6119 kfd.pszSecurity = (WCHAR*)folder->pszSecurity;
6120 kfd.dwAttributes = folder->dwAttributes;
6121 kfd.kfdFlags = folder->kfdFlags;
6122 memcpy(&kfd.ftidType, folder->ftidType, sizeof(FOLDERTYPEID));
6124 register_folder(folder->id, &kfd);
6129 HRESULT SHELL_RegisterShellFolders(void)
6131 HRESULT hr;
6133 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6134 * 'My Videos', 'My Music' and 'Desktop' in advance, so that the
6135 * _SHRegister*ShellFolders() functions will find everything nice and clean
6136 * and thus will not attempt to create them in the profile directory. */
6137 _SHCreateSymbolicLinks();
6139 hr = _SHRegisterUserShellFolders(TRUE);
6140 if (SUCCEEDED(hr))
6141 hr = _SHRegisterUserShellFolders(FALSE);
6142 if (SUCCEEDED(hr))
6143 hr = _SHRegisterCommonShellFolders();
6144 if (SUCCEEDED(hr))
6145 hr = create_extra_folders();
6146 if (SUCCEEDED(hr))
6147 hr = set_folder_attributes();
6148 if (SUCCEEDED(hr))
6149 register_system_knownfolders();
6150 return hr;