mf/evr: Post sink marker events.
[wine.git] / dlls / shell32 / shellpath.c
blob71267ecf58010eb3f3d812793e6a81c21c1f14cf
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 BOOL WINAPI PathFindOnPathExA(LPSTR,LPCSTR *,DWORD);
688 BOOL WINAPI PathFindOnPathExW(LPWSTR,LPCWSTR *,DWORD);
689 BOOL WINAPI PathFileExistsDefExtA(LPSTR,DWORD);
690 BOOL WINAPI PathFileExistsDefExtW(LPWSTR,DWORD);
692 static BOOL PathResolveA(char *path, const char **dirs, DWORD flags)
694 BOOL is_file_spec = PathIsFileSpecA(path);
695 DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xff;
697 TRACE("(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags);
699 if (flags & PRF_VERIFYEXISTS && !PathFileExistsA(path))
701 if (PathFindOnPathExA(path, dirs, dwWhich))
702 return TRUE;
703 if (PathFileExistsDefExtA(path, dwWhich))
704 return TRUE;
705 if (!is_file_spec) GetFullPathNameA(path, MAX_PATH, path, NULL);
706 SetLastError(ERROR_FILE_NOT_FOUND);
707 return FALSE;
710 if (is_file_spec)
712 SetLastError(ERROR_FILE_NOT_FOUND);
713 return FALSE;
716 GetFullPathNameA(path, MAX_PATH, path, NULL);
718 return TRUE;
721 static BOOL PathResolveW(WCHAR *path, const WCHAR **dirs, DWORD flags)
723 BOOL is_file_spec = PathIsFileSpecW(path);
724 DWORD dwWhich = flags & PRF_DONTFINDLNK ? 0xf : 0xff;
726 TRACE("(%s,%p,0x%08x)\n", debugstr_w(path), dirs, flags);
728 if (flags & PRF_VERIFYEXISTS && !PathFileExistsW(path))
730 if (PathFindOnPathExW(path, dirs, dwWhich))
731 return TRUE;
732 if (PathFileExistsDefExtW(path, dwWhich))
733 return TRUE;
734 if (!is_file_spec) GetFullPathNameW(path, MAX_PATH, path, NULL);
735 SetLastError(ERROR_FILE_NOT_FOUND);
736 return FALSE;
739 if (is_file_spec)
741 SetLastError(ERROR_FILE_NOT_FOUND);
742 return FALSE;
745 GetFullPathNameW(path, MAX_PATH, path, NULL);
747 return TRUE;
750 /*************************************************************************
751 * PathResolve [SHELL32.51]
753 BOOL WINAPI PathResolveAW(void *path, const void **paths, DWORD flags)
755 if (SHELL_OsIsUnicode())
756 return PathResolveW(path, (const WCHAR **)paths, flags);
757 else
758 return PathResolveA(path, (const char **)paths, flags);
761 /*************************************************************************
762 * PathProcessCommandA
764 static LONG PathProcessCommandA (
765 LPCSTR lpszPath,
766 LPSTR lpszBuff,
767 DWORD dwBuffSize,
768 DWORD dwFlags)
770 FIXME("%s %p 0x%04x 0x%04x stub\n",
771 lpszPath, lpszBuff, dwBuffSize, dwFlags);
772 if(!lpszPath) return -1;
773 if(lpszBuff) strcpy(lpszBuff, lpszPath);
774 return strlen(lpszPath);
777 /*************************************************************************
778 * PathProcessCommandW
780 static LONG PathProcessCommandW (
781 LPCWSTR lpszPath,
782 LPWSTR lpszBuff,
783 DWORD dwBuffSize,
784 DWORD dwFlags)
786 FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
787 debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
788 if(!lpszPath) return -1;
789 if(lpszBuff) strcpyW(lpszBuff, lpszPath);
790 return strlenW(lpszPath);
793 /*************************************************************************
794 * PathProcessCommand (SHELL32.653)
796 LONG WINAPI PathProcessCommandAW (
797 LPCVOID lpszPath,
798 LPVOID lpszBuff,
799 DWORD dwBuffSize,
800 DWORD dwFlags)
802 if (SHELL_OsIsUnicode())
803 return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
804 return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
808 ########## special ##########
811 /*************************************************************************
812 * PathSetDlgItemPath (SHELL32.48)
814 VOID WINAPI PathSetDlgItemPathAW(HWND hDlg, int id, LPCVOID pszPath)
816 if (SHELL_OsIsUnicode())
817 PathSetDlgItemPathW(hDlg, id, pszPath);
818 else
819 PathSetDlgItemPathA(hDlg, id, pszPath);
822 static const WCHAR szCategory[] = {'C','a','t','e','g','o','r','y',0};
823 static const WCHAR szAttributes[] = {'A','t','t','r','i','b','u','t','e','s',0};
824 static const WCHAR szName[] = {'N','a','m','e',0};
825 static const WCHAR szParsingName[] = {'P','a','r','s','i','n','g','N','a','m','e',0};
826 static const WCHAR szRelativePath[] = {'R','e','l','a','t','i','v','e','P','a','t','h',0};
827 static const WCHAR szParentFolder[] = {'P','a','r','e','n','t','F','o','l','d','e','r',0};
829 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'};
830 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};
831 static const WCHAR AppUpdatesFolderW[] = {'A','p','p','U','p','d','a','t','e','s','F','o','l','d','e','r',0};
832 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'};
833 static const WCHAR AppDataW[] = {'A','p','p','D','a','t','a','\0'};
834 static const WCHAR AppData_RoamingW[] = {'A','p','p','D','a','t','a','\\','R','o','a','m','i','n','g','\0'};
835 static const WCHAR AppData_LocalLowW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','L','o','w','\0'};
836 static const WCHAR AppData_LocalW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','\0'};
837 static const WCHAR Application_DataW[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
838 static const WCHAR CacheW[] = {'C','a','c','h','e','\0'};
839 static const WCHAR CD_BurningW[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
840 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};
841 static const WCHAR CommonW[] = {'C','o','m','m','o','n',0};
842 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'};
843 static const WCHAR Common_AppDataW[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'};
844 static const WCHAR Common_DesktopW[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'};
845 static const WCHAR Common_DocumentsW[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'};
846 static const WCHAR CommonDownloadsW[] = {'C','o','m','m','o','n','D','o','w','n','l','o','a','d','s',0};
847 static const WCHAR Common_FavoritesW[] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'};
848 static const WCHAR CommonFilesDirW[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'};
849 static const WCHAR CommonFilesDirX86W[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
850 static const WCHAR CommonMusicW[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'};
851 static const WCHAR CommonPicturesW[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'};
852 static const WCHAR Common_ProgramsW[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'};
853 static const WCHAR CommonRingtonesW[] = {'C','o','m','m','o','n','R','i','n','g','t','o','n','e','s',0};
854 static const WCHAR Common_StartUpW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'};
855 static const WCHAR Common_StartupW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','u','p','\0'};
856 static const WCHAR Common_Start_MenuW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'};
857 static const WCHAR Common_TemplatesW[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'};
858 static const WCHAR CommonVideoW[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
859 static const WCHAR ConflictFolderW[] = {'C','o','n','f','l','i','c','t','F','o','l','d','e','r',0};
860 static const WCHAR ConnectionsFolderW[] = {'C','o','n','n','e','c','t','i','o','n','s','F','o','l','d','e','r',0};
861 static const WCHAR ContactsW[] = {'C','o','n','t','a','c','t','s','\0'};
862 static const WCHAR ControlPanelFolderW[] = {'C','o','n','t','r','o','l','P','a','n','e','l','F','o','l','d','e','r',0};
863 static const WCHAR CookiesW[] = {'C','o','o','k','i','e','s','\0'};
864 static const WCHAR CSCFolderW[] = {'C','S','C','F','o','l','d','e','r',0};
865 static const WCHAR Default_GadgetsW[] = {'D','e','f','a','u','l','t',' ','G','a','d','g','e','t','s',0};
866 static const WCHAR DesktopW[] = {'D','e','s','k','t','o','p','\0'};
867 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};
868 static const WCHAR DocumentsW[] = {'D','o','c','u','m','e','n','t','s','\0'};
869 static const WCHAR DocumentsLibraryW[] = {'D','o','c','u','m','e','n','t','s','L','i','b','r','a','r','y','\0'};
870 static const WCHAR Documents_librarymsW[] = {'D','o','c','u','m','e','n','t','s','.','l','i','b','r','a','r','y','-','m','s',0};
871 static const WCHAR DownloadsW[] = {'D','o','w','n','l','o','a','d','s','\0'};
872 static const WCHAR FavoritesW[] = {'F','a','v','o','r','i','t','e','s','\0'};
873 static const WCHAR FontsW[] = {'F','o','n','t','s','\0'};
874 static const WCHAR GadgetsW[] = {'G','a','d','g','e','t','s',0};
875 static const WCHAR GamesW[] = {'G','a','m','e','s',0};
876 static const WCHAR GameTasksW[] = {'G','a','m','e','T','a','s','k','s',0};
877 static const WCHAR HistoryW[] = {'H','i','s','t','o','r','y','\0'};
878 static const WCHAR HomeGroupFolderW[] = {'H','o','m','e','G','r','o','u','p','F','o','l','d','e','r',0};
879 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};
880 static const WCHAR InternetFolderW[] = {'I','n','t','e','r','n','e','t','F','o','l','d','e','r',0};
881 static const WCHAR LibrariesW[] = {'L','i','b','r','a','r','i','e','s',0};
882 static const WCHAR LinksW[] = {'L','i','n','k','s','\0'};
883 static const WCHAR Local_AppDataW[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
884 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'};
885 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'};
886 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'};
887 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'};
888 static const WCHAR LocalAppDataLowW[] = {'L','o','c','a','l','A','p','p','D','a','t','a','L','o','w',0};
889 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};
890 static const WCHAR MAPIFolderW[] = {'M','A','P','I','F','o','l','d','e','r',0};
891 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};
892 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};
893 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};
894 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'};
895 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};
896 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};
897 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'};
898 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};
899 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};
900 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};
901 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'};
902 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'};
903 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};
904 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};
905 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};
906 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'};
907 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'};
908 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'};
909 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};
910 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};
911 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};
912 static const WCHAR MoviesW[] = {'M','o','v','i','e','s','\0'};
913 static const WCHAR MusicW[] = {'M','u','s','i','c','\0'};
914 static const WCHAR MusicLibraryW[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
915 static const WCHAR Music_librarymsW[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
916 static const WCHAR Music_PlaylistsW[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
917 static const WCHAR Music_Sample_MusicW[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
918 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'};
919 static const WCHAR My_MusicW[] = {'M','y',' ','M','u','s','i','c','\0'};
920 static const WCHAR My_PicturesW[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
921 static const WCHAR My_VideosW[] = {'M','y',' ','V','i','d','e','o','s','\0'};
922 static const WCHAR My_VideoW[] = {'M','y',' ','V','i','d','e','o','\0'};
923 static const WCHAR MyComputerFolderW[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
924 static const WCHAR NetHoodW[] = {'N','e','t','H','o','o','d','\0'};
925 static const WCHAR NetworkPlacesFolderW[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
926 static const WCHAR OEM_LinksW[] = {'O','E','M',' ','L','i','n','k','s','\0'};
927 static const WCHAR Original_ImagesW[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
928 static const WCHAR PersonalW[] = {'P','e','r','s','o','n','a','l','\0'};
929 static const WCHAR PhotoAlbumsW[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
930 static const WCHAR PicturesW[] = {'P','i','c','t','u','r','e','s','\0'};
931 static const WCHAR PicturesLibraryW[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
932 static const WCHAR Pictures_librarymsW[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
933 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'};
934 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'};
935 static const WCHAR PlaylistsW[] = {'P','l','a','y','l','i','s','t','s',0};
936 static const WCHAR PrintersFolderW[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
937 static const WCHAR PrintHoodW[] = {'P','r','i','n','t','H','o','o','d','\0'};
938 static const WCHAR ProfileW[] = {'P','r','o','f','i','l','e',0};
939 static const WCHAR ProgramDataW[] = {'P','r','o','g','r','a','m','D','a','t','a','\0'};
940 static const WCHAR Program_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
941 static const WCHAR ProgramFilesW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
942 static const WCHAR ProgramFilesX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
943 static const WCHAR ProgramFilesX64W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
944 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'};
945 static const WCHAR Program_Files_x86W[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
946 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'};
947 static const WCHAR ProgramFilesCommonW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
948 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};
949 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};
950 static const WCHAR ProgramFilesDirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
951 static const WCHAR ProgramFilesDirX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
952 static const WCHAR ProgramsW[] = {'P','r','o','g','r','a','m','s','\0'};
953 static const WCHAR PublicW[] = {'P','u','b','l','i','c',0};
954 static const WCHAR PublicGameTasksW[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
955 static const WCHAR PublicLibrariesW[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
956 static const WCHAR Quick_LaunchW[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
957 static const WCHAR RecentW[] = {'R','e','c','e','n','t','\0'};
958 static const WCHAR RecordedTVLibraryW[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
959 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};
960 static const WCHAR RecycleBinFolderW[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
961 static const WCHAR ResourceDirW[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
962 static const WCHAR ResourcesW[] = {'R','e','s','o','u','r','c','e','s','\0'};
963 static const WCHAR RingtonesW[] = {'R','i','n','g','t','o','n','e','s',0};
964 static const WCHAR SampleMusicW[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
965 static const WCHAR Sample_MusicW[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
966 static const WCHAR SamplePicturesW[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
967 static const WCHAR Sample_PicturesW[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
968 static const WCHAR SamplePlaylistsW[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
969 static const WCHAR Sample_PlaylistsW[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
970 static const WCHAR Sample_VideosW[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
971 static const WCHAR SampleVideosW[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
972 static const WCHAR Saved_GamesW[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
973 static const WCHAR SavedGamesW[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
974 static const WCHAR SearchesW[] = {'S','e','a','r','c','h','e','s','\0'};
975 static const WCHAR SearchHomeFolderW[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
976 static const WCHAR SendToW[] = {'S','e','n','d','T','o','\0'};
977 static const WCHAR Slide_ShowsW[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
978 static const WCHAR StartUpW[] = {'S','t','a','r','t','U','p','\0'};
979 static const WCHAR StartupW[] = {'S','t','a','r','t','u','p','\0'};
980 static const WCHAR Start_MenuW[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
981 static const WCHAR Start_Menu_ProgramsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
982 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'};
983 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'};
984 static const WCHAR SyncCenterFolderW[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
985 static const WCHAR SyncResultsFolderW[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
986 static const WCHAR SyncSetupFolderW[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
987 static const WCHAR SystemW[] = {'S','y','s','t','e','m',0};
988 static const WCHAR SystemX86W[] = {'S','y','s','t','e','m','X','8','6',0};
989 static const WCHAR TemplatesW[] = {'T','e','m','p','l','a','t','e','s','\0'};
990 static const WCHAR User_PinnedW[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
991 static const WCHAR UsersW[] = {'U','s','e','r','s','\0'};
992 static const WCHAR UsersFilesFolderW[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
993 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};
994 static const WCHAR UserProfilesW[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
995 static const WCHAR UserProgramFilesW[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
996 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};
997 static const WCHAR UsersPublicW[] = {'u','s','e','r','s','\\','P','u','b','l','i','c','\0'};
998 static const WCHAR VideosW[] = {'V','i','d','e','o','s','\0'};
999 static const WCHAR VideosLibraryW[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
1000 static const WCHAR Videos_librarymsW[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
1001 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'};
1002 static const WCHAR WindowsW[] = {'W','i','n','d','o','w','s',0};
1003 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};
1004 static const WCHAR DefaultW[] = {'.','D','e','f','a','u','l','t','\0'};
1005 static const WCHAR AllUsersProfileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
1006 static const WCHAR PublicProfileW[] = {'%','P','U','B','L','I','C','%',0};
1007 static const WCHAR UserProfileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
1008 static const WCHAR ProgramDataVarW[] = {'%','P','r','o','g','r','a','m','D','a','t','a','%','\0'};
1009 static const WCHAR SystemDriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
1010 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};
1011 static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
1012 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'};
1013 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'};
1014 static const WCHAR szDefaultProfileDirW[] = {'u','s','e','r','s',0};
1015 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'};
1016 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};
1018 #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','}'
1019 #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','}'
1020 #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','}'
1021 #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','}'
1022 #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','}'
1024 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};
1025 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};
1026 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};
1027 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};
1028 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};
1029 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};
1030 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};
1031 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};
1032 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};
1033 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};
1034 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};
1035 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};
1036 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};
1037 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};
1038 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};
1039 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};
1040 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};
1041 static const WCHAR ChangeRemoveProgramsParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID, 0};
1042 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};
1043 static const WCHAR SyncManagerFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', SYNCMANAGER_PARSING_GUID, 0};
1044 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};
1045 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};
1046 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};
1047 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};
1048 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};
1049 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};
1050 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};
1051 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};
1052 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};
1053 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};
1054 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};
1055 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};
1056 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};
1057 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};
1058 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};
1060 typedef enum _CSIDL_Type {
1061 CSIDL_Type_User,
1062 CSIDL_Type_AllUsers,
1063 CSIDL_Type_CurrVer,
1064 CSIDL_Type_Disallowed,
1065 CSIDL_Type_NonExistent,
1066 CSIDL_Type_WindowsPath,
1067 CSIDL_Type_SystemPath,
1068 CSIDL_Type_SystemX86Path,
1069 CSIDL_Type_ProgramData,
1070 } CSIDL_Type;
1072 #define CSIDL_CONTACTS 0x0043
1073 #define CSIDL_DOWNLOADS 0x0047
1074 #define CSIDL_LINKS 0x004d
1075 #define CSIDL_APPDATA_LOCALLOW 0x004e
1076 #define CSIDL_SAVED_GAMES 0x0062
1077 #define CSIDL_SEARCHES 0x0063
1079 typedef struct
1081 IApplicationDestinations IApplicationDestinations_iface;
1082 LONG ref;
1083 } IApplicationDestinationsImpl;
1085 static inline IApplicationDestinationsImpl *impl_from_IApplicationDestinations( IApplicationDestinations *iface )
1087 return CONTAINING_RECORD(iface, IApplicationDestinationsImpl, IApplicationDestinations_iface);
1090 static HRESULT WINAPI ApplicationDestinations_QueryInterface(IApplicationDestinations *iface, REFIID riid,
1091 LPVOID *ppv)
1093 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1095 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppv);
1097 if (ppv == NULL)
1098 return E_POINTER;
1100 if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IApplicationDestinations, riid))
1102 *ppv = &This->IApplicationDestinations_iface;
1103 IUnknown_AddRef((IUnknown*)*ppv);
1105 TRACE("Returning IApplicationDestinations: %p\n", *ppv);
1106 return S_OK;
1109 *ppv = NULL;
1110 FIXME("(%p)->(%s, %p) interface not supported.\n", This, debugstr_guid(riid), ppv);
1112 return E_NOINTERFACE;
1115 static ULONG WINAPI ApplicationDestinations_AddRef(IApplicationDestinations *iface)
1117 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1118 ULONG ref = InterlockedIncrement(&This->ref);
1120 TRACE("(%p), new refcount=%i\n", This, ref);
1122 return ref;
1125 static ULONG WINAPI ApplicationDestinations_Release(IApplicationDestinations *iface)
1127 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1128 ULONG ref = InterlockedDecrement(&This->ref);
1130 TRACE("(%p), new refcount=%i\n", This, ref);
1132 if (ref == 0)
1133 heap_free(This);
1135 return ref;
1138 static HRESULT WINAPI ApplicationDestinations_SetAppID(IApplicationDestinations *iface, const WCHAR *appid)
1140 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1142 FIXME("(%p, %s) stub!\n", This, debugstr_w(appid));
1144 return E_NOTIMPL;
1147 static HRESULT WINAPI ApplicationDestinations_RemoveDestination(IApplicationDestinations *iface, IUnknown *punk)
1149 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1151 FIXME("(%p, %p) stub!\n", This, punk);
1153 return E_NOTIMPL;
1156 static HRESULT WINAPI ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations *iface)
1158 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1160 FIXME("(%p) stub!\n", This);
1162 return E_NOTIMPL;
1165 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl =
1167 ApplicationDestinations_QueryInterface,
1168 ApplicationDestinations_AddRef,
1169 ApplicationDestinations_Release,
1170 ApplicationDestinations_SetAppID,
1171 ApplicationDestinations_RemoveDestination,
1172 ApplicationDestinations_RemoveAllDestinations
1175 HRESULT WINAPI ApplicationDestinations_Constructor(IUnknown *outer, REFIID riid, LPVOID *ppv)
1177 IApplicationDestinationsImpl *This;
1178 HRESULT hr;
1180 TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);
1182 if (outer)
1183 return CLASS_E_NOAGGREGATION;
1185 if (!(This = SHAlloc(sizeof(*This))))
1186 return E_OUTOFMEMORY;
1188 This->IApplicationDestinations_iface.lpVtbl = &ApplicationDestinationsVtbl;
1189 This->ref = 0;
1191 hr = IUnknown_QueryInterface(&This->IApplicationDestinations_iface, riid, ppv);
1192 if (FAILED(hr))
1193 SHFree(This);
1195 return hr;
1198 typedef struct
1200 const KNOWNFOLDERID *id;
1201 CSIDL_Type type;
1202 LPCWSTR szValueName;
1203 LPCWSTR szDefaultPath; /* fallback string or resource ID */
1205 /* KNOWNFOLDER_DEFINITION fields */
1206 KF_CATEGORY category;
1207 const WCHAR *pszName;
1208 const WCHAR *pszDescription;
1209 const KNOWNFOLDERID *fidParent;
1210 const WCHAR *pszRelativePath;
1211 const WCHAR *pszParsingName;
1212 const WCHAR *pszTooltip;
1213 const WCHAR *pszLocalizedName;
1214 const WCHAR *pszIcon;
1215 const WCHAR *pszSecurity;
1216 DWORD dwAttributes;
1217 KF_DEFINITION_FLAGS kfdFlags;
1218 const FOLDERTYPEID *ftidType;
1219 } CSIDL_DATA;
1221 static const CSIDL_DATA CSIDL_Data[] =
1223 { /* 0x00 - CSIDL_DESKTOP */
1224 &FOLDERID_Desktop,
1225 CSIDL_Type_User,
1226 DesktopW,
1227 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1229 KF_CATEGORY_PERUSER, /* category */
1230 DesktopW, /* name */
1231 NULL, /* description */
1232 &GUID_NULL, /* parent */
1233 DesktopW, /* relative path */
1234 NULL, /* parsing */
1235 NULL, /* tooltip */
1236 NULL, /* localized */
1237 NULL, /* icon */
1238 NULL, /* security */
1239 FILE_ATTRIBUTE_READONLY, /* attributes */
1240 0, /* flags */
1241 &GUID_NULL /* typeid */
1243 { /* 0x01 - CSIDL_INTERNET */
1244 &FOLDERID_InternetFolder,
1245 CSIDL_Type_Disallowed,
1246 NULL,
1247 NULL,
1249 KF_CATEGORY_VIRTUAL, /* category */
1250 InternetFolderW, /* name */
1251 NULL, /* description */
1252 &GUID_NULL, /* parent */
1253 NULL, /* relative path */
1254 InternetFolderParsingNameW, /* parsing */
1255 NULL, /* tooltip */
1256 NULL, /* localized */
1257 NULL, /* icon */
1258 NULL, /* security */
1259 0, /* attributes */
1260 0, /* flags */
1261 &GUID_NULL /* typeid */
1263 { /* 0x02 - CSIDL_PROGRAMS */
1264 &FOLDERID_Programs,
1265 CSIDL_Type_User,
1266 ProgramsW,
1267 Start_Menu_ProgramsW,
1269 KF_CATEGORY_PERUSER, /* category */
1270 ProgramsW, /* name */
1271 NULL, /* description */
1272 &GUID_NULL, /* parent */
1273 ProgramsW, /* relative path */
1274 NULL, /* parsing */
1275 NULL, /* tooltip */
1276 NULL, /* localized */
1277 NULL, /* icon */
1278 NULL, /* security */
1279 FILE_ATTRIBUTE_READONLY, /* attributes */
1280 0, /* flags */
1281 &GUID_NULL /* typeid */
1283 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1284 &FOLDERID_ControlPanelFolder,
1285 CSIDL_Type_SystemPath,
1286 NULL,
1287 NULL,
1289 KF_CATEGORY_VIRTUAL, /* category */
1290 ControlPanelFolderW, /* name */
1291 NULL, /* description */
1292 &GUID_NULL, /* parent */
1293 ControlPanelFolderRelativePathW, /* relative path */
1294 ControlPanelFolderParsingNameW, /* parsing */
1295 NULL, /* tooltip */
1296 NULL, /* localized */
1297 NULL, /* icon */
1298 NULL, /* security */
1299 0, /* attributes */
1300 0, /* flags */
1301 &GUID_NULL /* typeid */
1303 { /* 0x04 - CSIDL_PRINTERS */
1304 &FOLDERID_PrintersFolder,
1305 CSIDL_Type_SystemPath,
1306 NULL,
1307 NULL,
1309 KF_CATEGORY_VIRTUAL, /* category */
1310 PrintersFolderW, /* name */
1311 NULL, /* description */
1312 &GUID_NULL, /* parent */
1313 NULL, /* relative path */
1314 PrintersFolderParsingNameW, /* parsing */
1315 NULL, /* tooltip */
1316 NULL, /* localized */
1317 NULL, /* icon */
1318 NULL, /* security */
1319 0, /* attributes */
1320 0, /* flags */
1321 &GUID_NULL /* typeid */
1323 { /* 0x05 - CSIDL_PERSONAL */
1324 &FOLDERID_Documents,
1325 CSIDL_Type_User,
1326 PersonalW,
1327 MAKEINTRESOURCEW(IDS_PERSONAL),
1329 KF_CATEGORY_PERUSER, /* category */
1330 PersonalW, /* name */
1331 NULL, /* description */
1332 &GUID_NULL, /* parent */
1333 DocumentsW, /* relative path */
1334 DocumentsParsingNameW, /* parsing */
1335 NULL, /* tooltip */
1336 NULL, /* localized */
1337 NULL, /* icon */
1338 NULL, /* security */
1339 FILE_ATTRIBUTE_READONLY, /* attributes */
1340 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1341 &GUID_NULL /* typeid */
1343 { /* 0x06 - CSIDL_FAVORITES */
1344 &FOLDERID_Favorites,
1345 CSIDL_Type_User,
1346 FavoritesW,
1347 FavoritesW,
1349 KF_CATEGORY_PERUSER, /* category */
1350 FavoritesW, /* name */
1351 NULL, /* description */
1352 &GUID_NULL, /* parent */
1353 FavoritesW, /* relative path */
1354 NULL, /* parsing */
1355 NULL, /* tooltip */
1356 NULL, /* localized */
1357 NULL, /* icon */
1358 NULL, /* security */
1359 FILE_ATTRIBUTE_READONLY, /* attributes */
1360 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1361 &GUID_NULL /* typeid */
1363 { /* 0x07 - CSIDL_STARTUP */
1364 &FOLDERID_Startup,
1365 CSIDL_Type_User,
1366 StartUpW,
1367 Start_Menu_StartupW,
1369 KF_CATEGORY_PERUSER, /* category */
1370 StartupW, /* name */
1371 NULL, /* description */
1372 &GUID_NULL, /* parent */
1373 StartUpW, /* relative path */
1374 NULL, /* parsing */
1375 NULL, /* tooltip */
1376 NULL, /* localized */
1377 NULL, /* icon */
1378 NULL, /* security */
1379 FILE_ATTRIBUTE_READONLY, /* attributes */
1380 KFDF_PRECREATE, /* flags */
1381 &GUID_NULL /* typeid */
1383 { /* 0x08 - CSIDL_RECENT */
1384 &FOLDERID_Recent,
1385 CSIDL_Type_User,
1386 RecentW,
1387 RecentW,
1389 KF_CATEGORY_PERUSER, /* category */
1390 RecentW, /* name */
1391 NULL, /* description */
1392 &FOLDERID_RoamingAppData, /* parent */
1393 Microsoft_Windows_RecentW, /* relative path */
1394 NULL, /* parsing */
1395 NULL, /* tooltip */
1396 NULL, /* localized */
1397 NULL, /* icon */
1398 NULL, /* security */
1399 FILE_ATTRIBUTE_READONLY, /* attributes */
1400 KFDF_PRECREATE, /* flags */
1401 &GUID_NULL /* typeid */
1403 { /* 0x09 - CSIDL_SENDTO */
1404 &FOLDERID_SendTo,
1405 CSIDL_Type_User,
1406 SendToW,
1407 SendToW,
1409 KF_CATEGORY_PERUSER, /* category */
1410 SendToW, /* name */
1411 NULL, /* description */
1412 &FOLDERID_RoamingAppData, /* parent */
1413 Microsoft_Windows_SendToW, /* relative path */
1414 NULL, /* parsing */
1415 NULL, /* tooltip */
1416 NULL, /* localized */
1417 NULL, /* icon */
1418 NULL, /* security */
1419 0, /* attributes */
1420 KFDF_PRECREATE, /* flags */
1421 &GUID_NULL /* typeid */
1423 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1424 &FOLDERID_RecycleBinFolder,
1425 CSIDL_Type_Disallowed,
1426 NULL,
1427 NULL,
1429 KF_CATEGORY_VIRTUAL, /* category */
1430 RecycleBinFolderW, /* name */
1431 NULL, /* description */
1432 &GUID_NULL, /* parent */
1433 NULL, /* relative path */
1434 RecycleBinFolderParsingNameW, /* parsing */
1435 NULL, /* tooltip */
1436 NULL, /* localized */
1437 NULL, /* icon */
1438 NULL, /* security */
1439 0, /* attributes */
1440 0, /* flags */
1441 &GUID_NULL /* typeid */
1443 { /* 0x0b - CSIDL_STARTMENU */
1444 &FOLDERID_StartMenu,
1445 CSIDL_Type_User,
1446 Start_MenuW,
1447 Start_MenuW,
1449 KF_CATEGORY_PERUSER, /* category */
1450 Start_MenuW, /* name */
1451 NULL, /* description */
1452 &FOLDERID_RoamingAppData, /* parent */
1453 Microsoft_Windows_Start_MenuW, /* relative path */
1454 NULL, /* parsing */
1455 NULL, /* tooltip */
1456 NULL, /* localized */
1457 NULL, /* icon */
1458 NULL, /* security */
1459 FILE_ATTRIBUTE_READONLY, /* attributes */
1460 KFDF_PRECREATE, /* flags */
1461 &GUID_NULL /* typeid */
1463 { /* 0x0c - CSIDL_MYDOCUMENTS */
1464 &GUID_NULL,
1465 CSIDL_Type_Disallowed, /* matches WinXP--can't get its path */
1466 NULL,
1467 NULL
1469 { /* 0x0d - CSIDL_MYMUSIC */
1470 &FOLDERID_Music,
1471 CSIDL_Type_User,
1472 My_MusicW,
1473 MAKEINTRESOURCEW(IDS_MYMUSIC),
1475 KF_CATEGORY_PERUSER, /* category */
1476 My_MusicW, /* name */
1477 NULL, /* description */
1478 &FOLDERID_Profile, /* parent */
1479 MusicW, /* relative path */
1480 MusicParsingNameW, /* parsing */
1481 NULL, /* tooltip */
1482 NULL, /* localized */
1483 NULL, /* icon */
1484 NULL, /* security */
1485 FILE_ATTRIBUTE_READONLY, /* attributes */
1486 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1487 &GUID_NULL /* typeid */
1489 { /* 0x0e - CSIDL_MYVIDEO */
1490 &FOLDERID_Videos,
1491 CSIDL_Type_User,
1492 My_VideosW,
1493 MAKEINTRESOURCEW(IDS_MYVIDEOS),
1495 KF_CATEGORY_PERUSER, /* category */
1496 My_VideoW, /* name */
1497 NULL, /* description */
1498 &FOLDERID_Profile, /* parent */
1499 VideosW, /* relative path */
1500 VideosParsingNameW, /* parsing */
1501 NULL, /* tooltip */
1502 NULL, /* localized */
1503 NULL, /* icon */
1504 NULL, /* security */
1505 FILE_ATTRIBUTE_READONLY, /* attributes */
1506 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1507 &GUID_NULL /* typeid */
1509 { /* 0x0f - unassigned */
1510 &GUID_NULL,
1511 CSIDL_Type_Disallowed,
1512 NULL,
1513 NULL,
1515 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1516 &FOLDERID_Desktop,
1517 CSIDL_Type_User,
1518 DesktopW,
1519 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1521 KF_CATEGORY_PERUSER, /* category */
1522 DesktopW, /* name */
1523 NULL, /* description */
1524 &FOLDERID_Profile, /* parent */
1525 DesktopW, /* relative path */
1526 NULL, /* parsing */
1527 NULL, /* tooltip */
1528 NULL, /* localized */
1529 NULL, /* icon */
1530 NULL, /* security */
1531 FILE_ATTRIBUTE_READONLY, /* attributes */
1532 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1533 &GUID_NULL /* typeid */
1535 { /* 0x11 - CSIDL_DRIVES */
1536 &FOLDERID_ComputerFolder,
1537 CSIDL_Type_Disallowed,
1538 NULL,
1539 NULL,
1541 KF_CATEGORY_VIRTUAL, /* category */
1542 MyComputerFolderW, /* name */
1543 NULL, /* description */
1544 &GUID_NULL, /* parent */
1545 NULL, /* relative path */
1546 ComputerFolderParsingNameW, /* parsing */
1547 NULL, /* tooltip */
1548 NULL, /* localized */
1549 NULL, /* icon */
1550 NULL, /* security */
1551 0, /* attributes */
1552 0, /* flags */
1553 &GUID_NULL /* typeid */
1555 { /* 0x12 - CSIDL_NETWORK */
1556 &FOLDERID_NetworkFolder,
1557 CSIDL_Type_Disallowed,
1558 NULL,
1559 NULL,
1561 KF_CATEGORY_VIRTUAL, /* category */
1562 NetworkPlacesFolderW, /* name */
1563 NULL, /* description */
1564 &GUID_NULL, /* parent */
1565 NULL, /* relative path */
1566 NetworkFolderParsingNameW, /* parsing */
1567 NULL, /* tooltip */
1568 NULL, /* localized */
1569 NULL, /* icon */
1570 NULL, /* security */
1571 0, /* attributes */
1572 0, /* flags */
1573 &GUID_NULL /* typeid */
1575 { /* 0x13 - CSIDL_NETHOOD */
1576 &FOLDERID_NetHood,
1577 CSIDL_Type_User,
1578 NetHoodW,
1579 NetHoodW,
1581 KF_CATEGORY_PERUSER, /* category */
1582 NetHoodW, /* name */
1583 NULL, /* description */
1584 &FOLDERID_RoamingAppData, /* parent */
1585 Microsoft_Windows_Network_ShortcutsW, /* relative path */
1586 NULL, /* parsing */
1587 NULL, /* tooltip */
1588 NULL, /* localized */
1589 NULL, /* icon */
1590 NULL, /* security */
1591 0, /* attributes */
1592 0, /* flags */
1593 &GUID_NULL /* typeid */
1595 { /* 0x14 - CSIDL_FONTS */
1596 &FOLDERID_Fonts,
1597 CSIDL_Type_WindowsPath,
1598 FontsW,
1599 FontsW,
1601 KF_CATEGORY_FIXED, /* category */
1602 FontsW, /* name */
1603 NULL, /* description */
1604 &GUID_NULL, /* parent */
1605 NULL, /* relative path */
1606 NULL, /* parsing */
1607 NULL, /* tooltip */
1608 NULL, /* localized */
1609 NULL, /* icon */
1610 NULL, /* security */
1611 0, /* attributes */
1612 0, /* flags */
1613 &FOLDERID_Windows/* typeid */
1615 { /* 0x15 - CSIDL_TEMPLATES */
1616 &FOLDERID_Templates,
1617 CSIDL_Type_User,
1618 TemplatesW,
1619 TemplatesW,
1621 KF_CATEGORY_PERUSER, /* category */
1622 TemplatesW, /* name */
1623 NULL, /* description */
1624 &FOLDERID_RoamingAppData, /* parent */
1625 Microsoft_Windows_TemplatesW, /* relative path */
1626 NULL, /* parsing */
1627 NULL, /* tooltip */
1628 NULL, /* localized */
1629 NULL, /* icon */
1630 NULL, /* security */
1631 0, /* attributes */
1632 0, /* flags */
1633 &GUID_NULL /* typeid */
1635 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1636 &FOLDERID_CommonStartMenu,
1637 CSIDL_Type_ProgramData,
1638 Common_Start_MenuW,
1639 Microsoft_Windows_Start_MenuW,
1641 KF_CATEGORY_COMMON, /* category */
1642 Common_Start_MenuW, /* name */
1643 NULL, /* description */
1644 &FOLDERID_ProgramData, /* parent */
1645 Microsoft_Windows_Start_MenuW, /* relative path */
1646 NULL, /* parsing */
1647 NULL, /* tooltip */
1648 NULL, /* localized */
1649 NULL, /* icon */
1650 NULL, /* security */
1651 FILE_ATTRIBUTE_READONLY, /* attributes */
1652 0, /* flags */
1653 &GUID_NULL /* typeid */
1655 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1656 &FOLDERID_CommonPrograms,
1657 CSIDL_Type_ProgramData,
1658 Common_ProgramsW,
1659 Microsoft_Windows_Start_Menu_ProgramsW,
1661 KF_CATEGORY_COMMON, /* category */
1662 Common_ProgramsW, /* name */
1663 NULL, /* description */
1664 &FOLDERID_CommonStartMenu, /* parent */
1665 ProgramsW, /* relative path */
1666 NULL, /* parsing */
1667 NULL, /* tooltip */
1668 NULL, /* localized */
1669 NULL, /* icon */
1670 NULL, /* security */
1671 FILE_ATTRIBUTE_READONLY, /* attributes */
1672 0, /* flags */
1673 &GUID_NULL /* typeid */
1675 { /* 0x18 - CSIDL_COMMON_STARTUP */
1676 &FOLDERID_CommonStartup,
1677 CSIDL_Type_ProgramData,
1678 Common_StartUpW,
1679 Microsoft_Windows_Start_Menu_StartupW,
1681 KF_CATEGORY_COMMON, /* category */
1682 Common_StartupW, /* name */
1683 NULL, /* description */
1684 &FOLDERID_CommonPrograms, /* parent */
1685 StartUpW, /* relative path */
1686 NULL, /* parsing */
1687 NULL, /* tooltip */
1688 NULL, /* localized */
1689 NULL, /* icon */
1690 NULL, /* security */
1691 FILE_ATTRIBUTE_READONLY, /* attributes */
1692 KFDF_PRECREATE, /* flags */
1693 &GUID_NULL /* typeid */
1695 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1696 &FOLDERID_PublicDesktop,
1697 CSIDL_Type_AllUsers,
1698 Common_DesktopW,
1699 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1701 KF_CATEGORY_COMMON, /* category */
1702 Common_DesktopW, /* name */
1703 NULL, /* description */
1704 &FOLDERID_Public, /* parent */
1705 DesktopW, /* relative path */
1706 NULL, /* parsing */
1707 NULL, /* tooltip */
1708 NULL, /* localized */
1709 NULL, /* icon */
1710 NULL, /* security */
1711 FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN, /* attributes */
1712 KFDF_PRECREATE, /* flags */
1713 &GUID_NULL /* typeid */
1715 { /* 0x1a - CSIDL_APPDATA */
1716 &FOLDERID_RoamingAppData,
1717 CSIDL_Type_User,
1718 AppDataW,
1719 Application_DataW,
1721 KF_CATEGORY_PERUSER, /* category */
1722 AppDataW, /* name */
1723 NULL, /* description */
1724 &FOLDERID_Profile, /* parent */
1725 AppData_RoamingW, /* relative path */
1726 NULL, /* parsing */
1727 NULL, /* tooltip */
1728 NULL, /* localized */
1729 NULL, /* icon */
1730 NULL, /* security */
1731 0, /* attributes */
1732 0, /* flags */
1733 &GUID_NULL /* typeid */
1735 { /* 0x1b - CSIDL_PRINTHOOD */
1736 &FOLDERID_PrintHood,
1737 CSIDL_Type_User,
1738 PrintHoodW,
1739 PrintHoodW,
1741 KF_CATEGORY_PERUSER, /* category */
1742 PrintHoodW, /* name */
1743 NULL, /* description */
1744 &FOLDERID_RoamingAppData, /* parent */
1745 Microsoft_Windows_Printer_ShortcutsW, /* relative path */
1746 NULL, /* parsing */
1747 NULL, /* tooltip */
1748 NULL, /* localized */
1749 NULL, /* icon */
1750 NULL, /* security */
1751 0, /* attributes */
1752 0, /* flags */
1753 &GUID_NULL /* typeid */
1755 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1756 &FOLDERID_LocalAppData,
1757 CSIDL_Type_User,
1758 Local_AppDataW,
1759 Local_Settings_Application_DataW,
1761 KF_CATEGORY_PERUSER, /* category */
1762 Local_AppDataW, /* name */
1763 NULL, /* description */
1764 &FOLDERID_Profile, /* parent */
1765 AppData_LocalW, /* relative path */
1766 NULL, /* parsing */
1767 NULL, /* tooltip */
1768 NULL, /* localized */
1769 NULL, /* icon */
1770 NULL, /* security */
1771 0, /* attributes */
1772 KFDF_LOCAL_REDIRECT_ONLY | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1773 &GUID_NULL /* typeid */
1775 { /* 0x1d - CSIDL_ALTSTARTUP */
1776 &GUID_NULL,
1777 CSIDL_Type_NonExistent,
1778 NULL,
1779 NULL
1781 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1782 &GUID_NULL,
1783 CSIDL_Type_NonExistent,
1784 NULL,
1785 NULL
1787 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1788 &FOLDERID_Favorites,
1789 CSIDL_Type_AllUsers,
1790 Common_FavoritesW,
1791 FavoritesW,
1793 KF_CATEGORY_PERUSER, /* category */
1794 FavoritesW, /* name */
1795 NULL, /* description */
1796 &FOLDERID_Profile, /* parent */
1797 FavoritesW, /* relative path */
1798 NULL, /* parsing */
1799 NULL, /* tooltip */
1800 NULL, /* localized */
1801 NULL, /* icon */
1802 NULL, /* security */
1803 FILE_ATTRIBUTE_READONLY, /* attributes */
1804 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1805 &GUID_NULL /* typeid */
1807 { /* 0x20 - CSIDL_INTERNET_CACHE */
1808 &FOLDERID_InternetCache,
1809 CSIDL_Type_User,
1810 CacheW,
1811 Local_Settings_Temporary_Internet_FilesW,
1813 KF_CATEGORY_PERUSER, /* category */
1814 CacheW, /* name */
1815 NULL, /* description */
1816 &FOLDERID_LocalAppData, /* parent */
1817 Microsoft_Windows_Temporary_Internet_FilesW, /* relative path */
1818 NULL, /* parsing */
1819 NULL, /* tooltip */
1820 NULL, /* localized */
1821 NULL, /* icon */
1822 NULL, /* security */
1823 0, /* attributes */
1824 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
1825 &GUID_NULL /* typeid */
1827 { /* 0x21 - CSIDL_COOKIES */
1828 &FOLDERID_Cookies,
1829 CSIDL_Type_User,
1830 CookiesW,
1831 CookiesW,
1833 KF_CATEGORY_PERUSER, /* category */
1834 CookiesW, /* name */
1835 NULL, /* description */
1836 &FOLDERID_RoamingAppData, /* parent */
1837 Microsoft_Windows_CookiesW, /* relative path */
1838 NULL, /* parsing */
1839 NULL, /* tooltip */
1840 NULL, /* localized */
1841 NULL, /* icon */
1842 NULL, /* security */
1843 0, /* attributes */
1844 0, /* flags */
1845 &GUID_NULL /* typeid */
1847 { /* 0x22 - CSIDL_HISTORY */
1848 &FOLDERID_History,
1849 CSIDL_Type_User,
1850 HistoryW,
1851 Local_Settings_HistoryW,
1853 KF_CATEGORY_PERUSER, /* category */
1854 HistoryW, /* name */
1855 NULL, /* description */
1856 &FOLDERID_LocalAppData, /* parent */
1857 Microsoft_Windows_HistoryW, /* relative path */
1858 NULL, /* parsing */
1859 NULL, /* tooltip */
1860 NULL, /* localized */
1861 NULL, /* icon */
1862 NULL, /* security */
1863 0, /* attributes */
1864 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
1865 &GUID_NULL /* typeid */
1867 { /* 0x23 - CSIDL_COMMON_APPDATA */
1868 &FOLDERID_ProgramData,
1869 CSIDL_Type_ProgramData,
1870 Common_AppDataW,
1871 NULL,
1873 KF_CATEGORY_FIXED, /* category */
1874 Common_AppDataW, /* name */
1875 NULL, /* description */
1876 &GUID_NULL, /* parent */
1877 NULL, /* relative path */
1878 NULL, /* parsing */
1879 NULL, /* tooltip */
1880 NULL, /* localized */
1881 NULL, /* icon */
1882 NULL, /* security */
1883 0, /* attributes */
1884 0, /* flags */
1885 &GUID_NULL /* typeid */
1887 { /* 0x24 - CSIDL_WINDOWS */
1888 &FOLDERID_Windows,
1889 CSIDL_Type_WindowsPath,
1890 NULL,
1891 NULL,
1893 KF_CATEGORY_FIXED, /* category */
1894 WindowsW, /* name */
1895 NULL, /* description */
1896 &GUID_NULL, /* parent */
1897 NULL, /* relative path */
1898 NULL, /* parsing */
1899 NULL, /* tooltip */
1900 NULL, /* localized */
1901 NULL, /* icon */
1902 NULL, /* security */
1903 0, /* attributes */
1904 0, /* flags */
1905 &GUID_NULL /* typeid */
1907 { /* 0x25 - CSIDL_SYSTEM */
1908 &FOLDERID_System,
1909 CSIDL_Type_SystemPath,
1910 NULL,
1911 NULL,
1913 KF_CATEGORY_FIXED, /* category */
1914 SystemW, /* name */
1915 NULL, /* description */
1916 &GUID_NULL, /* parent */
1917 NULL, /* relative path */
1918 NULL, /* parsing */
1919 NULL, /* tooltip */
1920 NULL, /* localized */
1921 NULL, /* icon */
1922 NULL, /* security */
1923 0, /* attributes */
1924 0, /* flags */
1925 &GUID_NULL /* typeid */
1927 { /* 0x26 - CSIDL_PROGRAM_FILES */
1928 &FOLDERID_ProgramFiles,
1929 CSIDL_Type_CurrVer,
1930 ProgramFilesDirW,
1931 Program_FilesW,
1933 KF_CATEGORY_FIXED, /* category */
1934 ProgramFilesW, /* name */
1935 NULL, /* description */
1936 &GUID_NULL, /* parent */
1937 NULL, /* relative path */
1938 NULL, /* parsing */
1939 NULL, /* tooltip */
1940 NULL, /* localized */
1941 NULL, /* icon */
1942 NULL, /* security */
1943 FILE_ATTRIBUTE_READONLY, /* attributes */
1944 0, /* flags */
1945 &GUID_NULL /* typeid */
1947 { /* 0x27 - CSIDL_MYPICTURES */
1948 &FOLDERID_Pictures,
1949 CSIDL_Type_User,
1950 My_PicturesW,
1951 MAKEINTRESOURCEW(IDS_MYPICTURES),
1953 KF_CATEGORY_PERUSER, /* category */
1954 My_PicturesW, /* name */
1955 NULL, /* description */
1956 &FOLDERID_Profile, /* parent */
1957 PicturesW, /* relative path */
1958 PicturesParsingNameW, /* parsing */
1959 NULL, /* tooltip */
1960 NULL, /* localized */
1961 NULL, /* icon */
1962 NULL, /* security */
1963 FILE_ATTRIBUTE_READONLY, /* attributes */
1964 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1965 &GUID_NULL /* typeid */
1967 { /* 0x28 - CSIDL_PROFILE */
1968 &FOLDERID_Profile,
1969 CSIDL_Type_User,
1970 NULL,
1971 NULL,
1973 KF_CATEGORY_FIXED, /* category */
1974 ProfileW, /* name */
1975 NULL, /* description */
1976 &GUID_NULL, /* parent */
1977 NULL, /* relative path */
1978 NULL, /* parsing */
1979 NULL, /* tooltip */
1980 NULL, /* localized */
1981 NULL, /* icon */
1982 NULL, /* security */
1983 0, /* attributes */
1984 0, /* flags */
1985 &GUID_NULL /* typeid */
1987 { /* 0x29 - CSIDL_SYSTEMX86 */
1988 &FOLDERID_SystemX86,
1989 CSIDL_Type_SystemX86Path,
1990 NULL,
1991 NULL,
1993 KF_CATEGORY_FIXED, /* category */
1994 SystemX86W, /* name */
1995 NULL, /* description */
1996 &GUID_NULL, /* parent */
1997 NULL, /* relative path */
1998 NULL, /* parsing */
1999 NULL, /* tooltip */
2000 NULL, /* localized */
2001 NULL, /* icon */
2002 NULL, /* security */
2003 0, /* attributes */
2004 0, /* flags */
2005 &GUID_NULL /* typeid */
2007 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
2008 &FOLDERID_ProgramFilesX86,
2009 CSIDL_Type_CurrVer,
2010 ProgramFilesDirX86W,
2011 Program_Files_x86W,
2013 KF_CATEGORY_FIXED, /* category */
2014 ProgramFilesX86W, /* name */
2015 NULL, /* description */
2016 &GUID_NULL, /* parent */
2017 NULL, /* relative path */
2018 NULL, /* parsing */
2019 NULL, /* tooltip */
2020 NULL, /* localized */
2021 NULL, /* icon */
2022 NULL, /* security */
2023 FILE_ATTRIBUTE_READONLY, /* attributes */
2024 0, /* flags */
2025 &GUID_NULL /* typeid */
2027 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
2028 &FOLDERID_ProgramFilesCommon,
2029 CSIDL_Type_CurrVer,
2030 CommonFilesDirW,
2031 Program_Files_Common_FilesW,
2033 KF_CATEGORY_FIXED, /* category */
2034 ProgramFilesCommonW, /* name */
2035 NULL, /* description */
2036 &GUID_NULL, /* parent */
2037 NULL, /* relative path */
2038 NULL, /* parsing */
2039 NULL, /* tooltip */
2040 NULL, /* localized */
2041 NULL, /* icon */
2042 NULL, /* security */
2043 0, /* attributes */
2044 0, /* flags */
2045 &GUID_NULL /* typeid */
2047 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
2048 &FOLDERID_ProgramFilesCommonX86,
2049 CSIDL_Type_CurrVer,
2050 CommonFilesDirX86W,
2051 Program_Files_x86_Common_FilesW,
2053 KF_CATEGORY_FIXED, /* category */
2054 ProgramFilesCommonX86W, /* name */
2055 NULL, /* description */
2056 &GUID_NULL, /* parent */
2057 NULL, /* relative path */
2058 NULL, /* parsing */
2059 NULL, /* tooltip */
2060 NULL, /* localized */
2061 NULL, /* icon */
2062 NULL, /* security */
2063 0, /* attributes */
2064 0, /* flags */
2065 &GUID_NULL /* typeid */
2067 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2068 &FOLDERID_CommonTemplates,
2069 CSIDL_Type_ProgramData,
2070 Common_TemplatesW,
2071 Microsoft_Windows_TemplatesW,
2073 KF_CATEGORY_COMMON, /* category */
2074 Common_TemplatesW, /* name */
2075 NULL, /* description */
2076 &FOLDERID_ProgramData, /* parent */
2077 Microsoft_Windows_TemplatesW, /* relative path */
2078 NULL, /* parsing */
2079 NULL, /* tooltip */
2080 NULL, /* localized */
2081 NULL, /* icon */
2082 NULL, /* security */
2083 0, /* attributes */
2084 0, /* flags */
2085 &GUID_NULL /* typeid */
2087 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2088 &FOLDERID_PublicDocuments,
2089 CSIDL_Type_AllUsers,
2090 Common_DocumentsW,
2091 DocumentsW,
2093 KF_CATEGORY_COMMON, /* category */
2094 Common_DocumentsW, /* name */
2095 NULL, /* description */
2096 &FOLDERID_Public, /* parent */
2097 DocumentsW, /* relative path */
2098 NULL, /* parsing */
2099 NULL, /* tooltip */
2100 NULL, /* localized */
2101 NULL, /* icon */
2102 NULL, /* security */
2103 FILE_ATTRIBUTE_READONLY, /* attributes */
2104 KFDF_PRECREATE, /* flags */
2105 &GUID_NULL /* typeid */
2107 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2108 &FOLDERID_CommonAdminTools,
2109 CSIDL_Type_ProgramData,
2110 Common_Administrative_ToolsW,
2111 Microsoft_Windows_Start_Menu_Admin_ToolsW,
2113 KF_CATEGORY_COMMON, /* category */
2114 Common_Administrative_ToolsW, /* name */
2115 NULL, /* description */
2116 &FOLDERID_CommonPrograms, /* parent */
2117 Administrative_ToolsW, /* relative path */
2118 NULL, /* parsing */
2119 NULL, /* tooltip */
2120 NULL, /* localized */
2121 NULL, /* icon */
2122 NULL, /* security */
2123 FILE_ATTRIBUTE_READONLY, /* attributes */
2124 KFDF_PRECREATE, /* flags */
2125 &GUID_NULL /* typeid */
2127 { /* 0x30 - CSIDL_ADMINTOOLS */
2128 &FOLDERID_AdminTools,
2129 CSIDL_Type_User,
2130 Administrative_ToolsW,
2131 Start_Menu_Admin_ToolsW,
2133 KF_CATEGORY_PERUSER, /* category */
2134 Administrative_ToolsW, /* name */
2135 NULL, /* description */
2136 &FOLDERID_Programs, /* parent */
2137 Administrative_ToolsW, /* relative path */
2138 NULL, /* parsing */
2139 NULL, /* tooltip */
2140 NULL, /* localized */
2141 NULL, /* icon */
2142 NULL, /* security */
2143 FILE_ATTRIBUTE_READONLY, /* attributes */
2144 KFDF_PRECREATE, /* flags */
2145 &GUID_NULL /* typeid */
2147 { /* 0x31 - CSIDL_CONNECTIONS */
2148 &FOLDERID_ConnectionsFolder,
2149 CSIDL_Type_Disallowed,
2150 NULL,
2151 NULL,
2153 KF_CATEGORY_VIRTUAL, /* category */
2154 ConnectionsFolderW, /* name */
2155 NULL, /* description */
2156 &GUID_NULL, /* parent */
2157 Administrative_ToolsW, /* relative path */
2158 ConnectionsFolderParsingNameW, /* parsing */
2159 NULL, /* tooltip */
2160 NULL, /* localized */
2161 NULL, /* icon */
2162 NULL, /* security */
2163 0, /* attributes */
2164 0, /* flags */
2165 &GUID_NULL /* typeid */
2167 { /* 0x32 - unassigned */
2168 &GUID_NULL,
2169 CSIDL_Type_Disallowed,
2170 NULL,
2171 NULL
2173 { /* 0x33 - unassigned */
2174 &GUID_NULL,
2175 CSIDL_Type_Disallowed,
2176 NULL,
2177 NULL
2179 { /* 0x34 - unassigned */
2180 &GUID_NULL,
2181 CSIDL_Type_Disallowed,
2182 NULL,
2183 NULL
2185 { /* 0x35 - CSIDL_COMMON_MUSIC */
2186 &FOLDERID_PublicMusic,
2187 CSIDL_Type_AllUsers,
2188 CommonMusicW,
2189 MusicW,
2191 KF_CATEGORY_COMMON, /* category */
2192 CommonMusicW, /* name */
2193 NULL, /* description */
2194 &FOLDERID_Public, /* parent */
2195 MusicW, /* relative path */
2196 NULL, /* parsing */
2197 NULL, /* tooltip */
2198 NULL, /* localized */
2199 NULL, /* icon */
2200 NULL, /* security */
2201 FILE_ATTRIBUTE_READONLY, /* attributes */
2202 KFDF_PRECREATE, /* flags */
2203 &GUID_NULL /* typeid */
2205 { /* 0x36 - CSIDL_COMMON_PICTURES */
2206 &FOLDERID_PublicPictures,
2207 CSIDL_Type_AllUsers,
2208 CommonPicturesW,
2209 PicturesW,
2211 KF_CATEGORY_COMMON, /* category */
2212 CommonPicturesW, /* name */
2213 NULL, /* description */
2214 &FOLDERID_Public, /* parent */
2215 PicturesW, /* relative path */
2216 NULL, /* parsing */
2217 NULL, /* tooltip */
2218 NULL, /* localized */
2219 NULL, /* icon */
2220 NULL, /* security */
2221 FILE_ATTRIBUTE_READONLY, /* attributes */
2222 KFDF_PRECREATE, /* flags */
2223 &GUID_NULL /* typeid */
2225 { /* 0x37 - CSIDL_COMMON_VIDEO */
2226 &FOLDERID_PublicVideos,
2227 CSIDL_Type_AllUsers,
2228 CommonVideoW,
2229 VideosW,
2231 KF_CATEGORY_COMMON, /* category */
2232 CommonVideoW, /* name */
2233 NULL, /* description */
2234 &FOLDERID_Public, /* parent */
2235 VideosW, /* relative path */
2236 NULL, /* parsing */
2237 NULL, /* tooltip */
2238 NULL, /* localized */
2239 NULL, /* icon */
2240 NULL, /* security */
2241 FILE_ATTRIBUTE_READONLY, /* attributes */
2242 KFDF_PRECREATE, /* flags */
2243 &GUID_NULL /* typeid */
2245 { /* 0x38 - CSIDL_RESOURCES */
2246 &FOLDERID_ResourceDir,
2247 CSIDL_Type_WindowsPath,
2248 NULL,
2249 ResourcesW,
2251 KF_CATEGORY_FIXED, /* category */
2252 ResourceDirW, /* name */
2253 NULL, /* description */
2254 &GUID_NULL, /* parent */
2255 NULL, /* relative path */
2256 NULL, /* parsing */
2257 NULL, /* tooltip */
2258 NULL, /* localized */
2259 NULL, /* icon */
2260 NULL, /* security */
2261 0, /* attributes */
2262 0, /* flags */
2263 &GUID_NULL /* typeid */
2265 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2266 &FOLDERID_LocalizedResourcesDir,
2267 CSIDL_Type_NonExistent,
2268 NULL,
2269 NULL,
2271 KF_CATEGORY_FIXED, /* category */
2272 LocalizedResourcesDirW, /* name */
2273 NULL, /* description */
2274 &GUID_NULL, /* parent */
2275 NULL, /* relative path */
2276 NULL, /* parsing */
2277 NULL, /* tooltip */
2278 NULL, /* localized */
2279 NULL, /* icon */
2280 NULL, /* security */
2281 0, /* attributes */
2282 0, /* flags */
2283 &GUID_NULL /* typeid */
2285 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2286 &FOLDERID_CommonOEMLinks,
2287 CSIDL_Type_ProgramData,
2288 NULL,
2289 OEM_LinksW,
2291 KF_CATEGORY_COMMON, /* category */
2292 OEM_LinksW, /* name */
2293 NULL, /* description */
2294 &FOLDERID_ProgramData, /* parent */
2295 OEM_LinksW, /* relative path */
2296 NULL, /* parsing */
2297 NULL, /* tooltip */
2298 NULL, /* localized */
2299 NULL, /* icon */
2300 NULL, /* security */
2301 0, /* attributes */
2302 0, /* flags */
2303 &GUID_NULL /* typeid */
2305 { /* 0x3b - CSIDL_CDBURN_AREA */
2306 &FOLDERID_CDBurning,
2307 CSIDL_Type_User,
2308 CD_BurningW,
2309 Local_Settings_CD_BurningW,
2311 KF_CATEGORY_PERUSER, /* category */
2312 CD_BurningW, /* name */
2313 NULL, /* description */
2314 &FOLDERID_LocalAppData, /* parent */
2315 Microsoft_Windows_Burn_BurnW, /* relative path */
2316 NULL, /* parsing */
2317 NULL, /* tooltip */
2318 NULL, /* localized */
2319 NULL, /* icon */
2320 NULL, /* security */
2321 FILE_ATTRIBUTE_READONLY, /* attributes */
2322 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2323 &GUID_NULL /* typeid */
2325 { /* 0x3c unassigned */
2326 &GUID_NULL,
2327 CSIDL_Type_Disallowed,
2328 NULL,
2329 NULL
2331 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2332 &GUID_NULL,
2333 CSIDL_Type_Disallowed, /* FIXME */
2334 NULL,
2335 NULL
2337 { /* 0x3e - CSIDL_PROFILES */
2338 &GUID_NULL,
2339 CSIDL_Type_Disallowed, /* oddly, this matches WinXP */
2340 NULL,
2341 NULL
2343 { /* 0x3f */
2344 &FOLDERID_AddNewPrograms,
2345 CSIDL_Type_Disallowed,
2346 NULL,
2347 NULL,
2349 KF_CATEGORY_VIRTUAL, /* category */
2350 AddNewProgramsFolderW, /* name */
2351 NULL, /* description */
2352 &GUID_NULL, /* parent */
2353 NULL, /* relative path */
2354 AddNewProgramsParsingNameW, /* parsing */
2355 NULL, /* tooltip */
2356 NULL, /* localized */
2357 NULL, /* icon */
2358 NULL, /* security */
2359 0, /* attributes */
2360 0, /* flags */
2361 &GUID_NULL /* typeid */
2363 { /* 0x40 */
2364 &FOLDERID_AppUpdates,
2365 CSIDL_Type_Disallowed,
2366 NULL,
2367 NULL,
2369 KF_CATEGORY_VIRTUAL, /* category */
2370 AppUpdatesFolderW, /* name */
2371 NULL, /* description */
2372 &GUID_NULL, /* parent */
2373 NULL, /* relative path */
2374 AppUpdatesParsingNameW, /* parsing */
2375 NULL, /* tooltip */
2376 NULL, /* localized */
2377 NULL, /* icon */
2378 NULL, /* security */
2379 0, /* attributes */
2380 0, /* flags */
2381 &GUID_NULL /* typeid */
2383 { /* 0x41 */
2384 &FOLDERID_ChangeRemovePrograms,
2385 CSIDL_Type_Disallowed,
2386 NULL,
2387 NULL,
2389 KF_CATEGORY_VIRTUAL, /* category */
2390 ChangeRemoveProgramsFolderW, /* name */
2391 NULL, /* description */
2392 &GUID_NULL, /* parent */
2393 NULL, /* relative path */
2394 ChangeRemoveProgramsParsingNameW, /* parsing */
2395 NULL, /* tooltip */
2396 NULL, /* localized */
2397 NULL, /* icon */
2398 NULL, /* security */
2399 0, /* attributes */
2400 0, /* flags */
2401 &GUID_NULL /* typeid */
2403 { /* 0x42 */
2404 &FOLDERID_ConflictFolder,
2405 CSIDL_Type_Disallowed,
2406 NULL,
2407 NULL,
2409 KF_CATEGORY_VIRTUAL, /* category */
2410 ConflictFolderW, /* name */
2411 NULL, /* description */
2412 &GUID_NULL, /* parent */
2413 NULL, /* relative path */
2414 ConflictFolderParsingNameW, /* parsing */
2415 NULL, /* tooltip */
2416 NULL, /* localized */
2417 NULL, /* icon */
2418 NULL, /* security */
2419 0, /* attributes */
2420 0, /* flags */
2421 &GUID_NULL /* typeid */
2423 { /* 0x43 - CSIDL_CONTACTS */
2424 &FOLDERID_Contacts,
2425 CSIDL_Type_User,
2426 NULL,
2427 ContactsW,
2429 KF_CATEGORY_PERUSER, /* category */
2430 ContactsW, /* name */
2431 NULL, /* description */
2432 &FOLDERID_Profile, /* parent */
2433 ContactsW, /* relative path */
2434 ContactsParsingNameW, /* parsing */
2435 NULL, /* tooltip */
2436 NULL, /* localized */
2437 NULL, /* icon */
2438 NULL, /* security */
2439 FILE_ATTRIBUTE_READONLY, /* attributes */
2440 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2441 &GUID_NULL /* typeid */
2443 { /* 0x44 */
2444 &FOLDERID_DeviceMetadataStore,
2445 CSIDL_Type_Disallowed, /* FIXME */
2446 NULL,
2447 NULL,
2449 KF_CATEGORY_COMMON, /* category */
2450 Device_Metadata_StoreW, /* name */
2451 NULL, /* description */
2452 &FOLDERID_ProgramData, /* parent */
2453 Microsoft_Windows_DeviceMetadataStoreW, /* relative path */
2454 NULL, /* parsing */
2455 NULL, /* tooltip */
2456 NULL, /* localized */
2457 NULL, /* icon */
2458 NULL, /* security */
2459 0, /* attributes */
2460 0, /* flags */
2461 &GUID_NULL /* typeid */
2463 { /* 0x45 */
2464 &GUID_NULL,
2465 CSIDL_Type_User,
2466 NULL,
2467 DocumentsW
2469 { /* 0x46 */
2470 &FOLDERID_DocumentsLibrary,
2471 CSIDL_Type_Disallowed, /* FIXME */
2472 NULL,
2473 NULL,
2475 KF_CATEGORY_PERUSER, /* category */
2476 DocumentsLibraryW, /* name */
2477 NULL, /* description */
2478 &FOLDERID_Libraries, /* parent */
2479 Documents_librarymsW, /* relative path */
2480 DocumentsLibraryParsingNameW, /* parsing */
2481 NULL, /* tooltip */
2482 NULL, /* localized */
2483 NULL, /* icon */
2484 NULL, /* security */
2485 0, /* attributes */
2486 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2487 &GUID_NULL /* typeid */
2489 { /* 0x47 - CSIDL_DOWNLOADS */
2490 &FOLDERID_Downloads,
2491 CSIDL_Type_User,
2492 NULL,
2493 DownloadsW,
2495 KF_CATEGORY_PERUSER, /* category */
2496 DownloadsW, /* name */
2497 NULL, /* description */
2498 &FOLDERID_Profile, /* parent */
2499 DownloadsW, /* relative path */
2500 NULL, /* parsing */
2501 NULL, /* tooltip */
2502 NULL, /* localized */
2503 NULL, /* icon */
2504 NULL, /* security */
2505 FILE_ATTRIBUTE_READONLY, /* attributes */
2506 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2507 &GUID_NULL /* typeid */
2509 { /* 0x48 */
2510 &FOLDERID_Games,
2511 CSIDL_Type_Disallowed,
2512 NULL,
2513 NULL,
2515 KF_CATEGORY_VIRTUAL, /* category */
2516 GamesW, /* name */
2517 NULL, /* description */
2518 &GUID_NULL, /* parent */
2519 NULL, /* relative path */
2520 GamesParsingNameW, /* parsing */
2521 NULL, /* tooltip */
2522 NULL, /* localized */
2523 NULL, /* icon */
2524 NULL, /* security */
2525 0, /* attributes */
2526 0, /* flags */
2527 &GUID_NULL /* typeid */
2529 { /* 0x49 */
2530 &FOLDERID_GameTasks,
2531 CSIDL_Type_Disallowed, /* FIXME */
2532 NULL,
2533 NULL,
2535 KF_CATEGORY_PERUSER, /* category */
2536 GameTasksW, /* name */
2537 NULL, /* description */
2538 &FOLDERID_LocalAppData, /* parent */
2539 Microsoft_Windows_GameExplorerW, /* relative path */
2540 NULL, /* parsing */
2541 NULL, /* tooltip */
2542 NULL, /* localized */
2543 NULL, /* icon */
2544 NULL, /* security */
2545 0, /* attributes */
2546 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2547 &GUID_NULL /* typeid */
2549 { /* 0x4a */
2550 &FOLDERID_HomeGroup,
2551 CSIDL_Type_Disallowed,
2552 NULL,
2553 NULL,
2555 KF_CATEGORY_VIRTUAL, /* category */
2556 HomeGroupFolderW, /* name */
2557 NULL, /* description */
2558 &GUID_NULL, /* parent */
2559 NULL, /* relative path */
2560 HomeGroupParsingNameW, /* parsing */
2561 NULL, /* tooltip */
2562 NULL, /* localized */
2563 NULL, /* icon */
2564 NULL, /* security */
2565 0, /* attributes */
2566 0, /* flags */
2567 &GUID_NULL /* typeid */
2569 { /* 0x4b */
2570 &FOLDERID_ImplicitAppShortcuts,
2571 CSIDL_Type_Disallowed, /* FIXME */
2572 NULL,
2573 NULL,
2575 KF_CATEGORY_PERUSER, /* category */
2576 ImplicitAppShortcutsW, /* name */
2577 NULL, /* description */
2578 &FOLDERID_UserPinned, /* parent */
2579 ImplicitAppShortcutsW, /* relative path */
2580 NULL, /* parsing */
2581 NULL, /* tooltip */
2582 NULL, /* localized */
2583 NULL, /* icon */
2584 NULL, /* security */
2585 0, /* attributes */
2586 KFDF_PRECREATE, /* flags */
2587 &GUID_NULL /* typeid */
2589 { /* 0x4c */
2590 &FOLDERID_Libraries,
2591 CSIDL_Type_Disallowed, /* FIXME */
2592 NULL,
2593 NULL,
2595 KF_CATEGORY_PERUSER, /* category */
2596 LibrariesW, /* name */
2597 NULL, /* description */
2598 &FOLDERID_RoamingAppData, /* parent */
2599 Microsoft_Windows_LibrariesW, /* relative path */
2600 NULL, /* parsing */
2601 NULL, /* tooltip */
2602 NULL, /* localized */
2603 NULL, /* icon */
2604 NULL, /* security */
2605 0, /* attributes */
2606 KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2607 &GUID_NULL /* typeid */
2609 { /* 0x4d - CSIDL_LINKS */
2610 &FOLDERID_Links,
2611 CSIDL_Type_User,
2612 NULL,
2613 LinksW,
2615 KF_CATEGORY_PERUSER, /* category */
2616 LinksW, /* name */
2617 NULL, /* description */
2618 &FOLDERID_Profile, /* parent */
2619 LinksW, /* relative path */
2620 LinksParsingNameW, /* parsing */
2621 NULL, /* tooltip */
2622 NULL, /* localized */
2623 NULL, /* icon */
2624 NULL, /* security */
2625 FILE_ATTRIBUTE_READONLY, /* attributes */
2626 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2627 &GUID_NULL /* typeid */
2629 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2630 &FOLDERID_LocalAppDataLow,
2631 CSIDL_Type_User,
2632 NULL,
2633 AppData_LocalLowW,
2635 KF_CATEGORY_PERUSER, /* category */
2636 LocalAppDataLowW, /* name */
2637 NULL, /* description */
2638 &FOLDERID_Profile, /* parent */
2639 AppData_LocalLowW, /* relative path */
2640 NULL, /* parsing */
2641 NULL, /* tooltip */
2642 NULL, /* localized */
2643 NULL, /* icon */
2644 NULL, /* security */
2645 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, /* attributes */
2646 KFDF_LOCAL_REDIRECT_ONLY | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2647 &GUID_NULL /* typeid */
2649 { /* 0x4f */
2650 &FOLDERID_MusicLibrary,
2651 CSIDL_Type_Disallowed, /* FIXME */
2652 NULL,
2653 NULL,
2655 KF_CATEGORY_PERUSER, /* category */
2656 MusicLibraryW, /* name */
2657 NULL, /* description */
2658 &FOLDERID_Libraries, /* parent */
2659 Music_librarymsW, /* relative path */
2660 MusicLibraryParsingNameW, /* parsing */
2661 NULL, /* tooltip */
2662 NULL, /* localized */
2663 NULL, /* icon */
2664 NULL, /* security */
2665 0, /* attributes */
2666 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2667 &GUID_NULL /* typeid */
2669 { /* 0x50 */
2670 &FOLDERID_OriginalImages,
2671 CSIDL_Type_Disallowed, /* FIXME */
2672 NULL,
2673 NULL,
2675 KF_CATEGORY_PERUSER, /* category */
2676 Original_ImagesW, /* name */
2677 NULL, /* description */
2678 &FOLDERID_LocalAppData, /* parent */
2679 Microsoft_Windows_Photo_Gallery_Original_ImagesW, /* relative path */
2680 NULL, /* parsing */
2681 NULL, /* tooltip */
2682 NULL, /* localized */
2683 NULL, /* icon */
2684 NULL, /* security */
2685 0, /* attributes */
2686 0, /* flags */
2687 &GUID_NULL /* typeid */
2689 { /* 0x51 */
2690 &FOLDERID_PhotoAlbums,
2691 CSIDL_Type_User,
2692 NULL,
2693 Pictures_Slide_ShowsW,
2695 KF_CATEGORY_PERUSER, /* category */
2696 PhotoAlbumsW, /* name */
2697 NULL, /* description */
2698 &FOLDERID_Pictures, /* parent */
2699 Slide_ShowsW, /* relative path */
2700 NULL, /* parsing */
2701 NULL, /* tooltip */
2702 NULL, /* localized */
2703 NULL, /* icon */
2704 NULL, /* security */
2705 FILE_ATTRIBUTE_READONLY, /* attributes */
2706 0, /* flags */
2707 &GUID_NULL /* typeid */
2709 { /* 0x52 */
2710 &FOLDERID_PicturesLibrary,
2711 CSIDL_Type_Disallowed, /* FIXME */
2712 NULL,
2713 NULL,
2715 KF_CATEGORY_PERUSER, /* category */
2716 PicturesLibraryW, /* name */
2717 NULL, /* description */
2718 &FOLDERID_Libraries, /* parent */
2719 Pictures_librarymsW, /* relative path */
2720 PicturesLibraryParsingNameW, /* parsing */
2721 NULL, /* tooltip */
2722 NULL, /* localized */
2723 NULL, /* icon */
2724 NULL, /* security */
2725 0, /* attributes */
2726 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2727 &GUID_NULL /* typeid */
2729 { /* 0x53 */
2730 &FOLDERID_Playlists,
2731 CSIDL_Type_User,
2732 NULL,
2733 Music_PlaylistsW,
2735 KF_CATEGORY_PERUSER, /* category */
2736 PlaylistsW, /* name */
2737 NULL, /* description */
2738 &FOLDERID_Music, /* parent */
2739 PlaylistsW, /* relative path */
2740 NULL, /* parsing */
2741 NULL, /* tooltip */
2742 NULL, /* localized */
2743 NULL, /* icon */
2744 NULL, /* security */
2745 FILE_ATTRIBUTE_READONLY, /* attributes */
2746 0, /* flags */
2747 &GUID_NULL /* typeid */
2749 { /* 0x54 */
2750 &FOLDERID_ProgramFilesX64,
2751 #ifdef _WIN64
2752 CSIDL_Type_CurrVer,
2753 ProgramFilesDirW,
2754 Program_FilesW,
2755 #else
2756 CSIDL_Type_NonExistent,
2757 NULL,
2758 NULL,
2759 #endif
2761 KF_CATEGORY_FIXED, /* category */
2762 ProgramFilesX64W, /* name */
2763 NULL, /* description */
2764 &GUID_NULL, /* parent */
2765 NULL, /* relative path */
2766 NULL, /* parsing */
2767 NULL, /* tooltip */
2768 NULL, /* localized */
2769 NULL, /* icon */
2770 NULL, /* security */
2771 0, /* attributes */
2772 0, /* flags */
2773 &GUID_NULL /* typeid */
2775 { /* 0x55 */
2776 &FOLDERID_ProgramFilesCommonX64,
2777 #ifdef _WIN64
2778 CSIDL_Type_CurrVer,
2779 ProgramFilesCommonX64W,
2780 Program_Files_Common_FilesW,
2781 #else
2782 CSIDL_Type_NonExistent,
2783 NULL,
2784 NULL,
2785 #endif
2787 KF_CATEGORY_FIXED, /* category */
2788 ProgramFilesCommonX64W, /* name */
2789 NULL, /* description */
2790 &GUID_NULL, /* parent */
2791 NULL, /* relative path */
2792 NULL, /* parsing */
2793 NULL, /* tooltip */
2794 NULL, /* localized */
2795 NULL, /* icon */
2796 NULL, /* security */
2797 0, /* attributes */
2798 0, /* flags */
2799 &GUID_NULL /* typeid */
2801 { /* 0x56 */
2802 &FOLDERID_Public,
2803 CSIDL_Type_CurrVer, /* FIXME */
2804 NULL,
2805 UsersPublicW,
2807 KF_CATEGORY_FIXED, /* category */
2808 PublicW, /* name */
2809 NULL, /* description */
2810 &GUID_NULL, /* parent */
2811 NULL, /* relative path */
2812 PublicParsingNameW, /* parsing */
2813 NULL, /* tooltip */
2814 NULL, /* localized */
2815 NULL, /* icon */
2816 NULL, /* security */
2817 FILE_ATTRIBUTE_READONLY, /* attributes */
2818 KFDF_PRECREATE, /* flags */
2819 &GUID_NULL /* typeid */
2821 { /* 0x57 */
2822 &FOLDERID_PublicDownloads,
2823 CSIDL_Type_AllUsers,
2824 NULL,
2825 DownloadsW,
2827 KF_CATEGORY_COMMON, /* category */
2828 CommonDownloadsW, /* name */
2829 NULL, /* description */
2830 &FOLDERID_Public, /* parent */
2831 DownloadsW, /* relative path */
2832 NULL, /* parsing */
2833 NULL, /* tooltip */
2834 NULL, /* localized */
2835 NULL, /* icon */
2836 NULL, /* security */
2837 FILE_ATTRIBUTE_READONLY, /* attributes */
2838 KFDF_PRECREATE, /* flags */
2839 &GUID_NULL /* typeid */
2841 { /* 0x58 */
2842 &FOLDERID_PublicGameTasks,
2843 CSIDL_Type_ProgramData,
2844 NULL,
2845 Microsoft_Windows_GameExplorerW,
2847 KF_CATEGORY_COMMON, /* category */
2848 PublicGameTasksW, /* name */
2849 NULL, /* description */
2850 &FOLDERID_ProgramData, /* parent */
2851 Microsoft_Windows_GameExplorerW, /* relative path */
2852 NULL, /* parsing */
2853 NULL, /* tooltip */
2854 NULL, /* localized */
2855 NULL, /* icon */
2856 NULL, /* security */
2857 0, /* attributes */
2858 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2859 &GUID_NULL /* typeid */
2861 { /* 0x59 */
2862 &FOLDERID_PublicLibraries,
2863 CSIDL_Type_AllUsers,
2864 NULL,
2865 Microsoft_Windows_LibrariesW,
2867 KF_CATEGORY_COMMON, /* category */
2868 PublicLibrariesW, /* name */
2869 NULL, /* description */
2870 &FOLDERID_Public, /* parent */
2871 LibrariesW, /* relative path */
2872 NULL, /* parsing */
2873 NULL, /* tooltip */
2874 NULL, /* localized */
2875 NULL, /* icon */
2876 NULL, /* security */
2877 FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN, /* attributes */
2878 KFDF_PRECREATE, /* flags */
2879 &GUID_NULL /* typeid */
2881 { /* 0x5a */
2882 &FOLDERID_PublicRingtones,
2883 CSIDL_Type_ProgramData,
2884 NULL,
2885 Microsoft_Windows_RingtonesW,
2887 KF_CATEGORY_COMMON, /* category */
2888 CommonRingtonesW, /* name */
2889 NULL, /* description */
2890 &FOLDERID_ProgramData, /* parent */
2891 Microsoft_Windows_RingtonesW, /* relative path */
2892 NULL, /* parsing */
2893 NULL, /* tooltip */
2894 NULL, /* localized */
2895 NULL, /* icon */
2896 NULL, /* security */
2897 0, /* attributes */
2898 KFDF_PRECREATE, /* flags */
2899 &GUID_NULL /* typeid */
2901 { /* 0x5b */
2902 &FOLDERID_QuickLaunch,
2903 CSIDL_Type_Disallowed, /* FIXME */
2904 NULL,
2905 NULL,
2907 KF_CATEGORY_PERUSER, /* category */
2908 Quick_LaunchW, /* name */
2909 NULL, /* description */
2910 &FOLDERID_RoamingAppData, /* parent */
2911 Microsoft_Internet_Explorer_Quick_LaunchW, /* relative path */
2912 NULL, /* parsing */
2913 NULL, /* tooltip */
2914 NULL, /* localized */
2915 NULL, /* icon */
2916 NULL, /* security */
2917 0, /* attributes */
2918 0, /* flags */
2919 &GUID_NULL /* typeid */
2921 { /* 0x5c */
2922 &FOLDERID_RecordedTVLibrary,
2923 CSIDL_Type_Disallowed, /* FIXME */
2924 NULL,
2925 NULL,
2927 KF_CATEGORY_COMMON, /* category */
2928 RecordedTVLibraryW, /* name */
2929 NULL, /* description */
2930 &FOLDERID_PublicLibraries, /* parent */
2931 RecordedTV_librarymsW, /* relative path */
2932 NULL, /* parsing */
2933 NULL, /* tooltip */
2934 NULL, /* localized */
2935 NULL, /* icon */
2936 NULL, /* security */
2937 0, /* attributes */
2938 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2939 &GUID_NULL /* typeid */
2941 { /* 0x5d */
2942 &FOLDERID_Ringtones,
2943 CSIDL_Type_Disallowed, /* FIXME */
2944 NULL,
2945 NULL,
2947 KF_CATEGORY_PERUSER, /* category */
2948 RingtonesW, /* name */
2949 NULL, /* description */
2950 &FOLDERID_LocalAppData, /* parent */
2951 Microsoft_Windows_RingtonesW, /* relative path */
2952 NULL, /* parsing */
2953 NULL, /* tooltip */
2954 NULL, /* localized */
2955 NULL, /* icon */
2956 NULL, /* security */
2957 0, /* attributes */
2958 KFDF_PRECREATE, /* flags */
2959 &GUID_NULL /* typeid */
2961 { /* 0x5e */
2962 &FOLDERID_SampleMusic,
2963 CSIDL_Type_AllUsers,
2964 NULL,
2965 Music_Sample_MusicW,
2967 KF_CATEGORY_COMMON, /* category */
2968 SampleMusicW, /* name */
2969 NULL, /* description */
2970 &FOLDERID_PublicMusic, /* parent */
2971 Sample_MusicW, /* relative path */
2972 NULL, /* parsing */
2973 NULL, /* tooltip */
2974 NULL, /* localized */
2975 NULL, /* icon */
2976 NULL, /* security */
2977 FILE_ATTRIBUTE_READONLY, /* attributes */
2978 KFDF_PRECREATE, /* flags */
2979 &GUID_NULL /* typeid */
2981 { /* 0x5f */
2982 &FOLDERID_SamplePictures,
2983 CSIDL_Type_AllUsers,
2984 NULL,
2985 Pictures_Sample_PicturesW,
2987 KF_CATEGORY_COMMON, /* category */
2988 SamplePicturesW, /* name */
2989 NULL, /* description */
2990 &FOLDERID_PublicPictures, /* parent */
2991 Sample_PicturesW, /* relative path */
2992 NULL, /* parsing */
2993 NULL, /* tooltip */
2994 NULL, /* localized */
2995 NULL, /* icon */
2996 NULL, /* security */
2997 FILE_ATTRIBUTE_READONLY, /* attributes */
2998 KFDF_PRECREATE, /* flags */
2999 &GUID_NULL /* typeid */
3001 { /* 0x60 */
3002 &FOLDERID_SamplePlaylists,
3003 CSIDL_Type_AllUsers,
3004 NULL,
3005 Music_Sample_PlaylistsW,
3007 KF_CATEGORY_COMMON, /* category */
3008 SamplePlaylistsW, /* name */
3009 NULL, /* description */
3010 &FOLDERID_PublicMusic, /* parent */
3011 Sample_PlaylistsW, /* relative path */
3012 NULL, /* parsing */
3013 NULL, /* tooltip */
3014 NULL, /* localized */
3015 NULL, /* icon */
3016 NULL, /* security */
3017 FILE_ATTRIBUTE_READONLY, /* attributes */
3018 KFDF_PRECREATE, /* flags */
3019 &GUID_NULL /* typeid */
3021 { /* 0x61 */
3022 &FOLDERID_SampleVideos,
3023 CSIDL_Type_AllUsers,
3024 NULL,
3025 Videos_Sample_VideosW,
3027 KF_CATEGORY_COMMON, /* category */
3028 SampleVideosW, /* name */
3029 NULL, /* description */
3030 &FOLDERID_PublicVideos, /* parent */
3031 Sample_VideosW, /* relative path */
3032 NULL, /* parsing */
3033 NULL, /* tooltip */
3034 NULL, /* localized */
3035 NULL, /* icon */
3036 NULL, /* security */
3037 FILE_ATTRIBUTE_READONLY, /* attributes */
3038 KFDF_PRECREATE, /* flags */
3039 &GUID_NULL /* typeid */
3041 { /* 0x62 - CSIDL_SAVED_GAMES */
3042 &FOLDERID_SavedGames,
3043 CSIDL_Type_User,
3044 NULL,
3045 Saved_GamesW,
3047 KF_CATEGORY_PERUSER, /* category */
3048 SavedGamesW, /* name */
3049 NULL, /* description */
3050 &FOLDERID_Profile, /* parent */
3051 Saved_GamesW, /* relative path */
3052 SavedGamesParsingNameW, /* parsing */
3053 NULL, /* tooltip */
3054 NULL, /* localized */
3055 NULL, /* icon */
3056 NULL, /* security */
3057 FILE_ATTRIBUTE_READONLY, /* attributes */
3058 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
3059 &GUID_NULL /* typeid */
3061 { /* 0x63 - CSIDL_SEARCHES */
3062 &FOLDERID_SavedSearches,
3063 CSIDL_Type_User,
3064 NULL,
3065 SearchesW,
3067 KF_CATEGORY_PERUSER, /* category */
3068 SearchesW, /* name */
3069 NULL, /* description */
3070 &FOLDERID_Profile, /* parent */
3071 SearchesW, /* relative path */
3072 SavedSearchesParsingNameW, /* parsing */
3073 NULL, /* tooltip */
3074 NULL, /* localized */
3075 NULL, /* icon */
3076 NULL, /* security */
3077 FILE_ATTRIBUTE_READONLY, /* attributes */
3078 KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
3079 &GUID_NULL /* typeid */
3081 { /* 0x64 */
3082 &FOLDERID_SEARCH_CSC,
3083 CSIDL_Type_Disallowed,
3084 NULL,
3085 NULL,
3087 KF_CATEGORY_VIRTUAL, /* category */
3088 CSCFolderW, /* name */
3089 NULL, /* description */
3090 &GUID_NULL, /* parent */
3091 NULL, /* relative path */
3092 SEARCH_CSCParsingNameW, /* parsing */
3093 NULL, /* tooltip */
3094 NULL, /* localized */
3095 NULL, /* icon */
3096 NULL, /* security */
3097 0, /* attributes */
3098 0, /* flags */
3099 &GUID_NULL /* typeid */
3101 { /* 0x65 */
3102 &FOLDERID_SEARCH_MAPI,
3103 CSIDL_Type_Disallowed,
3104 NULL,
3105 NULL,
3107 KF_CATEGORY_VIRTUAL, /* category */
3108 MAPIFolderW, /* name */
3109 NULL, /* description */
3110 &GUID_NULL, /* parent */
3111 NULL, /* relative path */
3112 SEARCH_MAPIParsingNameW, /* parsing */
3113 NULL, /* tooltip */
3114 NULL, /* localized */
3115 NULL, /* icon */
3116 NULL, /* security */
3117 0, /* attributes */
3118 0, /* flags */
3119 &GUID_NULL /* typeid */
3121 { /* 0x66 */
3122 &FOLDERID_SearchHome,
3123 CSIDL_Type_Disallowed,
3124 NULL,
3125 NULL,
3127 KF_CATEGORY_VIRTUAL, /* category */
3128 SearchHomeFolderW, /* name */
3129 NULL, /* description */
3130 &GUID_NULL, /* parent */
3131 NULL, /* relative path */
3132 SearchHomeParsingNameW, /* parsing */
3133 NULL, /* tooltip */
3134 NULL, /* localized */
3135 NULL, /* icon */
3136 NULL, /* security */
3137 0, /* attributes */
3138 0, /* flags */
3139 &GUID_NULL /* typeid */
3141 { /* 0x67 */
3142 &FOLDERID_SidebarDefaultParts,
3143 CSIDL_Type_Disallowed, /* FIXME */
3144 NULL,
3145 NULL,
3147 KF_CATEGORY_COMMON, /* category */
3148 Default_GadgetsW, /* name */
3149 NULL, /* description */
3150 &FOLDERID_ProgramFiles, /* parent */
3151 Windows_Sidebar_GadgetsW, /* relative path */
3152 NULL, /* parsing */
3153 NULL, /* tooltip */
3154 NULL, /* localized */
3155 NULL, /* icon */
3156 NULL, /* security */
3157 0, /* attributes */
3158 0, /* flags */
3159 &GUID_NULL /* typeid */
3161 { /* 0x68 */
3162 &FOLDERID_SidebarParts,
3163 CSIDL_Type_Disallowed, /* FIXME */
3164 NULL,
3165 NULL,
3167 KF_CATEGORY_PERUSER, /* category */
3168 GadgetsW, /* name */
3169 NULL, /* description */
3170 &FOLDERID_LocalAppData, /* parent */
3171 Microsoft_Windows_Sidebar_GadgetsW, /* relative path */
3172 NULL, /* parsing */
3173 NULL, /* tooltip */
3174 NULL, /* localized */
3175 NULL, /* icon */
3176 NULL, /* security */
3177 0, /* attributes */
3178 0, /* flags */
3179 &GUID_NULL /* typeid */
3181 { /* 0x69 */
3182 &FOLDERID_SyncManagerFolder,
3183 CSIDL_Type_Disallowed,
3184 NULL,
3185 NULL,
3187 KF_CATEGORY_VIRTUAL, /* category */
3188 SyncCenterFolderW, /* name */
3189 NULL, /* description */
3190 &GUID_NULL, /* parent */
3191 NULL, /* relative path */
3192 SyncManagerFolderParsingNameW, /* parsing */
3193 NULL, /* tooltip */
3194 NULL, /* localized */
3195 NULL, /* icon */
3196 NULL, /* security */
3197 0, /* attributes */
3198 0, /* flags */
3199 &GUID_NULL /* typeid */
3201 { /* 0x6a */
3202 &FOLDERID_SyncResultsFolder,
3203 CSIDL_Type_Disallowed,
3204 NULL,
3205 NULL,
3207 KF_CATEGORY_VIRTUAL, /* category */
3208 SyncResultsFolderW, /* name */
3209 NULL, /* description */
3210 &GUID_NULL, /* parent */
3211 NULL, /* relative path */
3212 SyncResultsFolderParsingNameW, /* parsing */
3213 NULL, /* tooltip */
3214 NULL, /* localized */
3215 NULL, /* icon */
3216 NULL, /* security */
3217 0, /* attributes */
3218 0, /* flags */
3219 &GUID_NULL /* typeid */
3221 { /* 0x6b */
3222 &FOLDERID_SyncSetupFolder,
3223 CSIDL_Type_Disallowed,
3224 NULL,
3225 NULL,
3227 KF_CATEGORY_VIRTUAL, /* category */
3228 SyncSetupFolderW, /* name */
3229 NULL, /* description */
3230 &GUID_NULL, /* parent */
3231 NULL, /* relative path */
3232 SyncSetupFolderParsingNameW, /* parsing */
3233 NULL, /* tooltip */
3234 NULL, /* localized */
3235 NULL, /* icon */
3236 NULL, /* security */
3237 0, /* attributes */
3238 0, /* flags */
3239 &GUID_NULL /* typeid */
3241 { /* 0x6c */
3242 &FOLDERID_UserPinned,
3243 CSIDL_Type_Disallowed, /* FIXME */
3244 NULL,
3245 NULL,
3247 KF_CATEGORY_PERUSER, /* category */
3248 User_PinnedW, /* name */
3249 NULL, /* description */
3250 &FOLDERID_QuickLaunch, /* parent */
3251 User_PinnedW, /* relative path */
3252 NULL, /* parsing */
3253 NULL, /* tooltip */
3254 NULL, /* localized */
3255 NULL, /* icon */
3256 NULL, /* security */
3257 FILE_ATTRIBUTE_HIDDEN, /* attributes */
3258 KFDF_PRECREATE, /* flags */
3259 &GUID_NULL /* typeid */
3261 { /* 0x6d */
3262 &FOLDERID_UserProfiles,
3263 CSIDL_Type_CurrVer,
3264 UsersW,
3265 UsersW,
3267 KF_CATEGORY_FIXED, /* category */
3268 UserProfilesW, /* name */
3269 NULL, /* description */
3270 &GUID_NULL, /* parent */
3271 NULL, /* relative path */
3272 NULL, /* parsing */
3273 NULL, /* tooltip */
3274 NULL, /* localized */
3275 NULL, /* icon */
3276 NULL, /* security */
3277 FILE_ATTRIBUTE_READONLY, /* attributes */
3278 KFDF_PRECREATE, /* flags */
3279 &GUID_NULL /* typeid */
3281 { /* 0x6e */
3282 &FOLDERID_UserProgramFiles,
3283 CSIDL_Type_Disallowed, /* FIXME */
3284 NULL,
3285 NULL,
3287 KF_CATEGORY_PERUSER, /* category */
3288 UserProgramFilesW, /* name */
3289 NULL, /* description */
3290 &FOLDERID_LocalAppData, /* parent */
3291 ProgramsW, /* relative path */
3292 NULL, /* parsing */
3293 NULL, /* tooltip */
3294 NULL, /* localized */
3295 NULL, /* icon */
3296 NULL, /* security */
3297 0, /* attributes */
3298 0, /* flags */
3299 &GUID_NULL /* typeid */
3301 { /* 0x6f */
3302 &FOLDERID_UserProgramFilesCommon,
3303 CSIDL_Type_Disallowed, /* FIXME */
3304 NULL,
3305 NULL,
3307 KF_CATEGORY_PERUSER, /* category */
3308 UserProgramFilesCommonW, /* name */
3309 NULL, /* description */
3310 &FOLDERID_UserProgramFiles, /* parent */
3311 CommonW, /* relative path */
3312 NULL, /* parsing */
3313 NULL, /* tooltip */
3314 NULL, /* localized */
3315 NULL, /* icon */
3316 NULL, /* security */
3317 0, /* attributes */
3318 0, /* flags */
3319 &GUID_NULL /* typeid */
3321 { /* 0x70 */
3322 &FOLDERID_UsersFiles,
3323 CSIDL_Type_Disallowed,
3324 NULL,
3325 NULL,
3327 KF_CATEGORY_VIRTUAL, /* category */
3328 UsersFilesFolderW, /* name */
3329 NULL, /* description */
3330 &GUID_NULL, /* parent */
3331 NULL, /* relative path */
3332 UsersFilesParsingNameW, /* parsing */
3333 NULL, /* tooltip */
3334 NULL, /* localized */
3335 NULL, /* icon */
3336 NULL, /* security */
3337 0, /* attributes */
3338 0, /* flags */
3339 &GUID_NULL /* typeid */
3341 { /* 0x71 */
3342 &FOLDERID_UsersLibraries,
3343 CSIDL_Type_Disallowed,
3344 NULL,
3345 NULL,
3347 KF_CATEGORY_VIRTUAL, /* category */
3348 UsersLibrariesFolderW, /* name */
3349 NULL, /* description */
3350 &GUID_NULL, /* parent */
3351 NULL, /* relative path */
3352 UsersLibrariesParsingNameW, /* parsing */
3353 NULL, /* tooltip */
3354 NULL, /* localized */
3355 NULL, /* icon */
3356 NULL, /* security */
3357 0, /* attributes */
3358 0, /* flags */
3359 &GUID_NULL /* typeid */
3361 { /* 0x72 */
3362 &FOLDERID_VideosLibrary,
3363 CSIDL_Type_Disallowed, /* FIXME */
3364 NULL,
3365 NULL,
3367 KF_CATEGORY_PERUSER, /* category */
3368 VideosLibraryW, /* name */
3369 NULL, /* description */
3370 &GUID_NULL, /* parent */
3371 Videos_librarymsW, /* relative path */
3372 VideosLibraryParsingNameW, /* parsing */
3373 NULL, /* tooltip */
3374 NULL, /* localized */
3375 NULL, /* icon */
3376 NULL, /* security */
3377 0, /* attributes */
3378 0, /* flags */
3379 &GUID_NULL /* typeid */
3383 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest);
3385 /* Gets the value named value from the registry key
3386 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3387 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3388 * is assumed to be MAX_PATH WCHARs in length.
3389 * If it exists, expands the value and writes the expanded value to
3390 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3391 * Returns successful error code if the value was retrieved from the registry,
3392 * and a failure otherwise.
3394 static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
3395 LPCWSTR value, LPWSTR path)
3397 HRESULT hr;
3398 WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
3399 LPCWSTR pShellFolderPath, pUserShellFolderPath;
3400 HKEY userShellFolderKey, shellFolderKey;
3401 DWORD dwType, dwPathLen;
3403 TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
3404 path);
3406 if (userPrefix)
3408 strcpyW(shellFolderPath, userPrefix);
3409 PathAddBackslashW(shellFolderPath);
3410 strcatW(shellFolderPath, szSHFolders);
3411 pShellFolderPath = shellFolderPath;
3412 strcpyW(userShellFolderPath, userPrefix);
3413 PathAddBackslashW(userShellFolderPath);
3414 strcatW(userShellFolderPath, szSHUserFolders);
3415 pUserShellFolderPath = userShellFolderPath;
3417 else
3419 pUserShellFolderPath = szSHUserFolders;
3420 pShellFolderPath = szSHFolders;
3423 if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
3425 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
3426 return E_FAIL;
3428 if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
3430 TRACE("Failed to create %s\n",
3431 debugstr_w(pUserShellFolderPath));
3432 RegCloseKey(shellFolderKey);
3433 return E_FAIL;
3436 dwPathLen = MAX_PATH * sizeof(WCHAR);
3437 if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
3438 (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
3440 LONG ret;
3442 path[dwPathLen / sizeof(WCHAR)] = '\0';
3443 if (dwType == REG_EXPAND_SZ && path[0] == '%')
3445 WCHAR szTemp[MAX_PATH];
3447 _SHExpandEnvironmentStrings(path, szTemp);
3448 lstrcpynW(path, szTemp, MAX_PATH);
3450 ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
3451 (strlenW(path) + 1) * sizeof(WCHAR));
3452 if (ret != ERROR_SUCCESS)
3453 hr = HRESULT_FROM_WIN32(ret);
3454 else
3455 hr = S_OK;
3457 else
3458 hr = E_FAIL;
3459 RegCloseKey(shellFolderKey);
3460 RegCloseKey(userShellFolderKey);
3461 TRACE("returning 0x%08x\n", hr);
3462 return hr;
3465 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3466 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3467 * - The entry's szDefaultPath may be either a string value or an integer
3468 * resource identifier. In the latter case, the string value of the resource
3469 * is written.
3470 * - Depending on the entry's type, the path may begin with an (unexpanded)
3471 * environment variable name. The caller is responsible for expanding
3472 * environment strings if so desired.
3473 * The types that are prepended with environment variables are:
3474 * CSIDL_Type_User: %USERPROFILE%
3475 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3476 * CSIDL_Type_CurrVer: %SystemDrive%
3477 * (Others might make sense too, but as yet are unneeded.)
3479 static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
3481 HRESULT hr;
3482 WCHAR resourcePath[MAX_PATH];
3483 LPCWSTR pDefaultPath = NULL;
3485 TRACE("0x%02x,%p\n", folder, pszPath);
3487 if (folder >= ARRAY_SIZE(CSIDL_Data))
3488 return E_INVALIDARG;
3490 if (!pszPath)
3491 return E_INVALIDARG;
3493 if (!is_win64)
3495 BOOL is_wow64;
3497 switch (folder)
3499 case CSIDL_PROGRAM_FILES:
3500 case CSIDL_PROGRAM_FILESX86:
3501 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3502 folder = is_wow64 ? CSIDL_PROGRAM_FILESX86 : CSIDL_PROGRAM_FILES;
3503 break;
3504 case CSIDL_PROGRAM_FILES_COMMON:
3505 case CSIDL_PROGRAM_FILES_COMMONX86:
3506 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3507 folder = is_wow64 ? CSIDL_PROGRAM_FILES_COMMONX86 : CSIDL_PROGRAM_FILES_COMMON;
3508 break;
3512 if (CSIDL_Data[folder].szDefaultPath &&
3513 IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
3515 if (LoadStringW(shell32_hInstance,
3516 LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
3518 hr = S_OK;
3519 pDefaultPath = resourcePath;
3521 else
3523 FIXME("(%d,%s), LoadString failed, missing translation?\n", folder,
3524 debugstr_w(pszPath));
3525 hr = E_FAIL;
3528 else
3530 hr = S_OK;
3531 pDefaultPath = CSIDL_Data[folder].szDefaultPath;
3533 if (SUCCEEDED(hr))
3535 switch (CSIDL_Data[folder].type)
3537 case CSIDL_Type_User:
3538 strcpyW(pszPath, UserProfileW);
3539 break;
3540 case CSIDL_Type_AllUsers:
3541 strcpyW(pszPath, PublicProfileW);
3542 break;
3543 case CSIDL_Type_ProgramData:
3544 strcpyW(pszPath, ProgramDataVarW);
3545 break;
3546 case CSIDL_Type_CurrVer:
3547 strcpyW(pszPath, SystemDriveW);
3548 break;
3549 default:
3550 ; /* no corresponding env. var, do nothing */
3552 if (pDefaultPath)
3554 PathAddBackslashW(pszPath);
3555 strcatW(pszPath, pDefaultPath);
3558 TRACE("returning 0x%08x\n", hr);
3559 return hr;
3562 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3563 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3564 * can be overridden in the HKLM\\szCurrentVersion key.
3565 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3566 * the registry, uses _SHGetDefaultValue to get the value.
3568 static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder,
3569 LPWSTR pszPath)
3571 HRESULT hr;
3573 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
3575 if (folder >= ARRAY_SIZE(CSIDL_Data))
3576 return E_INVALIDARG;
3577 if (CSIDL_Data[folder].type != CSIDL_Type_CurrVer)
3578 return E_INVALIDARG;
3579 if (!pszPath)
3580 return E_INVALIDARG;
3582 if (dwFlags & SHGFP_TYPE_DEFAULT)
3583 hr = _SHGetDefaultValue(folder, pszPath);
3584 else
3586 HKEY hKey;
3588 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, szCurrentVersion, &hKey))
3589 hr = E_FAIL;
3590 else
3592 DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
3594 if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
3595 &dwType, (LPBYTE)pszPath, &dwPathLen) ||
3596 (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
3598 hr = _SHGetDefaultValue(folder, pszPath);
3599 dwType = REG_EXPAND_SZ;
3600 switch (folder)
3602 case CSIDL_PROGRAM_FILESX86:
3603 case CSIDL_PROGRAM_FILES_COMMONX86:
3604 /* these two should never be set on 32-bit setups */
3605 if (!is_win64)
3607 BOOL is_wow64;
3608 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3609 if (!is_wow64) break;
3611 /* fall through */
3612 default:
3613 RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
3614 (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
3617 else
3619 pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
3620 hr = S_OK;
3622 RegCloseKey(hKey);
3625 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3626 return hr;
3629 static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
3631 char InfoBuffer[64];
3632 PTOKEN_USER UserInfo;
3633 DWORD InfoSize;
3634 LPWSTR SidStr;
3636 UserInfo = (PTOKEN_USER) InfoBuffer;
3637 if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
3638 &InfoSize))
3640 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
3641 return NULL;
3642 UserInfo = heap_alloc(InfoSize);
3643 if (UserInfo == NULL)
3644 return NULL;
3645 if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
3646 &InfoSize))
3648 heap_free(UserInfo);
3649 return NULL;
3653 if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
3654 SidStr = NULL;
3656 if (UserInfo != (PTOKEN_USER) InfoBuffer)
3657 heap_free(UserInfo);
3659 return SidStr;
3662 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3663 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3664 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3665 * - if hToken is -1, looks in HKEY_USERS\.Default
3666 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3667 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3668 * calls _SHGetDefaultValue for it.
3670 static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder,
3671 LPWSTR pszPath)
3673 const WCHAR *szValueName;
3674 WCHAR buffer[40];
3675 HRESULT hr;
3677 TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
3679 if (folder >= ARRAY_SIZE(CSIDL_Data))
3680 return E_INVALIDARG;
3681 if (CSIDL_Data[folder].type != CSIDL_Type_User)
3682 return E_INVALIDARG;
3683 if (!pszPath)
3684 return E_INVALIDARG;
3686 if (dwFlags & SHGFP_TYPE_DEFAULT)
3688 if (hToken != NULL && hToken != (HANDLE)-1)
3690 FIXME("unsupported for user other than current or default\n");
3691 return E_FAIL;
3693 hr = _SHGetDefaultValue(folder, pszPath);
3695 else
3697 LPCWSTR userPrefix = NULL;
3698 HKEY hRootKey;
3700 if (hToken == (HANDLE)-1)
3702 hRootKey = HKEY_USERS;
3703 userPrefix = DefaultW;
3705 else if (hToken == NULL)
3706 hRootKey = HKEY_CURRENT_USER;
3707 else
3709 hRootKey = HKEY_USERS;
3710 userPrefix = _GetUserSidStringFromToken(hToken);
3711 if (userPrefix == NULL)
3713 hr = E_FAIL;
3714 goto error;
3718 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3719 szValueName = CSIDL_Data[folder].szValueName;
3720 if (!szValueName)
3722 StringFromGUID2( CSIDL_Data[folder].id, buffer, 39 );
3723 szValueName = &buffer[0];
3726 hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
3727 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
3728 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
3729 if (FAILED(hr))
3730 hr = _SHGetDefaultValue(folder, pszPath);
3731 if (userPrefix != NULL && userPrefix != DefaultW)
3732 LocalFree((HLOCAL) userPrefix);
3734 error:
3735 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3736 return hr;
3739 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3740 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3741 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3742 * If this fails, falls back to _SHGetDefaultValue.
3744 static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder,
3745 LPWSTR pszPath)
3747 HRESULT hr;
3749 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
3751 if (folder >= ARRAY_SIZE(CSIDL_Data))
3752 return E_INVALIDARG;
3753 if (CSIDL_Data[folder].type != CSIDL_Type_AllUsers && CSIDL_Data[folder].type != CSIDL_Type_ProgramData)
3754 return E_INVALIDARG;
3755 if (!pszPath)
3756 return E_INVALIDARG;
3758 if (dwFlags & SHGFP_TYPE_DEFAULT)
3759 hr = _SHGetDefaultValue(folder, pszPath);
3760 else
3762 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL,
3763 CSIDL_Data[folder].szValueName, pszPath);
3764 if (FAILED(hr))
3765 hr = _SHGetDefaultValue(folder, pszPath);
3767 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3768 return hr;
3771 static HRESULT _SHOpenProfilesKey(PHKEY pKey)
3773 LONG lRet;
3774 DWORD disp;
3776 lRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ProfileListW, 0, NULL, 0,
3777 KEY_ALL_ACCESS, NULL, pKey, &disp);
3778 return HRESULT_FROM_WIN32(lRet);
3781 /* Reads the value named szValueName from the key profilesKey (assumed to be
3782 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3783 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3784 * szDefault to the registry).
3786 static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName,
3787 LPWSTR szValue, LPCWSTR szDefault)
3789 HRESULT hr;
3790 DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
3791 LONG lRet;
3793 TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
3794 debugstr_w(szDefault));
3795 lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
3796 (LPBYTE)szValue, &dwPathLen);
3797 if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
3798 && *szValue)
3800 dwPathLen /= sizeof(WCHAR);
3801 szValue[dwPathLen] = '\0';
3802 hr = S_OK;
3804 else
3806 /* Missing or invalid value, set a default */
3807 lstrcpynW(szValue, szDefault, MAX_PATH);
3808 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
3809 debugstr_w(szValue));
3810 lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
3811 (LPBYTE)szValue,
3812 (strlenW(szValue) + 1) * sizeof(WCHAR));
3813 if (lRet)
3814 hr = HRESULT_FROM_WIN32(lRet);
3815 else
3816 hr = S_OK;
3818 TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
3819 return hr;
3822 /* Attempts to expand environment variables from szSrc into szDest, which is
3823 * assumed to be MAX_PATH characters in length. Before referring to the
3824 * environment, handles a few variables directly, because the environment
3825 * variables may not be set when this is called (as during Wine's installation
3826 * when default values are being written to the registry).
3827 * The directly handled environment variables, and their source, are:
3828 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3829 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3830 * path
3831 * If one of the directly handled environment variables is expanded, only
3832 * expands a single variable, and only in the beginning of szSrc.
3834 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
3836 HRESULT hr;
3837 WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
3838 HKEY key = NULL;
3840 TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
3842 if (!szSrc || !szDest) return E_INVALIDARG;
3844 /* short-circuit if there's nothing to expand */
3845 if (szSrc[0] != '%')
3847 strcpyW(szDest, szSrc);
3848 hr = S_OK;
3849 goto end;
3851 /* Get the profile prefix, we'll probably be needing it */
3852 hr = _SHOpenProfilesKey(&key);
3853 if (SUCCEEDED(hr))
3855 WCHAR def_val[MAX_PATH];
3857 /* get the system drive */
3858 GetSystemDirectoryW(def_val, MAX_PATH);
3859 strcpyW( def_val + 3, szDefaultProfileDirW );
3861 hr = _SHGetProfilesValue(key, ProfilesDirectoryW, szProfilesPrefix, def_val );
3864 *szDest = 0;
3865 strcpyW(szTemp, szSrc);
3866 while (SUCCEEDED(hr) && szTemp[0] == '%')
3868 if (!strncmpiW(szTemp, AllUsersProfileW, strlenW(AllUsersProfileW)))
3870 WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
3872 GetSystemDirectoryW(def_val, MAX_PATH);
3873 strcpyW( def_val + 3, UsersPublicW );
3875 hr = _SHGetProfilesValue(key, PublicW, szAllUsers, def_val);
3876 PathAppendW(szDest, szAllUsers);
3877 PathAppendW(szDest, szTemp + strlenW(AllUsersProfileW));
3879 else if (!strncmpiW(szTemp, PublicProfileW, strlenW(PublicProfileW)))
3881 WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
3883 GetSystemDirectoryW(def_val, MAX_PATH);
3884 strcpyW( def_val + 3, UsersPublicW );
3886 hr = _SHGetProfilesValue(key, PublicW, szAllUsers, def_val);
3887 PathAppendW(szDest, szAllUsers);
3888 PathAppendW(szDest, szTemp + strlenW(PublicProfileW));
3890 else if (!strncmpiW(szTemp, ProgramDataVarW, strlenW(ProgramDataVarW)))
3892 WCHAR szProgramData[MAX_PATH], def_val[MAX_PATH];
3893 HKEY shellFolderKey;
3894 DWORD dwType, dwPathLen = sizeof(def_val);
3895 BOOL in_registry = FALSE;
3897 if (!RegCreateKeyW(HKEY_LOCAL_MACHINE, szSHFolders, &shellFolderKey))
3899 if (!RegQueryValueExW(shellFolderKey, Common_AppDataW, NULL, &dwType,
3900 (LPBYTE)def_val, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
3901 in_registry = TRUE;
3903 RegCloseKey(shellFolderKey);
3906 if (!in_registry)
3908 GetSystemDirectoryW(def_val, MAX_PATH);
3909 strcpyW( def_val + 3, ProgramDataW );
3912 hr = _SHGetProfilesValue(key, ProgramDataW, szProgramData, def_val);
3913 PathAppendW(szDest, szProgramData);
3914 PathAppendW(szDest, szTemp + strlenW(ProgramDataVarW));
3916 else if (!strncmpiW(szTemp, UserProfileW, strlenW(UserProfileW)))
3918 WCHAR userName[MAX_PATH];
3919 DWORD userLen = MAX_PATH;
3921 strcpyW(szDest, szProfilesPrefix);
3922 GetUserNameW(userName, &userLen);
3923 PathAppendW(szDest, userName);
3924 PathAppendW(szDest, szTemp + strlenW(UserProfileW));
3926 else if (!strncmpiW(szTemp, SystemDriveW, strlenW(SystemDriveW)))
3928 GetSystemDirectoryW(szDest, MAX_PATH);
3929 strcpyW(szDest + 3, szTemp + strlenW(SystemDriveW) + 1);
3931 else
3933 DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
3935 if (ret > MAX_PATH)
3936 hr = E_NOT_SUFFICIENT_BUFFER;
3937 else if (ret == 0)
3938 hr = HRESULT_FROM_WIN32(GetLastError());
3939 else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
3941 if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
3943 end:
3944 if (key)
3945 RegCloseKey(key);
3946 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
3947 debugstr_w(szSrc), debugstr_w(szDest));
3948 return hr;
3951 /*************************************************************************
3952 * _SHGetXDGUserDirs [Internal]
3954 * Get XDG directories paths from XDG configuration.
3956 * PARAMS
3957 * xdg_dirs [I] Array of XDG directories to look for.
3958 * num_dirs [I] Number of elements in xdg_dirs.
3959 * xdg_results [O] An array of the XDG directories paths.
3961 static inline void _SHGetXDGUserDirs(const char * const *xdg_dirs, const unsigned int num_dirs, char *** xdg_results) {
3962 HRESULT hr;
3964 hr = XDG_UserDirLookup(xdg_dirs, num_dirs, xdg_results);
3965 if (FAILED(hr)) *xdg_results = NULL;
3968 /*************************************************************************
3969 * _SHFreeXDGUserDirs [Internal]
3971 * Free resources allocated by XDG_UserDirLookup().
3973 * PARAMS
3974 * num_dirs [I] Number of elements in xdg_results.
3975 * xdg_results [I] An array of the XDG directories paths.
3977 static inline void _SHFreeXDGUserDirs(const unsigned int num_dirs, char ** xdg_results) {
3978 UINT i;
3980 if (xdg_results)
3982 for (i = 0; i < num_dirs; i++)
3983 heap_free(xdg_results[i]);
3984 heap_free(xdg_results);
3988 /*************************************************************************
3989 * _SHAppendToUnixPath [Internal]
3991 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
3992 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
3993 * and replaces backslashes with slashes.
3995 * PARAMS
3996 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
3997 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
3999 * RETURNS
4000 * Success: TRUE,
4001 * Failure: FALSE
4003 static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
4004 WCHAR wszSubPath[MAX_PATH];
4005 int cLen = strlen(szBasePath);
4006 char *pBackslash;
4008 if (IS_INTRESOURCE(pwszSubPath)) {
4009 if (!LoadStringW(shell32_hInstance, LOWORD(pwszSubPath), wszSubPath, MAX_PATH)) {
4010 /* Fall back to hard coded defaults. */
4011 switch (LOWORD(pwszSubPath)) {
4012 case IDS_PERSONAL:
4013 lstrcpyW(wszSubPath, DocumentsW);
4014 break;
4015 case IDS_MYMUSIC:
4016 lstrcpyW(wszSubPath, My_MusicW);
4017 break;
4018 case IDS_MYPICTURES:
4019 lstrcpyW(wszSubPath, My_PicturesW);
4020 break;
4021 case IDS_MYVIDEOS:
4022 lstrcpyW(wszSubPath, My_VideosW);
4023 break;
4024 case IDS_DOWNLOADS:
4025 lstrcpyW(wszSubPath, DownloadsW);
4026 break;
4027 case IDS_TEMPLATES:
4028 lstrcpyW(wszSubPath, TemplatesW);
4029 break;
4030 default:
4031 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath));
4032 return FALSE;
4035 } else {
4036 lstrcpyW(wszSubPath, pwszSubPath);
4039 if (szBasePath[cLen-1] != '/') szBasePath[cLen++] = '/';
4041 if (!WideCharToMultiByte(CP_UNIXCP, 0, wszSubPath, -1, szBasePath + cLen,
4042 FILENAME_MAX - cLen, NULL, NULL))
4044 return FALSE;
4047 pBackslash = szBasePath + cLen;
4048 while ((pBackslash = strchr(pBackslash, '\\'))) *pBackslash = '/';
4050 return TRUE;
4053 /******************************************************************************
4054 * _SHGetFolderUnixPath [Internal]
4056 * Create a shell folder and get its unix path.
4058 * PARAMS
4059 * nFolder [I] CSIDL identifying the folder.
4061 static inline char * _SHGetFolderUnixPath(const int nFolder)
4063 WCHAR wszTempPath[MAX_PATH];
4064 HRESULT hr;
4066 hr = SHGetFolderPathW(NULL, nFolder, NULL,
4067 SHGFP_TYPE_DEFAULT, wszTempPath);
4068 if (FAILED(hr)) return NULL;
4070 return wine_get_unix_file_name(wszTempPath);
4073 /******************************************************************************
4074 * _SHCreateMyDocumentsSubDirs [Internal]
4076 * Create real directories for various shell folders under 'My Documents'. For
4077 * Windows and homeless styles. Fails silently for already existing sub dirs.
4079 * PARAMS
4080 * aidsMyStuff [I] Array of IDS_* resources to create sub dirs for.
4081 * num [I] Number of elements in aidsMyStuff.
4082 * szPersonalTarget [I] Unix path to 'My Documents' directory.
4084 static void _SHCreateMyDocumentsSubDirs(const UINT * aidsMyStuff, const UINT num, const char * szPersonalTarget)
4086 char szMyStuffTarget[FILENAME_MAX];
4087 UINT i;
4089 if (aidsMyStuff && szPersonalTarget)
4091 for (i = 0; i < num; i++)
4093 strcpy(szMyStuffTarget, szPersonalTarget);
4094 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
4095 mkdir(szMyStuffTarget, 0777);
4100 /******************************************************************************
4101 * _SHCreateMyDocumentsSymbolicLink [Internal]
4103 * Sets up a symbolic link for the 'My Documents' shell folder to point into
4104 * the users home directory.
4106 * PARAMS
4107 * aidsMyStuff [I] Array of IDS_* resources to create sub dirs for.
4108 * aids_num [I] Number of elements in aidsMyStuff.
4110 static void _SHCreateMyDocumentsSymbolicLink(const UINT * aidsMyStuff, const UINT aids_num)
4112 static const char * const xdg_dirs[] = { "DOCUMENTS" };
4113 static const unsigned int num = ARRAY_SIZE(xdg_dirs);
4114 char szPersonalTarget[FILENAME_MAX], *pszPersonal;
4115 struct stat statFolder;
4116 const char *pszHome;
4117 char ** xdg_results;
4119 /* Get the unix path of 'My Documents'. */
4120 pszPersonal = _SHGetFolderUnixPath(CSIDL_PERSONAL|CSIDL_FLAG_DONT_VERIFY);
4121 if (!pszPersonal) return;
4123 _SHGetXDGUserDirs(xdg_dirs, num, &xdg_results);
4125 pszHome = getenv("HOME");
4126 if (pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode))
4128 while (1)
4130 /* Check if there's already a Wine-specific 'My Documents' folder */
4131 strcpy(szPersonalTarget, pszHome);
4132 if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) &&
4133 !stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
4135 /* '$HOME/My Documents' exists. Create subfolders for
4136 * 'My Pictures', 'My Videos', 'My Music' etc. or fail silently
4137 * if they already exist.
4139 _SHCreateMyDocumentsSubDirs(aidsMyStuff, aids_num, szPersonalTarget);
4140 break;
4143 /* Try to point to the XDG Documents folder */
4144 if (xdg_results && xdg_results[0] &&
4145 !stat(xdg_results[0], &statFolder) &&
4146 S_ISDIR(statFolder.st_mode))
4148 strcpy(szPersonalTarget, xdg_results[0]);
4149 break;
4152 /* Or the hardcoded / OS X Documents folder */
4153 strcpy(szPersonalTarget, pszHome);
4154 if (_SHAppendToUnixPath(szPersonalTarget, DocumentsW) &&
4155 !stat(szPersonalTarget, &statFolder) &&
4156 S_ISDIR(statFolder.st_mode))
4157 break;
4159 /* As a last resort point to $HOME. */
4160 strcpy(szPersonalTarget, pszHome);
4161 break;
4164 /* Create symbolic link to 'My Documents' or fail silently if a directory
4165 * or symlink exists. */
4166 symlink(szPersonalTarget, pszPersonal);
4168 else
4170 /* '$HOME' doesn't exist. Create subdirs for 'My Pictures', 'My Videos',
4171 * 'My Music' etc. in '%USERPROFILE%\My Documents' or fail silently if
4172 * they already exist. */
4173 pszHome = NULL;
4174 strcpy(szPersonalTarget, pszPersonal);
4175 _SHCreateMyDocumentsSubDirs(aidsMyStuff, aids_num, szPersonalTarget);
4178 heap_free(pszPersonal);
4180 _SHFreeXDGUserDirs(num, xdg_results);
4183 /******************************************************************************
4184 * _SHCreateMyStuffSymbolicLink [Internal]
4186 * Sets up a symbolic link for one of the 'My Whatever' shell folders to point
4187 * into the users home directory.
4189 * PARAMS
4190 * nFolder [I] CSIDL identifying the folder.
4192 static void _SHCreateMyStuffSymbolicLink(int nFolder)
4194 static const UINT aidsMyStuff[] = {
4195 IDS_MYPICTURES, IDS_MYVIDEOS, IDS_MYMUSIC, IDS_DOWNLOADS, IDS_TEMPLATES
4197 static const WCHAR * const MyOSXStuffW[] = {
4198 PicturesW, MoviesW, MusicW, DownloadsW, TemplatesW
4200 static const int acsidlMyStuff[] = {
4201 CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC, CSIDL_DOWNLOADS, CSIDL_TEMPLATES
4203 static const char * const xdg_dirs[] = {
4204 "PICTURES", "VIDEOS", "MUSIC", "DOWNLOAD", "TEMPLATES"
4206 static const unsigned int num = ARRAY_SIZE(xdg_dirs);
4207 char szPersonalTarget[FILENAME_MAX], *pszPersonal;
4208 char szMyStuffTarget[FILENAME_MAX], *pszMyStuff;
4209 struct stat statFolder;
4210 const char *pszHome;
4211 char ** xdg_results;
4212 DWORD folder = nFolder & CSIDL_FOLDER_MASK;
4213 UINT i;
4215 for (i = 0; i < ARRAY_SIZE(acsidlMyStuff) && acsidlMyStuff[i] != folder; i++);
4216 if (i >= ARRAY_SIZE(acsidlMyStuff)) return;
4218 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4219 pszPersonal = _SHGetFolderUnixPath(CSIDL_PERSONAL|CSIDL_FLAG_CREATE);
4220 if (!pszPersonal) return;
4222 strcpy(szPersonalTarget, pszPersonal);
4223 if (!stat(pszPersonal, &statFolder) && S_ISLNK(statFolder.st_mode))
4225 int cLen = readlink(pszPersonal, szPersonalTarget, FILENAME_MAX-1);
4226 if (cLen >= 0) szPersonalTarget[cLen] = '\0';
4228 heap_free(pszPersonal);
4230 _SHGetXDGUserDirs(xdg_dirs, num, &xdg_results);
4232 pszHome = getenv("HOME");
4234 while (1)
4236 /* Get the current 'My Whatever' folder unix path. */
4237 pszMyStuff = _SHGetFolderUnixPath(acsidlMyStuff[i]|CSIDL_FLAG_DONT_VERIFY);
4238 if (!pszMyStuff) break;
4240 while (1)
4242 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4243 strcpy(szMyStuffTarget, szPersonalTarget);
4244 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])) &&
4245 !stat(szMyStuffTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
4246 break;
4248 /* Try the XDG_XXX_DIR folder */
4249 if (xdg_results && xdg_results[i])
4251 strcpy(szMyStuffTarget, xdg_results[i]);
4252 break;
4255 /* Or the OS X folder (these are never localized) */
4256 if (pszHome)
4258 strcpy(szMyStuffTarget, pszHome);
4259 if (_SHAppendToUnixPath(szMyStuffTarget, MyOSXStuffW[i]) &&
4260 !stat(szMyStuffTarget, &statFolder) &&
4261 S_ISDIR(statFolder.st_mode))
4262 break;
4265 /* As a last resort point to the same location as 'My Documents' */
4266 strcpy(szMyStuffTarget, szPersonalTarget);
4267 break;
4269 symlink(szMyStuffTarget, pszMyStuff);
4270 heap_free(pszMyStuff);
4271 break;
4274 _SHFreeXDGUserDirs(num, xdg_results);
4277 /******************************************************************************
4278 * _SHCreateDesktopSymbolicLink [Internal]
4280 * Sets up a symbolic link for the 'Desktop' shell folder to point into the
4281 * users home directory.
4283 static void _SHCreateDesktopSymbolicLink(void)
4285 static const char * const xdg_dirs[] = { "DESKTOP" };
4286 static const unsigned int num = ARRAY_SIZE(xdg_dirs);
4287 char *pszPersonal;
4288 char szDesktopTarget[FILENAME_MAX], *pszDesktop;
4289 struct stat statFolder;
4290 const char *pszHome;
4291 char ** xdg_results;
4292 char * xdg_desktop_dir;
4294 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4295 pszPersonal = _SHGetFolderUnixPath(CSIDL_PERSONAL|CSIDL_FLAG_CREATE);
4296 if (!pszPersonal) return;
4298 _SHGetXDGUserDirs(xdg_dirs, num, &xdg_results);
4300 pszHome = getenv("HOME");
4302 if (pszHome)
4303 strcpy(szDesktopTarget, pszHome);
4304 else
4305 strcpy(szDesktopTarget, pszPersonal);
4306 heap_free(pszPersonal);
4308 xdg_desktop_dir = xdg_results ? xdg_results[0] : NULL;
4309 if (xdg_desktop_dir ||
4310 (_SHAppendToUnixPath(szDesktopTarget, DesktopW) &&
4311 !stat(szDesktopTarget, &statFolder) && S_ISDIR(statFolder.st_mode)))
4313 pszDesktop = _SHGetFolderUnixPath(CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_DONT_VERIFY);
4314 if (pszDesktop)
4316 if (xdg_desktop_dir)
4317 symlink(xdg_desktop_dir, pszDesktop);
4318 else
4319 symlink(szDesktopTarget, pszDesktop);
4320 heap_free(pszDesktop);
4324 _SHFreeXDGUserDirs(num, xdg_results);
4327 /******************************************************************************
4328 * _SHCreateSymbolicLink [Internal]
4330 * Sets up a symbolic link for one of the special shell folders to point into
4331 * the users home directory.
4333 * PARAMS
4334 * nFolder [I] CSIDL identifying the folder.
4336 static void _SHCreateSymbolicLink(int nFolder)
4338 static const UINT aidsMyStuff[] = {
4339 IDS_MYPICTURES, IDS_MYVIDEOS, IDS_MYMUSIC, IDS_DOWNLOADS, IDS_TEMPLATES
4341 DWORD folder = nFolder & CSIDL_FOLDER_MASK;
4343 switch (folder) {
4344 case CSIDL_PERSONAL:
4345 _SHCreateMyDocumentsSymbolicLink(aidsMyStuff, ARRAY_SIZE(aidsMyStuff));
4346 break;
4347 case CSIDL_MYPICTURES:
4348 case CSIDL_MYVIDEO:
4349 case CSIDL_MYMUSIC:
4350 case CSIDL_DOWNLOADS:
4351 case CSIDL_TEMPLATES:
4352 _SHCreateMyStuffSymbolicLink(folder);
4353 break;
4354 case CSIDL_DESKTOPDIRECTORY:
4355 _SHCreateDesktopSymbolicLink();
4356 break;
4360 /******************************************************************************
4361 * _SHCreateSymbolicLinks [Internal]
4363 * Sets up symbol links for various shell folders to point into the user's home
4364 * directory. We do an educated guess about what the user would probably want:
4365 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4366 * wine's 'My Documents' to point there. Furthermore, we infer that the user
4367 * is a Windows lover and has no problem with wine creating subfolders for
4368 * 'My Pictures', 'My Music', 'My Videos' etc. under '$HOME/My Documents', if
4369 * those do not already exist. We put appropriate symbolic links in place for
4370 * those, too.
4371 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4372 * point directly to $HOME. We assume the user to be a unix hacker who does not
4373 * want wine to create anything anywhere besides the .wine directory. So, if
4374 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4375 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4376 * directory, and try to link to that. If that fails, then we symlink to
4377 * $HOME directly. The same holds for 'My Pictures', 'My Videos' etc.
4378 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4379 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4380 * it alone.
4381 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4383 static void _SHCreateSymbolicLinks(void)
4385 static const int acsidlMyStuff[] = {
4386 CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC, CSIDL_DOWNLOADS, CSIDL_TEMPLATES, CSIDL_PERSONAL, CSIDL_DESKTOPDIRECTORY
4388 UINT i;
4390 for (i=0; i < ARRAY_SIZE(acsidlMyStuff); i++)
4391 _SHCreateSymbolicLink(acsidlMyStuff[i]);
4394 /******************************************************************************
4395 * SHGetFolderPathW [SHELL32.@]
4397 * Convert nFolder to path.
4399 * RETURNS
4400 * Success: S_OK
4401 * Failure: standard HRESULT error codes.
4403 * NOTES
4404 * Most values can be overridden in either
4405 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
4406 * or in the same location in HKLM.
4407 * The "Shell Folders" registry key was used in NT4 and earlier systems.
4408 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
4409 * changes made to it are made to the former key too. This synchronization is
4410 * done on-demand: not until someone requests the value of one of these paths
4411 * (by calling one of the SHGet functions) is the value synchronized.
4412 * Furthermore, the HKCU paths take precedence over the HKLM paths.
4414 HRESULT WINAPI SHGetFolderPathW(
4415 HWND hwndOwner, /* [I] owner window */
4416 int nFolder, /* [I] CSIDL identifying the folder */
4417 HANDLE hToken, /* [I] access token */
4418 DWORD dwFlags, /* [I] which path to return */
4419 LPWSTR pszPath) /* [O] converted path */
4421 HRESULT hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, NULL, pszPath);
4422 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr)
4423 hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
4424 return hr;
4427 HRESULT WINAPI SHGetFolderPathAndSubDirA(
4428 HWND hwndOwner, /* [I] owner window */
4429 int nFolder, /* [I] CSIDL identifying the folder */
4430 HANDLE hToken, /* [I] access token */
4431 DWORD dwFlags, /* [I] which path to return */
4432 LPCSTR pszSubPath, /* [I] sub directory of the specified folder */
4433 LPSTR pszPath) /* [O] converted path */
4435 int length;
4436 HRESULT hr = S_OK;
4437 LPWSTR pszSubPathW = NULL;
4438 LPWSTR pszPathW = NULL;
4440 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
4442 if(pszPath) {
4443 pszPathW = heap_alloc(MAX_PATH * sizeof(WCHAR));
4444 if(!pszPathW) {
4445 hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
4446 goto cleanup;
4449 TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
4451 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
4452 * set (null), or an empty string.therefore call it without the parameter set
4453 * if pszSubPath is an empty string
4455 if (pszSubPath && pszSubPath[0]) {
4456 length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
4457 pszSubPathW = heap_alloc(length * sizeof(WCHAR));
4458 if(!pszSubPathW) {
4459 hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
4460 goto cleanup;
4462 MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
4465 hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
4467 if (SUCCEEDED(hr) && pszPath)
4468 WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
4470 cleanup:
4471 heap_free(pszPathW);
4472 heap_free(pszSubPathW);
4473 return hr;
4476 /*************************************************************************
4477 * SHGetFolderPathAndSubDirW [SHELL32.@]
4479 HRESULT WINAPI SHGetFolderPathAndSubDirW(
4480 HWND hwndOwner, /* [I] owner window */
4481 int nFolder, /* [I] CSIDL identifying the folder */
4482 HANDLE hToken, /* [I] access token */
4483 DWORD dwFlags, /* [I] which path to return */
4484 LPCWSTR pszSubPath,/* [I] sub directory of the specified folder */
4485 LPWSTR pszPath) /* [O] converted path */
4487 HRESULT hr;
4488 WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
4489 DWORD folder = nFolder & CSIDL_FOLDER_MASK;
4490 CSIDL_Type type;
4491 int ret;
4493 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
4495 /* Windows always NULL-terminates the resulting path regardless of success
4496 * or failure, so do so first
4498 if (pszPath)
4499 *pszPath = '\0';
4501 if (folder >= ARRAY_SIZE(CSIDL_Data))
4502 return E_INVALIDARG;
4503 if ((SHGFP_TYPE_CURRENT != dwFlags) && (SHGFP_TYPE_DEFAULT != dwFlags))
4504 return E_INVALIDARG;
4505 szTemp[0] = 0;
4506 type = CSIDL_Data[folder].type;
4507 switch (type)
4509 case CSIDL_Type_Disallowed:
4510 hr = E_INVALIDARG;
4511 break;
4512 case CSIDL_Type_NonExistent:
4513 hr = S_FALSE;
4514 break;
4515 case CSIDL_Type_WindowsPath:
4516 GetWindowsDirectoryW(szTemp, MAX_PATH);
4517 if (CSIDL_Data[folder].szDefaultPath &&
4518 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4519 *CSIDL_Data[folder].szDefaultPath)
4521 PathAddBackslashW(szTemp);
4522 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4524 hr = S_OK;
4525 break;
4526 case CSIDL_Type_SystemPath:
4527 GetSystemDirectoryW(szTemp, MAX_PATH);
4528 if (CSIDL_Data[folder].szDefaultPath &&
4529 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4530 *CSIDL_Data[folder].szDefaultPath)
4532 PathAddBackslashW(szTemp);
4533 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4535 hr = S_OK;
4536 break;
4537 case CSIDL_Type_SystemX86Path:
4538 if (!GetSystemWow64DirectoryW(szTemp, MAX_PATH)) GetSystemDirectoryW(szTemp, MAX_PATH);
4539 if (CSIDL_Data[folder].szDefaultPath &&
4540 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4541 *CSIDL_Data[folder].szDefaultPath)
4543 PathAddBackslashW(szTemp);
4544 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4546 hr = S_OK;
4547 break;
4548 case CSIDL_Type_CurrVer:
4549 hr = _SHGetCurrentVersionPath(dwFlags, folder, szTemp);
4550 break;
4551 case CSIDL_Type_User:
4552 hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
4553 break;
4554 case CSIDL_Type_AllUsers:
4555 case CSIDL_Type_ProgramData:
4556 hr = _SHGetAllUsersProfilePath(dwFlags, folder, szTemp);
4557 break;
4558 default:
4559 FIXME("bogus type %d, please fix\n", type);
4560 hr = E_INVALIDARG;
4561 break;
4564 /* Expand environment strings if necessary */
4565 if (*szTemp == '%')
4566 hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
4567 else
4568 strcpyW(szBuildPath, szTemp);
4570 if (FAILED(hr)) goto end;
4572 if(pszSubPath) {
4573 /* make sure the new path does not exceed the buffer length
4574 * and remember to backslash and terminate it */
4575 if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
4576 hr = HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE);
4577 goto end;
4579 PathAppendW(szBuildPath, pszSubPath);
4580 PathRemoveBackslashW(szBuildPath);
4582 /* Copy the path if it's available before we might return */
4583 if (SUCCEEDED(hr) && pszPath)
4584 strcpyW(pszPath, szBuildPath);
4586 /* if we don't care about existing directories we are ready */
4587 if(nFolder & CSIDL_FLAG_DONT_VERIFY) goto end;
4589 if (PathFileExistsW(szBuildPath)) goto end;
4591 /* not existing but we are not allowed to create it. The return value
4592 * is verified against shell32 version 6.0.
4594 if (!(nFolder & CSIDL_FLAG_CREATE))
4596 hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
4597 goto end;
4600 /* create symbolic links rather than directories for specific
4601 * user shell folders */
4602 _SHCreateSymbolicLink(folder);
4604 /* create directory/directories */
4605 ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
4606 if (ret && ret != ERROR_ALREADY_EXISTS)
4608 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
4609 hr = E_FAIL;
4610 goto end;
4613 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
4614 end:
4615 TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
4616 return hr;
4619 /*************************************************************************
4620 * SHGetFolderPathA [SHELL32.@]
4622 * See SHGetFolderPathW.
4624 HRESULT WINAPI SHGetFolderPathA(
4625 HWND hwndOwner,
4626 int nFolder,
4627 HANDLE hToken,
4628 DWORD dwFlags,
4629 LPSTR pszPath)
4631 WCHAR szTemp[MAX_PATH];
4632 HRESULT hr;
4634 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
4636 if (pszPath)
4637 *pszPath = '\0';
4638 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
4639 if (SUCCEEDED(hr) && pszPath)
4640 WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
4641 NULL);
4643 return hr;
4646 /* For each folder in folders, if its value has not been set in the registry,
4647 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4648 * folder's type) to get the unexpanded value first.
4649 * Writes the unexpanded value to User Shell Folders, and queries it with
4650 * SHGetFolderPathW to force the creation of the directory if it doesn't
4651 * already exist. SHGetFolderPathW also returns the expanded value, which
4652 * this then writes to Shell Folders.
4654 static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken,
4655 LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[],
4656 UINT foldersLen)
4658 const WCHAR *szValueName;
4659 WCHAR buffer[40];
4660 UINT i;
4661 WCHAR path[MAX_PATH];
4662 HRESULT hr = S_OK;
4663 HKEY hUserKey = NULL, hKey = NULL;
4664 DWORD dwType, dwPathLen;
4665 LONG ret;
4667 TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
4668 debugstr_w(szUserShellFolderPath), folders, foldersLen);
4670 ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
4671 if (ret)
4672 hr = HRESULT_FROM_WIN32(ret);
4673 else
4675 ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
4676 if (ret)
4677 hr = HRESULT_FROM_WIN32(ret);
4679 for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
4681 dwPathLen = MAX_PATH * sizeof(WCHAR);
4683 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4684 szValueName = CSIDL_Data[folders[i]].szValueName;
4685 if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
4687 StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
4688 szValueName = &buffer[0];
4691 if (RegQueryValueExW(hUserKey, szValueName, NULL,
4692 &dwType, (LPBYTE)path, &dwPathLen) || (dwType != REG_SZ &&
4693 dwType != REG_EXPAND_SZ))
4695 *path = '\0';
4696 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
4697 _SHGetUserProfilePath(hToken, SHGFP_TYPE_DEFAULT, folders[i],
4698 path);
4699 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers ||
4700 CSIDL_Data[folders[i]].type == CSIDL_Type_ProgramData)
4701 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT, folders[i], path);
4702 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
4704 GetWindowsDirectoryW(path, MAX_PATH);
4705 if (CSIDL_Data[folders[i]].szDefaultPath &&
4706 !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
4708 PathAddBackslashW(path);
4709 strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
4712 else
4713 hr = E_FAIL;
4714 if (*path)
4716 ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
4717 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
4718 if (ret)
4719 hr = HRESULT_FROM_WIN32(ret);
4720 else
4722 hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
4723 hToken, SHGFP_TYPE_DEFAULT, path);
4724 ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
4725 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
4726 if (ret)
4727 hr = HRESULT_FROM_WIN32(ret);
4732 if (hUserKey)
4733 RegCloseKey(hUserKey);
4734 if (hKey)
4735 RegCloseKey(hKey);
4737 TRACE("returning 0x%08x\n", hr);
4738 return hr;
4741 static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
4743 static const UINT folders[] = {
4744 CSIDL_PROGRAMS,
4745 CSIDL_PERSONAL,
4746 CSIDL_FAVORITES,
4747 CSIDL_APPDATA,
4748 CSIDL_STARTUP,
4749 CSIDL_RECENT,
4750 CSIDL_SENDTO,
4751 CSIDL_STARTMENU,
4752 CSIDL_MYMUSIC,
4753 CSIDL_MYVIDEO,
4754 CSIDL_DESKTOPDIRECTORY,
4755 CSIDL_NETHOOD,
4756 CSIDL_TEMPLATES,
4757 CSIDL_PRINTHOOD,
4758 CSIDL_LOCAL_APPDATA,
4759 CSIDL_INTERNET_CACHE,
4760 CSIDL_COOKIES,
4761 CSIDL_HISTORY,
4762 CSIDL_MYPICTURES,
4763 CSIDL_FONTS,
4764 CSIDL_ADMINTOOLS,
4765 CSIDL_CONTACTS,
4766 CSIDL_DOWNLOADS,
4767 CSIDL_LINKS,
4768 CSIDL_APPDATA_LOCALLOW,
4769 CSIDL_SAVED_GAMES,
4770 CSIDL_SEARCHES
4772 WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
4773 LPCWSTR pUserShellFolderPath, pShellFolderPath;
4774 HRESULT hr = S_OK;
4775 HKEY hRootKey;
4776 HANDLE hToken;
4778 TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
4779 if (bDefault)
4781 hToken = (HANDLE)-1;
4782 hRootKey = HKEY_USERS;
4783 strcpyW(userShellFolderPath, DefaultW);
4784 PathAddBackslashW(userShellFolderPath);
4785 strcatW(userShellFolderPath, szSHUserFolders);
4786 pUserShellFolderPath = userShellFolderPath;
4787 strcpyW(shellFolderPath, DefaultW);
4788 PathAddBackslashW(shellFolderPath);
4789 strcatW(shellFolderPath, szSHFolders);
4790 pShellFolderPath = shellFolderPath;
4792 else
4794 hToken = NULL;
4795 hRootKey = HKEY_CURRENT_USER;
4796 pUserShellFolderPath = szSHUserFolders;
4797 pShellFolderPath = szSHFolders;
4800 hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
4801 pShellFolderPath, folders, ARRAY_SIZE(folders));
4802 TRACE("returning 0x%08x\n", hr);
4803 return hr;
4806 static HRESULT _SHRegisterCommonShellFolders(void)
4808 static const UINT folders[] = {
4809 CSIDL_COMMON_STARTMENU,
4810 CSIDL_COMMON_PROGRAMS,
4811 CSIDL_COMMON_STARTUP,
4812 CSIDL_COMMON_DESKTOPDIRECTORY,
4813 CSIDL_COMMON_FAVORITES,
4814 CSIDL_COMMON_APPDATA,
4815 CSIDL_COMMON_TEMPLATES,
4816 CSIDL_COMMON_DOCUMENTS,
4817 CSIDL_COMMON_ADMINTOOLS,
4818 CSIDL_COMMON_MUSIC,
4819 CSIDL_COMMON_PICTURES,
4820 CSIDL_COMMON_VIDEO,
4822 HRESULT hr;
4824 TRACE("\n");
4825 hr = _SHRegisterFolders(HKEY_LOCAL_MACHINE, NULL, szSHUserFolders,
4826 szSHFolders, folders, ARRAY_SIZE(folders));
4827 TRACE("returning 0x%08x\n", hr);
4828 return hr;
4831 /******************************************************************************
4832 * create_extra_folders [Internal]
4834 * Create some extra folders that don't have a standard CSIDL definition.
4836 static HRESULT create_extra_folders(void)
4838 static const WCHAR environW[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4839 static const WCHAR microsoftW[] = {'M','i','c','r','o','s','o','f','t',0};
4840 static const WCHAR TempW[] = {'T','e','m','p',0};
4841 static const WCHAR TEMPW[] = {'T','E','M','P',0};
4842 static const WCHAR TMPW[] = {'T','M','P',0};
4843 WCHAR path[MAX_PATH+5];
4844 HRESULT hr;
4845 HKEY hkey;
4846 DWORD type, size, ret;
4848 ret = RegCreateKeyW( HKEY_CURRENT_USER, environW, &hkey );
4849 if (ret) return HRESULT_FROM_WIN32( ret );
4851 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4852 hr = SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL,
4853 SHGFP_TYPE_DEFAULT, TempW, path );
4854 if (SUCCEEDED(hr))
4856 size = sizeof(path);
4857 if (RegQueryValueExW( hkey, TEMPW, NULL, &type, (LPBYTE)path, &size ))
4858 RegSetValueExW( hkey, TEMPW, 0, REG_SZ, (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR) );
4859 size = sizeof(path);
4860 if (RegQueryValueExW( hkey, TMPW, NULL, &type, (LPBYTE)path, &size ))
4861 RegSetValueExW( hkey, TMPW, 0, REG_SZ, (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR) );
4863 RegCloseKey( hkey );
4865 if (SUCCEEDED(hr))
4867 hr = SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL,
4868 SHGFP_TYPE_DEFAULT, microsoftW, path );
4870 if (SUCCEEDED(hr))
4872 hr = SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL,
4873 SHGFP_TYPE_DEFAULT, Microsoft_Windows_ThemesW, path);
4875 return hr;
4879 /******************************************************************************
4880 * set_folder_attributes
4882 * Set the various folder attributes registry keys.
4884 static HRESULT set_folder_attributes(void)
4886 static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0 };
4887 static const WCHAR shellfolderW[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4888 static const WCHAR wfparsingW[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4889 static const WCHAR wfdisplayW[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4890 static const WCHAR hideasdeleteW[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4891 static const WCHAR cfattributesW[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4892 static const WCHAR emptyW[] = {0};
4894 static const struct
4896 const CLSID *clsid;
4897 BOOL wfparsing : 1;
4898 BOOL wfdisplay : 1;
4899 BOOL hideasdel : 1;
4900 DWORD attr;
4901 DWORD call_for_attr;
4902 } folders[] =
4904 { &CLSID_UnixFolder, TRUE, FALSE, FALSE },
4905 { &CLSID_UnixDosFolder, TRUE, FALSE, FALSE,
4906 SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER, SFGAO_FILESYSTEM },
4907 { &CLSID_FolderShortcut, FALSE, FALSE, FALSE,
4908 SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_LINK,
4909 SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR },
4910 { &CLSID_MyDocuments, TRUE, FALSE, FALSE,
4911 SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER, SFGAO_FILESYSTEM },
4912 { &CLSID_RecycleBin, FALSE, FALSE, FALSE,
4913 SFGAO_FOLDER|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET },
4914 { &CLSID_ControlPanel, FALSE, TRUE, TRUE,
4915 SFGAO_FOLDER|SFGAO_HASSUBFOLDER }
4918 unsigned int i;
4919 WCHAR buffer[39 + ARRAY_SIZE(clsidW) + ARRAY_SIZE(shellfolderW)];
4920 LONG res;
4921 HKEY hkey;
4923 for (i = 0; i < ARRAY_SIZE(folders); i++)
4925 strcpyW( buffer, clsidW );
4926 StringFromGUID2( folders[i].clsid, buffer + strlenW(buffer), 39 );
4927 strcatW( buffer, shellfolderW );
4928 res = RegCreateKeyExW( HKEY_CLASSES_ROOT, buffer, 0, NULL, 0,
4929 KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
4930 if (res) return HRESULT_FROM_WIN32( res );
4931 if (folders[i].wfparsing)
4932 res = RegSetValueExW( hkey, wfparsingW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4933 if (folders[i].wfdisplay)
4934 res = RegSetValueExW( hkey, wfdisplayW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4935 if (folders[i].hideasdel)
4936 res = RegSetValueExW( hkey, hideasdeleteW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4937 if (folders[i].attr)
4938 res = RegSetValueExW( hkey, szAttributes, 0, REG_DWORD,
4939 (const BYTE *)&folders[i].attr, sizeof(DWORD));
4940 if (folders[i].call_for_attr)
4941 res = RegSetValueExW( hkey, cfattributesW, 0, REG_DWORD,
4942 (const BYTE *)&folders[i].call_for_attr, sizeof(DWORD));
4943 RegCloseKey( hkey );
4945 return S_OK;
4948 /*************************************************************************
4949 * SHGetSpecialFolderPathA [SHELL32.@]
4951 BOOL WINAPI SHGetSpecialFolderPathA (
4952 HWND hwndOwner,
4953 LPSTR szPath,
4954 int nFolder,
4955 BOOL bCreate)
4957 return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
4958 szPath) == S_OK;
4961 /*************************************************************************
4962 * SHGetSpecialFolderPathW
4964 BOOL WINAPI SHGetSpecialFolderPathW (
4965 HWND hwndOwner,
4966 LPWSTR szPath,
4967 int nFolder,
4968 BOOL bCreate)
4970 return SHGetFolderPathW(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
4971 szPath) == S_OK;
4974 /*************************************************************************
4975 * SHGetSpecialFolderPath (SHELL32.175)
4977 BOOL WINAPI SHGetSpecialFolderPathAW (
4978 HWND hwndOwner,
4979 LPVOID szPath,
4980 int nFolder,
4981 BOOL bCreate)
4984 if (SHELL_OsIsUnicode())
4985 return SHGetSpecialFolderPathW (hwndOwner, szPath, nFolder, bCreate);
4986 return SHGetSpecialFolderPathA (hwndOwner, szPath, nFolder, bCreate);
4989 /*************************************************************************
4990 * SHGetFolderLocation [SHELL32.@]
4992 * Gets the folder locations from the registry and creates a pidl.
4994 * PARAMS
4995 * hwndOwner [I]
4996 * nFolder [I] CSIDL_xxxxx
4997 * hToken [I] token representing user, or NULL for current user, or -1 for
4998 * default user
4999 * dwReserved [I] must be zero
5000 * ppidl [O] PIDL of a special folder
5002 * RETURNS
5003 * Success: S_OK
5004 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
5006 * NOTES
5007 * Creates missing reg keys and directories.
5008 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
5009 * virtual folders that are handled here.
5011 HRESULT WINAPI SHGetFolderLocation(
5012 HWND hwndOwner,
5013 int nFolder,
5014 HANDLE hToken,
5015 DWORD dwReserved,
5016 LPITEMIDLIST *ppidl)
5018 HRESULT hr = E_INVALIDARG;
5020 TRACE("%p 0x%08x %p 0x%08x %p\n",
5021 hwndOwner, nFolder, hToken, dwReserved, ppidl);
5023 if (!ppidl)
5024 return E_INVALIDARG;
5025 if (dwReserved)
5026 return E_INVALIDARG;
5028 /* The virtual folders' locations are not user-dependent */
5029 *ppidl = NULL;
5030 switch (nFolder & CSIDL_FOLDER_MASK)
5032 case CSIDL_DESKTOP:
5033 *ppidl = _ILCreateDesktop();
5034 break;
5036 case CSIDL_PERSONAL:
5037 *ppidl = _ILCreateMyDocuments();
5038 break;
5040 case CSIDL_INTERNET:
5041 *ppidl = _ILCreateIExplore();
5042 break;
5044 case CSIDL_CONTROLS:
5045 *ppidl = _ILCreateControlPanel();
5046 break;
5048 case CSIDL_PRINTERS:
5049 *ppidl = _ILCreatePrinters();
5050 break;
5052 case CSIDL_BITBUCKET:
5053 *ppidl = _ILCreateBitBucket();
5054 break;
5056 case CSIDL_DRIVES:
5057 *ppidl = _ILCreateMyComputer();
5058 break;
5060 case CSIDL_NETWORK:
5061 *ppidl = _ILCreateNetwork();
5062 break;
5064 default:
5066 WCHAR szPath[MAX_PATH];
5068 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
5069 SHGFP_TYPE_CURRENT, szPath);
5070 if (SUCCEEDED(hr))
5072 DWORD attributes=0;
5074 TRACE("Value=%s\n", debugstr_w(szPath));
5075 hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
5077 else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
5079 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
5080 * version 6.0 returns E_FAIL for nonexistent paths
5082 hr = E_FAIL;
5086 if(*ppidl)
5087 hr = S_OK;
5089 TRACE("-- (new pidl %p)\n",*ppidl);
5090 return hr;
5093 /*************************************************************************
5094 * SHGetSpecialFolderLocation [SHELL32.@]
5096 * NOTES
5097 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
5098 * directory.
5100 HRESULT WINAPI SHGetSpecialFolderLocation(
5101 HWND hwndOwner,
5102 INT nFolder,
5103 LPITEMIDLIST * ppidl)
5105 HRESULT hr = E_INVALIDARG;
5107 TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
5109 if (!ppidl)
5110 return E_INVALIDARG;
5112 hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
5113 return hr;
5116 static int csidl_from_id( const KNOWNFOLDERID *id )
5118 int i;
5119 for (i = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
5120 if (IsEqualGUID( CSIDL_Data[i].id, id )) return i;
5121 return -1;
5124 /*************************************************************************
5125 * SHGetKnownFolderPath [SHELL32.@]
5127 HRESULT WINAPI SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, WCHAR **ret_path)
5129 WCHAR pathW[MAX_PATH], tempW[MAX_PATH];
5130 HRESULT hr;
5131 CSIDL_Type type;
5132 int ret;
5133 int folder = csidl_from_id(rfid), shgfp_flags;
5135 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid), flags, token, ret_path);
5137 *ret_path = NULL;
5139 if (folder < 0)
5140 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
5142 if (flags & ~(KF_FLAG_CREATE|KF_FLAG_SIMPLE_IDLIST|KF_FLAG_DONT_UNEXPAND|
5143 KF_FLAG_DONT_VERIFY|KF_FLAG_NO_ALIAS|KF_FLAG_INIT|KF_FLAG_DEFAULT_PATH))
5145 FIXME("flags 0x%08x not supported\n", flags);
5146 return E_INVALIDARG;
5149 shgfp_flags = flags & KF_FLAG_DEFAULT_PATH ? SHGFP_TYPE_DEFAULT : SHGFP_TYPE_CURRENT;
5151 type = CSIDL_Data[folder].type;
5152 switch (type)
5154 case CSIDL_Type_Disallowed:
5155 hr = E_INVALIDARG;
5156 break;
5157 case CSIDL_Type_NonExistent:
5158 *tempW = 0;
5159 hr = S_FALSE;
5160 break;
5161 case CSIDL_Type_WindowsPath:
5162 GetWindowsDirectoryW(tempW, MAX_PATH);
5163 if (CSIDL_Data[folder].szDefaultPath &&
5164 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
5165 *CSIDL_Data[folder].szDefaultPath)
5167 PathAddBackslashW(tempW);
5168 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
5170 hr = S_OK;
5171 break;
5172 case CSIDL_Type_SystemPath:
5173 GetSystemDirectoryW(tempW, MAX_PATH);
5174 if (CSIDL_Data[folder].szDefaultPath &&
5175 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
5176 *CSIDL_Data[folder].szDefaultPath)
5178 PathAddBackslashW(tempW);
5179 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
5181 hr = S_OK;
5182 break;
5183 case CSIDL_Type_SystemX86Path:
5184 if (!GetSystemWow64DirectoryW(tempW, MAX_PATH)) GetSystemDirectoryW(tempW, MAX_PATH);
5185 if (CSIDL_Data[folder].szDefaultPath &&
5186 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
5187 *CSIDL_Data[folder].szDefaultPath)
5189 PathAddBackslashW(tempW);
5190 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
5192 hr = S_OK;
5193 break;
5194 case CSIDL_Type_CurrVer:
5195 hr = _SHGetCurrentVersionPath(shgfp_flags, folder, tempW);
5196 break;
5197 case CSIDL_Type_User:
5198 hr = _SHGetUserProfilePath(token, shgfp_flags, folder, tempW);
5199 break;
5200 case CSIDL_Type_AllUsers:
5201 case CSIDL_Type_ProgramData:
5202 hr = _SHGetAllUsersProfilePath(shgfp_flags, folder, tempW);
5203 break;
5204 default:
5205 FIXME("bogus type %d, please fix\n", type);
5206 hr = E_INVALIDARG;
5207 break;
5210 if (FAILED(hr))
5211 goto failed;
5213 /* Expand environment strings if necessary */
5214 if (*tempW == '%')
5216 hr = _SHExpandEnvironmentStrings(tempW, pathW);
5217 if (FAILED(hr))
5218 goto failed;
5220 else
5221 strcpyW(pathW, tempW);
5223 /* if we don't care about existing directories we are ready */
5224 if (flags & KF_FLAG_DONT_VERIFY) goto done;
5226 if (PathFileExistsW(pathW)) goto done;
5228 /* Does not exist but we are not allowed to create it. The return value
5229 * is verified against shell32 version 6.0.
5231 if (!(flags & KF_FLAG_CREATE))
5233 hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
5234 goto failed;
5237 /* create symbolic links rather than directories for specific
5238 * user shell folders */
5239 _SHCreateSymbolicLink(folder);
5241 /* create directory/directories */
5242 ret = SHCreateDirectoryExW(NULL, pathW, NULL);
5243 if (ret && ret != ERROR_ALREADY_EXISTS)
5245 ERR("Failed to create directory %s.\n", debugstr_w(pathW));
5246 hr = E_FAIL;
5247 goto failed;
5250 TRACE("Created missing system directory %s\n", debugstr_w(pathW));
5252 done:
5253 TRACE("Final path is %s, %#x\n", debugstr_w(pathW), hr);
5255 *ret_path = CoTaskMemAlloc((strlenW(pathW) + 1) * sizeof(WCHAR));
5256 if (!*ret_path)
5257 return E_OUTOFMEMORY;
5258 strcpyW(*ret_path, pathW);
5260 return hr;
5262 failed:
5263 TRACE("Failed to get folder path, %#x.\n", hr);
5265 return hr;
5268 /*************************************************************************
5269 * SHGetFolderPathEx [SHELL32.@]
5271 HRESULT WINAPI SHGetFolderPathEx(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, LPWSTR path, DWORD len)
5273 HRESULT hr;
5274 WCHAR *buffer;
5276 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid), flags, token, path, len);
5278 if (!path || !len) return E_INVALIDARG;
5280 hr = SHGetKnownFolderPath( rfid, flags, token, &buffer );
5281 if (SUCCEEDED( hr ))
5283 if (strlenW( buffer ) + 1 > len)
5285 CoTaskMemFree( buffer );
5286 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER );
5288 strcpyW( path, buffer );
5289 CoTaskMemFree( buffer );
5291 return hr;
5295 * Internal function to convert known folder identifier to path of registry key
5296 * associated with known folder.
5298 * Parameters:
5299 * rfid [I] pointer to known folder identifier (may be NULL)
5300 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
5301 * lpPath [O] place to store string address. String should be
5302 * later freed using HeapFree(GetProcessHeap(),0, ... )
5304 static HRESULT get_known_folder_registry_path(
5305 REFKNOWNFOLDERID rfid,
5306 LPWSTR lpStringGuid,
5307 LPWSTR *lpPath)
5309 static const WCHAR sBackslash[] = {'\\',0};
5310 HRESULT hr = S_OK;
5311 int length;
5312 WCHAR sGuid[50];
5314 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid), debugstr_w(lpStringGuid), lpPath);
5316 if(rfid)
5317 StringFromGUID2(rfid, sGuid, ARRAY_SIZE(sGuid));
5318 else
5319 lstrcpyW(sGuid, lpStringGuid);
5321 length = lstrlenW(szKnownFolderDescriptions)+51;
5322 *lpPath = heap_alloc(length*sizeof(WCHAR));
5323 if(!(*lpPath))
5324 hr = E_OUTOFMEMORY;
5326 if(SUCCEEDED(hr))
5328 lstrcpyW(*lpPath, szKnownFolderDescriptions);
5329 lstrcatW(*lpPath, sBackslash);
5330 lstrcatW(*lpPath, sGuid);
5333 return hr;
5336 static HRESULT get_known_folder_wstr(const WCHAR *regpath, const WCHAR *value, WCHAR **out)
5338 DWORD size = 0;
5339 HRESULT hr;
5341 size = 0;
5342 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, regpath, value, RRF_RT_REG_SZ, NULL, NULL, &size));
5343 if(FAILED(hr))
5344 return hr;
5346 *out = CoTaskMemAlloc(size);
5347 if(!*out)
5348 return E_OUTOFMEMORY;
5350 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, regpath, value, RRF_RT_REG_SZ, NULL, *out, &size));
5351 if(FAILED(hr)){
5352 CoTaskMemFree(*out);
5353 *out = NULL;
5356 return hr;
5359 static HRESULT get_known_folder_dword(const WCHAR *registryPath, const WCHAR *value, DWORD *out)
5361 DWORD dwSize = sizeof(DWORD);
5362 DWORD dwType;
5363 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, value, RRF_RT_DWORD, &dwType, out, &dwSize));
5367 * Internal function to get place where folder redirection information are stored.
5369 * Parameters:
5370 * rfid [I] pointer to known folder identifier (may be NULL)
5371 * rootKey [O] root key where the redirection information are stored
5372 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5373 * However, besides root key, path is always that same, and is stored
5374 * as "szKnownFolderRedirections" constant
5376 static HRESULT get_known_folder_redirection_place(
5377 REFKNOWNFOLDERID rfid,
5378 HKEY *rootKey)
5380 HRESULT hr;
5381 LPWSTR lpRegistryPath = NULL;
5382 KF_CATEGORY category;
5384 /* first, get known folder's category */
5385 hr = get_known_folder_registry_path(rfid, NULL, &lpRegistryPath);
5387 if(SUCCEEDED(hr))
5388 hr = get_known_folder_dword(lpRegistryPath, szCategory, &category);
5390 if(SUCCEEDED(hr))
5392 if(category == KF_CATEGORY_COMMON)
5394 *rootKey = HKEY_LOCAL_MACHINE;
5395 hr = S_OK;
5397 else if(category == KF_CATEGORY_PERUSER)
5399 *rootKey = HKEY_CURRENT_USER;
5400 hr = S_OK;
5402 else
5403 hr = E_FAIL;
5406 heap_free(lpRegistryPath);
5407 return hr;
5410 static HRESULT get_known_folder_path_by_id(REFKNOWNFOLDERID folderId, LPWSTR lpRegistryPath, DWORD dwFlags, LPWSTR *ppszPath);
5412 static HRESULT redirect_known_folder(
5413 REFKNOWNFOLDERID rfid,
5414 HWND hwnd,
5415 KF_REDIRECT_FLAGS flags,
5416 LPCWSTR pszTargetPath,
5417 UINT cFolders,
5418 KNOWNFOLDERID const *pExclusion,
5419 LPWSTR *ppszError)
5421 HRESULT hr;
5422 HKEY rootKey = HKEY_LOCAL_MACHINE, hKey;
5423 WCHAR sGuid[39];
5424 LPWSTR lpRegistryPath = NULL, lpSrcPath = NULL;
5425 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid), hwnd, flags, debugstr_w(pszTargetPath), cFolders, pExclusion, ppszError);
5427 if (ppszError) *ppszError = NULL;
5429 hr = get_known_folder_registry_path(rfid, NULL, &lpRegistryPath);
5431 if(SUCCEEDED(hr))
5432 hr = get_known_folder_path_by_id(rfid, lpRegistryPath, 0, &lpSrcPath);
5434 heap_free(lpRegistryPath);
5436 /* get path to redirection storage */
5437 if(SUCCEEDED(hr))
5438 hr = get_known_folder_redirection_place(rfid, &rootKey);
5440 /* write redirection information */
5441 if(SUCCEEDED(hr))
5442 hr = HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey, szKnownFolderRedirections, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL));
5444 if(SUCCEEDED(hr))
5446 StringFromGUID2(rfid, sGuid, ARRAY_SIZE(sGuid));
5448 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, sGuid, 0, REG_SZ, (LPBYTE)pszTargetPath, (lstrlenW(pszTargetPath)+1)*sizeof(WCHAR)));
5450 RegCloseKey(hKey);
5453 /* make sure destination path exists */
5454 SHCreateDirectory(NULL, pszTargetPath);
5456 /* copy content if required */
5457 if(SUCCEEDED(hr) && (flags & KF_REDIRECT_COPY_CONTENTS) )
5459 static const WCHAR sWildcard[] = {'\\','*',0};
5460 WCHAR srcPath[MAX_PATH+1], dstPath[MAX_PATH+1];
5461 SHFILEOPSTRUCTW fileOp;
5463 ZeroMemory(srcPath, sizeof(srcPath));
5464 lstrcpyW(srcPath, lpSrcPath);
5465 lstrcatW(srcPath, sWildcard);
5467 ZeroMemory(dstPath, sizeof(dstPath));
5468 lstrcpyW(dstPath, pszTargetPath);
5470 ZeroMemory(&fileOp, sizeof(fileOp));
5472 if(flags & KF_REDIRECT_DEL_SOURCE_CONTENTS)
5473 fileOp.wFunc = FO_MOVE;
5474 else
5475 fileOp.wFunc = FO_COPY;
5477 fileOp.pFrom = srcPath;
5478 fileOp.pTo = dstPath;
5479 fileOp.fFlags = FOF_NO_UI;
5481 hr = (SHFileOperationW(&fileOp)==0 ? S_OK : E_FAIL);
5483 if(flags & KF_REDIRECT_DEL_SOURCE_CONTENTS)
5485 ZeroMemory(srcPath, sizeof(srcPath));
5486 lstrcpyW(srcPath, lpSrcPath);
5488 ZeroMemory(&fileOp, sizeof(fileOp));
5489 fileOp.wFunc = FO_DELETE;
5490 fileOp.pFrom = srcPath;
5491 fileOp.fFlags = FOF_NO_UI;
5493 hr = (SHFileOperationW(&fileOp)==0 ? S_OK : E_FAIL);
5497 CoTaskMemFree(lpSrcPath);
5499 return hr;
5503 struct knownfolder
5505 IKnownFolder IKnownFolder_iface;
5506 LONG refs;
5507 KNOWNFOLDERID id;
5508 LPWSTR registryPath;
5511 static inline struct knownfolder *impl_from_IKnownFolder( IKnownFolder *iface )
5513 return CONTAINING_RECORD( iface, struct knownfolder, IKnownFolder_iface );
5516 static ULONG WINAPI knownfolder_AddRef(
5517 IKnownFolder *iface )
5519 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5520 return InterlockedIncrement( &knownfolder->refs );
5523 static ULONG WINAPI knownfolder_Release(
5524 IKnownFolder *iface )
5526 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5527 LONG refs = InterlockedDecrement( &knownfolder->refs );
5528 if (!refs)
5530 TRACE("destroying %p\n", knownfolder);
5531 heap_free( knownfolder->registryPath );
5532 heap_free( knownfolder );
5534 return refs;
5537 static HRESULT WINAPI knownfolder_QueryInterface(
5538 IKnownFolder *iface,
5539 REFIID riid,
5540 void **ppv )
5542 struct knownfolder *This = impl_from_IKnownFolder( iface );
5544 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
5546 *ppv = NULL;
5547 if ( IsEqualGUID( riid, &IID_IKnownFolder ) ||
5548 IsEqualGUID( riid, &IID_IUnknown ) )
5550 *ppv = iface;
5552 else if ( IsEqualGUID( riid, &IID_IMarshal ) )
5554 TRACE("IID_IMarshal returning NULL.\n");
5555 return E_NOINTERFACE;
5557 else
5559 FIXME("interface %s not implemented\n", debugstr_guid(riid));
5560 return E_NOINTERFACE;
5562 IKnownFolder_AddRef( iface );
5563 return S_OK;
5566 static HRESULT knownfolder_set_id(
5567 struct knownfolder *knownfolder,
5568 const KNOWNFOLDERID *kfid)
5570 HKEY hKey;
5571 HRESULT hr;
5573 TRACE("%s\n", debugstr_guid(kfid));
5575 knownfolder->id = *kfid;
5577 /* check is it registry-registered folder */
5578 hr = get_known_folder_registry_path(kfid, NULL, &knownfolder->registryPath);
5579 if(SUCCEEDED(hr))
5580 hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, knownfolder->registryPath, 0, 0, &hKey));
5582 if(SUCCEEDED(hr))
5584 hr = S_OK;
5585 RegCloseKey(hKey);
5587 else
5589 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5590 heap_free(knownfolder->registryPath);
5591 knownfolder->registryPath = NULL;
5592 hr = S_OK;
5595 return hr;
5598 static HRESULT WINAPI knownfolder_GetId(
5599 IKnownFolder *iface,
5600 KNOWNFOLDERID *pkfid)
5602 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5604 TRACE("%p\n", pkfid);
5606 *pkfid = knownfolder->id;
5607 return S_OK;
5610 static HRESULT WINAPI knownfolder_GetCategory(
5611 IKnownFolder *iface,
5612 KF_CATEGORY *pCategory)
5614 struct knownfolder *knownfolder = impl_from_IKnownFolder(iface);
5615 HRESULT hr = S_OK;
5617 TRACE("%p, %p\n", knownfolder, pCategory);
5619 /* we cannot get a category for a folder which is not registered */
5620 if(!knownfolder->registryPath)
5621 hr = E_FAIL;
5623 if(SUCCEEDED(hr))
5624 hr = get_known_folder_dword(knownfolder->registryPath, szCategory, pCategory);
5626 return hr;
5629 static HRESULT WINAPI knownfolder_GetShellItem(
5630 IKnownFolder *iface,
5631 DWORD flags,
5632 REFIID riid,
5633 void **ppv)
5635 struct knownfolder *knownfolder = impl_from_IKnownFolder(iface);
5636 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder, flags, debugstr_guid(riid), ppv);
5637 return SHGetKnownFolderItem(&knownfolder->id, flags, NULL, riid, ppv);
5640 static HRESULT get_known_folder_path(
5641 LPWSTR sFolderId,
5642 LPWSTR registryPath,
5643 LPWSTR *ppszPath)
5645 static const WCHAR sBackslash[] = {'\\',0};
5646 HRESULT hr;
5647 DWORD dwSize, dwType;
5648 WCHAR path[MAX_PATH] = {0};
5649 WCHAR parentGuid[39];
5650 KF_CATEGORY category;
5651 LPWSTR parentRegistryPath, parentPath;
5652 HKEY hRedirectionRootKey = NULL;
5654 TRACE("(%s, %p)\n", debugstr_w(registryPath), ppszPath);
5655 *ppszPath = NULL;
5657 /* check if folder has parent */
5658 dwSize = sizeof(parentGuid);
5659 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szParentFolder, RRF_RT_REG_SZ, &dwType, parentGuid, &dwSize));
5660 if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) hr = S_FALSE;
5662 if(hr == S_OK)
5664 /* get parent's known folder path (recursive) */
5665 hr = get_known_folder_registry_path(NULL, parentGuid, &parentRegistryPath);
5666 if(FAILED(hr)) return hr;
5668 hr = get_known_folder_path(parentGuid, parentRegistryPath, &parentPath);
5669 if(FAILED(hr)) {
5670 heap_free(parentRegistryPath);
5671 return hr;
5674 lstrcatW(path, parentPath);
5675 lstrcatW(path, sBackslash);
5677 heap_free(parentRegistryPath);
5678 heap_free(parentPath);
5681 /* check, if folder was redirected */
5682 if(SUCCEEDED(hr))
5683 hr = get_known_folder_dword(registryPath, szCategory, &category);
5685 if(SUCCEEDED(hr))
5687 if(category == KF_CATEGORY_COMMON)
5688 hRedirectionRootKey = HKEY_LOCAL_MACHINE;
5689 else if(category == KF_CATEGORY_PERUSER)
5690 hRedirectionRootKey = HKEY_CURRENT_USER;
5692 if(hRedirectionRootKey)
5694 hr = HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey, szKnownFolderRedirections, sFolderId, RRF_RT_REG_SZ, NULL, NULL, &dwSize));
5696 if(SUCCEEDED(hr))
5698 *ppszPath = CoTaskMemAlloc(dwSize+(lstrlenW(path)+1)*sizeof(WCHAR));
5699 if(!*ppszPath) hr = E_OUTOFMEMORY;
5702 if(SUCCEEDED(hr))
5704 lstrcpyW(*ppszPath, path);
5705 hr = HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey, szKnownFolderRedirections, sFolderId, RRF_RT_REG_SZ, NULL, *ppszPath + lstrlenW(path), &dwSize));
5709 if(!*ppszPath)
5711 /* no redirection, use previous way - read the relative path from folder definition */
5712 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szRelativePath, RRF_RT_REG_SZ, &dwType, NULL, &dwSize));
5714 if(SUCCEEDED(hr))
5716 *ppszPath = CoTaskMemAlloc(dwSize+(lstrlenW(path)+1)*sizeof(WCHAR));
5717 if(!*ppszPath) hr = E_OUTOFMEMORY;
5720 if(SUCCEEDED(hr))
5722 lstrcpyW(*ppszPath, path);
5723 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szRelativePath, RRF_RT_REG_SZ, &dwType, *ppszPath + lstrlenW(path), &dwSize));
5728 TRACE("returning path: %s\n", debugstr_w(*ppszPath));
5729 return hr;
5732 static HRESULT get_known_folder_path_by_id(
5733 REFKNOWNFOLDERID folderId,
5734 LPWSTR lpRegistryPath,
5735 DWORD dwFlags,
5736 LPWSTR *ppszPath)
5738 HRESULT hr = E_FAIL;
5739 WCHAR sGuid[39];
5740 DWORD dwAttributes;
5742 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId), debugstr_w(lpRegistryPath), dwFlags, ppszPath);
5744 /* if this is registry-registered known folder, get path from registry */
5745 if(lpRegistryPath)
5747 StringFromGUID2(folderId, sGuid, ARRAY_SIZE(sGuid));
5749 hr = get_known_folder_path(sGuid, lpRegistryPath, ppszPath);
5751 /* in other case, use older way */
5753 if(FAILED(hr))
5754 hr = SHGetKnownFolderPath( folderId, dwFlags, NULL, ppszPath );
5756 if (FAILED(hr)) return hr;
5758 /* check if known folder really exists */
5759 dwAttributes = GetFileAttributesW(*ppszPath);
5760 if(dwAttributes == INVALID_FILE_ATTRIBUTES || !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY) )
5762 TRACE("directory %s not found\n", debugstr_w(*ppszPath));
5763 CoTaskMemFree(*ppszPath);
5764 *ppszPath = NULL;
5765 hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
5768 return hr;
5771 static HRESULT WINAPI knownfolder_GetPath(
5772 IKnownFolder *iface,
5773 DWORD dwFlags,
5774 LPWSTR *ppszPath)
5776 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5777 TRACE("(%p, 0x%08x, %p)\n", knownfolder, dwFlags, ppszPath);
5779 return get_known_folder_path_by_id(&knownfolder->id, knownfolder->registryPath, dwFlags, ppszPath);
5782 static HRESULT WINAPI knownfolder_SetPath(
5783 IKnownFolder *iface,
5784 DWORD dwFlags,
5785 LPCWSTR pszPath)
5787 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5788 HRESULT hr = S_OK;
5790 TRACE("(%p, 0x%08x, %s)\n", knownfolder, dwFlags, debugstr_w(pszPath));
5792 /* check if the known folder is registered */
5793 if(!knownfolder->registryPath)
5794 hr = E_FAIL;
5796 if(SUCCEEDED(hr))
5797 hr = redirect_known_folder(&knownfolder->id, NULL, 0, pszPath, 0, NULL, NULL);
5799 return hr;
5802 static HRESULT WINAPI knownfolder_GetIDList(
5803 IKnownFolder *iface,
5804 DWORD flags,
5805 PIDLIST_ABSOLUTE *ppidl)
5807 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5808 TRACE("(%p, 0x%08x, %p)\n", knownfolder, flags, ppidl);
5809 return SHGetKnownFolderIDList(&knownfolder->id, flags, NULL, ppidl);
5812 static HRESULT WINAPI knownfolder_GetFolderType(
5813 IKnownFolder *iface,
5814 FOLDERTYPEID *pftid)
5816 FIXME("%p\n", pftid);
5817 return E_NOTIMPL;
5820 static HRESULT WINAPI knownfolder_GetRedirectionCapabilities(
5821 IKnownFolder *iface,
5822 KF_REDIRECTION_CAPABILITIES *pCapabilities)
5824 FIXME("%p stub\n", pCapabilities);
5825 if(!pCapabilities) return E_INVALIDARG;
5826 *pCapabilities = KF_REDIRECTION_CAPABILITIES_DENY_ALL;
5827 return S_OK;
5830 static HRESULT WINAPI knownfolder_GetFolderDefinition(
5831 IKnownFolder *iface,
5832 KNOWNFOLDER_DEFINITION *pKFD)
5834 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5835 HRESULT hr;
5836 DWORD dwSize;
5837 WCHAR parentGuid[39];
5838 TRACE("(%p, %p)\n", knownfolder, pKFD);
5840 if(!pKFD) return E_INVALIDARG;
5842 ZeroMemory(pKFD, sizeof(*pKFD));
5844 /* required fields */
5845 hr = get_known_folder_dword(knownfolder->registryPath, szCategory, &pKFD->category);
5846 if(FAILED(hr))
5847 return hr;
5849 hr = get_known_folder_wstr(knownfolder->registryPath, szName, &pKFD->pszName);
5850 if(FAILED(hr))
5851 return hr;
5853 /* optional fields */
5854 dwSize = sizeof(parentGuid);
5855 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, knownfolder->registryPath, szParentFolder,
5856 RRF_RT_REG_SZ, NULL, parentGuid, &dwSize));
5857 if(SUCCEEDED(hr))
5859 hr = IIDFromString(parentGuid, &pKFD->fidParent);
5860 if(FAILED(hr))
5861 return hr;
5864 get_known_folder_dword(knownfolder->registryPath, szAttributes, &pKFD->dwAttributes);
5866 get_known_folder_wstr(knownfolder->registryPath, szRelativePath, &pKFD->pszRelativePath);
5868 get_known_folder_wstr(knownfolder->registryPath, szParsingName, &pKFD->pszParsingName);
5870 return S_OK;
5873 static const struct IKnownFolderVtbl knownfolder_vtbl =
5875 knownfolder_QueryInterface,
5876 knownfolder_AddRef,
5877 knownfolder_Release,
5878 knownfolder_GetId,
5879 knownfolder_GetCategory,
5880 knownfolder_GetShellItem,
5881 knownfolder_GetPath,
5882 knownfolder_SetPath,
5883 knownfolder_GetIDList,
5884 knownfolder_GetFolderType,
5885 knownfolder_GetRedirectionCapabilities,
5886 knownfolder_GetFolderDefinition
5889 static HRESULT knownfolder_create( struct knownfolder **knownfolder )
5891 struct knownfolder *kf;
5893 kf = heap_alloc( sizeof(*kf) );
5894 if (!kf) return E_OUTOFMEMORY;
5896 kf->IKnownFolder_iface.lpVtbl = &knownfolder_vtbl;
5897 kf->refs = 1;
5898 memset( &kf->id, 0, sizeof(kf->id) );
5899 kf->registryPath = NULL;
5901 *knownfolder = kf;
5903 TRACE("returning iface %p\n", &kf->IKnownFolder_iface);
5904 return S_OK;
5907 struct foldermanager
5909 IKnownFolderManager IKnownFolderManager_iface;
5910 LONG refs;
5911 UINT num_ids;
5912 KNOWNFOLDERID *ids;
5915 static inline struct foldermanager *impl_from_IKnownFolderManager( IKnownFolderManager *iface )
5917 return CONTAINING_RECORD( iface, struct foldermanager, IKnownFolderManager_iface );
5920 static ULONG WINAPI foldermanager_AddRef(
5921 IKnownFolderManager *iface )
5923 struct foldermanager *foldermanager = impl_from_IKnownFolderManager( iface );
5924 return InterlockedIncrement( &foldermanager->refs );
5927 static ULONG WINAPI foldermanager_Release(
5928 IKnownFolderManager *iface )
5930 struct foldermanager *foldermanager = impl_from_IKnownFolderManager( iface );
5931 LONG refs = InterlockedDecrement( &foldermanager->refs );
5932 if (!refs)
5934 TRACE("destroying %p\n", foldermanager);
5935 heap_free( foldermanager->ids );
5936 heap_free( foldermanager );
5938 return refs;
5941 static HRESULT WINAPI foldermanager_QueryInterface(
5942 IKnownFolderManager *iface,
5943 REFIID riid,
5944 void **ppv )
5946 struct foldermanager *This = impl_from_IKnownFolderManager( iface );
5948 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
5950 *ppv = NULL;
5951 if ( IsEqualGUID( riid, &IID_IKnownFolderManager ) ||
5952 IsEqualGUID( riid, &IID_IUnknown ) )
5954 *ppv = iface;
5956 else if ( IsEqualGUID( riid, &IID_IMarshal ) )
5958 TRACE("IID_IMarshal returning NULL.\n");
5959 return E_NOINTERFACE;
5961 else
5963 FIXME("interface %s not implemented\n", debugstr_guid(riid));
5964 return E_NOINTERFACE;
5966 IKnownFolderManager_AddRef( iface );
5967 return S_OK;
5970 static HRESULT WINAPI foldermanager_FolderIdFromCsidl(
5971 IKnownFolderManager *iface,
5972 int nCsidl,
5973 KNOWNFOLDERID *pfid)
5975 TRACE("%d, %p\n", nCsidl, pfid);
5977 if (nCsidl >= ARRAY_SIZE(CSIDL_Data))
5978 return E_INVALIDARG;
5979 *pfid = *CSIDL_Data[nCsidl].id;
5980 return S_OK;
5983 static HRESULT WINAPI foldermanager_FolderIdToCsidl(
5984 IKnownFolderManager *iface,
5985 REFKNOWNFOLDERID rfid,
5986 int *pnCsidl)
5988 int csidl;
5990 TRACE("%s, %p\n", debugstr_guid(rfid), pnCsidl);
5992 csidl = csidl_from_id( rfid );
5993 if (csidl == -1) return E_INVALIDARG;
5994 *pnCsidl = csidl;
5995 return S_OK;
5998 static HRESULT WINAPI foldermanager_GetFolderIds(
5999 IKnownFolderManager *iface,
6000 KNOWNFOLDERID **ppKFId,
6001 UINT *pCount)
6003 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
6005 TRACE("%p, %p\n", ppKFId, pCount);
6007 *ppKFId = CoTaskMemAlloc(fm->num_ids * sizeof(KNOWNFOLDERID));
6008 memcpy(*ppKFId, fm->ids, fm->num_ids * sizeof(KNOWNFOLDERID));
6009 *pCount = fm->num_ids;
6010 return S_OK;
6013 static BOOL is_knownfolder( struct foldermanager *fm, const KNOWNFOLDERID *id )
6015 UINT i;
6016 HRESULT hr;
6017 LPWSTR registryPath = NULL;
6018 HKEY hKey;
6020 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
6021 for (i = 0; i < fm->num_ids; i++)
6022 if (IsEqualGUID( &fm->ids[i], id )) return TRUE;
6024 hr = get_known_folder_registry_path(id, NULL, &registryPath);
6025 if(SUCCEEDED(hr))
6027 hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryPath, 0, 0, &hKey));
6028 heap_free(registryPath);
6031 if(SUCCEEDED(hr))
6033 hr = S_OK;
6034 RegCloseKey(hKey);
6037 return hr == S_OK;
6040 static HRESULT WINAPI foldermanager_GetFolder(
6041 IKnownFolderManager *iface,
6042 REFKNOWNFOLDERID rfid,
6043 IKnownFolder **ppkf)
6045 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
6046 struct knownfolder *kf;
6047 HRESULT hr;
6049 TRACE("%s, %p\n", debugstr_guid(rfid), ppkf);
6051 if (!is_knownfolder( fm, rfid ))
6053 WARN("unknown folder\n");
6054 return E_INVALIDARG;
6056 hr = knownfolder_create( &kf );
6057 if (SUCCEEDED( hr ))
6059 hr = knownfolder_set_id( kf, rfid );
6060 *ppkf = &kf->IKnownFolder_iface;
6062 else
6063 *ppkf = NULL;
6065 return hr;
6068 static HRESULT WINAPI foldermanager_GetFolderByName(
6069 IKnownFolderManager *iface,
6070 LPCWSTR pszCanonicalName,
6071 IKnownFolder **ppkf)
6073 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
6074 struct knownfolder *kf;
6075 BOOL found = FALSE;
6076 HRESULT hr;
6077 UINT i;
6079 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName), ppkf );
6081 for (i = 0; i < fm->num_ids; i++)
6083 WCHAR *path, *name;
6084 hr = get_known_folder_registry_path( &fm->ids[i], NULL, &path );
6085 if (FAILED( hr )) return hr;
6087 hr = get_known_folder_wstr( path, szName, &name );
6088 heap_free( path );
6089 if (FAILED( hr )) return hr;
6091 found = !strcmpiW( pszCanonicalName, name );
6092 CoTaskMemFree( name );
6093 if (found) break;
6096 if (found)
6098 hr = knownfolder_create( &kf );
6099 if (FAILED( hr )) return hr;
6101 hr = knownfolder_set_id( kf, &fm->ids[i] );
6102 if (FAILED( hr ))
6104 IKnownFolder_Release( &kf->IKnownFolder_iface );
6105 return hr;
6107 *ppkf = &kf->IKnownFolder_iface;
6109 else
6111 hr = HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
6112 *ppkf = NULL;
6115 return hr;
6118 static HRESULT register_folder(const KNOWNFOLDERID *rfid, const KNOWNFOLDER_DEFINITION *pKFD)
6120 HRESULT hr;
6121 HKEY hKey = NULL;
6122 DWORD dwDisp;
6123 LPWSTR registryPath = NULL;
6125 hr = get_known_folder_registry_path(rfid, NULL, &registryPath);
6126 TRACE("registry path: %s\n", debugstr_w(registryPath));
6128 if(SUCCEEDED(hr))
6129 hr = HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE, registryPath, 0, NULL, 0, KEY_WRITE, 0, &hKey, &dwDisp));
6131 if(SUCCEEDED(hr))
6133 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szCategory, 0, REG_DWORD, (LPBYTE)&pKFD->category, sizeof(pKFD->category)));
6135 if(SUCCEEDED(hr) && pKFD->dwAttributes != 0)
6136 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szAttributes, 0, REG_DWORD, (LPBYTE)&pKFD->dwAttributes, sizeof(pKFD->dwAttributes)));
6138 if(SUCCEEDED(hr))
6139 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szName, 0, REG_SZ, (LPBYTE)pKFD->pszName, (lstrlenW(pKFD->pszName)+1)*sizeof(WCHAR) ));
6141 if(SUCCEEDED(hr) && pKFD->pszParsingName)
6142 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szParsingName, 0, REG_SZ, (LPBYTE)pKFD->pszParsingName, (lstrlenW(pKFD->pszParsingName)+1)*sizeof(WCHAR) ));
6144 if(SUCCEEDED(hr) && !IsEqualGUID(&pKFD->fidParent, &GUID_NULL))
6146 WCHAR sParentGuid[39];
6147 StringFromGUID2(&pKFD->fidParent, sParentGuid, ARRAY_SIZE(sParentGuid));
6149 /* this known folder has parent folder */
6150 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szParentFolder, 0, REG_SZ, (LPBYTE)sParentGuid, sizeof(sParentGuid)));
6153 if(SUCCEEDED(hr) && pKFD->category != KF_CATEGORY_VIRTUAL && pKFD->pszRelativePath)
6154 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szRelativePath, 0, REG_SZ, (LPBYTE)pKFD->pszRelativePath, (lstrlenW(pKFD->pszRelativePath)+1)*sizeof(WCHAR) ));
6156 RegCloseKey(hKey);
6158 if(FAILED(hr))
6159 SHDeleteKeyW(HKEY_LOCAL_MACHINE, registryPath);
6162 heap_free(registryPath);
6163 return hr;
6166 static HRESULT WINAPI foldermanager_RegisterFolder(
6167 IKnownFolderManager *iface,
6168 REFKNOWNFOLDERID rfid,
6169 KNOWNFOLDER_DEFINITION const *pKFD)
6171 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(rfid), pKFD);
6172 return register_folder(rfid, pKFD);
6175 static HRESULT WINAPI foldermanager_UnregisterFolder(
6176 IKnownFolderManager *iface,
6177 REFKNOWNFOLDERID rfid)
6179 HRESULT hr;
6180 LPWSTR registryPath = NULL;
6181 TRACE("(%p, %s)\n", iface, debugstr_guid(rfid));
6183 hr = get_known_folder_registry_path(rfid, NULL, &registryPath);
6185 if(SUCCEEDED(hr))
6186 hr = HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE, registryPath));
6188 heap_free(registryPath);
6189 return hr;
6192 static HRESULT WINAPI foldermanager_FindFolderFromPath(
6193 IKnownFolderManager *iface,
6194 LPCWSTR pszPath,
6195 FFFP_MODE mode,
6196 IKnownFolder **ppkf)
6198 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath), mode, ppkf);
6199 return E_NOTIMPL;
6202 static HRESULT WINAPI foldermanager_FindFolderFromIDList(
6203 IKnownFolderManager *iface,
6204 PCIDLIST_ABSOLUTE pidl,
6205 IKnownFolder **ppkf)
6207 FIXME("%p, %p\n", pidl, ppkf);
6208 return E_NOTIMPL;
6211 static HRESULT WINAPI foldermanager_Redirect(
6212 IKnownFolderManager *iface,
6213 REFKNOWNFOLDERID rfid,
6214 HWND hwnd,
6215 KF_REDIRECT_FLAGS flags,
6216 LPCWSTR pszTargetPath,
6217 UINT cFolders,
6218 KNOWNFOLDERID const *pExclusion,
6219 LPWSTR *ppszError)
6221 return redirect_known_folder(rfid, hwnd, flags, pszTargetPath, cFolders, pExclusion, ppszError);
6224 static const struct IKnownFolderManagerVtbl foldermanager_vtbl =
6226 foldermanager_QueryInterface,
6227 foldermanager_AddRef,
6228 foldermanager_Release,
6229 foldermanager_FolderIdFromCsidl,
6230 foldermanager_FolderIdToCsidl,
6231 foldermanager_GetFolderIds,
6232 foldermanager_GetFolder,
6233 foldermanager_GetFolderByName,
6234 foldermanager_RegisterFolder,
6235 foldermanager_UnregisterFolder,
6236 foldermanager_FindFolderFromPath,
6237 foldermanager_FindFolderFromIDList,
6238 foldermanager_Redirect
6241 static HRESULT foldermanager_create( void **ppv )
6243 UINT i, j;
6244 struct foldermanager *fm;
6246 fm = heap_alloc( sizeof(*fm) );
6247 if (!fm) return E_OUTOFMEMORY;
6249 fm->IKnownFolderManager_iface.lpVtbl = &foldermanager_vtbl;
6250 fm->refs = 1;
6251 fm->num_ids = 0;
6253 for (i = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
6255 if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL )) fm->num_ids++;
6257 fm->ids = heap_alloc( fm->num_ids * sizeof(KNOWNFOLDERID) );
6258 if (!fm->ids)
6260 heap_free( fm );
6261 return E_OUTOFMEMORY;
6263 for (i = j = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
6265 if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL ))
6267 fm->ids[j] = *CSIDL_Data[i].id;
6268 j++;
6271 TRACE("found %u known folders\n", fm->num_ids);
6272 *ppv = &fm->IKnownFolderManager_iface;
6274 TRACE("returning iface %p\n", *ppv);
6275 return S_OK;
6278 HRESULT WINAPI KnownFolderManager_Constructor( IUnknown *punk, REFIID riid, void **ppv )
6280 TRACE("%p, %s, %p\n", punk, debugstr_guid(riid), ppv);
6282 if (!ppv)
6283 return E_POINTER;
6284 if (punk)
6285 return CLASS_E_NOAGGREGATION;
6287 return foldermanager_create( ppv );
6290 HRESULT WINAPI SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, PIDLIST_ABSOLUTE *pidl)
6292 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid), flags, token, pidl);
6294 if (!pidl)
6295 return E_INVALIDARG;
6297 if (flags)
6298 FIXME("unsupported flags: 0x%08x\n", flags);
6300 if (token)
6301 FIXME("user token is not used.\n");
6303 *pidl = NULL;
6304 if (IsEqualIID(rfid, &FOLDERID_Desktop))
6305 *pidl = _ILCreateDesktop();
6306 else if (IsEqualIID(rfid, &FOLDERID_RecycleBinFolder))
6307 *pidl = _ILCreateBitBucket();
6308 else if (IsEqualIID(rfid, &FOLDERID_ComputerFolder))
6309 *pidl = _ILCreateMyComputer();
6310 else if (IsEqualIID(rfid, &FOLDERID_PrintersFolder))
6311 *pidl = _ILCreatePrinters();
6312 else if (IsEqualIID(rfid, &FOLDERID_ControlPanelFolder))
6313 *pidl = _ILCreateControlPanel();
6314 else if (IsEqualIID(rfid, &FOLDERID_NetworkFolder))
6315 *pidl = _ILCreateNetwork();
6316 else if (IsEqualIID(rfid, &FOLDERID_Documents))
6317 *pidl = _ILCreateMyDocuments();
6318 else
6320 DWORD attributes = 0;
6321 WCHAR *pathW;
6322 HRESULT hr;
6324 hr = SHGetKnownFolderPath(rfid, flags, token, &pathW);
6325 if (FAILED(hr))
6326 return hr;
6328 hr = SHILCreateFromPathW(pathW, pidl, &attributes);
6329 CoTaskMemFree(pathW);
6330 return hr;
6333 return *pidl ? S_OK : E_FAIL;
6336 HRESULT WINAPI SHGetKnownFolderItem(REFKNOWNFOLDERID rfid, KNOWN_FOLDER_FLAG flags, HANDLE hToken,
6337 REFIID riid, void **ppv)
6339 PIDLIST_ABSOLUTE pidl;
6340 HRESULT hr;
6342 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid), flags, hToken, debugstr_guid(riid), ppv);
6344 hr = SHGetKnownFolderIDList(rfid, flags, hToken, &pidl);
6345 if (FAILED(hr))
6347 *ppv = NULL;
6348 return hr;
6351 hr = SHCreateItemFromIDList(pidl, riid, ppv);
6352 CoTaskMemFree(pidl);
6353 return hr;
6356 static void register_system_knownfolders(void)
6358 int i;
6360 for (i = 0; i < ARRAY_SIZE(CSIDL_Data); ++i)
6362 const CSIDL_DATA *folder = &CSIDL_Data[i];
6363 if(folder->pszName){
6364 KNOWNFOLDER_DEFINITION kfd;
6366 /* register_folder won't modify kfd, so cast away const instead of
6367 * reallocating */
6368 kfd.category = folder->category;
6369 kfd.pszName = (WCHAR*)folder->pszName;
6370 kfd.pszDescription = (WCHAR*)folder->pszDescription;
6371 memcpy(&kfd.fidParent, folder->fidParent, sizeof(KNOWNFOLDERID));
6372 kfd.pszRelativePath = (WCHAR*)folder->pszRelativePath;
6373 kfd.pszParsingName = (WCHAR*)folder->pszParsingName;
6374 kfd.pszTooltip = (WCHAR*)folder->pszTooltip;
6375 kfd.pszLocalizedName = (WCHAR*)folder->pszLocalizedName;
6376 kfd.pszIcon = (WCHAR*)folder->pszIcon;
6377 kfd.pszSecurity = (WCHAR*)folder->pszSecurity;
6378 kfd.dwAttributes = folder->dwAttributes;
6379 kfd.kfdFlags = folder->kfdFlags;
6380 memcpy(&kfd.ftidType, folder->ftidType, sizeof(FOLDERTYPEID));
6382 register_folder(folder->id, &kfd);
6387 HRESULT SHELL_RegisterShellFolders(void)
6389 HRESULT hr;
6391 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6392 * 'My Videos', 'My Music', 'Desktop' etc. in advance, so that the
6393 * _SHRegister*ShellFolders() functions will find everything nice and clean
6394 * and thus will not attempt to create them in the profile directory. */
6395 _SHCreateSymbolicLinks();
6397 hr = _SHRegisterUserShellFolders(TRUE);
6398 if (SUCCEEDED(hr))
6399 hr = _SHRegisterUserShellFolders(FALSE);
6400 if (SUCCEEDED(hr))
6401 hr = _SHRegisterCommonShellFolders();
6402 if (SUCCEEDED(hr))
6403 hr = create_extra_folders();
6404 if (SUCCEEDED(hr))
6405 hr = set_folder_attributes();
6406 if (SUCCEEDED(hr))
6407 register_system_knownfolders();
6408 return hr;