mshtml: Rename fire_event_obj and dispatch_event.
[wine.git] / dlls / shell32 / shellpath.c
blobc5ba6295cda6040ea1974a8d9957ca08c7c0ca78
1 /*
2 * Path Functions
4 * Copyright 1998, 1999, 2000 Juergen Schmied
5 * Copyright 2004 Juan Lang
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * NOTES:
23 * Many of these functions are in SHLWAPI.DLL also
27 #define COBJMACROS
29 #include "config.h"
30 #include "wine/port.h"
32 #include <stdio.h>
33 #include <stdarg.h>
34 #include <string.h>
35 #include <ctype.h>
36 #include "wine/debug.h"
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winnls.h"
40 #include "winreg.h"
41 #include "wingdi.h"
42 #include "winuser.h"
44 #include "shlobj.h"
45 #include "shtypes.h"
46 #include "shresdef.h"
47 #include "shell32_main.h"
48 #include "undocshell.h"
49 #include "pidl.h"
50 #include "wine/unicode.h"
51 #include "shlwapi.h"
52 #include "xdg.h"
53 #include "sddl.h"
54 #include "knownfolders.h"
55 #include "initguid.h"
56 #include "shobjidl.h"
58 WINE_DEFAULT_DEBUG_CHANNEL(shell);
60 static const BOOL is_win64 = sizeof(void *) > sizeof(int);
63 ########## Combining and Constructing paths ##########
66 /*************************************************************************
67 * PathAppend [SHELL32.36]
69 BOOL WINAPI PathAppendAW(
70 LPVOID lpszPath1,
71 LPCVOID lpszPath2)
73 if (SHELL_OsIsUnicode())
74 return PathAppendW(lpszPath1, lpszPath2);
75 return PathAppendA(lpszPath1, lpszPath2);
78 /*************************************************************************
79 * PathCombine [SHELL32.37]
81 LPVOID WINAPI PathCombineAW(
82 LPVOID szDest,
83 LPCVOID lpszDir,
84 LPCVOID lpszFile)
86 if (SHELL_OsIsUnicode())
87 return PathCombineW( szDest, lpszDir, lpszFile );
88 return PathCombineA( szDest, lpszDir, lpszFile );
91 /*************************************************************************
92 * PathAddBackslash [SHELL32.32]
94 LPVOID WINAPI PathAddBackslashAW(LPVOID lpszPath)
96 if(SHELL_OsIsUnicode())
97 return PathAddBackslashW(lpszPath);
98 return PathAddBackslashA(lpszPath);
101 /*************************************************************************
102 * PathBuildRoot [SHELL32.30]
104 LPVOID WINAPI PathBuildRootAW(LPVOID lpszPath, int drive)
106 if(SHELL_OsIsUnicode())
107 return PathBuildRootW(lpszPath, drive);
108 return PathBuildRootA(lpszPath, drive);
112 Extracting Component Parts
115 /*************************************************************************
116 * PathFindFileName [SHELL32.34]
118 LPVOID WINAPI PathFindFileNameAW(LPCVOID lpszPath)
120 if(SHELL_OsIsUnicode())
121 return PathFindFileNameW(lpszPath);
122 return PathFindFileNameA(lpszPath);
125 /*************************************************************************
126 * PathFindExtension [SHELL32.31]
128 LPVOID WINAPI PathFindExtensionAW(LPCVOID lpszPath)
130 if (SHELL_OsIsUnicode())
131 return PathFindExtensionW(lpszPath);
132 return PathFindExtensionA(lpszPath);
136 /*************************************************************************
137 * PathGetExtensionA [internal]
139 * NOTES
140 * exported by ordinal
141 * return value points to the first char after the dot
143 static LPSTR PathGetExtensionA(LPCSTR lpszPath)
145 TRACE("(%s)\n",lpszPath);
147 lpszPath = PathFindExtensionA(lpszPath);
148 return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath);
151 /*************************************************************************
152 * PathGetExtensionW [internal]
154 static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
156 TRACE("(%s)\n",debugstr_w(lpszPath));
158 lpszPath = PathFindExtensionW(lpszPath);
159 return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath);
162 /*************************************************************************
163 * PathGetExtension [SHELL32.158]
165 LPVOID WINAPI PathGetExtensionAW(LPCVOID lpszPath,DWORD void1, DWORD void2)
167 if (SHELL_OsIsUnicode())
168 return PathGetExtensionW(lpszPath);
169 return PathGetExtensionA(lpszPath);
172 /*************************************************************************
173 * PathGetArgs [SHELL32.52]
175 LPVOID WINAPI PathGetArgsAW(LPVOID lpszPath)
177 if (SHELL_OsIsUnicode())
178 return PathGetArgsW(lpszPath);
179 return PathGetArgsA(lpszPath);
182 /*************************************************************************
183 * PathGetDriveNumber [SHELL32.57]
185 int WINAPI PathGetDriveNumberAW(LPVOID lpszPath)
187 if (SHELL_OsIsUnicode())
188 return PathGetDriveNumberW(lpszPath);
189 return PathGetDriveNumberA(lpszPath);
192 /*************************************************************************
193 * PathRemoveFileSpec [SHELL32.35]
195 BOOL WINAPI PathRemoveFileSpecAW(LPVOID lpszPath)
197 if (SHELL_OsIsUnicode())
198 return PathRemoveFileSpecW(lpszPath);
199 return PathRemoveFileSpecA(lpszPath);
202 /*************************************************************************
203 * PathStripPath [SHELL32.38]
205 void WINAPI PathStripPathAW(LPVOID lpszPath)
207 if (SHELL_OsIsUnicode())
208 PathStripPathW(lpszPath);
209 else
210 PathStripPathA(lpszPath);
213 /*************************************************************************
214 * PathStripToRoot [SHELL32.50]
216 BOOL WINAPI PathStripToRootAW(LPVOID lpszPath)
218 if (SHELL_OsIsUnicode())
219 return PathStripToRootW(lpszPath);
220 return PathStripToRootA(lpszPath);
223 /*************************************************************************
224 * PathRemoveArgs [SHELL32.251]
226 void WINAPI PathRemoveArgsAW(LPVOID lpszPath)
228 if (SHELL_OsIsUnicode())
229 PathRemoveArgsW(lpszPath);
230 else
231 PathRemoveArgsA(lpszPath);
234 /*************************************************************************
235 * PathRemoveExtension [SHELL32.250]
237 void WINAPI PathRemoveExtensionAW(LPVOID lpszPath)
239 if (SHELL_OsIsUnicode())
240 PathRemoveExtensionW(lpszPath);
241 else
242 PathRemoveExtensionA(lpszPath);
247 Path Manipulations
250 /*************************************************************************
251 * PathGetShortPathA [internal]
253 static void PathGetShortPathA(LPSTR pszPath)
255 CHAR path[MAX_PATH];
257 TRACE("%s\n", pszPath);
259 if (GetShortPathNameA(pszPath, path, MAX_PATH))
261 lstrcpyA(pszPath, path);
265 /*************************************************************************
266 * PathGetShortPathW [internal]
268 static void PathGetShortPathW(LPWSTR pszPath)
270 WCHAR path[MAX_PATH];
272 TRACE("%s\n", debugstr_w(pszPath));
274 if (GetShortPathNameW(pszPath, path, MAX_PATH))
276 lstrcpyW(pszPath, path);
280 /*************************************************************************
281 * PathGetShortPath [SHELL32.92]
283 VOID WINAPI PathGetShortPathAW(LPVOID pszPath)
285 if(SHELL_OsIsUnicode())
286 PathGetShortPathW(pszPath);
287 PathGetShortPathA(pszPath);
290 /*************************************************************************
291 * PathRemoveBlanks [SHELL32.33]
293 void WINAPI PathRemoveBlanksAW(LPVOID str)
295 if(SHELL_OsIsUnicode())
296 PathRemoveBlanksW(str);
297 else
298 PathRemoveBlanksA(str);
301 /*************************************************************************
302 * PathQuoteSpaces [SHELL32.55]
304 VOID WINAPI PathQuoteSpacesAW (LPVOID lpszPath)
306 if(SHELL_OsIsUnicode())
307 PathQuoteSpacesW(lpszPath);
308 else
309 PathQuoteSpacesA(lpszPath);
312 /*************************************************************************
313 * PathUnquoteSpaces [SHELL32.56]
315 VOID WINAPI PathUnquoteSpacesAW(LPVOID str)
317 if(SHELL_OsIsUnicode())
318 PathUnquoteSpacesW(str);
319 else
320 PathUnquoteSpacesA(str);
323 /*************************************************************************
324 * PathParseIconLocation [SHELL32.249]
326 int WINAPI PathParseIconLocationAW (LPVOID lpszPath)
328 if(SHELL_OsIsUnicode())
329 return PathParseIconLocationW(lpszPath);
330 return PathParseIconLocationA(lpszPath);
334 ########## Path Testing ##########
336 /*************************************************************************
337 * PathIsUNC [SHELL32.39]
339 BOOL WINAPI PathIsUNCAW (LPCVOID lpszPath)
341 if (SHELL_OsIsUnicode())
342 return PathIsUNCW( lpszPath );
343 return PathIsUNCA( lpszPath );
346 /*************************************************************************
347 * PathIsRelative [SHELL32.40]
349 BOOL WINAPI PathIsRelativeAW (LPCVOID lpszPath)
351 if (SHELL_OsIsUnicode())
352 return PathIsRelativeW( lpszPath );
353 return PathIsRelativeA( lpszPath );
356 /*************************************************************************
357 * PathIsRoot [SHELL32.29]
359 BOOL WINAPI PathIsRootAW(LPCVOID lpszPath)
361 if (SHELL_OsIsUnicode())
362 return PathIsRootW(lpszPath);
363 return PathIsRootA(lpszPath);
366 /*************************************************************************
367 * PathIsExeA [internal]
369 static BOOL PathIsExeA (LPCSTR lpszPath)
371 LPCSTR lpszExtension = PathGetExtensionA(lpszPath);
372 int i;
373 static const char * const lpszExtensions[] =
374 {"exe", "com", "pif", "cmd", "bat", "scf", "scr", NULL };
376 TRACE("path=%s\n",lpszPath);
378 for(i=0; lpszExtensions[i]; i++)
379 if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE;
381 return FALSE;
384 /*************************************************************************
385 * PathIsExeW [internal]
387 static BOOL PathIsExeW (LPCWSTR lpszPath)
389 LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
390 int i;
391 static const WCHAR lpszExtensions[][4] =
392 {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','f','\0'},
393 {'c','m','d','\0'}, {'b','a','t','\0'}, {'s','c','f','\0'},
394 {'s','c','r','\0'}, {'\0'} };
396 TRACE("path=%s\n",debugstr_w(lpszPath));
398 for(i=0; lpszExtensions[i][0]; i++)
399 if (!strcmpiW(lpszExtension,lpszExtensions[i])) return TRUE;
401 return FALSE;
404 /*************************************************************************
405 * PathIsExe [SHELL32.43]
407 BOOL WINAPI PathIsExeAW (LPCVOID path)
409 if (SHELL_OsIsUnicode())
410 return PathIsExeW (path);
411 return PathIsExeA(path);
414 /*************************************************************************
415 * PathIsDirectory [SHELL32.159]
417 BOOL WINAPI PathIsDirectoryAW (LPCVOID lpszPath)
419 if (SHELL_OsIsUnicode())
420 return PathIsDirectoryW (lpszPath);
421 return PathIsDirectoryA (lpszPath);
424 /*************************************************************************
425 * PathFileExists [SHELL32.45]
427 BOOL WINAPI PathFileExistsAW (LPCVOID lpszPath)
429 if (SHELL_OsIsUnicode())
430 return PathFileExistsW (lpszPath);
431 return PathFileExistsA (lpszPath);
434 /*************************************************************************
435 * PathMatchSpec [SHELL32.46]
437 BOOL WINAPI PathMatchSpecAW(LPVOID name, LPVOID mask)
439 if (SHELL_OsIsUnicode())
440 return PathMatchSpecW( name, mask );
441 return PathMatchSpecA( name, mask );
444 /*************************************************************************
445 * PathIsSameRoot [SHELL32.650]
447 BOOL WINAPI PathIsSameRootAW(LPCVOID lpszPath1, LPCVOID lpszPath2)
449 if (SHELL_OsIsUnicode())
450 return PathIsSameRootW(lpszPath1, lpszPath2);
451 return PathIsSameRootA(lpszPath1, lpszPath2);
454 /*************************************************************************
455 * IsLFNDriveA [SHELL32.41]
457 BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath)
459 DWORD fnlen;
461 if (!GetVolumeInformationA(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
462 return FALSE;
463 return fnlen > 12;
466 /*************************************************************************
467 * IsLFNDriveW [SHELL32.42]
469 BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
471 DWORD fnlen;
473 if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
474 return FALSE;
475 return fnlen > 12;
478 /*************************************************************************
479 * IsLFNDrive [SHELL32.119]
481 BOOL WINAPI IsLFNDriveAW(LPCVOID lpszPath)
483 if (SHELL_OsIsUnicode())
484 return IsLFNDriveW(lpszPath);
485 return IsLFNDriveA(lpszPath);
489 ########## Creating Something Unique ##########
491 /*************************************************************************
492 * PathMakeUniqueNameA [internal]
494 static BOOL PathMakeUniqueNameA(
495 LPSTR lpszBuffer,
496 DWORD dwBuffSize,
497 LPCSTR lpszShortName,
498 LPCSTR lpszLongName,
499 LPCSTR lpszPathName)
501 FIXME("%p %u %s %s %s stub\n",
502 lpszBuffer, dwBuffSize, debugstr_a(lpszShortName),
503 debugstr_a(lpszLongName), debugstr_a(lpszPathName));
504 return TRUE;
507 /*************************************************************************
508 * PathMakeUniqueNameW [internal]
510 static BOOL PathMakeUniqueNameW(
511 LPWSTR lpszBuffer,
512 DWORD dwBuffSize,
513 LPCWSTR lpszShortName,
514 LPCWSTR lpszLongName,
515 LPCWSTR lpszPathName)
517 FIXME("%p %u %s %s %s stub\n",
518 lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
519 debugstr_w(lpszLongName), debugstr_w(lpszPathName));
520 return TRUE;
523 /*************************************************************************
524 * PathMakeUniqueName [SHELL32.47]
526 BOOL WINAPI PathMakeUniqueNameAW(
527 LPVOID lpszBuffer,
528 DWORD dwBuffSize,
529 LPCVOID lpszShortName,
530 LPCVOID lpszLongName,
531 LPCVOID lpszPathName)
533 if (SHELL_OsIsUnicode())
534 return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
535 return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
538 /*************************************************************************
539 * PathYetAnotherMakeUniqueName [SHELL32.75]
541 BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
543 WCHAR pathW[MAX_PATH], retW[MAX_PATH];
544 const WCHAR *file, *ext;
545 int i = 2;
547 TRACE("(%p, %s, %s, %s)\n", buffer, debugstr_w(path), debugstr_w(shortname), debugstr_w(longname));
549 file = longname ? longname : shortname;
550 PathCombineW(pathW, path, file);
551 strcpyW(retW, pathW);
552 PathRemoveExtensionW(pathW);
554 ext = PathFindExtensionW(file);
556 /* now try to make it unique */
557 while (PathFileExistsW(retW))
559 static const WCHAR fmtW[] = {'%','s',' ','(','%','d',')','%','s',0};
561 sprintfW(retW, fmtW, pathW, i, ext);
562 i++;
565 strcpyW(buffer, retW);
566 TRACE("ret - %s\n", debugstr_w(buffer));
568 return TRUE;
572 ########## cleaning and resolving paths ##########
575 /*************************************************************************
576 * PathFindOnPath [SHELL32.145]
578 BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID *sOtherDirs)
580 if (SHELL_OsIsUnicode())
581 return PathFindOnPathW(sFile, (LPCWSTR *)sOtherDirs);
582 return PathFindOnPathA(sFile, (LPCSTR *)sOtherDirs);
585 /*************************************************************************
586 * PathCleanupSpec [SHELL32.171]
588 * lpszFile is changed in place.
590 int WINAPI PathCleanupSpec( LPCWSTR lpszPathW, LPWSTR lpszFileW )
592 int i = 0;
593 DWORD rc = 0;
594 int length = 0;
596 if (SHELL_OsIsUnicode())
598 LPWSTR p = lpszFileW;
600 TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
602 if (lpszPathW)
603 length = strlenW(lpszPathW);
605 while (*p)
607 int gct = PathGetCharTypeW(*p);
608 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
610 lpszFileW[i]='-';
611 rc |= PCS_REPLACEDCHAR;
613 else
614 lpszFileW[i]=*p;
615 i++;
616 p++;
617 if (length + i == MAX_PATH)
619 rc |= PCS_FATAL | PCS_PATHTOOLONG;
620 break;
623 lpszFileW[i]=0;
625 else
627 LPSTR lpszFileA = (LPSTR)lpszFileW;
628 LPCSTR lpszPathA = (LPCSTR)lpszPathW;
629 LPSTR p = lpszFileA;
631 TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
633 if (lpszPathA)
634 length = strlen(lpszPathA);
636 while (*p)
638 int gct = PathGetCharTypeA(*p);
639 if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
641 lpszFileA[i]='-';
642 rc |= PCS_REPLACEDCHAR;
644 else
645 lpszFileA[i]=*p;
646 i++;
647 p++;
648 if (length + i == MAX_PATH)
650 rc |= PCS_FATAL | PCS_PATHTOOLONG;
651 break;
654 lpszFileA[i]=0;
656 return rc;
659 /*************************************************************************
660 * PathQualifyA [SHELL32]
662 static BOOL PathQualifyA(LPCSTR pszPath)
664 FIXME("%s\n",pszPath);
665 return FALSE;
668 /*************************************************************************
669 * PathQualifyW [SHELL32]
671 static BOOL PathQualifyW(LPCWSTR pszPath)
673 FIXME("%s\n",debugstr_w(pszPath));
674 return FALSE;
677 /*************************************************************************
678 * PathQualify [SHELL32.49]
680 BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
682 if (SHELL_OsIsUnicode())
683 return PathQualifyW(pszPath);
684 return PathQualifyA(pszPath);
687 static BOOL PathResolveA(LPSTR path, LPCSTR *paths, DWORD flags)
689 FIXME("(%s,%p,0x%08x),stub!\n", debugstr_a(path), paths, flags);
690 return FALSE;
693 static BOOL PathResolveW(LPWSTR path, LPCWSTR *paths, DWORD flags)
695 FIXME("(%s,%p,0x%08x),stub!\n", debugstr_w(path), paths, flags);
696 return FALSE;
699 /*************************************************************************
700 * PathResolve [SHELL32.51]
702 BOOL WINAPI PathResolveAW(LPVOID path, LPCVOID *paths, DWORD flags)
704 if (SHELL_OsIsUnicode())
705 return PathResolveW(path, (LPCWSTR*)paths, flags);
706 else
707 return PathResolveA(path, (LPCSTR*)paths, flags);
710 /*************************************************************************
711 * PathProcessCommandA
713 static LONG PathProcessCommandA (
714 LPCSTR lpszPath,
715 LPSTR lpszBuff,
716 DWORD dwBuffSize,
717 DWORD dwFlags)
719 FIXME("%s %p 0x%04x 0x%04x stub\n",
720 lpszPath, lpszBuff, dwBuffSize, dwFlags);
721 if(!lpszPath) return -1;
722 if(lpszBuff) strcpy(lpszBuff, lpszPath);
723 return strlen(lpszPath);
726 /*************************************************************************
727 * PathProcessCommandW
729 static LONG PathProcessCommandW (
730 LPCWSTR lpszPath,
731 LPWSTR lpszBuff,
732 DWORD dwBuffSize,
733 DWORD dwFlags)
735 FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
736 debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
737 if(!lpszPath) return -1;
738 if(lpszBuff) strcpyW(lpszBuff, lpszPath);
739 return strlenW(lpszPath);
742 /*************************************************************************
743 * PathProcessCommand (SHELL32.653)
745 LONG WINAPI PathProcessCommandAW (
746 LPCVOID lpszPath,
747 LPVOID lpszBuff,
748 DWORD dwBuffSize,
749 DWORD dwFlags)
751 if (SHELL_OsIsUnicode())
752 return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
753 return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
757 ########## special ##########
760 /*************************************************************************
761 * PathSetDlgItemPath (SHELL32.48)
763 VOID WINAPI PathSetDlgItemPathAW(HWND hDlg, int id, LPCVOID pszPath)
765 if (SHELL_OsIsUnicode())
766 PathSetDlgItemPathW(hDlg, id, pszPath);
767 else
768 PathSetDlgItemPathA(hDlg, id, pszPath);
771 static const WCHAR szCategory[] = {'C','a','t','e','g','o','r','y',0};
772 static const WCHAR szAttributes[] = {'A','t','t','r','i','b','u','t','e','s',0};
773 static const WCHAR szName[] = {'N','a','m','e',0};
774 static const WCHAR szParsingName[] = {'P','a','r','s','i','n','g','N','a','m','e',0};
775 static const WCHAR szRelativePath[] = {'R','e','l','a','t','i','v','e','P','a','t','h',0};
776 static const WCHAR szParentFolder[] = {'P','a','r','e','n','t','F','o','l','d','e','r',0};
778 static const WCHAR szCurrentVersion[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0'};
779 static const WCHAR AddNewProgramsFolderW[] = {'A','d','d','N','e','w','P','r','o','g','r','a','m','s','F','o','l','d','e','r',0};
780 static const WCHAR AppUpdatesFolderW[] = {'A','p','p','U','p','d','a','t','e','s','F','o','l','d','e','r',0};
781 static const WCHAR Administrative_ToolsW[] = {'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
782 static const WCHAR AppDataW[] = {'A','p','p','D','a','t','a','\0'};
783 static const WCHAR AppData_RoamingW[] = {'A','p','p','D','a','t','a','\\','R','o','a','m','i','n','g','\0'};
784 static const WCHAR AppData_LocalLowW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','L','o','w','\0'};
785 static const WCHAR AppData_LocalW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','\0'};
786 static const WCHAR Application_DataW[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
787 static const WCHAR CacheW[] = {'C','a','c','h','e','\0'};
788 static const WCHAR CD_BurningW[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
789 static const WCHAR ChangeRemoveProgramsFolderW[] = {'C','h','a','n','g','e','R','e','m','o','v','e','P','r','o','g','r','a','m','s','F','o','l','d','e','r',0};
790 static const WCHAR CommonW[] = {'C','o','m','m','o','n',0};
791 static const WCHAR Common_Administrative_ToolsW[] = {'C','o','m','m','o','n',' ','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
792 static const WCHAR Common_AppDataW[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'};
793 static const WCHAR Common_DesktopW[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'};
794 static const WCHAR Common_DocumentsW[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'};
795 static const WCHAR CommonDownloadsW[] = {'C','o','m','m','o','n','D','o','w','n','l','o','a','d','s',0};
796 static const WCHAR Common_FavoritesW[] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'};
797 static const WCHAR CommonFilesDirW[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'};
798 static const WCHAR CommonFilesDirX86W[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
799 static const WCHAR CommonMusicW[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'};
800 static const WCHAR CommonPicturesW[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'};
801 static const WCHAR Common_ProgramsW[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'};
802 static const WCHAR CommonRingtonesW[] = {'C','o','m','m','o','n','R','i','n','g','t','o','n','e','s',0};
803 static const WCHAR Common_StartUpW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'};
804 static const WCHAR Common_StartupW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','u','p','\0'};
805 static const WCHAR Common_Start_MenuW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'};
806 static const WCHAR Common_TemplatesW[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'};
807 static const WCHAR CommonVideoW[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
808 static const WCHAR ConflictFolderW[] = {'C','o','n','f','l','i','c','t','F','o','l','d','e','r',0};
809 static const WCHAR ConnectionsFolderW[] = {'C','o','n','n','e','c','t','i','o','n','s','F','o','l','d','e','r',0};
810 static const WCHAR ContactsW[] = {'C','o','n','t','a','c','t','s','\0'};
811 static const WCHAR ControlPanelFolderW[] = {'C','o','n','t','r','o','l','P','a','n','e','l','F','o','l','d','e','r',0};
812 static const WCHAR CookiesW[] = {'C','o','o','k','i','e','s','\0'};
813 static const WCHAR CSCFolderW[] = {'C','S','C','F','o','l','d','e','r',0};
814 static const WCHAR Default_GadgetsW[] = {'D','e','f','a','u','l','t',' ','G','a','d','g','e','t','s',0};
815 static const WCHAR DesktopW[] = {'D','e','s','k','t','o','p','\0'};
816 static const WCHAR Device_Metadata_StoreW[] = {'D','e','v','i','c','e',' ','M','e','t','a','d','a','t','a',' ','S','t','o','r','e',0};
817 static const WCHAR DocumentsW[] = {'D','o','c','u','m','e','n','t','s','\0'};
818 static const WCHAR DocumentsLibraryW[] = {'D','o','c','u','m','e','n','t','s','L','i','b','r','a','r','y','\0'};
819 static const WCHAR Documents_librarymsW[] = {'D','o','c','u','m','e','n','t','s','.','l','i','b','r','a','r','y','-','m','s',0};
820 static const WCHAR DownloadsW[] = {'D','o','w','n','l','o','a','d','s','\0'};
821 static const WCHAR FavoritesW[] = {'F','a','v','o','r','i','t','e','s','\0'};
822 static const WCHAR FontsW[] = {'F','o','n','t','s','\0'};
823 static const WCHAR GadgetsW[] = {'G','a','d','g','e','t','s',0};
824 static const WCHAR GamesW[] = {'G','a','m','e','s',0};
825 static const WCHAR GameTasksW[] = {'G','a','m','e','T','a','s','k','s',0};
826 static const WCHAR HistoryW[] = {'H','i','s','t','o','r','y','\0'};
827 static const WCHAR HomeGroupFolderW[] = {'H','o','m','e','G','r','o','u','p','F','o','l','d','e','r',0};
828 static const WCHAR ImplicitAppShortcutsW[] = {'I','m','p','l','i','c','i','t','A','p','p','S','h','o','r','t','c','u','t','s',0};
829 static const WCHAR InternetFolderW[] = {'I','n','t','e','r','n','e','t','F','o','l','d','e','r',0};
830 static const WCHAR LibrariesW[] = {'L','i','b','r','a','r','i','e','s',0};
831 static const WCHAR LinksW[] = {'L','i','n','k','s','\0'};
832 static const WCHAR Local_AppDataW[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
833 static const WCHAR Local_Settings_Application_DataW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
834 static const WCHAR Local_Settings_CD_BurningW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\\','M','i','c','r','o','s','o','f','t','\\','C','D',' ','B','u','r','n','i','n','g','\0'};
835 static const WCHAR Local_Settings_HistoryW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','H','i','s','t','o','r','y','\0'};
836 static const WCHAR Local_Settings_Temporary_Internet_FilesW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s','\0'};
837 static const WCHAR LocalAppDataLowW[] = {'L','o','c','a','l','A','p','p','D','a','t','a','L','o','w',0};
838 static const WCHAR LocalizedResourcesDirW[] = {'L','o','c','a','l','i','z','e','d','R','e','s','o','u','r','c','e','s','D','i','r',0};
839 static const WCHAR MAPIFolderW[] = {'M','A','P','I','F','o','l','d','e','r',0};
840 static const WCHAR Microsoft_Internet_Explorer_Quick_LaunchW[] = {'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\','Q','u','i','c','k',' ','L','a','u','n','c','h',0};
841 static const WCHAR Microsoft_Windows_Burn_BurnW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','B','u','r','n','\\','B','u','r','n',0};
842 static const WCHAR Microsoft_Windows_CookiesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','o','o','k','i','e','s',0};
843 static const WCHAR Microsoft_Windows_GameExplorerW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','G','a','m','e','E','x','p','l','o','r','e','r','\0'};
844 static const WCHAR Microsoft_Windows_DeviceMetadataStoreW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','D','e','v','i','c','e','M','e','t','a','d','a','t','a','S','t','o','r','e',0};
845 static const WCHAR Microsoft_Windows_HistoryW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','H','i','s','t','o','r','y',0};
846 static const WCHAR Microsoft_Windows_LibrariesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','L','i','b','r','a','r','i','e','s','\0'};
847 static const WCHAR Microsoft_Windows_Network_ShortcutsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','N','e','t','w','o','r','k',' ','S','h','o','r','t','c','u','t','s',0};
848 static const WCHAR Microsoft_Windows_Photo_Gallery_Original_ImagesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','P','h','o','t','o',' ','G','a','l','l','e','r','y','\\','O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
849 static const WCHAR Microsoft_Windows_Printer_ShortcutsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','P','r','i','n','t','e','r',' ','S','h','o','r','t','c','u','t','s',0};
850 static const WCHAR Microsoft_Windows_RecentW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','R','e','c','e','n','t','\0'};
851 static const WCHAR Microsoft_Windows_RingtonesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','R','i','n','g','t','o','n','e','s','\0'};
852 static const WCHAR Microsoft_Windows_SendToW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','e','n','d','T','o',0};
853 static const WCHAR Microsoft_Windows_Sidebar_GadgetsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','S','i','d','e','b','a','r','\\','G','a','d','g','e','t','s',0};
854 static const WCHAR Microsoft_Windows_Start_MenuW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u',0};
855 static const WCHAR Microsoft_Windows_Start_Menu_ProgramsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
856 static const WCHAR Microsoft_Windows_Start_Menu_Admin_ToolsW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
857 static const WCHAR Microsoft_Windows_Start_Menu_StartupW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
858 static const WCHAR Microsoft_Windows_TemplatesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','l','a','t','e','s',0};
859 static const WCHAR Microsoft_Windows_Temporary_Internet_FilesW[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s',0};
860 static const WCHAR MoviesW[] = {'M','o','v','i','e','s','\0'};
861 static const WCHAR MusicW[] = {'M','u','s','i','c','\0'};
862 static const WCHAR MusicLibraryW[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
863 static const WCHAR Music_librarymsW[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
864 static const WCHAR Music_PlaylistsW[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
865 static const WCHAR Music_Sample_MusicW[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
866 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'};
867 static const WCHAR My_MusicW[] = {'M','y',' ','M','u','s','i','c','\0'};
868 static const WCHAR My_PicturesW[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
869 static const WCHAR My_VideosW[] = {'M','y',' ','V','i','d','e','o','s','\0'};
870 static const WCHAR My_VideoW[] = {'M','y',' ','V','i','d','e','o','\0'};
871 static const WCHAR MyComputerFolderW[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
872 static const WCHAR NetHoodW[] = {'N','e','t','H','o','o','d','\0'};
873 static const WCHAR NetworkPlacesFolderW[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
874 static const WCHAR OEM_LinksW[] = {'O','E','M',' ','L','i','n','k','s','\0'};
875 static const WCHAR Original_ImagesW[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
876 static const WCHAR PersonalW[] = {'P','e','r','s','o','n','a','l','\0'};
877 static const WCHAR PhotoAlbumsW[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
878 static const WCHAR PicturesW[] = {'P','i','c','t','u','r','e','s','\0'};
879 static const WCHAR PicturesLibraryW[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
880 static const WCHAR Pictures_librarymsW[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
881 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'};
882 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'};
883 static const WCHAR PlaylistsW[] = {'P','l','a','y','l','i','s','t','s',0};
884 static const WCHAR PrintersFolderW[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
885 static const WCHAR PrintHoodW[] = {'P','r','i','n','t','H','o','o','d','\0'};
886 static const WCHAR ProfileW[] = {'P','r','o','f','i','l','e',0};
887 static const WCHAR ProgramDataW[] = {'P','r','o','g','r','a','m','D','a','t','a','\0'};
888 static const WCHAR Program_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
889 static const WCHAR ProgramFilesW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
890 static const WCHAR ProgramFilesX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
891 static const WCHAR ProgramFilesX64W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
892 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'};
893 static const WCHAR Program_Files_x86W[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
894 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'};
895 static const WCHAR ProgramFilesCommonW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
896 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};
897 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};
898 static const WCHAR ProgramFilesDirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
899 static const WCHAR ProgramFilesDirX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
900 static const WCHAR ProgramsW[] = {'P','r','o','g','r','a','m','s','\0'};
901 static const WCHAR PublicW[] = {'P','u','b','l','i','c',0};
902 static const WCHAR PublicGameTasksW[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
903 static const WCHAR PublicLibrariesW[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
904 static const WCHAR Quick_LaunchW[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
905 static const WCHAR RecentW[] = {'R','e','c','e','n','t','\0'};
906 static const WCHAR RecordedTVLibraryW[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
907 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};
908 static const WCHAR RecycleBinFolderW[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
909 static const WCHAR ResourceDirW[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
910 static const WCHAR ResourcesW[] = {'R','e','s','o','u','r','c','e','s','\0'};
911 static const WCHAR RingtonesW[] = {'R','i','n','g','t','o','n','e','s',0};
912 static const WCHAR SampleMusicW[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
913 static const WCHAR Sample_MusicW[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
914 static const WCHAR SamplePicturesW[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
915 static const WCHAR Sample_PicturesW[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
916 static const WCHAR SamplePlaylistsW[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
917 static const WCHAR Sample_PlaylistsW[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
918 static const WCHAR Sample_VideosW[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
919 static const WCHAR SampleVideosW[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
920 static const WCHAR Saved_GamesW[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
921 static const WCHAR SavedGamesW[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
922 static const WCHAR SearchesW[] = {'S','e','a','r','c','h','e','s','\0'};
923 static const WCHAR SearchHomeFolderW[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
924 static const WCHAR SendToW[] = {'S','e','n','d','T','o','\0'};
925 static const WCHAR Slide_ShowsW[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
926 static const WCHAR StartUpW[] = {'S','t','a','r','t','U','p','\0'};
927 static const WCHAR StartupW[] = {'S','t','a','r','t','u','p','\0'};
928 static const WCHAR Start_MenuW[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
929 static const WCHAR Start_Menu_ProgramsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
930 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'};
931 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'};
932 static const WCHAR SyncCenterFolderW[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
933 static const WCHAR SyncResultsFolderW[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
934 static const WCHAR SyncSetupFolderW[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
935 static const WCHAR SystemW[] = {'S','y','s','t','e','m',0};
936 static const WCHAR SystemX86W[] = {'S','y','s','t','e','m','X','8','6',0};
937 static const WCHAR TemplatesW[] = {'T','e','m','p','l','a','t','e','s','\0'};
938 static const WCHAR User_PinnedW[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
939 static const WCHAR UsersW[] = {'U','s','e','r','s','\0'};
940 static const WCHAR UsersFilesFolderW[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
941 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};
942 static const WCHAR UserProfilesW[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
943 static const WCHAR UserProgramFilesW[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
944 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};
945 static const WCHAR UsersPublicW[] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'};
946 static const WCHAR VideosW[] = {'V','i','d','e','o','s','\0'};
947 static const WCHAR VideosLibraryW[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
948 static const WCHAR Videos_librarymsW[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
949 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'};
950 static const WCHAR WindowsW[] = {'W','i','n','d','o','w','s',0};
951 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};
952 static const WCHAR DefaultW[] = {'.','D','e','f','a','u','l','t','\0'};
953 static const WCHAR AllUsersProfileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
954 static const WCHAR UserProfileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
955 static const WCHAR ProgramDataVarW[] = {'%','P','r','o','g','r','a','m','D','a','t','a','%','\0'};
956 static const WCHAR SystemDriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
957 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};
958 static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
959 static const WCHAR AllUsersProfileValueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
960 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'};
961 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'};
962 static const WCHAR szDefaultProfileDirW[] = {'u','s','e','r','s',0};
963 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'};
964 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};
965 static const WCHAR AllUsersW[] = {'P','u','b','l','i','c',0};
967 #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','}'
968 #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','}'
969 #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','}'
970 #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','}'
971 #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','}'
973 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};
974 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};
975 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};
976 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};
977 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};
978 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};
979 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};
980 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};
981 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};
982 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};
983 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};
984 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};
985 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};
986 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};
987 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};
988 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};
989 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};
990 static const WCHAR ChangeRemoveProgramsParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID, 0};
991 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};
992 static const WCHAR SyncManagerFolderParsingNameW[] = {':',':', SYSTEMFOLDERS_PARSING_GUID, '\\',':',':', SYNCMANAGER_PARSING_GUID, 0};
993 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};
994 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};
995 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};
996 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};
997 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};
998 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};
999 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};
1000 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};
1001 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};
1002 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};
1003 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};
1004 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};
1005 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};
1006 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};
1007 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};
1009 typedef enum _CSIDL_Type {
1010 CSIDL_Type_User,
1011 CSIDL_Type_AllUsers,
1012 CSIDL_Type_CurrVer,
1013 CSIDL_Type_Disallowed,
1014 CSIDL_Type_NonExistent,
1015 CSIDL_Type_WindowsPath,
1016 CSIDL_Type_SystemPath,
1017 CSIDL_Type_SystemX86Path,
1018 CSIDL_Type_ProgramData,
1019 } CSIDL_Type;
1021 #define CSIDL_CONTACTS 0x0043
1022 #define CSIDL_DOWNLOADS 0x0047
1023 #define CSIDL_LINKS 0x004d
1024 #define CSIDL_APPDATA_LOCALLOW 0x004e
1025 #define CSIDL_SAVED_GAMES 0x0062
1026 #define CSIDL_SEARCHES 0x0063
1028 typedef struct
1030 IApplicationDestinations IApplicationDestinations_iface;
1031 LONG ref;
1032 } IApplicationDestinationsImpl;
1034 static inline IApplicationDestinationsImpl *impl_from_IApplicationDestinations( IApplicationDestinations *iface )
1036 return CONTAINING_RECORD(iface, IApplicationDestinationsImpl, IApplicationDestinations_iface);
1039 static HRESULT WINAPI ApplicationDestinations_QueryInterface(IApplicationDestinations *iface, REFIID riid,
1040 LPVOID *ppv)
1042 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1044 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppv);
1046 if (ppv == NULL)
1047 return E_POINTER;
1049 if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IApplicationDestinations, riid))
1051 *ppv = &This->IApplicationDestinations_iface;
1052 IUnknown_AddRef((IUnknown*)*ppv);
1054 TRACE("Returning IApplicationDestinations: %p\n", *ppv);
1055 return S_OK;
1058 *ppv = NULL;
1059 FIXME("(%p)->(%s, %p) interface not supported.\n", This, debugstr_guid(riid), ppv);
1061 return E_NOINTERFACE;
1064 static ULONG WINAPI ApplicationDestinations_AddRef(IApplicationDestinations *iface)
1066 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1067 ULONG ref = InterlockedIncrement(&This->ref);
1069 TRACE("(%p), new refcount=%i\n", This, ref);
1071 return ref;
1074 static ULONG WINAPI ApplicationDestinations_Release(IApplicationDestinations *iface)
1076 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1077 ULONG ref = InterlockedDecrement(&This->ref);
1079 TRACE("(%p), new refcount=%i\n", This, ref);
1081 if (ref == 0)
1082 HeapFree(GetProcessHeap(), 0, This);
1084 return ref;
1087 static HRESULT WINAPI ApplicationDestinations_SetAppID(IApplicationDestinations *iface, const WCHAR *appid)
1089 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1091 FIXME("(%p, %s) stub!\n", This, debugstr_w(appid));
1093 return E_NOTIMPL;
1096 static HRESULT WINAPI ApplicationDestinations_RemoveDestination(IApplicationDestinations *iface, IUnknown *punk)
1098 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1100 FIXME("(%p, %p) stub!\n", This, punk);
1102 return E_NOTIMPL;
1105 static HRESULT WINAPI ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations *iface)
1107 IApplicationDestinationsImpl *This = impl_from_IApplicationDestinations(iface);
1109 FIXME("(%p) stub!\n", This);
1111 return E_NOTIMPL;
1114 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl =
1116 ApplicationDestinations_QueryInterface,
1117 ApplicationDestinations_AddRef,
1118 ApplicationDestinations_Release,
1119 ApplicationDestinations_SetAppID,
1120 ApplicationDestinations_RemoveDestination,
1121 ApplicationDestinations_RemoveAllDestinations
1124 HRESULT WINAPI ApplicationDestinations_Constructor(IUnknown *outer, REFIID riid, LPVOID *ppv)
1126 IApplicationDestinationsImpl *This;
1127 HRESULT hr;
1129 TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), ppv);
1131 if (outer)
1132 return CLASS_E_NOAGGREGATION;
1134 if (!(This = SHAlloc(sizeof(*This))))
1135 return E_OUTOFMEMORY;
1137 This->IApplicationDestinations_iface.lpVtbl = &ApplicationDestinationsVtbl;
1138 This->ref = 0;
1140 hr = IUnknown_QueryInterface(&This->IApplicationDestinations_iface, riid, ppv);
1141 if (FAILED(hr))
1142 SHFree(This);
1144 return hr;
1147 typedef struct
1149 const KNOWNFOLDERID *id;
1150 CSIDL_Type type;
1151 LPCWSTR szValueName;
1152 LPCWSTR szDefaultPath; /* fallback string or resource ID */
1154 /* KNOWNFOLDER_DEFINITION fields */
1155 KF_CATEGORY category;
1156 const WCHAR *pszName;
1157 const WCHAR *pszDescription;
1158 const KNOWNFOLDERID *fidParent;
1159 const WCHAR *pszRelativePath;
1160 const WCHAR *pszParsingName;
1161 const WCHAR *pszTooltip;
1162 const WCHAR *pszLocalizedName;
1163 const WCHAR *pszIcon;
1164 const WCHAR *pszSecurity;
1165 DWORD dwAttributes;
1166 KF_DEFINITION_FLAGS kfdFlags;
1167 const FOLDERTYPEID *ftidType;
1168 } CSIDL_DATA;
1170 static const CSIDL_DATA CSIDL_Data[] =
1172 { /* 0x00 - CSIDL_DESKTOP */
1173 &FOLDERID_Desktop,
1174 CSIDL_Type_User,
1175 DesktopW,
1176 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1178 KF_CATEGORY_PERUSER, /* category */
1179 DesktopW, /* name */
1180 NULL, /* description */
1181 &GUID_NULL, /* parent */
1182 DesktopW, /* relative path */
1183 NULL, /* parsing */
1184 NULL, /* tooltip */
1185 NULL, /* localized */
1186 NULL, /* icon */
1187 NULL, /* security */
1188 FILE_ATTRIBUTE_READONLY, /* attributes */
1189 0, /* flags */
1190 &GUID_NULL /* typeid */
1192 { /* 0x01 - CSIDL_INTERNET */
1193 &FOLDERID_InternetFolder,
1194 CSIDL_Type_Disallowed,
1195 NULL,
1196 NULL,
1198 KF_CATEGORY_VIRTUAL, /* category */
1199 InternetFolderW, /* name */
1200 NULL, /* description */
1201 &GUID_NULL, /* parent */
1202 NULL, /* relative path */
1203 InternetFolderParsingNameW, /* parsing */
1204 NULL, /* tooltip */
1205 NULL, /* localized */
1206 NULL, /* icon */
1207 NULL, /* security */
1208 0, /* attributes */
1209 0, /* flags */
1210 &GUID_NULL /* typeid */
1212 { /* 0x02 - CSIDL_PROGRAMS */
1213 &FOLDERID_Programs,
1214 CSIDL_Type_User,
1215 ProgramsW,
1216 Start_Menu_ProgramsW,
1218 KF_CATEGORY_PERUSER, /* category */
1219 ProgramsW, /* name */
1220 NULL, /* description */
1221 &GUID_NULL, /* parent */
1222 ProgramsW, /* relative path */
1223 NULL, /* parsing */
1224 NULL, /* tooltip */
1225 NULL, /* localized */
1226 NULL, /* icon */
1227 NULL, /* security */
1228 FILE_ATTRIBUTE_READONLY, /* attributes */
1229 0, /* flags */
1230 &GUID_NULL /* typeid */
1232 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1233 &FOLDERID_ControlPanelFolder,
1234 CSIDL_Type_SystemPath,
1235 NULL,
1236 NULL,
1238 KF_CATEGORY_VIRTUAL, /* category */
1239 ControlPanelFolderW, /* name */
1240 NULL, /* description */
1241 &GUID_NULL, /* parent */
1242 ControlPanelFolderRelativePathW, /* relative path */
1243 ControlPanelFolderParsingNameW, /* parsing */
1244 NULL, /* tooltip */
1245 NULL, /* localized */
1246 NULL, /* icon */
1247 NULL, /* security */
1248 0, /* attributes */
1249 0, /* flags */
1250 &GUID_NULL /* typeid */
1252 { /* 0x04 - CSIDL_PRINTERS */
1253 &FOLDERID_PrintersFolder,
1254 CSIDL_Type_SystemPath,
1255 NULL,
1256 NULL,
1258 KF_CATEGORY_VIRTUAL, /* category */
1259 PrintersFolderW, /* name */
1260 NULL, /* description */
1261 &GUID_NULL, /* parent */
1262 NULL, /* relative path */
1263 PrintersFolderParsingNameW, /* parsing */
1264 NULL, /* tooltip */
1265 NULL, /* localized */
1266 NULL, /* icon */
1267 NULL, /* security */
1268 0, /* attributes */
1269 0, /* flags */
1270 &GUID_NULL /* typeid */
1272 { /* 0x05 - CSIDL_PERSONAL */
1273 &FOLDERID_Documents,
1274 CSIDL_Type_User,
1275 PersonalW,
1276 MAKEINTRESOURCEW(IDS_PERSONAL),
1278 KF_CATEGORY_PERUSER, /* category */
1279 PersonalW, /* name */
1280 NULL, /* description */
1281 &GUID_NULL, /* parent */
1282 DocumentsW, /* relative path */
1283 DocumentsParsingNameW, /* parsing */
1284 NULL, /* tooltip */
1285 NULL, /* localized */
1286 NULL, /* icon */
1287 NULL, /* security */
1288 FILE_ATTRIBUTE_READONLY, /* attributes */
1289 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1290 &GUID_NULL /* typeid */
1292 { /* 0x06 - CSIDL_FAVORITES */
1293 &FOLDERID_Favorites,
1294 CSIDL_Type_User,
1295 FavoritesW,
1296 FavoritesW,
1298 KF_CATEGORY_PERUSER, /* category */
1299 FavoritesW, /* name */
1300 NULL, /* description */
1301 &GUID_NULL, /* parent */
1302 FavoritesW, /* relative path */
1303 NULL, /* parsing */
1304 NULL, /* tooltip */
1305 NULL, /* localized */
1306 NULL, /* icon */
1307 NULL, /* security */
1308 FILE_ATTRIBUTE_READONLY, /* attributes */
1309 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1310 &GUID_NULL /* typeid */
1312 { /* 0x07 - CSIDL_STARTUP */
1313 &FOLDERID_Startup,
1314 CSIDL_Type_User,
1315 StartUpW,
1316 Start_Menu_StartupW,
1318 KF_CATEGORY_PERUSER, /* category */
1319 StartupW, /* name */
1320 NULL, /* description */
1321 &GUID_NULL, /* parent */
1322 StartUpW, /* relative path */
1323 NULL, /* parsing */
1324 NULL, /* tooltip */
1325 NULL, /* localized */
1326 NULL, /* icon */
1327 NULL, /* security */
1328 FILE_ATTRIBUTE_READONLY, /* attributes */
1329 KFDF_PRECREATE, /* flags */
1330 &GUID_NULL /* typeid */
1332 { /* 0x08 - CSIDL_RECENT */
1333 &FOLDERID_Recent,
1334 CSIDL_Type_User,
1335 RecentW,
1336 RecentW,
1338 KF_CATEGORY_PERUSER, /* category */
1339 RecentW, /* name */
1340 NULL, /* description */
1341 &FOLDERID_RoamingAppData, /* parent */
1342 Microsoft_Windows_RecentW, /* relative path */
1343 NULL, /* parsing */
1344 NULL, /* tooltip */
1345 NULL, /* localized */
1346 NULL, /* icon */
1347 NULL, /* security */
1348 FILE_ATTRIBUTE_READONLY, /* attributes */
1349 KFDF_PRECREATE, /* flags */
1350 &GUID_NULL /* typeid */
1352 { /* 0x09 - CSIDL_SENDTO */
1353 &FOLDERID_SendTo,
1354 CSIDL_Type_User,
1355 SendToW,
1356 SendToW,
1358 KF_CATEGORY_PERUSER, /* category */
1359 SendToW, /* name */
1360 NULL, /* description */
1361 &FOLDERID_RoamingAppData, /* parent */
1362 Microsoft_Windows_SendToW, /* relative path */
1363 NULL, /* parsing */
1364 NULL, /* tooltip */
1365 NULL, /* localized */
1366 NULL, /* icon */
1367 NULL, /* security */
1368 0, /* attributes */
1369 KFDF_PRECREATE, /* flags */
1370 &GUID_NULL /* typeid */
1372 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1373 &FOLDERID_RecycleBinFolder,
1374 CSIDL_Type_Disallowed,
1375 NULL,
1376 NULL,
1378 KF_CATEGORY_VIRTUAL, /* category */
1379 RecycleBinFolderW, /* name */
1380 NULL, /* description */
1381 &GUID_NULL, /* parent */
1382 NULL, /* relative path */
1383 RecycleBinFolderParsingNameW, /* parsing */
1384 NULL, /* tooltip */
1385 NULL, /* localized */
1386 NULL, /* icon */
1387 NULL, /* security */
1388 0, /* attributes */
1389 0, /* flags */
1390 &GUID_NULL /* typeid */
1392 { /* 0x0b - CSIDL_STARTMENU */
1393 &FOLDERID_StartMenu,
1394 CSIDL_Type_User,
1395 Start_MenuW,
1396 Start_MenuW,
1398 KF_CATEGORY_PERUSER, /* category */
1399 Start_MenuW, /* name */
1400 NULL, /* description */
1401 &FOLDERID_RoamingAppData, /* parent */
1402 Microsoft_Windows_Start_MenuW, /* relative path */
1403 NULL, /* parsing */
1404 NULL, /* tooltip */
1405 NULL, /* localized */
1406 NULL, /* icon */
1407 NULL, /* security */
1408 FILE_ATTRIBUTE_READONLY, /* attributes */
1409 KFDF_PRECREATE, /* flags */
1410 &GUID_NULL /* typeid */
1412 { /* 0x0c - CSIDL_MYDOCUMENTS */
1413 &GUID_NULL,
1414 CSIDL_Type_Disallowed, /* matches WinXP--can't get its path */
1415 NULL,
1416 NULL
1418 { /* 0x0d - CSIDL_MYMUSIC */
1419 &FOLDERID_Music,
1420 CSIDL_Type_User,
1421 My_MusicW,
1422 MAKEINTRESOURCEW(IDS_MYMUSIC),
1424 KF_CATEGORY_PERUSER, /* category */
1425 My_MusicW, /* name */
1426 NULL, /* description */
1427 &FOLDERID_Profile, /* parent */
1428 MusicW, /* relative path */
1429 MusicParsingNameW, /* parsing */
1430 NULL, /* tooltip */
1431 NULL, /* localized */
1432 NULL, /* icon */
1433 NULL, /* security */
1434 FILE_ATTRIBUTE_READONLY, /* attributes */
1435 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1436 &GUID_NULL /* typeid */
1438 { /* 0x0e - CSIDL_MYVIDEO */
1439 &FOLDERID_Videos,
1440 CSIDL_Type_User,
1441 My_VideosW,
1442 MAKEINTRESOURCEW(IDS_MYVIDEOS),
1444 KF_CATEGORY_PERUSER, /* category */
1445 My_VideoW, /* name */
1446 NULL, /* description */
1447 &FOLDERID_Profile, /* parent */
1448 VideosW, /* relative path */
1449 VideosParsingNameW, /* parsing */
1450 NULL, /* tooltip */
1451 NULL, /* localized */
1452 NULL, /* icon */
1453 NULL, /* security */
1454 FILE_ATTRIBUTE_READONLY, /* attributes */
1455 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1456 &GUID_NULL /* typeid */
1458 { /* 0x0f - unassigned */
1459 &GUID_NULL,
1460 CSIDL_Type_Disallowed,
1461 NULL,
1462 NULL,
1464 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1465 &FOLDERID_Desktop,
1466 CSIDL_Type_User,
1467 DesktopW,
1468 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1470 KF_CATEGORY_PERUSER, /* category */
1471 DesktopW, /* name */
1472 NULL, /* description */
1473 &FOLDERID_Profile, /* parent */
1474 DesktopW, /* relative path */
1475 NULL, /* parsing */
1476 NULL, /* tooltip */
1477 NULL, /* localized */
1478 NULL, /* icon */
1479 NULL, /* security */
1480 FILE_ATTRIBUTE_READONLY, /* attributes */
1481 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1482 &GUID_NULL /* typeid */
1484 { /* 0x11 - CSIDL_DRIVES */
1485 &FOLDERID_ComputerFolder,
1486 CSIDL_Type_Disallowed,
1487 NULL,
1488 NULL,
1490 KF_CATEGORY_VIRTUAL, /* category */
1491 MyComputerFolderW, /* name */
1492 NULL, /* description */
1493 &GUID_NULL, /* parent */
1494 NULL, /* relative path */
1495 ComputerFolderParsingNameW, /* parsing */
1496 NULL, /* tooltip */
1497 NULL, /* localized */
1498 NULL, /* icon */
1499 NULL, /* security */
1500 0, /* attributes */
1501 0, /* flags */
1502 &GUID_NULL /* typeid */
1504 { /* 0x12 - CSIDL_NETWORK */
1505 &FOLDERID_NetworkFolder,
1506 CSIDL_Type_Disallowed,
1507 NULL,
1508 NULL,
1510 KF_CATEGORY_VIRTUAL, /* category */
1511 NetworkPlacesFolderW, /* name */
1512 NULL, /* description */
1513 &GUID_NULL, /* parent */
1514 NULL, /* relative path */
1515 NetworkFolderParsingNameW, /* parsing */
1516 NULL, /* tooltip */
1517 NULL, /* localized */
1518 NULL, /* icon */
1519 NULL, /* security */
1520 0, /* attributes */
1521 0, /* flags */
1522 &GUID_NULL /* typeid */
1524 { /* 0x13 - CSIDL_NETHOOD */
1525 &FOLDERID_NetHood,
1526 CSIDL_Type_User,
1527 NetHoodW,
1528 NetHoodW,
1530 KF_CATEGORY_PERUSER, /* category */
1531 NetHoodW, /* name */
1532 NULL, /* description */
1533 &FOLDERID_RoamingAppData, /* parent */
1534 Microsoft_Windows_Network_ShortcutsW, /* relative path */
1535 NULL, /* parsing */
1536 NULL, /* tooltip */
1537 NULL, /* localized */
1538 NULL, /* icon */
1539 NULL, /* security */
1540 0, /* attributes */
1541 0, /* flags */
1542 &GUID_NULL /* typeid */
1544 { /* 0x14 - CSIDL_FONTS */
1545 &FOLDERID_Fonts,
1546 CSIDL_Type_WindowsPath,
1547 FontsW,
1548 FontsW,
1550 KF_CATEGORY_FIXED, /* category */
1551 FontsW, /* name */
1552 NULL, /* description */
1553 &GUID_NULL, /* parent */
1554 NULL, /* relative path */
1555 NULL, /* parsing */
1556 NULL, /* tooltip */
1557 NULL, /* localized */
1558 NULL, /* icon */
1559 NULL, /* security */
1560 0, /* attributes */
1561 0, /* flags */
1562 &FOLDERID_Windows/* typeid */
1564 { /* 0x15 - CSIDL_TEMPLATES */
1565 &FOLDERID_Templates,
1566 CSIDL_Type_User,
1567 TemplatesW,
1568 TemplatesW,
1570 KF_CATEGORY_PERUSER, /* category */
1571 TemplatesW, /* name */
1572 NULL, /* description */
1573 &FOLDERID_RoamingAppData, /* parent */
1574 Microsoft_Windows_TemplatesW, /* relative path */
1575 NULL, /* parsing */
1576 NULL, /* tooltip */
1577 NULL, /* localized */
1578 NULL, /* icon */
1579 NULL, /* security */
1580 0, /* attributes */
1581 0, /* flags */
1582 &GUID_NULL /* typeid */
1584 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1585 &FOLDERID_CommonStartMenu,
1586 CSIDL_Type_ProgramData,
1587 Common_Start_MenuW,
1588 Microsoft_Windows_Start_MenuW,
1590 KF_CATEGORY_COMMON, /* category */
1591 Common_Start_MenuW, /* name */
1592 NULL, /* description */
1593 &FOLDERID_ProgramData, /* parent */
1594 Microsoft_Windows_Start_MenuW, /* relative path */
1595 NULL, /* parsing */
1596 NULL, /* tooltip */
1597 NULL, /* localized */
1598 NULL, /* icon */
1599 NULL, /* security */
1600 FILE_ATTRIBUTE_READONLY, /* attributes */
1601 0, /* flags */
1602 &GUID_NULL /* typeid */
1604 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1605 &FOLDERID_CommonPrograms,
1606 CSIDL_Type_ProgramData,
1607 Common_ProgramsW,
1608 Microsoft_Windows_Start_Menu_ProgramsW,
1610 KF_CATEGORY_COMMON, /* category */
1611 Common_ProgramsW, /* name */
1612 NULL, /* description */
1613 &FOLDERID_CommonStartMenu, /* parent */
1614 ProgramsW, /* relative path */
1615 NULL, /* parsing */
1616 NULL, /* tooltip */
1617 NULL, /* localized */
1618 NULL, /* icon */
1619 NULL, /* security */
1620 FILE_ATTRIBUTE_READONLY, /* attributes */
1621 0, /* flags */
1622 &GUID_NULL /* typeid */
1624 { /* 0x18 - CSIDL_COMMON_STARTUP */
1625 &FOLDERID_CommonStartup,
1626 CSIDL_Type_ProgramData,
1627 Common_StartUpW,
1628 Microsoft_Windows_Start_Menu_StartupW,
1630 KF_CATEGORY_COMMON, /* category */
1631 Common_StartupW, /* name */
1632 NULL, /* description */
1633 &FOLDERID_CommonPrograms, /* parent */
1634 StartUpW, /* relative path */
1635 NULL, /* parsing */
1636 NULL, /* tooltip */
1637 NULL, /* localized */
1638 NULL, /* icon */
1639 NULL, /* security */
1640 FILE_ATTRIBUTE_READONLY, /* attributes */
1641 KFDF_PRECREATE, /* flags */
1642 &GUID_NULL /* typeid */
1644 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1645 &FOLDERID_PublicDesktop,
1646 CSIDL_Type_AllUsers,
1647 Common_DesktopW,
1648 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY),
1650 KF_CATEGORY_COMMON, /* category */
1651 Common_DesktopW, /* name */
1652 NULL, /* description */
1653 &FOLDERID_Public, /* parent */
1654 DesktopW, /* relative path */
1655 NULL, /* parsing */
1656 NULL, /* tooltip */
1657 NULL, /* localized */
1658 NULL, /* icon */
1659 NULL, /* security */
1660 FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN, /* attributes */
1661 KFDF_PRECREATE, /* flags */
1662 &GUID_NULL /* typeid */
1664 { /* 0x1a - CSIDL_APPDATA */
1665 &FOLDERID_RoamingAppData,
1666 CSIDL_Type_User,
1667 AppDataW,
1668 Application_DataW,
1670 KF_CATEGORY_PERUSER, /* category */
1671 AppDataW, /* name */
1672 NULL, /* description */
1673 &FOLDERID_Profile, /* parent */
1674 AppData_RoamingW, /* relative path */
1675 NULL, /* parsing */
1676 NULL, /* tooltip */
1677 NULL, /* localized */
1678 NULL, /* icon */
1679 NULL, /* security */
1680 0, /* attributes */
1681 0, /* flags */
1682 &GUID_NULL /* typeid */
1684 { /* 0x1b - CSIDL_PRINTHOOD */
1685 &FOLDERID_PrintHood,
1686 CSIDL_Type_User,
1687 PrintHoodW,
1688 PrintHoodW,
1690 KF_CATEGORY_PERUSER, /* category */
1691 PrintHoodW, /* name */
1692 NULL, /* description */
1693 &FOLDERID_RoamingAppData, /* parent */
1694 Microsoft_Windows_Printer_ShortcutsW, /* relative path */
1695 NULL, /* parsing */
1696 NULL, /* tooltip */
1697 NULL, /* localized */
1698 NULL, /* icon */
1699 NULL, /* security */
1700 0, /* attributes */
1701 0, /* flags */
1702 &GUID_NULL /* typeid */
1704 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1705 &FOLDERID_LocalAppData,
1706 CSIDL_Type_User,
1707 Local_AppDataW,
1708 Local_Settings_Application_DataW,
1710 KF_CATEGORY_PERUSER, /* category */
1711 Local_AppDataW, /* name */
1712 NULL, /* description */
1713 &FOLDERID_Profile, /* parent */
1714 AppData_LocalW, /* relative path */
1715 NULL, /* parsing */
1716 NULL, /* tooltip */
1717 NULL, /* localized */
1718 NULL, /* icon */
1719 NULL, /* security */
1720 0, /* attributes */
1721 KFDF_LOCAL_REDIRECT_ONLY | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1722 &GUID_NULL /* typeid */
1724 { /* 0x1d - CSIDL_ALTSTARTUP */
1725 &GUID_NULL,
1726 CSIDL_Type_NonExistent,
1727 NULL,
1728 NULL
1730 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1731 &GUID_NULL,
1732 CSIDL_Type_NonExistent,
1733 NULL,
1734 NULL
1736 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1737 &FOLDERID_Favorites,
1738 CSIDL_Type_AllUsers,
1739 Common_FavoritesW,
1740 FavoritesW,
1742 KF_CATEGORY_PERUSER, /* category */
1743 FavoritesW, /* name */
1744 NULL, /* description */
1745 &FOLDERID_Profile, /* parent */
1746 FavoritesW, /* relative path */
1747 NULL, /* parsing */
1748 NULL, /* tooltip */
1749 NULL, /* localized */
1750 NULL, /* icon */
1751 NULL, /* security */
1752 FILE_ATTRIBUTE_READONLY, /* attributes */
1753 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
1754 &GUID_NULL /* typeid */
1756 { /* 0x20 - CSIDL_INTERNET_CACHE */
1757 &FOLDERID_InternetCache,
1758 CSIDL_Type_User,
1759 CacheW,
1760 Local_Settings_Temporary_Internet_FilesW,
1762 KF_CATEGORY_PERUSER, /* category */
1763 CacheW, /* name */
1764 NULL, /* description */
1765 &FOLDERID_LocalAppData, /* parent */
1766 Microsoft_Windows_Temporary_Internet_FilesW, /* relative path */
1767 NULL, /* parsing */
1768 NULL, /* tooltip */
1769 NULL, /* localized */
1770 NULL, /* icon */
1771 NULL, /* security */
1772 0, /* attributes */
1773 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
1774 &GUID_NULL /* typeid */
1776 { /* 0x21 - CSIDL_COOKIES */
1777 &FOLDERID_Cookies,
1778 CSIDL_Type_User,
1779 CookiesW,
1780 CookiesW,
1782 KF_CATEGORY_PERUSER, /* category */
1783 CookiesW, /* name */
1784 NULL, /* description */
1785 &FOLDERID_RoamingAppData, /* parent */
1786 Microsoft_Windows_CookiesW, /* relative path */
1787 NULL, /* parsing */
1788 NULL, /* tooltip */
1789 NULL, /* localized */
1790 NULL, /* icon */
1791 NULL, /* security */
1792 0, /* attributes */
1793 0, /* flags */
1794 &GUID_NULL /* typeid */
1796 { /* 0x22 - CSIDL_HISTORY */
1797 &FOLDERID_History,
1798 CSIDL_Type_User,
1799 HistoryW,
1800 Local_Settings_HistoryW,
1802 KF_CATEGORY_PERUSER, /* category */
1803 HistoryW, /* name */
1804 NULL, /* description */
1805 &FOLDERID_LocalAppData, /* parent */
1806 Microsoft_Windows_HistoryW, /* relative path */
1807 NULL, /* parsing */
1808 NULL, /* tooltip */
1809 NULL, /* localized */
1810 NULL, /* icon */
1811 NULL, /* security */
1812 0, /* attributes */
1813 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
1814 &GUID_NULL /* typeid */
1816 { /* 0x23 - CSIDL_COMMON_APPDATA */
1817 &FOLDERID_ProgramData,
1818 CSIDL_Type_ProgramData,
1819 Common_AppDataW,
1820 NULL,
1822 KF_CATEGORY_FIXED, /* category */
1823 Common_AppDataW, /* name */
1824 NULL, /* description */
1825 &GUID_NULL, /* parent */
1826 NULL, /* relative path */
1827 NULL, /* parsing */
1828 NULL, /* tooltip */
1829 NULL, /* localized */
1830 NULL, /* icon */
1831 NULL, /* security */
1832 0, /* attributes */
1833 0, /* flags */
1834 &GUID_NULL /* typeid */
1836 { /* 0x24 - CSIDL_WINDOWS */
1837 &FOLDERID_Windows,
1838 CSIDL_Type_WindowsPath,
1839 NULL,
1840 NULL,
1842 KF_CATEGORY_FIXED, /* category */
1843 WindowsW, /* name */
1844 NULL, /* description */
1845 &GUID_NULL, /* parent */
1846 NULL, /* relative path */
1847 NULL, /* parsing */
1848 NULL, /* tooltip */
1849 NULL, /* localized */
1850 NULL, /* icon */
1851 NULL, /* security */
1852 0, /* attributes */
1853 0, /* flags */
1854 &GUID_NULL /* typeid */
1856 { /* 0x25 - CSIDL_SYSTEM */
1857 &FOLDERID_System,
1858 CSIDL_Type_SystemPath,
1859 NULL,
1860 NULL,
1862 KF_CATEGORY_FIXED, /* category */
1863 SystemW, /* name */
1864 NULL, /* description */
1865 &GUID_NULL, /* parent */
1866 NULL, /* relative path */
1867 NULL, /* parsing */
1868 NULL, /* tooltip */
1869 NULL, /* localized */
1870 NULL, /* icon */
1871 NULL, /* security */
1872 0, /* attributes */
1873 0, /* flags */
1874 &GUID_NULL /* typeid */
1876 { /* 0x26 - CSIDL_PROGRAM_FILES */
1877 &FOLDERID_ProgramFiles,
1878 CSIDL_Type_CurrVer,
1879 ProgramFilesDirW,
1880 Program_FilesW,
1882 KF_CATEGORY_FIXED, /* category */
1883 ProgramFilesW, /* name */
1884 NULL, /* description */
1885 &GUID_NULL, /* parent */
1886 NULL, /* relative path */
1887 NULL, /* parsing */
1888 NULL, /* tooltip */
1889 NULL, /* localized */
1890 NULL, /* icon */
1891 NULL, /* security */
1892 FILE_ATTRIBUTE_READONLY, /* attributes */
1893 0, /* flags */
1894 &GUID_NULL /* typeid */
1896 { /* 0x27 - CSIDL_MYPICTURES */
1897 &FOLDERID_Pictures,
1898 CSIDL_Type_User,
1899 My_PicturesW,
1900 MAKEINTRESOURCEW(IDS_MYPICTURES),
1902 KF_CATEGORY_PERUSER, /* category */
1903 My_PicturesW, /* name */
1904 NULL, /* description */
1905 &FOLDERID_Profile, /* parent */
1906 PicturesW, /* relative path */
1907 PicturesParsingNameW, /* parsing */
1908 NULL, /* tooltip */
1909 NULL, /* localized */
1910 NULL, /* icon */
1911 NULL, /* security */
1912 FILE_ATTRIBUTE_READONLY, /* attributes */
1913 KFDF_ROAMABLE | KFDF_PRECREATE, /* flags */
1914 &GUID_NULL /* typeid */
1916 { /* 0x28 - CSIDL_PROFILE */
1917 &FOLDERID_Profile,
1918 CSIDL_Type_User,
1919 NULL,
1920 NULL,
1922 KF_CATEGORY_FIXED, /* category */
1923 ProfileW, /* name */
1924 NULL, /* description */
1925 &GUID_NULL, /* parent */
1926 NULL, /* relative path */
1927 NULL, /* parsing */
1928 NULL, /* tooltip */
1929 NULL, /* localized */
1930 NULL, /* icon */
1931 NULL, /* security */
1932 0, /* attributes */
1933 0, /* flags */
1934 &GUID_NULL /* typeid */
1936 { /* 0x29 - CSIDL_SYSTEMX86 */
1937 &FOLDERID_SystemX86,
1938 CSIDL_Type_SystemX86Path,
1939 NULL,
1940 NULL,
1942 KF_CATEGORY_FIXED, /* category */
1943 SystemX86W, /* name */
1944 NULL, /* description */
1945 &GUID_NULL, /* parent */
1946 NULL, /* relative path */
1947 NULL, /* parsing */
1948 NULL, /* tooltip */
1949 NULL, /* localized */
1950 NULL, /* icon */
1951 NULL, /* security */
1952 0, /* attributes */
1953 0, /* flags */
1954 &GUID_NULL /* typeid */
1956 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
1957 &FOLDERID_ProgramFilesX86,
1958 CSIDL_Type_CurrVer,
1959 ProgramFilesDirX86W,
1960 Program_Files_x86W,
1962 KF_CATEGORY_FIXED, /* category */
1963 ProgramFilesX86W, /* name */
1964 NULL, /* description */
1965 &GUID_NULL, /* parent */
1966 NULL, /* relative path */
1967 NULL, /* parsing */
1968 NULL, /* tooltip */
1969 NULL, /* localized */
1970 NULL, /* icon */
1971 NULL, /* security */
1972 FILE_ATTRIBUTE_READONLY, /* attributes */
1973 0, /* flags */
1974 &GUID_NULL /* typeid */
1976 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
1977 &FOLDERID_ProgramFilesCommon,
1978 CSIDL_Type_CurrVer,
1979 CommonFilesDirW,
1980 Program_Files_Common_FilesW,
1982 KF_CATEGORY_FIXED, /* category */
1983 ProgramFilesCommonW, /* name */
1984 NULL, /* description */
1985 &GUID_NULL, /* parent */
1986 NULL, /* relative path */
1987 NULL, /* parsing */
1988 NULL, /* tooltip */
1989 NULL, /* localized */
1990 NULL, /* icon */
1991 NULL, /* security */
1992 0, /* attributes */
1993 0, /* flags */
1994 &GUID_NULL /* typeid */
1996 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
1997 &FOLDERID_ProgramFilesCommonX86,
1998 CSIDL_Type_CurrVer,
1999 CommonFilesDirX86W,
2000 Program_Files_x86_Common_FilesW,
2002 KF_CATEGORY_FIXED, /* category */
2003 ProgramFilesCommonX86W, /* name */
2004 NULL, /* description */
2005 &GUID_NULL, /* parent */
2006 NULL, /* relative path */
2007 NULL, /* parsing */
2008 NULL, /* tooltip */
2009 NULL, /* localized */
2010 NULL, /* icon */
2011 NULL, /* security */
2012 0, /* attributes */
2013 0, /* flags */
2014 &GUID_NULL /* typeid */
2016 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2017 &FOLDERID_CommonTemplates,
2018 CSIDL_Type_ProgramData,
2019 Common_TemplatesW,
2020 Microsoft_Windows_TemplatesW,
2022 KF_CATEGORY_COMMON, /* category */
2023 Common_TemplatesW, /* name */
2024 NULL, /* description */
2025 &FOLDERID_ProgramData, /* parent */
2026 Microsoft_Windows_TemplatesW, /* relative path */
2027 NULL, /* parsing */
2028 NULL, /* tooltip */
2029 NULL, /* localized */
2030 NULL, /* icon */
2031 NULL, /* security */
2032 0, /* attributes */
2033 0, /* flags */
2034 &GUID_NULL /* typeid */
2036 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2037 &FOLDERID_PublicDocuments,
2038 CSIDL_Type_AllUsers,
2039 Common_DocumentsW,
2040 DocumentsW,
2042 KF_CATEGORY_COMMON, /* category */
2043 Common_DocumentsW, /* name */
2044 NULL, /* description */
2045 &FOLDERID_Public, /* parent */
2046 DocumentsW, /* relative path */
2047 NULL, /* parsing */
2048 NULL, /* tooltip */
2049 NULL, /* localized */
2050 NULL, /* icon */
2051 NULL, /* security */
2052 FILE_ATTRIBUTE_READONLY, /* attributes */
2053 KFDF_PRECREATE, /* flags */
2054 &GUID_NULL /* typeid */
2056 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2057 &FOLDERID_CommonAdminTools,
2058 CSIDL_Type_ProgramData,
2059 Common_Administrative_ToolsW,
2060 Microsoft_Windows_Start_Menu_Admin_ToolsW,
2062 KF_CATEGORY_COMMON, /* category */
2063 Common_Administrative_ToolsW, /* name */
2064 NULL, /* description */
2065 &FOLDERID_CommonPrograms, /* parent */
2066 Administrative_ToolsW, /* relative path */
2067 NULL, /* parsing */
2068 NULL, /* tooltip */
2069 NULL, /* localized */
2070 NULL, /* icon */
2071 NULL, /* security */
2072 FILE_ATTRIBUTE_READONLY, /* attributes */
2073 KFDF_PRECREATE, /* flags */
2074 &GUID_NULL /* typeid */
2076 { /* 0x30 - CSIDL_ADMINTOOLS */
2077 &FOLDERID_AdminTools,
2078 CSIDL_Type_User,
2079 Administrative_ToolsW,
2080 Start_Menu_Admin_ToolsW,
2082 KF_CATEGORY_PERUSER, /* category */
2083 Administrative_ToolsW, /* name */
2084 NULL, /* description */
2085 &FOLDERID_Programs, /* parent */
2086 Administrative_ToolsW, /* relative path */
2087 NULL, /* parsing */
2088 NULL, /* tooltip */
2089 NULL, /* localized */
2090 NULL, /* icon */
2091 NULL, /* security */
2092 FILE_ATTRIBUTE_READONLY, /* attributes */
2093 KFDF_PRECREATE, /* flags */
2094 &GUID_NULL /* typeid */
2096 { /* 0x31 - CSIDL_CONNECTIONS */
2097 &FOLDERID_ConnectionsFolder,
2098 CSIDL_Type_Disallowed,
2099 NULL,
2100 NULL,
2102 KF_CATEGORY_VIRTUAL, /* category */
2103 ConnectionsFolderW, /* name */
2104 NULL, /* description */
2105 &GUID_NULL, /* parent */
2106 Administrative_ToolsW, /* relative path */
2107 ConnectionsFolderParsingNameW, /* parsing */
2108 NULL, /* tooltip */
2109 NULL, /* localized */
2110 NULL, /* icon */
2111 NULL, /* security */
2112 0, /* attributes */
2113 0, /* flags */
2114 &GUID_NULL /* typeid */
2116 { /* 0x32 - unassigned */
2117 &GUID_NULL,
2118 CSIDL_Type_Disallowed,
2119 NULL,
2120 NULL
2122 { /* 0x33 - unassigned */
2123 &GUID_NULL,
2124 CSIDL_Type_Disallowed,
2125 NULL,
2126 NULL
2128 { /* 0x34 - unassigned */
2129 &GUID_NULL,
2130 CSIDL_Type_Disallowed,
2131 NULL,
2132 NULL
2134 { /* 0x35 - CSIDL_COMMON_MUSIC */
2135 &FOLDERID_PublicMusic,
2136 CSIDL_Type_AllUsers,
2137 CommonMusicW,
2138 MusicW,
2140 KF_CATEGORY_COMMON, /* category */
2141 CommonMusicW, /* name */
2142 NULL, /* description */
2143 &FOLDERID_Public, /* parent */
2144 MusicW, /* relative path */
2145 NULL, /* parsing */
2146 NULL, /* tooltip */
2147 NULL, /* localized */
2148 NULL, /* icon */
2149 NULL, /* security */
2150 FILE_ATTRIBUTE_READONLY, /* attributes */
2151 KFDF_PRECREATE, /* flags */
2152 &GUID_NULL /* typeid */
2154 { /* 0x36 - CSIDL_COMMON_PICTURES */
2155 &FOLDERID_PublicPictures,
2156 CSIDL_Type_AllUsers,
2157 CommonPicturesW,
2158 PicturesW,
2160 KF_CATEGORY_COMMON, /* category */
2161 CommonPicturesW, /* name */
2162 NULL, /* description */
2163 &FOLDERID_Public, /* parent */
2164 PicturesW, /* relative path */
2165 NULL, /* parsing */
2166 NULL, /* tooltip */
2167 NULL, /* localized */
2168 NULL, /* icon */
2169 NULL, /* security */
2170 FILE_ATTRIBUTE_READONLY, /* attributes */
2171 KFDF_PRECREATE, /* flags */
2172 &GUID_NULL /* typeid */
2174 { /* 0x37 - CSIDL_COMMON_VIDEO */
2175 &FOLDERID_PublicVideos,
2176 CSIDL_Type_AllUsers,
2177 CommonVideoW,
2178 VideosW,
2180 KF_CATEGORY_COMMON, /* category */
2181 CommonVideoW, /* name */
2182 NULL, /* description */
2183 &FOLDERID_Public, /* parent */
2184 VideosW, /* relative path */
2185 NULL, /* parsing */
2186 NULL, /* tooltip */
2187 NULL, /* localized */
2188 NULL, /* icon */
2189 NULL, /* security */
2190 FILE_ATTRIBUTE_READONLY, /* attributes */
2191 KFDF_PRECREATE, /* flags */
2192 &GUID_NULL /* typeid */
2194 { /* 0x38 - CSIDL_RESOURCES */
2195 &FOLDERID_ResourceDir,
2196 CSIDL_Type_WindowsPath,
2197 NULL,
2198 ResourcesW,
2200 KF_CATEGORY_FIXED, /* category */
2201 ResourceDirW, /* name */
2202 NULL, /* description */
2203 &GUID_NULL, /* parent */
2204 NULL, /* relative path */
2205 NULL, /* parsing */
2206 NULL, /* tooltip */
2207 NULL, /* localized */
2208 NULL, /* icon */
2209 NULL, /* security */
2210 0, /* attributes */
2211 0, /* flags */
2212 &GUID_NULL /* typeid */
2214 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2215 &FOLDERID_LocalizedResourcesDir,
2216 CSIDL_Type_NonExistent,
2217 NULL,
2218 NULL,
2220 KF_CATEGORY_FIXED, /* category */
2221 LocalizedResourcesDirW, /* name */
2222 NULL, /* description */
2223 &GUID_NULL, /* parent */
2224 NULL, /* relative path */
2225 NULL, /* parsing */
2226 NULL, /* tooltip */
2227 NULL, /* localized */
2228 NULL, /* icon */
2229 NULL, /* security */
2230 0, /* attributes */
2231 0, /* flags */
2232 &GUID_NULL /* typeid */
2234 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2235 &FOLDERID_CommonOEMLinks,
2236 CSIDL_Type_ProgramData,
2237 NULL,
2238 OEM_LinksW,
2240 KF_CATEGORY_COMMON, /* category */
2241 OEM_LinksW, /* name */
2242 NULL, /* description */
2243 &FOLDERID_ProgramData, /* parent */
2244 OEM_LinksW, /* relative path */
2245 NULL, /* parsing */
2246 NULL, /* tooltip */
2247 NULL, /* localized */
2248 NULL, /* icon */
2249 NULL, /* security */
2250 0, /* attributes */
2251 0, /* flags */
2252 &GUID_NULL /* typeid */
2254 { /* 0x3b - CSIDL_CDBURN_AREA */
2255 &FOLDERID_CDBurning,
2256 CSIDL_Type_User,
2257 CD_BurningW,
2258 Local_Settings_CD_BurningW,
2260 KF_CATEGORY_PERUSER, /* category */
2261 CD_BurningW, /* name */
2262 NULL, /* description */
2263 &FOLDERID_LocalAppData, /* parent */
2264 Microsoft_Windows_Burn_BurnW, /* relative path */
2265 NULL, /* parsing */
2266 NULL, /* tooltip */
2267 NULL, /* localized */
2268 NULL, /* icon */
2269 NULL, /* security */
2270 FILE_ATTRIBUTE_READONLY, /* attributes */
2271 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2272 &GUID_NULL /* typeid */
2274 { /* 0x3c unassigned */
2275 &GUID_NULL,
2276 CSIDL_Type_Disallowed,
2277 NULL,
2278 NULL
2280 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2281 &GUID_NULL,
2282 CSIDL_Type_Disallowed, /* FIXME */
2283 NULL,
2284 NULL
2286 { /* 0x3e - CSIDL_PROFILES */
2287 &GUID_NULL,
2288 CSIDL_Type_Disallowed, /* oddly, this matches WinXP */
2289 NULL,
2290 NULL
2292 { /* 0x3f */
2293 &FOLDERID_AddNewPrograms,
2294 CSIDL_Type_Disallowed,
2295 NULL,
2296 NULL,
2298 KF_CATEGORY_VIRTUAL, /* category */
2299 AddNewProgramsFolderW, /* name */
2300 NULL, /* description */
2301 &GUID_NULL, /* parent */
2302 NULL, /* relative path */
2303 AddNewProgramsParsingNameW, /* parsing */
2304 NULL, /* tooltip */
2305 NULL, /* localized */
2306 NULL, /* icon */
2307 NULL, /* security */
2308 0, /* attributes */
2309 0, /* flags */
2310 &GUID_NULL /* typeid */
2312 { /* 0x40 */
2313 &FOLDERID_AppUpdates,
2314 CSIDL_Type_Disallowed,
2315 NULL,
2316 NULL,
2318 KF_CATEGORY_VIRTUAL, /* category */
2319 AppUpdatesFolderW, /* name */
2320 NULL, /* description */
2321 &GUID_NULL, /* parent */
2322 NULL, /* relative path */
2323 AppUpdatesParsingNameW, /* parsing */
2324 NULL, /* tooltip */
2325 NULL, /* localized */
2326 NULL, /* icon */
2327 NULL, /* security */
2328 0, /* attributes */
2329 0, /* flags */
2330 &GUID_NULL /* typeid */
2332 { /* 0x41 */
2333 &FOLDERID_ChangeRemovePrograms,
2334 CSIDL_Type_Disallowed,
2335 NULL,
2336 NULL,
2338 KF_CATEGORY_VIRTUAL, /* category */
2339 ChangeRemoveProgramsFolderW, /* name */
2340 NULL, /* description */
2341 &GUID_NULL, /* parent */
2342 NULL, /* relative path */
2343 ChangeRemoveProgramsParsingNameW, /* parsing */
2344 NULL, /* tooltip */
2345 NULL, /* localized */
2346 NULL, /* icon */
2347 NULL, /* security */
2348 0, /* attributes */
2349 0, /* flags */
2350 &GUID_NULL /* typeid */
2352 { /* 0x42 */
2353 &FOLDERID_ConflictFolder,
2354 CSIDL_Type_Disallowed,
2355 NULL,
2356 NULL,
2358 KF_CATEGORY_VIRTUAL, /* category */
2359 ConflictFolderW, /* name */
2360 NULL, /* description */
2361 &GUID_NULL, /* parent */
2362 NULL, /* relative path */
2363 ConflictFolderParsingNameW, /* parsing */
2364 NULL, /* tooltip */
2365 NULL, /* localized */
2366 NULL, /* icon */
2367 NULL, /* security */
2368 0, /* attributes */
2369 0, /* flags */
2370 &GUID_NULL /* typeid */
2372 { /* 0x43 - CSIDL_CONTACTS */
2373 &FOLDERID_Contacts,
2374 CSIDL_Type_User,
2375 NULL,
2376 ContactsW,
2378 KF_CATEGORY_PERUSER, /* category */
2379 ContactsW, /* name */
2380 NULL, /* description */
2381 &FOLDERID_Profile, /* parent */
2382 ContactsW, /* relative path */
2383 ContactsParsingNameW, /* parsing */
2384 NULL, /* tooltip */
2385 NULL, /* localized */
2386 NULL, /* icon */
2387 NULL, /* security */
2388 FILE_ATTRIBUTE_READONLY, /* attributes */
2389 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2390 &GUID_NULL /* typeid */
2392 { /* 0x44 */
2393 &FOLDERID_DeviceMetadataStore,
2394 CSIDL_Type_Disallowed, /* FIXME */
2395 NULL,
2396 NULL,
2398 KF_CATEGORY_COMMON, /* category */
2399 Device_Metadata_StoreW, /* name */
2400 NULL, /* description */
2401 &FOLDERID_ProgramData, /* parent */
2402 Microsoft_Windows_DeviceMetadataStoreW, /* relative path */
2403 NULL, /* parsing */
2404 NULL, /* tooltip */
2405 NULL, /* localized */
2406 NULL, /* icon */
2407 NULL, /* security */
2408 0, /* attributes */
2409 0, /* flags */
2410 &GUID_NULL /* typeid */
2412 { /* 0x45 */
2413 &GUID_NULL,
2414 CSIDL_Type_User,
2415 NULL,
2416 DocumentsW
2418 { /* 0x46 */
2419 &FOLDERID_DocumentsLibrary,
2420 CSIDL_Type_Disallowed, /* FIXME */
2421 NULL,
2422 NULL,
2424 KF_CATEGORY_PERUSER, /* category */
2425 DocumentsLibraryW, /* name */
2426 NULL, /* description */
2427 &FOLDERID_Libraries, /* parent */
2428 Documents_librarymsW, /* relative path */
2429 DocumentsLibraryParsingNameW, /* parsing */
2430 NULL, /* tooltip */
2431 NULL, /* localized */
2432 NULL, /* icon */
2433 NULL, /* security */
2434 0, /* attributes */
2435 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2436 &GUID_NULL /* typeid */
2438 { /* 0x47 - CSIDL_DOWNLOADS */
2439 &FOLDERID_Downloads,
2440 CSIDL_Type_User,
2441 NULL,
2442 DownloadsW,
2444 KF_CATEGORY_PERUSER, /* category */
2445 DownloadsW, /* name */
2446 NULL, /* description */
2447 &FOLDERID_Profile, /* parent */
2448 DownloadsW, /* relative path */
2449 NULL, /* parsing */
2450 NULL, /* tooltip */
2451 NULL, /* localized */
2452 NULL, /* icon */
2453 NULL, /* security */
2454 FILE_ATTRIBUTE_READONLY, /* attributes */
2455 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2456 &GUID_NULL /* typeid */
2458 { /* 0x48 */
2459 &FOLDERID_Games,
2460 CSIDL_Type_Disallowed,
2461 NULL,
2462 NULL,
2464 KF_CATEGORY_VIRTUAL, /* category */
2465 GamesW, /* name */
2466 NULL, /* description */
2467 &GUID_NULL, /* parent */
2468 NULL, /* relative path */
2469 GamesParsingNameW, /* parsing */
2470 NULL, /* tooltip */
2471 NULL, /* localized */
2472 NULL, /* icon */
2473 NULL, /* security */
2474 0, /* attributes */
2475 0, /* flags */
2476 &GUID_NULL /* typeid */
2478 { /* 0x49 */
2479 &FOLDERID_GameTasks,
2480 CSIDL_Type_Disallowed, /* FIXME */
2481 NULL,
2482 NULL,
2484 KF_CATEGORY_PERUSER, /* category */
2485 GameTasksW, /* name */
2486 NULL, /* description */
2487 &FOLDERID_LocalAppData, /* parent */
2488 Microsoft_Windows_GameExplorerW, /* relative path */
2489 NULL, /* parsing */
2490 NULL, /* tooltip */
2491 NULL, /* localized */
2492 NULL, /* icon */
2493 NULL, /* security */
2494 0, /* attributes */
2495 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2496 &GUID_NULL /* typeid */
2498 { /* 0x4a */
2499 &FOLDERID_HomeGroup,
2500 CSIDL_Type_Disallowed,
2501 NULL,
2502 NULL,
2504 KF_CATEGORY_VIRTUAL, /* category */
2505 HomeGroupFolderW, /* name */
2506 NULL, /* description */
2507 &GUID_NULL, /* parent */
2508 NULL, /* relative path */
2509 HomeGroupParsingNameW, /* parsing */
2510 NULL, /* tooltip */
2511 NULL, /* localized */
2512 NULL, /* icon */
2513 NULL, /* security */
2514 0, /* attributes */
2515 0, /* flags */
2516 &GUID_NULL /* typeid */
2518 { /* 0x4b */
2519 &FOLDERID_ImplicitAppShortcuts,
2520 CSIDL_Type_Disallowed, /* FIXME */
2521 NULL,
2522 NULL,
2524 KF_CATEGORY_PERUSER, /* category */
2525 ImplicitAppShortcutsW, /* name */
2526 NULL, /* description */
2527 &FOLDERID_UserPinned, /* parent */
2528 ImplicitAppShortcutsW, /* relative path */
2529 NULL, /* parsing */
2530 NULL, /* tooltip */
2531 NULL, /* localized */
2532 NULL, /* icon */
2533 NULL, /* security */
2534 0, /* attributes */
2535 KFDF_PRECREATE, /* flags */
2536 &GUID_NULL /* typeid */
2538 { /* 0x4c */
2539 &FOLDERID_Libraries,
2540 CSIDL_Type_Disallowed, /* FIXME */
2541 NULL,
2542 NULL,
2544 KF_CATEGORY_PERUSER, /* category */
2545 LibrariesW, /* name */
2546 NULL, /* description */
2547 &FOLDERID_RoamingAppData, /* parent */
2548 Microsoft_Windows_LibrariesW, /* relative path */
2549 NULL, /* parsing */
2550 NULL, /* tooltip */
2551 NULL, /* localized */
2552 NULL, /* icon */
2553 NULL, /* security */
2554 0, /* attributes */
2555 KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2556 &GUID_NULL /* typeid */
2558 { /* 0x4d - CSIDL_LINKS */
2559 &FOLDERID_Links,
2560 CSIDL_Type_User,
2561 NULL,
2562 LinksW,
2564 KF_CATEGORY_PERUSER, /* category */
2565 LinksW, /* name */
2566 NULL, /* description */
2567 &FOLDERID_Profile, /* parent */
2568 LinksW, /* relative path */
2569 LinksParsingNameW, /* parsing */
2570 NULL, /* tooltip */
2571 NULL, /* localized */
2572 NULL, /* icon */
2573 NULL, /* security */
2574 FILE_ATTRIBUTE_READONLY, /* attributes */
2575 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2576 &GUID_NULL /* typeid */
2578 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2579 &FOLDERID_LocalAppDataLow,
2580 CSIDL_Type_User,
2581 NULL,
2582 AppData_LocalLowW,
2584 KF_CATEGORY_PERUSER, /* category */
2585 LocalAppDataLowW, /* name */
2586 NULL, /* description */
2587 &FOLDERID_Profile, /* parent */
2588 AppData_LocalLowW, /* relative path */
2589 NULL, /* parsing */
2590 NULL, /* tooltip */
2591 NULL, /* localized */
2592 NULL, /* icon */
2593 NULL, /* security */
2594 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, /* attributes */
2595 KFDF_LOCAL_REDIRECT_ONLY | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2596 &GUID_NULL /* typeid */
2598 { /* 0x4f */
2599 &FOLDERID_MusicLibrary,
2600 CSIDL_Type_Disallowed, /* FIXME */
2601 NULL,
2602 NULL,
2604 KF_CATEGORY_PERUSER, /* category */
2605 MusicLibraryW, /* name */
2606 NULL, /* description */
2607 &FOLDERID_Libraries, /* parent */
2608 Music_librarymsW, /* relative path */
2609 MusicLibraryParsingNameW, /* parsing */
2610 NULL, /* tooltip */
2611 NULL, /* localized */
2612 NULL, /* icon */
2613 NULL, /* security */
2614 0, /* attributes */
2615 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2616 &GUID_NULL /* typeid */
2618 { /* 0x50 */
2619 &FOLDERID_OriginalImages,
2620 CSIDL_Type_Disallowed, /* FIXME */
2621 NULL,
2622 NULL,
2624 KF_CATEGORY_PERUSER, /* category */
2625 Original_ImagesW, /* name */
2626 NULL, /* description */
2627 &FOLDERID_LocalAppData, /* parent */
2628 Microsoft_Windows_Photo_Gallery_Original_ImagesW, /* relative path */
2629 NULL, /* parsing */
2630 NULL, /* tooltip */
2631 NULL, /* localized */
2632 NULL, /* icon */
2633 NULL, /* security */
2634 0, /* attributes */
2635 0, /* flags */
2636 &GUID_NULL /* typeid */
2638 { /* 0x51 */
2639 &FOLDERID_PhotoAlbums,
2640 CSIDL_Type_User,
2641 NULL,
2642 Pictures_Slide_ShowsW,
2644 KF_CATEGORY_PERUSER, /* category */
2645 PhotoAlbumsW, /* name */
2646 NULL, /* description */
2647 &FOLDERID_Pictures, /* parent */
2648 Slide_ShowsW, /* relative path */
2649 NULL, /* parsing */
2650 NULL, /* tooltip */
2651 NULL, /* localized */
2652 NULL, /* icon */
2653 NULL, /* security */
2654 FILE_ATTRIBUTE_READONLY, /* attributes */
2655 0, /* flags */
2656 &GUID_NULL /* typeid */
2658 { /* 0x52 */
2659 &FOLDERID_PicturesLibrary,
2660 CSIDL_Type_Disallowed, /* FIXME */
2661 NULL,
2662 NULL,
2664 KF_CATEGORY_PERUSER, /* category */
2665 PicturesLibraryW, /* name */
2666 NULL, /* description */
2667 &FOLDERID_Libraries, /* parent */
2668 Pictures_librarymsW, /* relative path */
2669 PicturesLibraryParsingNameW, /* parsing */
2670 NULL, /* tooltip */
2671 NULL, /* localized */
2672 NULL, /* icon */
2673 NULL, /* security */
2674 0, /* attributes */
2675 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2676 &GUID_NULL /* typeid */
2678 { /* 0x53 */
2679 &FOLDERID_Playlists,
2680 CSIDL_Type_User,
2681 NULL,
2682 Music_PlaylistsW,
2684 KF_CATEGORY_PERUSER, /* category */
2685 PlaylistsW, /* name */
2686 NULL, /* description */
2687 &FOLDERID_Music, /* parent */
2688 PlaylistsW, /* relative path */
2689 NULL, /* parsing */
2690 NULL, /* tooltip */
2691 NULL, /* localized */
2692 NULL, /* icon */
2693 NULL, /* security */
2694 FILE_ATTRIBUTE_READONLY, /* attributes */
2695 0, /* flags */
2696 &GUID_NULL /* typeid */
2698 { /* 0x54 */
2699 &FOLDERID_ProgramFilesX64,
2700 CSIDL_Type_NonExistent,
2701 NULL,
2702 NULL,
2704 KF_CATEGORY_FIXED, /* category */
2705 ProgramFilesX64W, /* name */
2706 NULL, /* description */
2707 &GUID_NULL, /* parent */
2708 NULL, /* relative path */
2709 NULL, /* parsing */
2710 NULL, /* tooltip */
2711 NULL, /* localized */
2712 NULL, /* icon */
2713 NULL, /* security */
2714 0, /* attributes */
2715 0, /* flags */
2716 &GUID_NULL /* typeid */
2718 { /* 0x55 */
2719 &FOLDERID_ProgramFilesCommonX64,
2720 CSIDL_Type_NonExistent,
2721 NULL,
2722 NULL,
2724 KF_CATEGORY_FIXED, /* category */
2725 ProgramFilesCommonX64W, /* name */
2726 NULL, /* description */
2727 &GUID_NULL, /* parent */
2728 NULL, /* relative path */
2729 NULL, /* parsing */
2730 NULL, /* tooltip */
2731 NULL, /* localized */
2732 NULL, /* icon */
2733 NULL, /* security */
2734 0, /* attributes */
2735 0, /* flags */
2736 &GUID_NULL /* typeid */
2738 { /* 0x56 */
2739 &FOLDERID_Public,
2740 CSIDL_Type_CurrVer, /* FIXME */
2741 NULL,
2742 UsersPublicW,
2744 KF_CATEGORY_FIXED, /* category */
2745 PublicW, /* name */
2746 NULL, /* description */
2747 &GUID_NULL, /* parent */
2748 NULL, /* relative path */
2749 PublicParsingNameW, /* parsing */
2750 NULL, /* tooltip */
2751 NULL, /* localized */
2752 NULL, /* icon */
2753 NULL, /* security */
2754 FILE_ATTRIBUTE_READONLY, /* attributes */
2755 KFDF_PRECREATE, /* flags */
2756 &GUID_NULL /* typeid */
2758 { /* 0x57 */
2759 &FOLDERID_PublicDownloads,
2760 CSIDL_Type_AllUsers,
2761 NULL,
2762 DownloadsW,
2764 KF_CATEGORY_COMMON, /* category */
2765 CommonDownloadsW, /* name */
2766 NULL, /* description */
2767 &FOLDERID_Public, /* parent */
2768 DownloadsW, /* relative path */
2769 NULL, /* parsing */
2770 NULL, /* tooltip */
2771 NULL, /* localized */
2772 NULL, /* icon */
2773 NULL, /* security */
2774 FILE_ATTRIBUTE_READONLY, /* attributes */
2775 KFDF_PRECREATE, /* flags */
2776 &GUID_NULL /* typeid */
2778 { /* 0x58 */
2779 &FOLDERID_PublicGameTasks,
2780 CSIDL_Type_ProgramData,
2781 NULL,
2782 Microsoft_Windows_GameExplorerW,
2784 KF_CATEGORY_COMMON, /* category */
2785 PublicGameTasksW, /* name */
2786 NULL, /* description */
2787 &FOLDERID_ProgramData, /* parent */
2788 Microsoft_Windows_GameExplorerW, /* relative path */
2789 NULL, /* parsing */
2790 NULL, /* tooltip */
2791 NULL, /* localized */
2792 NULL, /* icon */
2793 NULL, /* security */
2794 0, /* attributes */
2795 KFDF_LOCAL_REDIRECT_ONLY, /* flags */
2796 &GUID_NULL /* typeid */
2798 { /* 0x59 */
2799 &FOLDERID_PublicLibraries,
2800 CSIDL_Type_AllUsers,
2801 NULL,
2802 Microsoft_Windows_LibrariesW,
2804 KF_CATEGORY_COMMON, /* category */
2805 PublicLibrariesW, /* name */
2806 NULL, /* description */
2807 &FOLDERID_Public, /* parent */
2808 LibrariesW, /* relative path */
2809 NULL, /* parsing */
2810 NULL, /* tooltip */
2811 NULL, /* localized */
2812 NULL, /* icon */
2813 NULL, /* security */
2814 FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN, /* attributes */
2815 KFDF_PRECREATE, /* flags */
2816 &GUID_NULL /* typeid */
2818 { /* 0x5a */
2819 &FOLDERID_PublicRingtones,
2820 CSIDL_Type_ProgramData,
2821 NULL,
2822 Microsoft_Windows_RingtonesW,
2824 KF_CATEGORY_COMMON, /* category */
2825 CommonRingtonesW, /* name */
2826 NULL, /* description */
2827 &FOLDERID_ProgramData, /* parent */
2828 Microsoft_Windows_RingtonesW, /* relative path */
2829 NULL, /* parsing */
2830 NULL, /* tooltip */
2831 NULL, /* localized */
2832 NULL, /* icon */
2833 NULL, /* security */
2834 0, /* attributes */
2835 KFDF_PRECREATE, /* flags */
2836 &GUID_NULL /* typeid */
2838 { /* 0x5b */
2839 &FOLDERID_QuickLaunch,
2840 CSIDL_Type_Disallowed, /* FIXME */
2841 NULL,
2842 NULL,
2844 KF_CATEGORY_PERUSER, /* category */
2845 Quick_LaunchW, /* name */
2846 NULL, /* description */
2847 &FOLDERID_RoamingAppData, /* parent */
2848 Microsoft_Internet_Explorer_Quick_LaunchW, /* relative path */
2849 NULL, /* parsing */
2850 NULL, /* tooltip */
2851 NULL, /* localized */
2852 NULL, /* icon */
2853 NULL, /* security */
2854 0, /* attributes */
2855 0, /* flags */
2856 &GUID_NULL /* typeid */
2858 { /* 0x5c */
2859 &FOLDERID_RecordedTVLibrary,
2860 CSIDL_Type_Disallowed, /* FIXME */
2861 NULL,
2862 NULL,
2864 KF_CATEGORY_COMMON, /* category */
2865 RecordedTVLibraryW, /* name */
2866 NULL, /* description */
2867 &FOLDERID_PublicLibraries, /* parent */
2868 RecordedTV_librarymsW, /* relative path */
2869 NULL, /* parsing */
2870 NULL, /* tooltip */
2871 NULL, /* localized */
2872 NULL, /* icon */
2873 NULL, /* security */
2874 0, /* attributes */
2875 KFDF_PRECREATE | KFDF_STREAM, /* flags */
2876 &GUID_NULL /* typeid */
2878 { /* 0x5d */
2879 &FOLDERID_Ringtones,
2880 CSIDL_Type_Disallowed, /* FIXME */
2881 NULL,
2882 NULL,
2884 KF_CATEGORY_PERUSER, /* category */
2885 RingtonesW, /* name */
2886 NULL, /* description */
2887 &FOLDERID_LocalAppData, /* parent */
2888 Microsoft_Windows_RingtonesW, /* relative path */
2889 NULL, /* parsing */
2890 NULL, /* tooltip */
2891 NULL, /* localized */
2892 NULL, /* icon */
2893 NULL, /* security */
2894 0, /* attributes */
2895 KFDF_PRECREATE, /* flags */
2896 &GUID_NULL /* typeid */
2898 { /* 0x5e */
2899 &FOLDERID_SampleMusic,
2900 CSIDL_Type_AllUsers,
2901 NULL,
2902 Music_Sample_MusicW,
2904 KF_CATEGORY_COMMON, /* category */
2905 SampleMusicW, /* name */
2906 NULL, /* description */
2907 &FOLDERID_PublicMusic, /* parent */
2908 Sample_MusicW, /* relative path */
2909 NULL, /* parsing */
2910 NULL, /* tooltip */
2911 NULL, /* localized */
2912 NULL, /* icon */
2913 NULL, /* security */
2914 FILE_ATTRIBUTE_READONLY, /* attributes */
2915 KFDF_PRECREATE, /* flags */
2916 &GUID_NULL /* typeid */
2918 { /* 0x5f */
2919 &FOLDERID_SamplePictures,
2920 CSIDL_Type_AllUsers,
2921 NULL,
2922 Pictures_Sample_PicturesW,
2924 KF_CATEGORY_COMMON, /* category */
2925 SamplePicturesW, /* name */
2926 NULL, /* description */
2927 &FOLDERID_PublicPictures, /* parent */
2928 Sample_PicturesW, /* relative path */
2929 NULL, /* parsing */
2930 NULL, /* tooltip */
2931 NULL, /* localized */
2932 NULL, /* icon */
2933 NULL, /* security */
2934 FILE_ATTRIBUTE_READONLY, /* attributes */
2935 KFDF_PRECREATE, /* flags */
2936 &GUID_NULL /* typeid */
2938 { /* 0x60 */
2939 &FOLDERID_SamplePlaylists,
2940 CSIDL_Type_AllUsers,
2941 NULL,
2942 Music_Sample_PlaylistsW,
2944 KF_CATEGORY_COMMON, /* category */
2945 SamplePlaylistsW, /* name */
2946 NULL, /* description */
2947 &FOLDERID_PublicMusic, /* parent */
2948 Sample_PlaylistsW, /* relative path */
2949 NULL, /* parsing */
2950 NULL, /* tooltip */
2951 NULL, /* localized */
2952 NULL, /* icon */
2953 NULL, /* security */
2954 FILE_ATTRIBUTE_READONLY, /* attributes */
2955 KFDF_PRECREATE, /* flags */
2956 &GUID_NULL /* typeid */
2958 { /* 0x61 */
2959 &FOLDERID_SampleVideos,
2960 CSIDL_Type_AllUsers,
2961 NULL,
2962 Videos_Sample_VideosW,
2964 KF_CATEGORY_COMMON, /* category */
2965 SampleVideosW, /* name */
2966 NULL, /* description */
2967 &FOLDERID_PublicVideos, /* parent */
2968 Sample_VideosW, /* relative path */
2969 NULL, /* parsing */
2970 NULL, /* tooltip */
2971 NULL, /* localized */
2972 NULL, /* icon */
2973 NULL, /* security */
2974 FILE_ATTRIBUTE_READONLY, /* attributes */
2975 KFDF_PRECREATE, /* flags */
2976 &GUID_NULL /* typeid */
2978 { /* 0x62 - CSIDL_SAVED_GAMES */
2979 &FOLDERID_SavedGames,
2980 CSIDL_Type_User,
2981 NULL,
2982 Saved_GamesW,
2984 KF_CATEGORY_PERUSER, /* category */
2985 SavedGamesW, /* name */
2986 NULL, /* description */
2987 &FOLDERID_Profile, /* parent */
2988 Saved_GamesW, /* relative path */
2989 SavedGamesParsingNameW, /* parsing */
2990 NULL, /* tooltip */
2991 NULL, /* localized */
2992 NULL, /* icon */
2993 NULL, /* security */
2994 FILE_ATTRIBUTE_READONLY, /* attributes */
2995 KFDF_ROAMABLE | KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
2996 &GUID_NULL /* typeid */
2998 { /* 0x63 - CSIDL_SEARCHES */
2999 &FOLDERID_SavedSearches,
3000 CSIDL_Type_User,
3001 NULL,
3002 SearchesW,
3004 KF_CATEGORY_PERUSER, /* category */
3005 SearchesW, /* name */
3006 NULL, /* description */
3007 &FOLDERID_Profile, /* parent */
3008 SearchesW, /* relative path */
3009 SavedSearchesParsingNameW, /* parsing */
3010 NULL, /* tooltip */
3011 NULL, /* localized */
3012 NULL, /* icon */
3013 NULL, /* security */
3014 FILE_ATTRIBUTE_READONLY, /* attributes */
3015 KFDF_PRECREATE | KFDF_PUBLISHEXPANDEDPATH, /* flags */
3016 &GUID_NULL /* typeid */
3018 { /* 0x64 */
3019 &FOLDERID_SEARCH_CSC,
3020 CSIDL_Type_Disallowed,
3021 NULL,
3022 NULL,
3024 KF_CATEGORY_VIRTUAL, /* category */
3025 CSCFolderW, /* name */
3026 NULL, /* description */
3027 &GUID_NULL, /* parent */
3028 NULL, /* relative path */
3029 SEARCH_CSCParsingNameW, /* parsing */
3030 NULL, /* tooltip */
3031 NULL, /* localized */
3032 NULL, /* icon */
3033 NULL, /* security */
3034 0, /* attributes */
3035 0, /* flags */
3036 &GUID_NULL /* typeid */
3038 { /* 0x65 */
3039 &FOLDERID_SEARCH_MAPI,
3040 CSIDL_Type_Disallowed,
3041 NULL,
3042 NULL,
3044 KF_CATEGORY_VIRTUAL, /* category */
3045 MAPIFolderW, /* name */
3046 NULL, /* description */
3047 &GUID_NULL, /* parent */
3048 NULL, /* relative path */
3049 SEARCH_MAPIParsingNameW, /* parsing */
3050 NULL, /* tooltip */
3051 NULL, /* localized */
3052 NULL, /* icon */
3053 NULL, /* security */
3054 0, /* attributes */
3055 0, /* flags */
3056 &GUID_NULL /* typeid */
3058 { /* 0x66 */
3059 &FOLDERID_SearchHome,
3060 CSIDL_Type_Disallowed,
3061 NULL,
3062 NULL,
3064 KF_CATEGORY_VIRTUAL, /* category */
3065 SearchHomeFolderW, /* name */
3066 NULL, /* description */
3067 &GUID_NULL, /* parent */
3068 NULL, /* relative path */
3069 SearchHomeParsingNameW, /* parsing */
3070 NULL, /* tooltip */
3071 NULL, /* localized */
3072 NULL, /* icon */
3073 NULL, /* security */
3074 0, /* attributes */
3075 0, /* flags */
3076 &GUID_NULL /* typeid */
3078 { /* 0x67 */
3079 &FOLDERID_SidebarDefaultParts,
3080 CSIDL_Type_Disallowed, /* FIXME */
3081 NULL,
3082 NULL,
3084 KF_CATEGORY_COMMON, /* category */
3085 Default_GadgetsW, /* name */
3086 NULL, /* description */
3087 &FOLDERID_ProgramFiles, /* parent */
3088 Windows_Sidebar_GadgetsW, /* relative path */
3089 NULL, /* parsing */
3090 NULL, /* tooltip */
3091 NULL, /* localized */
3092 NULL, /* icon */
3093 NULL, /* security */
3094 0, /* attributes */
3095 0, /* flags */
3096 &GUID_NULL /* typeid */
3098 { /* 0x68 */
3099 &FOLDERID_SidebarParts,
3100 CSIDL_Type_Disallowed, /* FIXME */
3101 NULL,
3102 NULL,
3104 KF_CATEGORY_PERUSER, /* category */
3105 GadgetsW, /* name */
3106 NULL, /* description */
3107 &FOLDERID_LocalAppData, /* parent */
3108 Microsoft_Windows_Sidebar_GadgetsW, /* relative path */
3109 NULL, /* parsing */
3110 NULL, /* tooltip */
3111 NULL, /* localized */
3112 NULL, /* icon */
3113 NULL, /* security */
3114 0, /* attributes */
3115 0, /* flags */
3116 &GUID_NULL /* typeid */
3118 { /* 0x69 */
3119 &FOLDERID_SyncManagerFolder,
3120 CSIDL_Type_Disallowed,
3121 NULL,
3122 NULL,
3124 KF_CATEGORY_VIRTUAL, /* category */
3125 SyncCenterFolderW, /* name */
3126 NULL, /* description */
3127 &GUID_NULL, /* parent */
3128 NULL, /* relative path */
3129 SyncManagerFolderParsingNameW, /* parsing */
3130 NULL, /* tooltip */
3131 NULL, /* localized */
3132 NULL, /* icon */
3133 NULL, /* security */
3134 0, /* attributes */
3135 0, /* flags */
3136 &GUID_NULL /* typeid */
3138 { /* 0x6a */
3139 &FOLDERID_SyncResultsFolder,
3140 CSIDL_Type_Disallowed,
3141 NULL,
3142 NULL,
3144 KF_CATEGORY_VIRTUAL, /* category */
3145 SyncResultsFolderW, /* name */
3146 NULL, /* description */
3147 &GUID_NULL, /* parent */
3148 NULL, /* relative path */
3149 SyncResultsFolderParsingNameW, /* parsing */
3150 NULL, /* tooltip */
3151 NULL, /* localized */
3152 NULL, /* icon */
3153 NULL, /* security */
3154 0, /* attributes */
3155 0, /* flags */
3156 &GUID_NULL /* typeid */
3158 { /* 0x6b */
3159 &FOLDERID_SyncSetupFolder,
3160 CSIDL_Type_Disallowed,
3161 NULL,
3162 NULL,
3164 KF_CATEGORY_VIRTUAL, /* category */
3165 SyncSetupFolderW, /* name */
3166 NULL, /* description */
3167 &GUID_NULL, /* parent */
3168 NULL, /* relative path */
3169 SyncSetupFolderParsingNameW, /* parsing */
3170 NULL, /* tooltip */
3171 NULL, /* localized */
3172 NULL, /* icon */
3173 NULL, /* security */
3174 0, /* attributes */
3175 0, /* flags */
3176 &GUID_NULL /* typeid */
3178 { /* 0x6c */
3179 &FOLDERID_UserPinned,
3180 CSIDL_Type_Disallowed, /* FIXME */
3181 NULL,
3182 NULL,
3184 KF_CATEGORY_PERUSER, /* category */
3185 User_PinnedW, /* name */
3186 NULL, /* description */
3187 &FOLDERID_QuickLaunch, /* parent */
3188 User_PinnedW, /* relative path */
3189 NULL, /* parsing */
3190 NULL, /* tooltip */
3191 NULL, /* localized */
3192 NULL, /* icon */
3193 NULL, /* security */
3194 FILE_ATTRIBUTE_HIDDEN, /* attributes */
3195 KFDF_PRECREATE, /* flags */
3196 &GUID_NULL /* typeid */
3198 { /* 0x6d */
3199 &FOLDERID_UserProfiles,
3200 CSIDL_Type_CurrVer,
3201 UsersW,
3202 UsersW,
3204 KF_CATEGORY_FIXED, /* category */
3205 UserProfilesW, /* name */
3206 NULL, /* description */
3207 &GUID_NULL, /* parent */
3208 NULL, /* relative path */
3209 NULL, /* parsing */
3210 NULL, /* tooltip */
3211 NULL, /* localized */
3212 NULL, /* icon */
3213 NULL, /* security */
3214 FILE_ATTRIBUTE_READONLY, /* attributes */
3215 KFDF_PRECREATE, /* flags */
3216 &GUID_NULL /* typeid */
3218 { /* 0x6e */
3219 &FOLDERID_UserProgramFiles,
3220 CSIDL_Type_Disallowed, /* FIXME */
3221 NULL,
3222 NULL,
3224 KF_CATEGORY_PERUSER, /* category */
3225 UserProgramFilesW, /* name */
3226 NULL, /* description */
3227 &FOLDERID_LocalAppData, /* parent */
3228 ProgramsW, /* relative path */
3229 NULL, /* parsing */
3230 NULL, /* tooltip */
3231 NULL, /* localized */
3232 NULL, /* icon */
3233 NULL, /* security */
3234 0, /* attributes */
3235 0, /* flags */
3236 &GUID_NULL /* typeid */
3238 { /* 0x6f */
3239 &FOLDERID_UserProgramFilesCommon,
3240 CSIDL_Type_Disallowed, /* FIXME */
3241 NULL,
3242 NULL,
3244 KF_CATEGORY_PERUSER, /* category */
3245 UserProgramFilesCommonW, /* name */
3246 NULL, /* description */
3247 &FOLDERID_UserProgramFiles, /* parent */
3248 CommonW, /* relative path */
3249 NULL, /* parsing */
3250 NULL, /* tooltip */
3251 NULL, /* localized */
3252 NULL, /* icon */
3253 NULL, /* security */
3254 0, /* attributes */
3255 0, /* flags */
3256 &GUID_NULL /* typeid */
3258 { /* 0x70 */
3259 &FOLDERID_UsersFiles,
3260 CSIDL_Type_Disallowed,
3261 NULL,
3262 NULL,
3264 KF_CATEGORY_VIRTUAL, /* category */
3265 UsersFilesFolderW, /* name */
3266 NULL, /* description */
3267 &GUID_NULL, /* parent */
3268 NULL, /* relative path */
3269 UsersFilesParsingNameW, /* parsing */
3270 NULL, /* tooltip */
3271 NULL, /* localized */
3272 NULL, /* icon */
3273 NULL, /* security */
3274 0, /* attributes */
3275 0, /* flags */
3276 &GUID_NULL /* typeid */
3278 { /* 0x71 */
3279 &FOLDERID_UsersLibraries,
3280 CSIDL_Type_Disallowed,
3281 NULL,
3282 NULL,
3284 KF_CATEGORY_VIRTUAL, /* category */
3285 UsersLibrariesFolderW, /* name */
3286 NULL, /* description */
3287 &GUID_NULL, /* parent */
3288 NULL, /* relative path */
3289 UsersLibrariesParsingNameW, /* parsing */
3290 NULL, /* tooltip */
3291 NULL, /* localized */
3292 NULL, /* icon */
3293 NULL, /* security */
3294 0, /* attributes */
3295 0, /* flags */
3296 &GUID_NULL /* typeid */
3298 { /* 0x72 */
3299 &FOLDERID_VideosLibrary,
3300 CSIDL_Type_Disallowed, /* FIXME */
3301 NULL,
3302 NULL,
3304 KF_CATEGORY_PERUSER, /* category */
3305 VideosLibraryW, /* name */
3306 NULL, /* description */
3307 &GUID_NULL, /* parent */
3308 Videos_librarymsW, /* relative path */
3309 VideosLibraryParsingNameW, /* parsing */
3310 NULL, /* tooltip */
3311 NULL, /* localized */
3312 NULL, /* icon */
3313 NULL, /* security */
3314 0, /* attributes */
3315 0, /* flags */
3316 &GUID_NULL /* typeid */
3320 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest);
3322 /* Gets the value named value from the registry key
3323 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3324 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3325 * is assumed to be MAX_PATH WCHARs in length.
3326 * If it exists, expands the value and writes the expanded value to
3327 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3328 * Returns successful error code if the value was retrieved from the registry,
3329 * and a failure otherwise.
3331 static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
3332 LPCWSTR value, LPWSTR path)
3334 HRESULT hr;
3335 WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
3336 LPCWSTR pShellFolderPath, pUserShellFolderPath;
3337 HKEY userShellFolderKey, shellFolderKey;
3338 DWORD dwType, dwPathLen;
3340 TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
3341 path);
3343 if (userPrefix)
3345 strcpyW(shellFolderPath, userPrefix);
3346 PathAddBackslashW(shellFolderPath);
3347 strcatW(shellFolderPath, szSHFolders);
3348 pShellFolderPath = shellFolderPath;
3349 strcpyW(userShellFolderPath, userPrefix);
3350 PathAddBackslashW(userShellFolderPath);
3351 strcatW(userShellFolderPath, szSHUserFolders);
3352 pUserShellFolderPath = userShellFolderPath;
3354 else
3356 pUserShellFolderPath = szSHUserFolders;
3357 pShellFolderPath = szSHFolders;
3360 if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
3362 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
3363 return E_FAIL;
3365 if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
3367 TRACE("Failed to create %s\n",
3368 debugstr_w(pUserShellFolderPath));
3369 RegCloseKey(shellFolderKey);
3370 return E_FAIL;
3373 dwPathLen = MAX_PATH * sizeof(WCHAR);
3374 if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
3375 (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
3377 LONG ret;
3379 path[dwPathLen / sizeof(WCHAR)] = '\0';
3380 if (dwType == REG_EXPAND_SZ && path[0] == '%')
3382 WCHAR szTemp[MAX_PATH];
3384 _SHExpandEnvironmentStrings(path, szTemp);
3385 lstrcpynW(path, szTemp, MAX_PATH);
3387 ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
3388 (strlenW(path) + 1) * sizeof(WCHAR));
3389 if (ret != ERROR_SUCCESS)
3390 hr = HRESULT_FROM_WIN32(ret);
3391 else
3392 hr = S_OK;
3394 else
3395 hr = E_FAIL;
3396 RegCloseKey(shellFolderKey);
3397 RegCloseKey(userShellFolderKey);
3398 TRACE("returning 0x%08x\n", hr);
3399 return hr;
3402 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3403 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3404 * - The entry's szDefaultPath may be either a string value or an integer
3405 * resource identifier. In the latter case, the string value of the resource
3406 * is written.
3407 * - Depending on the entry's type, the path may begin with an (unexpanded)
3408 * environment variable name. The caller is responsible for expanding
3409 * environment strings if so desired.
3410 * The types that are prepended with environment variables are:
3411 * CSIDL_Type_User: %USERPROFILE%
3412 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3413 * CSIDL_Type_CurrVer: %SystemDrive%
3414 * (Others might make sense too, but as yet are unneeded.)
3416 static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
3418 HRESULT hr;
3419 WCHAR resourcePath[MAX_PATH];
3420 LPCWSTR pDefaultPath = NULL;
3422 TRACE("0x%02x,%p\n", folder, pszPath);
3424 if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
3425 return E_INVALIDARG;
3426 if (!pszPath)
3427 return E_INVALIDARG;
3429 if (!is_win64)
3431 BOOL is_wow64;
3433 switch (folder)
3435 case CSIDL_PROGRAM_FILES:
3436 case CSIDL_PROGRAM_FILESX86:
3437 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3438 folder = is_wow64 ? CSIDL_PROGRAM_FILESX86 : CSIDL_PROGRAM_FILES;
3439 break;
3440 case CSIDL_PROGRAM_FILES_COMMON:
3441 case CSIDL_PROGRAM_FILES_COMMONX86:
3442 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3443 folder = is_wow64 ? CSIDL_PROGRAM_FILES_COMMONX86 : CSIDL_PROGRAM_FILES_COMMON;
3444 break;
3448 if (CSIDL_Data[folder].szDefaultPath &&
3449 IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
3451 if (LoadStringW(shell32_hInstance,
3452 LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
3454 hr = S_OK;
3455 pDefaultPath = resourcePath;
3457 else
3459 FIXME("(%d,%s), LoadString failed, missing translation?\n", folder,
3460 debugstr_w(pszPath));
3461 hr = E_FAIL;
3464 else
3466 hr = S_OK;
3467 pDefaultPath = CSIDL_Data[folder].szDefaultPath;
3469 if (SUCCEEDED(hr))
3471 switch (CSIDL_Data[folder].type)
3473 case CSIDL_Type_User:
3474 strcpyW(pszPath, UserProfileW);
3475 break;
3476 case CSIDL_Type_AllUsers:
3477 strcpyW(pszPath, AllUsersProfileW);
3478 break;
3479 case CSIDL_Type_ProgramData:
3480 strcpyW(pszPath, ProgramDataVarW);
3481 break;
3482 case CSIDL_Type_CurrVer:
3483 strcpyW(pszPath, SystemDriveW);
3484 break;
3485 default:
3486 ; /* no corresponding env. var, do nothing */
3488 if (pDefaultPath)
3490 PathAddBackslashW(pszPath);
3491 strcatW(pszPath, pDefaultPath);
3494 TRACE("returning 0x%08x\n", hr);
3495 return hr;
3498 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3499 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3500 * can be overridden in the HKLM\\szCurrentVersion key.
3501 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3502 * the registry, uses _SHGetDefaultValue to get the value.
3504 static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder,
3505 LPWSTR pszPath)
3507 HRESULT hr;
3509 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
3511 if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
3512 return E_INVALIDARG;
3513 if (CSIDL_Data[folder].type != CSIDL_Type_CurrVer)
3514 return E_INVALIDARG;
3515 if (!pszPath)
3516 return E_INVALIDARG;
3518 if (dwFlags & SHGFP_TYPE_DEFAULT)
3519 hr = _SHGetDefaultValue(folder, pszPath);
3520 else
3522 HKEY hKey;
3524 if (RegCreateKeyW(HKEY_LOCAL_MACHINE, szCurrentVersion, &hKey))
3525 hr = E_FAIL;
3526 else
3528 DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
3530 if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
3531 &dwType, (LPBYTE)pszPath, &dwPathLen) ||
3532 (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
3534 hr = _SHGetDefaultValue(folder, pszPath);
3535 dwType = REG_EXPAND_SZ;
3536 switch (folder)
3538 case CSIDL_PROGRAM_FILESX86:
3539 case CSIDL_PROGRAM_FILES_COMMONX86:
3540 /* these two should never be set on 32-bit setups */
3541 if (!is_win64)
3543 BOOL is_wow64;
3544 IsWow64Process( GetCurrentProcess(), &is_wow64 );
3545 if (!is_wow64) break;
3547 /* fall through */
3548 default:
3549 RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
3550 (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
3553 else
3555 pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
3556 hr = S_OK;
3558 RegCloseKey(hKey);
3561 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3562 return hr;
3565 static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
3567 char InfoBuffer[64];
3568 PTOKEN_USER UserInfo;
3569 DWORD InfoSize;
3570 LPWSTR SidStr;
3572 UserInfo = (PTOKEN_USER) InfoBuffer;
3573 if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
3574 &InfoSize))
3576 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
3577 return NULL;
3578 UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
3579 if (UserInfo == NULL)
3580 return NULL;
3581 if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
3582 &InfoSize))
3584 HeapFree(GetProcessHeap(), 0, UserInfo);
3585 return NULL;
3589 if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
3590 SidStr = NULL;
3592 if (UserInfo != (PTOKEN_USER) InfoBuffer)
3593 HeapFree(GetProcessHeap(), 0, UserInfo);
3595 return SidStr;
3598 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3599 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3600 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3601 * - if hToken is -1, looks in HKEY_USERS\.Default
3602 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3603 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3604 * calls _SHGetDefaultValue for it.
3606 static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder,
3607 LPWSTR pszPath)
3609 const WCHAR *szValueName;
3610 WCHAR buffer[40];
3611 HRESULT hr;
3613 TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
3615 if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
3616 return E_INVALIDARG;
3617 if (CSIDL_Data[folder].type != CSIDL_Type_User)
3618 return E_INVALIDARG;
3619 if (!pszPath)
3620 return E_INVALIDARG;
3622 if (dwFlags & SHGFP_TYPE_DEFAULT)
3624 if (hToken != NULL && hToken != (HANDLE)-1)
3626 FIXME("unsupported for user other than current or default\n");
3627 return E_FAIL;
3629 hr = _SHGetDefaultValue(folder, pszPath);
3631 else
3633 LPCWSTR userPrefix = NULL;
3634 HKEY hRootKey;
3636 if (hToken == (HANDLE)-1)
3638 hRootKey = HKEY_USERS;
3639 userPrefix = DefaultW;
3641 else if (hToken == NULL)
3642 hRootKey = HKEY_CURRENT_USER;
3643 else
3645 hRootKey = HKEY_USERS;
3646 userPrefix = _GetUserSidStringFromToken(hToken);
3647 if (userPrefix == NULL)
3649 hr = E_FAIL;
3650 goto error;
3654 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3655 szValueName = CSIDL_Data[folder].szValueName;
3656 if (!szValueName)
3658 StringFromGUID2( CSIDL_Data[folder].id, buffer, 39 );
3659 szValueName = &buffer[0];
3662 hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
3663 if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
3664 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
3665 if (FAILED(hr))
3666 hr = _SHGetDefaultValue(folder, pszPath);
3667 if (userPrefix != NULL && userPrefix != DefaultW)
3668 LocalFree((HLOCAL) userPrefix);
3670 error:
3671 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3672 return hr;
3675 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3676 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3677 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3678 * If this fails, falls back to _SHGetDefaultValue.
3680 static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder,
3681 LPWSTR pszPath)
3683 HRESULT hr;
3685 TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
3687 if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
3688 return E_INVALIDARG;
3689 if (CSIDL_Data[folder].type != CSIDL_Type_AllUsers && CSIDL_Data[folder].type != CSIDL_Type_ProgramData)
3690 return E_INVALIDARG;
3691 if (!pszPath)
3692 return E_INVALIDARG;
3694 if (dwFlags & SHGFP_TYPE_DEFAULT)
3695 hr = _SHGetDefaultValue(folder, pszPath);
3696 else
3698 hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL,
3699 CSIDL_Data[folder].szValueName, pszPath);
3700 if (FAILED(hr))
3701 hr = _SHGetDefaultValue(folder, pszPath);
3703 TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
3704 return hr;
3707 static HRESULT _SHOpenProfilesKey(PHKEY pKey)
3709 LONG lRet;
3710 DWORD disp;
3712 lRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ProfileListW, 0, NULL, 0,
3713 KEY_ALL_ACCESS, NULL, pKey, &disp);
3714 return HRESULT_FROM_WIN32(lRet);
3717 /* Reads the value named szValueName from the key profilesKey (assumed to be
3718 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3719 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3720 * szDefault to the registry).
3722 static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName,
3723 LPWSTR szValue, LPCWSTR szDefault)
3725 HRESULT hr;
3726 DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
3727 LONG lRet;
3729 TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
3730 debugstr_w(szDefault));
3731 lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
3732 (LPBYTE)szValue, &dwPathLen);
3733 if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
3734 && *szValue)
3736 dwPathLen /= sizeof(WCHAR);
3737 szValue[dwPathLen] = '\0';
3738 hr = S_OK;
3740 else
3742 /* Missing or invalid value, set a default */
3743 lstrcpynW(szValue, szDefault, MAX_PATH);
3744 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
3745 debugstr_w(szValue));
3746 lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
3747 (LPBYTE)szValue,
3748 (strlenW(szValue) + 1) * sizeof(WCHAR));
3749 if (lRet)
3750 hr = HRESULT_FROM_WIN32(lRet);
3751 else
3752 hr = S_OK;
3754 TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
3755 return hr;
3758 /* Attempts to expand environment variables from szSrc into szDest, which is
3759 * assumed to be MAX_PATH characters in length. Before referring to the
3760 * environment, handles a few variables directly, because the environment
3761 * variables may not be set when this is called (as during Wine's installation
3762 * when default values are being written to the registry).
3763 * The directly handled environment variables, and their source, are:
3764 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3765 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3766 * path
3767 * If one of the directly handled environment variables is expanded, only
3768 * expands a single variable, and only in the beginning of szSrc.
3770 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
3772 HRESULT hr;
3773 WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
3774 HKEY key = NULL;
3776 TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
3778 if (!szSrc || !szDest) return E_INVALIDARG;
3780 /* short-circuit if there's nothing to expand */
3781 if (szSrc[0] != '%')
3783 strcpyW(szDest, szSrc);
3784 hr = S_OK;
3785 goto end;
3787 /* Get the profile prefix, we'll probably be needing it */
3788 hr = _SHOpenProfilesKey(&key);
3789 if (SUCCEEDED(hr))
3791 WCHAR def_val[MAX_PATH];
3793 /* get the system drive */
3794 GetSystemDirectoryW(def_val, MAX_PATH);
3795 if (def_val[1] == ':') strcpyW( def_val + 3, szDefaultProfileDirW );
3796 else FIXME("non-drive system paths unsupported\n");
3798 hr = _SHGetProfilesValue(key, ProfilesDirectoryW, szProfilesPrefix, def_val );
3801 *szDest = 0;
3802 strcpyW(szTemp, szSrc);
3803 while (SUCCEEDED(hr) && szTemp[0] == '%')
3805 if (!strncmpiW(szTemp, AllUsersProfileW, strlenW(AllUsersProfileW)))
3807 WCHAR szAllUsers[MAX_PATH];
3809 strcpyW(szDest, szProfilesPrefix);
3810 hr = _SHGetProfilesValue(key, AllUsersProfileValueW,
3811 szAllUsers, AllUsersW);
3812 PathAppendW(szDest, szAllUsers);
3813 PathAppendW(szDest, szTemp + strlenW(AllUsersProfileW));
3815 else if (!strncmpiW(szTemp, ProgramDataVarW, strlenW(ProgramDataVarW)))
3817 WCHAR szProgramData[MAX_PATH], def_val[MAX_PATH];
3818 HKEY shellFolderKey;
3819 DWORD dwType, dwPathLen = sizeof(def_val);
3820 BOOL in_registry = FALSE;
3822 if (!RegCreateKeyW(HKEY_LOCAL_MACHINE, szSHFolders, &shellFolderKey))
3824 if (!RegQueryValueExW(shellFolderKey, Common_AppDataW, NULL, &dwType,
3825 (LPBYTE)def_val, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
3826 in_registry = TRUE;
3828 RegCloseKey(shellFolderKey);
3831 if (!in_registry)
3833 GetSystemDirectoryW(def_val, MAX_PATH);
3834 if (def_val[1] == ':') strcpyW( def_val + 3, ProgramDataW );
3835 else FIXME("non-drive system paths unsupported\n");
3838 hr = _SHGetProfilesValue(key, ProgramDataW, szProgramData, def_val);
3839 PathAppendW(szDest, szProgramData);
3840 PathAppendW(szDest, szTemp + strlenW(ProgramDataVarW));
3842 else if (!strncmpiW(szTemp, UserProfileW, strlenW(UserProfileW)))
3844 WCHAR userName[MAX_PATH];
3845 DWORD userLen = MAX_PATH;
3847 strcpyW(szDest, szProfilesPrefix);
3848 GetUserNameW(userName, &userLen);
3849 PathAppendW(szDest, userName);
3850 PathAppendW(szDest, szTemp + strlenW(UserProfileW));
3852 else if (!strncmpiW(szTemp, SystemDriveW, strlenW(SystemDriveW)))
3854 GetSystemDirectoryW(szDest, MAX_PATH);
3855 if (szDest[1] != ':')
3857 FIXME("non-drive system paths unsupported\n");
3858 hr = E_FAIL;
3860 else
3862 strcpyW(szDest + 3, szTemp + strlenW(SystemDriveW) + 1);
3863 hr = S_OK;
3866 else
3868 DWORD ret = ExpandEnvironmentStringsW(szSrc, szDest, MAX_PATH);
3870 if (ret > MAX_PATH)
3871 hr = E_NOT_SUFFICIENT_BUFFER;
3872 else if (ret == 0)
3873 hr = HRESULT_FROM_WIN32(GetLastError());
3874 else
3875 hr = S_OK;
3877 if (SUCCEEDED(hr) && szDest[0] == '%')
3878 strcpyW(szTemp, szDest);
3879 else
3881 /* terminate loop */
3882 szTemp[0] = '\0';
3885 end:
3886 if (key)
3887 RegCloseKey(key);
3888 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
3889 debugstr_w(szSrc), debugstr_w(szDest));
3890 return hr;
3893 /*************************************************************************
3894 * SHGetFolderPathW [SHELL32.@]
3896 * Convert nFolder to path.
3898 * RETURNS
3899 * Success: S_OK
3900 * Failure: standard HRESULT error codes.
3902 * NOTES
3903 * Most values can be overridden in either
3904 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3905 * or in the same location in HKLM.
3906 * The "Shell Folders" registry key was used in NT4 and earlier systems.
3907 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
3908 * changes made to it are made to the former key too. This synchronization is
3909 * done on-demand: not until someone requests the value of one of these paths
3910 * (by calling one of the SHGet functions) is the value synchronized.
3911 * Furthermore, the HKCU paths take precedence over the HKLM paths.
3913 HRESULT WINAPI SHGetFolderPathW(
3914 HWND hwndOwner, /* [I] owner window */
3915 int nFolder, /* [I] CSIDL identifying the folder */
3916 HANDLE hToken, /* [I] access token */
3917 DWORD dwFlags, /* [I] which path to return */
3918 LPWSTR pszPath) /* [O] converted path */
3920 HRESULT hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, NULL, pszPath);
3921 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr)
3922 hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
3923 return hr;
3926 HRESULT WINAPI SHGetFolderPathAndSubDirA(
3927 HWND hwndOwner, /* [I] owner window */
3928 int nFolder, /* [I] CSIDL identifying the folder */
3929 HANDLE hToken, /* [I] access token */
3930 DWORD dwFlags, /* [I] which path to return */
3931 LPCSTR pszSubPath, /* [I] sub directory of the specified folder */
3932 LPSTR pszPath) /* [O] converted path */
3934 int length;
3935 HRESULT hr = S_OK;
3936 LPWSTR pszSubPathW = NULL;
3937 LPWSTR pszPathW = NULL;
3938 TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
3940 if(pszPath) {
3941 pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
3942 if(!pszPathW) {
3943 hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
3944 goto cleanup;
3947 TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
3949 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
3950 * set (null), or an empty string.therefore call it without the parameter set
3951 * if pszSubPath is an empty string
3953 if (pszSubPath && pszSubPath[0]) {
3954 length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
3955 pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
3956 if(!pszSubPathW) {
3957 hr = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
3958 goto cleanup;
3960 MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
3963 hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
3965 if (SUCCEEDED(hr) && pszPath)
3966 WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
3968 cleanup:
3969 HeapFree(GetProcessHeap(), 0, pszPathW);
3970 HeapFree(GetProcessHeap(), 0, pszSubPathW);
3971 return hr;
3974 /*************************************************************************
3975 * SHGetFolderPathAndSubDirW [SHELL32.@]
3977 HRESULT WINAPI SHGetFolderPathAndSubDirW(
3978 HWND hwndOwner, /* [I] owner window */
3979 int nFolder, /* [I] CSIDL identifying the folder */
3980 HANDLE hToken, /* [I] access token */
3981 DWORD dwFlags, /* [I] which path to return */
3982 LPCWSTR pszSubPath,/* [I] sub directory of the specified folder */
3983 LPWSTR pszPath) /* [O] converted path */
3985 HRESULT hr;
3986 WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
3987 DWORD folder = nFolder & CSIDL_FOLDER_MASK;
3988 CSIDL_Type type;
3989 int ret;
3991 TRACE("%p,%p,nFolder=0x%04x,%s\n", hwndOwner,pszPath,nFolder,debugstr_w(pszSubPath));
3993 /* Windows always NULL-terminates the resulting path regardless of success
3994 * or failure, so do so first
3996 if (pszPath)
3997 *pszPath = '\0';
3999 if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
4000 return E_INVALIDARG;
4001 if ((SHGFP_TYPE_CURRENT != dwFlags) && (SHGFP_TYPE_DEFAULT != dwFlags))
4002 return E_INVALIDARG;
4003 szTemp[0] = 0;
4004 type = CSIDL_Data[folder].type;
4005 switch (type)
4007 case CSIDL_Type_Disallowed:
4008 hr = E_INVALIDARG;
4009 break;
4010 case CSIDL_Type_NonExistent:
4011 hr = S_FALSE;
4012 break;
4013 case CSIDL_Type_WindowsPath:
4014 GetWindowsDirectoryW(szTemp, MAX_PATH);
4015 if (CSIDL_Data[folder].szDefaultPath &&
4016 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4017 *CSIDL_Data[folder].szDefaultPath)
4019 PathAddBackslashW(szTemp);
4020 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4022 hr = S_OK;
4023 break;
4024 case CSIDL_Type_SystemPath:
4025 GetSystemDirectoryW(szTemp, MAX_PATH);
4026 if (CSIDL_Data[folder].szDefaultPath &&
4027 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4028 *CSIDL_Data[folder].szDefaultPath)
4030 PathAddBackslashW(szTemp);
4031 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4033 hr = S_OK;
4034 break;
4035 case CSIDL_Type_SystemX86Path:
4036 if (!GetSystemWow64DirectoryW(szTemp, MAX_PATH)) GetSystemDirectoryW(szTemp, MAX_PATH);
4037 if (CSIDL_Data[folder].szDefaultPath &&
4038 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4039 *CSIDL_Data[folder].szDefaultPath)
4041 PathAddBackslashW(szTemp);
4042 strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
4044 hr = S_OK;
4045 break;
4046 case CSIDL_Type_CurrVer:
4047 hr = _SHGetCurrentVersionPath(dwFlags, folder, szTemp);
4048 break;
4049 case CSIDL_Type_User:
4050 hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
4051 break;
4052 case CSIDL_Type_AllUsers:
4053 case CSIDL_Type_ProgramData:
4054 hr = _SHGetAllUsersProfilePath(dwFlags, folder, szTemp);
4055 break;
4056 default:
4057 FIXME("bogus type %d, please fix\n", type);
4058 hr = E_INVALIDARG;
4059 break;
4062 /* Expand environment strings if necessary */
4063 if (*szTemp == '%')
4064 hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
4065 else
4066 strcpyW(szBuildPath, szTemp);
4068 if (FAILED(hr)) goto end;
4070 if(pszSubPath) {
4071 /* make sure the new path does not exceed the buffer length
4072 * and remember to backslash and terminate it */
4073 if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
4074 hr = HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE);
4075 goto end;
4077 PathAppendW(szBuildPath, pszSubPath);
4078 PathRemoveBackslashW(szBuildPath);
4080 /* Copy the path if it's available before we might return */
4081 if (SUCCEEDED(hr) && pszPath)
4082 strcpyW(pszPath, szBuildPath);
4084 /* if we don't care about existing directories we are ready */
4085 if(nFolder & CSIDL_FLAG_DONT_VERIFY) goto end;
4087 if (PathFileExistsW(szBuildPath)) goto end;
4089 /* not existing but we are not allowed to create it. The return value
4090 * is verified against shell32 version 6.0.
4092 if (!(nFolder & CSIDL_FLAG_CREATE))
4094 hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
4095 goto end;
4098 /* create directory/directories */
4099 ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
4100 if (ret && ret != ERROR_ALREADY_EXISTS)
4102 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
4103 hr = E_FAIL;
4104 goto end;
4107 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
4108 end:
4109 TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
4110 return hr;
4113 /*************************************************************************
4114 * SHGetFolderPathA [SHELL32.@]
4116 * See SHGetFolderPathW.
4118 HRESULT WINAPI SHGetFolderPathA(
4119 HWND hwndOwner,
4120 int nFolder,
4121 HANDLE hToken,
4122 DWORD dwFlags,
4123 LPSTR pszPath)
4125 WCHAR szTemp[MAX_PATH];
4126 HRESULT hr;
4128 TRACE("%p,%p,nFolder=0x%04x\n",hwndOwner,pszPath,nFolder);
4130 if (pszPath)
4131 *pszPath = '\0';
4132 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
4133 if (SUCCEEDED(hr) && pszPath)
4134 WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
4135 NULL);
4137 return hr;
4140 /* For each folder in folders, if its value has not been set in the registry,
4141 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4142 * folder's type) to get the unexpanded value first.
4143 * Writes the unexpanded value to User Shell Folders, and queries it with
4144 * SHGetFolderPathW to force the creation of the directory if it doesn't
4145 * already exist. SHGetFolderPathW also returns the expanded value, which
4146 * this then writes to Shell Folders.
4148 static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken,
4149 LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[],
4150 UINT foldersLen)
4152 const WCHAR *szValueName;
4153 WCHAR buffer[40];
4154 UINT i;
4155 WCHAR path[MAX_PATH];
4156 HRESULT hr = S_OK;
4157 HKEY hUserKey = NULL, hKey = NULL;
4158 DWORD dwType, dwPathLen;
4159 LONG ret;
4161 TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
4162 debugstr_w(szUserShellFolderPath), folders, foldersLen);
4164 ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
4165 if (ret)
4166 hr = HRESULT_FROM_WIN32(ret);
4167 else
4169 ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
4170 if (ret)
4171 hr = HRESULT_FROM_WIN32(ret);
4173 for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
4175 dwPathLen = MAX_PATH * sizeof(WCHAR);
4177 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4178 szValueName = CSIDL_Data[folders[i]].szValueName;
4179 if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
4181 StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
4182 szValueName = &buffer[0];
4185 if (RegQueryValueExW(hUserKey, szValueName, NULL,
4186 &dwType, (LPBYTE)path, &dwPathLen) || (dwType != REG_SZ &&
4187 dwType != REG_EXPAND_SZ))
4189 *path = '\0';
4190 if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
4191 _SHGetUserProfilePath(hToken, SHGFP_TYPE_DEFAULT, folders[i],
4192 path);
4193 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers ||
4194 CSIDL_Data[folders[i]].type == CSIDL_Type_ProgramData)
4195 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT, folders[i], path);
4196 else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
4198 GetWindowsDirectoryW(path, MAX_PATH);
4199 if (CSIDL_Data[folders[i]].szDefaultPath &&
4200 !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
4202 PathAddBackslashW(path);
4203 strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
4206 else
4207 hr = E_FAIL;
4208 if (*path)
4210 ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
4211 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
4212 if (ret)
4213 hr = HRESULT_FROM_WIN32(ret);
4214 else
4216 hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
4217 hToken, SHGFP_TYPE_DEFAULT, path);
4218 ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
4219 (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
4220 if (ret)
4221 hr = HRESULT_FROM_WIN32(ret);
4226 if (hUserKey)
4227 RegCloseKey(hUserKey);
4228 if (hKey)
4229 RegCloseKey(hKey);
4231 TRACE("returning 0x%08x\n", hr);
4232 return hr;
4235 static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
4237 static const UINT folders[] = {
4238 CSIDL_PROGRAMS,
4239 CSIDL_PERSONAL,
4240 CSIDL_FAVORITES,
4241 CSIDL_APPDATA,
4242 CSIDL_STARTUP,
4243 CSIDL_RECENT,
4244 CSIDL_SENDTO,
4245 CSIDL_STARTMENU,
4246 CSIDL_MYMUSIC,
4247 CSIDL_MYVIDEO,
4248 CSIDL_DESKTOPDIRECTORY,
4249 CSIDL_NETHOOD,
4250 CSIDL_TEMPLATES,
4251 CSIDL_PRINTHOOD,
4252 CSIDL_LOCAL_APPDATA,
4253 CSIDL_INTERNET_CACHE,
4254 CSIDL_COOKIES,
4255 CSIDL_HISTORY,
4256 CSIDL_MYPICTURES,
4257 CSIDL_FONTS,
4258 CSIDL_ADMINTOOLS,
4259 CSIDL_CONTACTS,
4260 CSIDL_DOWNLOADS,
4261 CSIDL_LINKS,
4262 CSIDL_APPDATA_LOCALLOW,
4263 CSIDL_SAVED_GAMES,
4264 CSIDL_SEARCHES
4266 WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
4267 LPCWSTR pUserShellFolderPath, pShellFolderPath;
4268 HRESULT hr = S_OK;
4269 HKEY hRootKey;
4270 HANDLE hToken;
4272 TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
4273 if (bDefault)
4275 hToken = (HANDLE)-1;
4276 hRootKey = HKEY_USERS;
4277 strcpyW(userShellFolderPath, DefaultW);
4278 PathAddBackslashW(userShellFolderPath);
4279 strcatW(userShellFolderPath, szSHUserFolders);
4280 pUserShellFolderPath = userShellFolderPath;
4281 strcpyW(shellFolderPath, DefaultW);
4282 PathAddBackslashW(shellFolderPath);
4283 strcatW(shellFolderPath, szSHFolders);
4284 pShellFolderPath = shellFolderPath;
4286 else
4288 hToken = NULL;
4289 hRootKey = HKEY_CURRENT_USER;
4290 pUserShellFolderPath = szSHUserFolders;
4291 pShellFolderPath = szSHFolders;
4294 hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
4295 pShellFolderPath, folders, sizeof(folders) / sizeof(folders[0]));
4296 TRACE("returning 0x%08x\n", hr);
4297 return hr;
4300 static HRESULT _SHRegisterCommonShellFolders(void)
4302 static const UINT folders[] = {
4303 CSIDL_COMMON_STARTMENU,
4304 CSIDL_COMMON_PROGRAMS,
4305 CSIDL_COMMON_STARTUP,
4306 CSIDL_COMMON_DESKTOPDIRECTORY,
4307 CSIDL_COMMON_FAVORITES,
4308 CSIDL_COMMON_APPDATA,
4309 CSIDL_COMMON_TEMPLATES,
4310 CSIDL_COMMON_DOCUMENTS,
4311 CSIDL_COMMON_ADMINTOOLS,
4312 CSIDL_COMMON_MUSIC,
4313 CSIDL_COMMON_PICTURES,
4314 CSIDL_COMMON_VIDEO,
4316 HRESULT hr;
4318 TRACE("\n");
4319 hr = _SHRegisterFolders(HKEY_LOCAL_MACHINE, NULL, szSHUserFolders,
4320 szSHFolders, folders, sizeof(folders) / sizeof(folders[0]));
4321 TRACE("returning 0x%08x\n", hr);
4322 return hr;
4325 /******************************************************************************
4326 * _SHAppendToUnixPath [Internal]
4328 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
4329 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
4330 * and replaces backslashes with slashes.
4332 * PARAMS
4333 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
4334 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
4336 * RETURNS
4337 * Success: TRUE,
4338 * Failure: FALSE
4340 static inline BOOL _SHAppendToUnixPath(char *szBasePath, LPCWSTR pwszSubPath) {
4341 WCHAR wszSubPath[MAX_PATH];
4342 int cLen = strlen(szBasePath);
4343 char *pBackslash;
4345 if (IS_INTRESOURCE(pwszSubPath)) {
4346 if (!LoadStringW(shell32_hInstance, LOWORD(pwszSubPath), wszSubPath, MAX_PATH)) {
4347 /* Fall back to hard coded defaults. */
4348 switch (LOWORD(pwszSubPath)) {
4349 case IDS_PERSONAL:
4350 lstrcpyW(wszSubPath, DocumentsW);
4351 break;
4352 case IDS_MYMUSIC:
4353 lstrcpyW(wszSubPath, My_MusicW);
4354 break;
4355 case IDS_MYPICTURES:
4356 lstrcpyW(wszSubPath, My_PicturesW);
4357 break;
4358 case IDS_MYVIDEOS:
4359 lstrcpyW(wszSubPath, My_VideosW);
4360 break;
4361 default:
4362 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath));
4363 return FALSE;
4366 } else {
4367 lstrcpyW(wszSubPath, pwszSubPath);
4370 if (szBasePath[cLen-1] != '/') szBasePath[cLen++] = '/';
4372 if (!WideCharToMultiByte(CP_UNIXCP, 0, wszSubPath, -1, szBasePath + cLen,
4373 FILENAME_MAX - cLen, NULL, NULL))
4375 return FALSE;
4378 pBackslash = szBasePath + cLen;
4379 while ((pBackslash = strchr(pBackslash, '\\'))) *pBackslash = '/';
4381 return TRUE;
4384 /******************************************************************************
4385 * _SHCreateSymbolicLinks [Internal]
4387 * Sets up symbol links for various shell folders to point into the users home
4388 * directory. We do an educated guess about what the user would probably want:
4389 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4390 * wine's 'My Documents' to point there. Furthermore, we imply that the user
4391 * is a Windows lover and has no problem with wine creating 'My Pictures',
4392 * 'My Music' and 'My Videos' subfolders under '$HOME/My Documents', if those
4393 * do not already exits. We put appropriate symbolic links in place for those,
4394 * too.
4395 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4396 * point directly to $HOME. We assume the user to be a unix hacker who does not
4397 * want wine to create anything anywhere besides the .wine directory. So, if
4398 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4399 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4400 * directory, and try to link to that. If that fails, then we symlink to
4401 * $HOME directly. The same holds fo 'My Pictures' and 'My Videos'.
4402 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4403 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4404 * it alone.
4405 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4407 static void _SHCreateSymbolicLinks(void)
4409 UINT aidsMyStuff[] = { IDS_MYPICTURES, IDS_MYVIDEOS, IDS_MYMUSIC }, i;
4410 const WCHAR* MyOSXStuffW[] = { PicturesW, MoviesW, MusicW };
4411 int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC };
4412 static const char * const xdg_dirs[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" };
4413 static const unsigned int num = sizeof(xdg_dirs) / sizeof(xdg_dirs[0]);
4414 WCHAR wszTempPath[MAX_PATH];
4415 char szPersonalTarget[FILENAME_MAX], *pszPersonal;
4416 char szMyStuffTarget[FILENAME_MAX], *pszMyStuff;
4417 char szDesktopTarget[FILENAME_MAX], *pszDesktop;
4418 struct stat statFolder;
4419 const char *pszHome;
4420 HRESULT hr;
4421 char ** xdg_results;
4422 char * xdg_desktop_dir;
4424 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4425 hr = SHGetFolderPathW(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL,
4426 SHGFP_TYPE_DEFAULT, wszTempPath);
4427 if (FAILED(hr)) return;
4428 pszPersonal = wine_get_unix_file_name(wszTempPath);
4429 if (!pszPersonal) return;
4431 hr = XDG_UserDirLookup(xdg_dirs, num, &xdg_results);
4432 if (FAILED(hr)) xdg_results = NULL;
4434 pszHome = getenv("HOME");
4435 if (pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode))
4437 while (1)
4439 /* Check if there's already a Wine-specific 'My Documents' folder */
4440 strcpy(szPersonalTarget, pszHome);
4441 if (_SHAppendToUnixPath(szPersonalTarget, MAKEINTRESOURCEW(IDS_PERSONAL)) &&
4442 !stat(szPersonalTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
4444 /* '$HOME/My Documents' exists. Create 'My Pictures',
4445 * 'My Videos' and 'My Music' subfolders or fail silently if
4446 * they already exist.
4448 for (i = 0; i < sizeof(aidsMyStuff)/sizeof(*aidsMyStuff); i++)
4450 strcpy(szMyStuffTarget, szPersonalTarget);
4451 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
4452 mkdir(szMyStuffTarget, 0777);
4454 break;
4457 /* Try to point to the XDG Documents folder */
4458 if (xdg_results && xdg_results[num-2] &&
4459 !stat(xdg_results[num-2], &statFolder) &&
4460 S_ISDIR(statFolder.st_mode))
4462 strcpy(szPersonalTarget, xdg_results[num-2]);
4463 break;
4466 /* Or the hardcoded / OS X Documents folder */
4467 strcpy(szPersonalTarget, pszHome);
4468 if (_SHAppendToUnixPath(szPersonalTarget, DocumentsW) &&
4469 !stat(szPersonalTarget, &statFolder) &&
4470 S_ISDIR(statFolder.st_mode))
4471 break;
4473 /* As a last resort point to $HOME. */
4474 strcpy(szPersonalTarget, pszHome);
4475 break;
4478 /* Replace 'My Documents' directory with a symlink or fail silently if not empty. */
4479 remove(pszPersonal);
4480 symlink(szPersonalTarget, pszPersonal);
4482 else
4484 /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs
4485 * in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */
4486 pszHome = NULL;
4487 strcpy(szPersonalTarget, pszPersonal);
4488 for (i = 0; i < sizeof(aidsMyStuff)/sizeof(aidsMyStuff[0]); i++) {
4489 strcpy(szMyStuffTarget, szPersonalTarget);
4490 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
4491 mkdir(szMyStuffTarget, 0777);
4495 /* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
4496 for (i=0; i < sizeof(aidsMyStuff)/sizeof(aidsMyStuff[0]); i++)
4498 /* Create the current 'My Whatever' folder and get its unix path. */
4499 hr = SHGetFolderPathW(NULL, acsidlMyStuff[i]|CSIDL_FLAG_CREATE, NULL,
4500 SHGFP_TYPE_DEFAULT, wszTempPath);
4501 if (FAILED(hr)) continue;
4503 pszMyStuff = wine_get_unix_file_name(wszTempPath);
4504 if (!pszMyStuff) continue;
4506 while (1)
4508 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4509 strcpy(szMyStuffTarget, szPersonalTarget);
4510 if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])) &&
4511 !stat(szMyStuffTarget, &statFolder) && S_ISDIR(statFolder.st_mode))
4512 break;
4514 /* Try the XDG_XXX_DIR folder */
4515 if (xdg_results && xdg_results[i])
4517 strcpy(szMyStuffTarget, xdg_results[i]);
4518 break;
4521 /* Or the OS X folder (these are never localized) */
4522 if (pszHome)
4524 strcpy(szMyStuffTarget, pszHome);
4525 if (_SHAppendToUnixPath(szMyStuffTarget, MyOSXStuffW[i]) &&
4526 !stat(szMyStuffTarget, &statFolder) &&
4527 S_ISDIR(statFolder.st_mode))
4528 break;
4531 /* As a last resort point to the same location as 'My Documents' */
4532 strcpy(szMyStuffTarget, szPersonalTarget);
4533 break;
4535 remove(pszMyStuff);
4536 symlink(szMyStuffTarget, pszMyStuff);
4537 HeapFree(GetProcessHeap(), 0, pszMyStuff);
4540 /* Last but not least, the Desktop folder */
4541 if (pszHome)
4542 strcpy(szDesktopTarget, pszHome);
4543 else
4544 strcpy(szDesktopTarget, pszPersonal);
4545 HeapFree(GetProcessHeap(), 0, pszPersonal);
4547 xdg_desktop_dir = xdg_results ? xdg_results[num - 1] : NULL;
4548 if (xdg_desktop_dir ||
4549 (_SHAppendToUnixPath(szDesktopTarget, DesktopW) &&
4550 !stat(szDesktopTarget, &statFolder) && S_ISDIR(statFolder.st_mode)))
4552 hr = SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, NULL,
4553 SHGFP_TYPE_DEFAULT, wszTempPath);
4554 if (SUCCEEDED(hr) && (pszDesktop = wine_get_unix_file_name(wszTempPath)))
4556 remove(pszDesktop);
4557 if (xdg_desktop_dir)
4558 symlink(xdg_desktop_dir, pszDesktop);
4559 else
4560 symlink(szDesktopTarget, pszDesktop);
4561 HeapFree(GetProcessHeap(), 0, pszDesktop);
4565 /* Free resources allocated by XDG_UserDirLookup() */
4566 if (xdg_results)
4568 for (i = 0; i < num; i++)
4569 HeapFree(GetProcessHeap(), 0, xdg_results[i]);
4570 HeapFree(GetProcessHeap(), 0, xdg_results);
4574 /******************************************************************************
4575 * create_extra_folders [Internal]
4577 * Create some extra folders that don't have a standard CSIDL definition.
4579 static HRESULT create_extra_folders(void)
4581 static const WCHAR environW[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4582 static const WCHAR microsoftW[] = {'M','i','c','r','o','s','o','f','t',0};
4583 static const WCHAR TempW[] = {'T','e','m','p',0};
4584 static const WCHAR TEMPW[] = {'T','E','M','P',0};
4585 static const WCHAR TMPW[] = {'T','M','P',0};
4586 WCHAR path[MAX_PATH+5];
4587 HRESULT hr;
4588 HKEY hkey;
4589 DWORD type, size, ret;
4591 ret = RegCreateKeyW( HKEY_CURRENT_USER, environW, &hkey );
4592 if (ret) return HRESULT_FROM_WIN32( ret );
4594 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4595 hr = SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL,
4596 SHGFP_TYPE_DEFAULT, TempW, path );
4597 if (SUCCEEDED(hr))
4599 size = sizeof(path);
4600 if (RegQueryValueExW( hkey, TEMPW, NULL, &type, (LPBYTE)path, &size ))
4601 RegSetValueExW( hkey, TEMPW, 0, REG_SZ, (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR) );
4602 size = sizeof(path);
4603 if (RegQueryValueExW( hkey, TMPW, NULL, &type, (LPBYTE)path, &size ))
4604 RegSetValueExW( hkey, TMPW, 0, REG_SZ, (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR) );
4606 RegCloseKey( hkey );
4608 if (SUCCEEDED(hr))
4610 hr = SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL,
4611 SHGFP_TYPE_DEFAULT, microsoftW, path );
4613 return hr;
4617 /******************************************************************************
4618 * set_folder_attributes
4620 * Set the various folder attributes registry keys.
4622 static HRESULT set_folder_attributes(void)
4624 static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0 };
4625 static const WCHAR shellfolderW[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4626 static const WCHAR wfparsingW[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4627 static const WCHAR wfdisplayW[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4628 static const WCHAR hideasdeleteW[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4629 static const WCHAR cfattributesW[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4630 static const WCHAR emptyW[] = {0};
4632 static const struct
4634 const CLSID *clsid;
4635 BOOL wfparsing : 1;
4636 BOOL wfdisplay : 1;
4637 BOOL hideasdel : 1;
4638 DWORD attr;
4639 DWORD call_for_attr;
4640 } folders[] =
4642 { &CLSID_UnixFolder, TRUE, FALSE, FALSE },
4643 { &CLSID_UnixDosFolder, TRUE, FALSE, FALSE,
4644 SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER, SFGAO_FILESYSTEM },
4645 { &CLSID_FolderShortcut, FALSE, FALSE, FALSE,
4646 SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_LINK,
4647 SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR },
4648 { &CLSID_MyDocuments, TRUE, FALSE, FALSE,
4649 SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER, SFGAO_FILESYSTEM },
4650 { &CLSID_RecycleBin, FALSE, FALSE, FALSE,
4651 SFGAO_FOLDER|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET },
4652 { &CLSID_ControlPanel, FALSE, TRUE, TRUE,
4653 SFGAO_FOLDER|SFGAO_HASSUBFOLDER }
4656 unsigned int i;
4657 WCHAR buffer[39 + (sizeof(clsidW) + sizeof(shellfolderW)) / sizeof(WCHAR)];
4658 LONG res;
4659 HKEY hkey;
4661 for (i = 0; i < sizeof(folders)/sizeof(folders[0]); i++)
4663 strcpyW( buffer, clsidW );
4664 StringFromGUID2( folders[i].clsid, buffer + strlenW(buffer), 39 );
4665 strcatW( buffer, shellfolderW );
4666 res = RegCreateKeyExW( HKEY_CLASSES_ROOT, buffer, 0, NULL, 0,
4667 KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
4668 if (res) return HRESULT_FROM_WIN32( res );
4669 if (folders[i].wfparsing)
4670 res = RegSetValueExW( hkey, wfparsingW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4671 if (folders[i].wfdisplay)
4672 res = RegSetValueExW( hkey, wfdisplayW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4673 if (folders[i].hideasdel)
4674 res = RegSetValueExW( hkey, hideasdeleteW, 0, REG_SZ, (const BYTE *)emptyW, sizeof(emptyW) );
4675 if (folders[i].attr)
4676 res = RegSetValueExW( hkey, szAttributes, 0, REG_DWORD,
4677 (const BYTE *)&folders[i].attr, sizeof(DWORD));
4678 if (folders[i].call_for_attr)
4679 res = RegSetValueExW( hkey, cfattributesW, 0, REG_DWORD,
4680 (const BYTE *)&folders[i].call_for_attr, sizeof(DWORD));
4681 RegCloseKey( hkey );
4683 return S_OK;
4686 /*************************************************************************
4687 * SHGetSpecialFolderPathA [SHELL32.@]
4689 BOOL WINAPI SHGetSpecialFolderPathA (
4690 HWND hwndOwner,
4691 LPSTR szPath,
4692 int nFolder,
4693 BOOL bCreate)
4695 return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
4696 szPath) == S_OK;
4699 /*************************************************************************
4700 * SHGetSpecialFolderPathW
4702 BOOL WINAPI SHGetSpecialFolderPathW (
4703 HWND hwndOwner,
4704 LPWSTR szPath,
4705 int nFolder,
4706 BOOL bCreate)
4708 return SHGetFolderPathW(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
4709 szPath) == S_OK;
4712 /*************************************************************************
4713 * SHGetSpecialFolderPath (SHELL32.175)
4715 BOOL WINAPI SHGetSpecialFolderPathAW (
4716 HWND hwndOwner,
4717 LPVOID szPath,
4718 int nFolder,
4719 BOOL bCreate)
4722 if (SHELL_OsIsUnicode())
4723 return SHGetSpecialFolderPathW (hwndOwner, szPath, nFolder, bCreate);
4724 return SHGetSpecialFolderPathA (hwndOwner, szPath, nFolder, bCreate);
4727 /*************************************************************************
4728 * SHGetFolderLocation [SHELL32.@]
4730 * Gets the folder locations from the registry and creates a pidl.
4732 * PARAMS
4733 * hwndOwner [I]
4734 * nFolder [I] CSIDL_xxxxx
4735 * hToken [I] token representing user, or NULL for current user, or -1 for
4736 * default user
4737 * dwReserved [I] must be zero
4738 * ppidl [O] PIDL of a special folder
4740 * RETURNS
4741 * Success: S_OK
4742 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
4744 * NOTES
4745 * Creates missing reg keys and directories.
4746 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
4747 * virtual folders that are handled here.
4749 HRESULT WINAPI SHGetFolderLocation(
4750 HWND hwndOwner,
4751 int nFolder,
4752 HANDLE hToken,
4753 DWORD dwReserved,
4754 LPITEMIDLIST *ppidl)
4756 HRESULT hr = E_INVALIDARG;
4758 TRACE("%p 0x%08x %p 0x%08x %p\n",
4759 hwndOwner, nFolder, hToken, dwReserved, ppidl);
4761 if (!ppidl)
4762 return E_INVALIDARG;
4763 if (dwReserved)
4764 return E_INVALIDARG;
4766 /* The virtual folders' locations are not user-dependent */
4767 *ppidl = NULL;
4768 switch (nFolder & CSIDL_FOLDER_MASK)
4770 case CSIDL_DESKTOP:
4771 *ppidl = _ILCreateDesktop();
4772 break;
4774 case CSIDL_PERSONAL:
4775 *ppidl = _ILCreateMyDocuments();
4776 break;
4778 case CSIDL_INTERNET:
4779 *ppidl = _ILCreateIExplore();
4780 break;
4782 case CSIDL_CONTROLS:
4783 *ppidl = _ILCreateControlPanel();
4784 break;
4786 case CSIDL_PRINTERS:
4787 *ppidl = _ILCreatePrinters();
4788 break;
4790 case CSIDL_BITBUCKET:
4791 *ppidl = _ILCreateBitBucket();
4792 break;
4794 case CSIDL_DRIVES:
4795 *ppidl = _ILCreateMyComputer();
4796 break;
4798 case CSIDL_NETWORK:
4799 *ppidl = _ILCreateNetwork();
4800 break;
4802 default:
4804 WCHAR szPath[MAX_PATH];
4806 hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
4807 SHGFP_TYPE_CURRENT, szPath);
4808 if (SUCCEEDED(hr))
4810 DWORD attributes=0;
4812 TRACE("Value=%s\n", debugstr_w(szPath));
4813 hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
4815 else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
4817 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
4818 * version 6.0 returns E_FAIL for nonexistent paths
4820 hr = E_FAIL;
4824 if(*ppidl)
4825 hr = S_OK;
4827 TRACE("-- (new pidl %p)\n",*ppidl);
4828 return hr;
4831 /*************************************************************************
4832 * SHGetSpecialFolderLocation [SHELL32.@]
4834 * NOTES
4835 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
4836 * directory.
4838 HRESULT WINAPI SHGetSpecialFolderLocation(
4839 HWND hwndOwner,
4840 INT nFolder,
4841 LPITEMIDLIST * ppidl)
4843 HRESULT hr = E_INVALIDARG;
4845 TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
4847 if (!ppidl)
4848 return E_INVALIDARG;
4850 hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
4851 return hr;
4854 static int csidl_from_id( const KNOWNFOLDERID *id )
4856 int i;
4857 for (i = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); i++)
4858 if (IsEqualGUID( CSIDL_Data[i].id, id )) return i;
4859 return -1;
4862 /*************************************************************************
4863 * SHGetKnownFolderPath [SHELL32.@]
4865 HRESULT WINAPI SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, WCHAR **ret_path)
4867 WCHAR pathW[MAX_PATH], tempW[MAX_PATH];
4868 HRESULT hr;
4869 CSIDL_Type type;
4870 int ret;
4871 int folder = csidl_from_id(rfid), shgfp_flags;
4873 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid), flags, token, ret_path);
4875 *ret_path = NULL;
4877 if (folder < 0)
4878 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
4880 if (flags & ~(KF_FLAG_CREATE|KF_FLAG_DONT_VERIFY|KF_FLAG_NO_ALIAS|
4881 KF_FLAG_INIT|KF_FLAG_DEFAULT_PATH))
4883 FIXME("flags 0x%08x not supported\n", flags);
4884 return E_INVALIDARG;
4887 shgfp_flags = flags & KF_FLAG_DEFAULT_PATH ? SHGFP_TYPE_DEFAULT : SHGFP_TYPE_CURRENT;
4889 type = CSIDL_Data[folder].type;
4890 switch (type)
4892 case CSIDL_Type_Disallowed:
4893 hr = E_INVALIDARG;
4894 break;
4895 case CSIDL_Type_NonExistent:
4896 *tempW = 0;
4897 hr = S_FALSE;
4898 break;
4899 case CSIDL_Type_WindowsPath:
4900 GetWindowsDirectoryW(tempW, MAX_PATH);
4901 if (CSIDL_Data[folder].szDefaultPath &&
4902 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4903 *CSIDL_Data[folder].szDefaultPath)
4905 PathAddBackslashW(tempW);
4906 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
4908 hr = S_OK;
4909 break;
4910 case CSIDL_Type_SystemPath:
4911 GetSystemDirectoryW(tempW, MAX_PATH);
4912 if (CSIDL_Data[folder].szDefaultPath &&
4913 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4914 *CSIDL_Data[folder].szDefaultPath)
4916 PathAddBackslashW(tempW);
4917 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
4919 hr = S_OK;
4920 break;
4921 case CSIDL_Type_SystemX86Path:
4922 if (!GetSystemWow64DirectoryW(tempW, MAX_PATH)) GetSystemDirectoryW(tempW, MAX_PATH);
4923 if (CSIDL_Data[folder].szDefaultPath &&
4924 !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
4925 *CSIDL_Data[folder].szDefaultPath)
4927 PathAddBackslashW(tempW);
4928 strcatW(tempW, CSIDL_Data[folder].szDefaultPath);
4930 hr = S_OK;
4931 break;
4932 case CSIDL_Type_CurrVer:
4933 hr = _SHGetCurrentVersionPath(shgfp_flags, folder, tempW);
4934 break;
4935 case CSIDL_Type_User:
4936 hr = _SHGetUserProfilePath(token, shgfp_flags, folder, tempW);
4937 break;
4938 case CSIDL_Type_AllUsers:
4939 case CSIDL_Type_ProgramData:
4940 hr = _SHGetAllUsersProfilePath(shgfp_flags, folder, tempW);
4941 break;
4942 default:
4943 FIXME("bogus type %d, please fix\n", type);
4944 hr = E_INVALIDARG;
4945 break;
4948 if (FAILED(hr))
4949 goto failed;
4951 /* Expand environment strings if necessary */
4952 if (*tempW == '%')
4954 hr = _SHExpandEnvironmentStrings(tempW, pathW);
4955 if (FAILED(hr))
4956 goto failed;
4958 else
4959 strcpyW(pathW, tempW);
4961 /* if we don't care about existing directories we are ready */
4962 if (flags & KF_FLAG_DONT_VERIFY) goto done;
4964 if (PathFileExistsW(pathW)) goto done;
4966 /* Does not exist but we are not allowed to create it. The return value
4967 * is verified against shell32 version 6.0.
4969 if (!(flags & KF_FLAG_CREATE))
4971 hr = HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
4972 goto done;
4975 /* create directory/directories */
4976 ret = SHCreateDirectoryExW(NULL, pathW, NULL);
4977 if (ret && ret != ERROR_ALREADY_EXISTS)
4979 ERR("Failed to create directory %s.\n", debugstr_w(pathW));
4980 hr = E_FAIL;
4981 goto failed;
4984 TRACE("Created missing system directory %s\n", debugstr_w(pathW));
4986 done:
4987 TRACE("Final path is %s, %#x\n", debugstr_w(pathW), hr);
4989 *ret_path = CoTaskMemAlloc((strlenW(pathW) + 1) * sizeof(WCHAR));
4990 if (!*ret_path)
4991 return E_OUTOFMEMORY;
4992 strcpyW(*ret_path, pathW);
4994 return hr;
4996 failed:
4997 TRACE("Failed to get folder path, %#x.\n", hr);
4999 return hr;
5002 /*************************************************************************
5003 * SHGetFolderPathEx [SHELL32.@]
5005 HRESULT WINAPI SHGetFolderPathEx(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, LPWSTR path, DWORD len)
5007 HRESULT hr;
5008 WCHAR *buffer;
5010 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid), flags, token, path, len);
5012 if (!path || !len) return E_INVALIDARG;
5014 hr = SHGetKnownFolderPath( rfid, flags, token, &buffer );
5015 if (SUCCEEDED( hr ))
5017 if (strlenW( buffer ) + 1 > len)
5019 CoTaskMemFree( buffer );
5020 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER );
5022 strcpyW( path, buffer );
5023 CoTaskMemFree( buffer );
5025 return hr;
5029 * Internal function to convert known folder identifier to path of registry key
5030 * associated with known folder.
5032 * Parameters:
5033 * rfid [I] pointer to known folder identifier (may be NULL)
5034 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
5035 * lpPath [O] place to store string address. String should be
5036 * later freed using HeapFree(GetProcessHeap(),0, ... )
5038 static HRESULT get_known_folder_registry_path(
5039 REFKNOWNFOLDERID rfid,
5040 LPWSTR lpStringGuid,
5041 LPWSTR *lpPath)
5043 static const WCHAR sBackslash[] = {'\\',0};
5044 HRESULT hr = S_OK;
5045 int length;
5046 WCHAR sGuid[50];
5048 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid), debugstr_w(lpStringGuid), lpPath);
5050 if(rfid)
5051 StringFromGUID2(rfid, sGuid, sizeof(sGuid)/sizeof(sGuid[0]));
5052 else
5053 lstrcpyW(sGuid, lpStringGuid);
5055 length = lstrlenW(szKnownFolderDescriptions)+51;
5056 *lpPath = HeapAlloc(GetProcessHeap(), 0, length*sizeof(WCHAR));
5057 if(!(*lpPath))
5058 hr = E_OUTOFMEMORY;
5060 if(SUCCEEDED(hr))
5062 lstrcpyW(*lpPath, szKnownFolderDescriptions);
5063 lstrcatW(*lpPath, sBackslash);
5064 lstrcatW(*lpPath, sGuid);
5067 return hr;
5070 static HRESULT get_known_folder_wstr(const WCHAR *regpath, const WCHAR *value, WCHAR **out)
5072 DWORD size = 0;
5073 HRESULT hr;
5075 size = 0;
5076 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, regpath, value, RRF_RT_REG_SZ, NULL, NULL, &size));
5077 if(FAILED(hr))
5078 return hr;
5080 *out = CoTaskMemAlloc(size);
5081 if(!*out)
5082 return E_OUTOFMEMORY;
5084 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, regpath, value, RRF_RT_REG_SZ, NULL, *out, &size));
5085 if(FAILED(hr)){
5086 CoTaskMemFree(*out);
5087 *out = NULL;
5090 return hr;
5093 static HRESULT get_known_folder_dword(const WCHAR *registryPath, const WCHAR *value, DWORD *out)
5095 DWORD dwSize = sizeof(DWORD);
5096 DWORD dwType;
5097 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, value, RRF_RT_DWORD, &dwType, out, &dwSize));
5101 * Internal function to get place where folder redirection information are stored.
5103 * Parameters:
5104 * rfid [I] pointer to known folder identifier (may be NULL)
5105 * rootKey [O] root key where the redirection information are stored
5106 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5107 * However, besides root key, path is always that same, and is stored
5108 * as "szKnownFolderRedirections" constant
5110 static HRESULT get_known_folder_redirection_place(
5111 REFKNOWNFOLDERID rfid,
5112 HKEY *rootKey)
5114 HRESULT hr;
5115 LPWSTR lpRegistryPath = NULL;
5116 KF_CATEGORY category;
5118 /* first, get known folder's category */
5119 hr = get_known_folder_registry_path(rfid, NULL, &lpRegistryPath);
5121 if(SUCCEEDED(hr))
5122 hr = get_known_folder_dword(lpRegistryPath, szCategory, &category);
5124 if(SUCCEEDED(hr))
5126 if(category == KF_CATEGORY_COMMON)
5128 *rootKey = HKEY_LOCAL_MACHINE;
5129 hr = S_OK;
5131 else if(category == KF_CATEGORY_PERUSER)
5133 *rootKey = HKEY_CURRENT_USER;
5134 hr = S_OK;
5136 else
5137 hr = E_FAIL;
5140 HeapFree(GetProcessHeap(), 0, lpRegistryPath);
5141 return hr;
5144 static HRESULT get_known_folder_path_by_id(REFKNOWNFOLDERID folderId, LPWSTR lpRegistryPath, DWORD dwFlags, LPWSTR *ppszPath);
5146 static HRESULT redirect_known_folder(
5147 REFKNOWNFOLDERID rfid,
5148 HWND hwnd,
5149 KF_REDIRECT_FLAGS flags,
5150 LPCWSTR pszTargetPath,
5151 UINT cFolders,
5152 KNOWNFOLDERID const *pExclusion,
5153 LPWSTR *ppszError)
5155 HRESULT hr;
5156 HKEY rootKey = HKEY_LOCAL_MACHINE, hKey;
5157 WCHAR sGuid[39];
5158 LPWSTR lpRegistryPath = NULL, lpSrcPath = NULL;
5159 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid), hwnd, flags, debugstr_w(pszTargetPath), cFolders, pExclusion, ppszError);
5161 if (ppszError) *ppszError = NULL;
5163 hr = get_known_folder_registry_path(rfid, NULL, &lpRegistryPath);
5165 if(SUCCEEDED(hr))
5166 hr = get_known_folder_path_by_id(rfid, lpRegistryPath, 0, &lpSrcPath);
5168 HeapFree(GetProcessHeap(), 0, lpRegistryPath);
5170 /* get path to redirection storage */
5171 if(SUCCEEDED(hr))
5172 hr = get_known_folder_redirection_place(rfid, &rootKey);
5174 /* write redirection information */
5175 if(SUCCEEDED(hr))
5176 hr = HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey, szKnownFolderRedirections, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL));
5178 if(SUCCEEDED(hr))
5180 StringFromGUID2(rfid, sGuid, sizeof(sGuid)/sizeof(sGuid[0]));
5182 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, sGuid, 0, REG_SZ, (LPBYTE)pszTargetPath, (lstrlenW(pszTargetPath)+1)*sizeof(WCHAR)));
5184 RegCloseKey(hKey);
5187 /* make sure destination path exists */
5188 SHCreateDirectory(NULL, pszTargetPath);
5190 /* copy content if required */
5191 if(SUCCEEDED(hr) && (flags & KF_REDIRECT_COPY_CONTENTS) )
5193 static const WCHAR sWildcard[] = {'\\','*',0};
5194 WCHAR srcPath[MAX_PATH+1], dstPath[MAX_PATH+1];
5195 SHFILEOPSTRUCTW fileOp;
5197 ZeroMemory(srcPath, sizeof(srcPath));
5198 lstrcpyW(srcPath, lpSrcPath);
5199 lstrcatW(srcPath, sWildcard);
5201 ZeroMemory(dstPath, sizeof(dstPath));
5202 lstrcpyW(dstPath, pszTargetPath);
5204 ZeroMemory(&fileOp, sizeof(fileOp));
5206 if(flags & KF_REDIRECT_DEL_SOURCE_CONTENTS)
5207 fileOp.wFunc = FO_MOVE;
5208 else
5209 fileOp.wFunc = FO_COPY;
5211 fileOp.pFrom = srcPath;
5212 fileOp.pTo = dstPath;
5213 fileOp.fFlags = FOF_NO_UI;
5215 hr = (SHFileOperationW(&fileOp)==0 ? S_OK : E_FAIL);
5217 if(flags & KF_REDIRECT_DEL_SOURCE_CONTENTS)
5219 ZeroMemory(srcPath, sizeof(srcPath));
5220 lstrcpyW(srcPath, lpSrcPath);
5222 ZeroMemory(&fileOp, sizeof(fileOp));
5223 fileOp.wFunc = FO_DELETE;
5224 fileOp.pFrom = srcPath;
5225 fileOp.fFlags = FOF_NO_UI;
5227 hr = (SHFileOperationW(&fileOp)==0 ? S_OK : E_FAIL);
5231 CoTaskMemFree(lpSrcPath);
5233 return hr;
5237 struct knownfolder
5239 IKnownFolder IKnownFolder_iface;
5240 LONG refs;
5241 KNOWNFOLDERID id;
5242 LPWSTR registryPath;
5245 static inline struct knownfolder *impl_from_IKnownFolder( IKnownFolder *iface )
5247 return CONTAINING_RECORD( iface, struct knownfolder, IKnownFolder_iface );
5250 static ULONG WINAPI knownfolder_AddRef(
5251 IKnownFolder *iface )
5253 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5254 return InterlockedIncrement( &knownfolder->refs );
5257 static ULONG WINAPI knownfolder_Release(
5258 IKnownFolder *iface )
5260 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5261 LONG refs = InterlockedDecrement( &knownfolder->refs );
5262 if (!refs)
5264 TRACE("destroying %p\n", knownfolder);
5265 HeapFree( GetProcessHeap(), 0, knownfolder->registryPath);
5266 HeapFree( GetProcessHeap(), 0, knownfolder );
5268 return refs;
5271 static HRESULT WINAPI knownfolder_QueryInterface(
5272 IKnownFolder *iface,
5273 REFIID riid,
5274 void **ppv )
5276 struct knownfolder *This = impl_from_IKnownFolder( iface );
5278 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
5280 *ppv = NULL;
5281 if ( IsEqualGUID( riid, &IID_IKnownFolder ) ||
5282 IsEqualGUID( riid, &IID_IUnknown ) )
5284 *ppv = iface;
5286 else if ( IsEqualGUID( riid, &IID_IMarshal ) )
5288 TRACE("IID_IMarshal returning NULL.\n");
5289 return E_NOINTERFACE;
5291 else
5293 FIXME("interface %s not implemented\n", debugstr_guid(riid));
5294 return E_NOINTERFACE;
5296 IKnownFolder_AddRef( iface );
5297 return S_OK;
5300 static HRESULT knownfolder_set_id(
5301 struct knownfolder *knownfolder,
5302 const KNOWNFOLDERID *kfid)
5304 HKEY hKey;
5305 HRESULT hr;
5307 TRACE("%s\n", debugstr_guid(kfid));
5309 knownfolder->id = *kfid;
5311 /* check is it registry-registered folder */
5312 hr = get_known_folder_registry_path(kfid, NULL, &knownfolder->registryPath);
5313 if(SUCCEEDED(hr))
5314 hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, knownfolder->registryPath, 0, 0, &hKey));
5316 if(SUCCEEDED(hr))
5318 hr = S_OK;
5319 RegCloseKey(hKey);
5321 else
5323 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5324 HeapFree(GetProcessHeap(), 0, knownfolder->registryPath);
5325 knownfolder->registryPath = NULL;
5326 hr = S_OK;
5329 return hr;
5332 static HRESULT WINAPI knownfolder_GetId(
5333 IKnownFolder *iface,
5334 KNOWNFOLDERID *pkfid)
5336 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5338 TRACE("%p\n", pkfid);
5340 *pkfid = knownfolder->id;
5341 return S_OK;
5344 static HRESULT WINAPI knownfolder_GetCategory(
5345 IKnownFolder *iface,
5346 KF_CATEGORY *pCategory)
5348 struct knownfolder *knownfolder = impl_from_IKnownFolder(iface);
5349 HRESULT hr = S_OK;
5351 TRACE("%p, %p\n", knownfolder, pCategory);
5353 /* we cannot get a category for a folder which is not registered */
5354 if(!knownfolder->registryPath)
5355 hr = E_FAIL;
5357 if(SUCCEEDED(hr))
5358 hr = get_known_folder_dword(knownfolder->registryPath, szCategory, pCategory);
5360 return hr;
5363 static HRESULT WINAPI knownfolder_GetShellItem(
5364 IKnownFolder *iface,
5365 DWORD flags,
5366 REFIID riid,
5367 void **ppv)
5369 struct knownfolder *knownfolder = impl_from_IKnownFolder(iface);
5370 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder, flags, debugstr_guid(riid), ppv);
5371 return SHGetKnownFolderItem(&knownfolder->id, flags, NULL, riid, ppv);
5374 static HRESULT get_known_folder_path(
5375 LPWSTR sFolderId,
5376 LPWSTR registryPath,
5377 LPWSTR *ppszPath)
5379 static const WCHAR sBackslash[] = {'\\',0};
5380 HRESULT hr;
5381 DWORD dwSize, dwType;
5382 WCHAR path[MAX_PATH] = {0};
5383 WCHAR parentGuid[39];
5384 KF_CATEGORY category;
5385 LPWSTR parentRegistryPath, parentPath;
5386 HKEY hRedirectionRootKey = NULL;
5388 TRACE("(%s, %p)\n", debugstr_w(registryPath), ppszPath);
5389 *ppszPath = NULL;
5391 /* check if folder has parent */
5392 dwSize = sizeof(parentGuid);
5393 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szParentFolder, RRF_RT_REG_SZ, &dwType, parentGuid, &dwSize));
5394 if(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)) hr = S_FALSE;
5396 if(hr == S_OK)
5398 /* get parent's known folder path (recursive) */
5399 hr = get_known_folder_registry_path(NULL, parentGuid, &parentRegistryPath);
5400 if(FAILED(hr)) return hr;
5402 hr = get_known_folder_path(parentGuid, parentRegistryPath, &parentPath);
5403 if(FAILED(hr)) {
5404 HeapFree(GetProcessHeap(), 0, parentRegistryPath);
5405 return hr;
5408 lstrcatW(path, parentPath);
5409 lstrcatW(path, sBackslash);
5411 HeapFree(GetProcessHeap(), 0, parentRegistryPath);
5412 HeapFree(GetProcessHeap(), 0, parentPath);
5415 /* check, if folder was redirected */
5416 if(SUCCEEDED(hr))
5417 hr = get_known_folder_dword(registryPath, szCategory, &category);
5419 if(SUCCEEDED(hr))
5421 if(category == KF_CATEGORY_COMMON)
5422 hRedirectionRootKey = HKEY_LOCAL_MACHINE;
5423 else if(category == KF_CATEGORY_PERUSER)
5424 hRedirectionRootKey = HKEY_CURRENT_USER;
5426 if(hRedirectionRootKey)
5428 hr = HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey, szKnownFolderRedirections, sFolderId, RRF_RT_REG_SZ, NULL, NULL, &dwSize));
5430 if(SUCCEEDED(hr))
5432 *ppszPath = CoTaskMemAlloc(dwSize+(lstrlenW(path)+1)*sizeof(WCHAR));
5433 if(!*ppszPath) hr = E_OUTOFMEMORY;
5436 if(SUCCEEDED(hr))
5438 lstrcpyW(*ppszPath, path);
5439 hr = HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey, szKnownFolderRedirections, sFolderId, RRF_RT_REG_SZ, NULL, *ppszPath + lstrlenW(path), &dwSize));
5443 if(!*ppszPath)
5445 /* no redirection, use previous way - read the relative path from folder definition */
5446 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szRelativePath, RRF_RT_REG_SZ, &dwType, NULL, &dwSize));
5448 if(SUCCEEDED(hr))
5450 *ppszPath = CoTaskMemAlloc(dwSize+(lstrlenW(path)+1)*sizeof(WCHAR));
5451 if(!*ppszPath) hr = E_OUTOFMEMORY;
5454 if(SUCCEEDED(hr))
5456 lstrcpyW(*ppszPath, path);
5457 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, registryPath, szRelativePath, RRF_RT_REG_SZ, &dwType, *ppszPath + lstrlenW(path), &dwSize));
5462 TRACE("returning path: %s\n", debugstr_w(*ppszPath));
5463 return hr;
5466 static HRESULT get_known_folder_path_by_id(
5467 REFKNOWNFOLDERID folderId,
5468 LPWSTR lpRegistryPath,
5469 DWORD dwFlags,
5470 LPWSTR *ppszPath)
5472 HRESULT hr = E_FAIL;
5473 WCHAR sGuid[39];
5474 DWORD dwAttributes;
5476 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId), debugstr_w(lpRegistryPath), dwFlags, ppszPath);
5478 /* if this is registry-registered known folder, get path from registry */
5479 if(lpRegistryPath)
5481 StringFromGUID2(folderId, sGuid, sizeof(sGuid)/sizeof(sGuid[0]));
5483 hr = get_known_folder_path(sGuid, lpRegistryPath, ppszPath);
5485 /* in other case, use older way */
5487 if(FAILED(hr))
5488 hr = SHGetKnownFolderPath( folderId, dwFlags, NULL, ppszPath );
5490 if (FAILED(hr)) return hr;
5492 /* check if known folder really exists */
5493 dwAttributes = GetFileAttributesW(*ppszPath);
5494 if(dwAttributes == INVALID_FILE_ATTRIBUTES || !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY) )
5496 TRACE("directory %s not found\n", debugstr_w(*ppszPath));
5497 CoTaskMemFree(*ppszPath);
5498 *ppszPath = NULL;
5499 hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
5502 return hr;
5505 static HRESULT WINAPI knownfolder_GetPath(
5506 IKnownFolder *iface,
5507 DWORD dwFlags,
5508 LPWSTR *ppszPath)
5510 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5511 TRACE("(%p, 0x%08x, %p)\n", knownfolder, dwFlags, ppszPath);
5513 return get_known_folder_path_by_id(&knownfolder->id, knownfolder->registryPath, dwFlags, ppszPath);
5516 static HRESULT WINAPI knownfolder_SetPath(
5517 IKnownFolder *iface,
5518 DWORD dwFlags,
5519 LPCWSTR pszPath)
5521 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5522 HRESULT hr = S_OK;
5524 TRACE("(%p, 0x%08x, %s)\n", knownfolder, dwFlags, debugstr_w(pszPath));
5526 /* check if the known folder is registered */
5527 if(!knownfolder->registryPath)
5528 hr = E_FAIL;
5530 if(SUCCEEDED(hr))
5531 hr = redirect_known_folder(&knownfolder->id, NULL, 0, pszPath, 0, NULL, NULL);
5533 return hr;
5536 static HRESULT WINAPI knownfolder_GetIDList(
5537 IKnownFolder *iface,
5538 DWORD flags,
5539 PIDLIST_ABSOLUTE *ppidl)
5541 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5542 TRACE("(%p, 0x%08x, %p)\n", knownfolder, flags, ppidl);
5543 return SHGetKnownFolderIDList(&knownfolder->id, flags, NULL, ppidl);
5546 static HRESULT WINAPI knownfolder_GetFolderType(
5547 IKnownFolder *iface,
5548 FOLDERTYPEID *pftid)
5550 FIXME("%p\n", pftid);
5551 return E_NOTIMPL;
5554 static HRESULT WINAPI knownfolder_GetRedirectionCapabilities(
5555 IKnownFolder *iface,
5556 KF_REDIRECTION_CAPABILITIES *pCapabilities)
5558 FIXME("%p\n", pCapabilities);
5559 return E_NOTIMPL;
5562 static HRESULT WINAPI knownfolder_GetFolderDefinition(
5563 IKnownFolder *iface,
5564 KNOWNFOLDER_DEFINITION *pKFD)
5566 struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
5567 HRESULT hr;
5568 DWORD dwSize;
5569 WCHAR parentGuid[39];
5570 TRACE("(%p, %p)\n", knownfolder, pKFD);
5572 if(!pKFD) return E_INVALIDARG;
5574 ZeroMemory(pKFD, sizeof(*pKFD));
5576 /* required fields */
5577 hr = get_known_folder_dword(knownfolder->registryPath, szCategory, &pKFD->category);
5578 if(FAILED(hr))
5579 return hr;
5581 hr = get_known_folder_wstr(knownfolder->registryPath, szName, &pKFD->pszName);
5582 if(FAILED(hr))
5583 return hr;
5585 /* optional fields */
5586 dwSize = sizeof(parentGuid);
5587 hr = HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE, knownfolder->registryPath, szParentFolder,
5588 RRF_RT_REG_SZ, NULL, parentGuid, &dwSize));
5589 if(SUCCEEDED(hr))
5591 hr = IIDFromString(parentGuid, &pKFD->fidParent);
5592 if(FAILED(hr))
5593 return hr;
5596 get_known_folder_dword(knownfolder->registryPath, szAttributes, &pKFD->dwAttributes);
5598 get_known_folder_wstr(knownfolder->registryPath, szRelativePath, &pKFD->pszRelativePath);
5600 get_known_folder_wstr(knownfolder->registryPath, szParsingName, &pKFD->pszParsingName);
5602 return S_OK;
5605 static const struct IKnownFolderVtbl knownfolder_vtbl =
5607 knownfolder_QueryInterface,
5608 knownfolder_AddRef,
5609 knownfolder_Release,
5610 knownfolder_GetId,
5611 knownfolder_GetCategory,
5612 knownfolder_GetShellItem,
5613 knownfolder_GetPath,
5614 knownfolder_SetPath,
5615 knownfolder_GetIDList,
5616 knownfolder_GetFolderType,
5617 knownfolder_GetRedirectionCapabilities,
5618 knownfolder_GetFolderDefinition
5621 static HRESULT knownfolder_create( struct knownfolder **knownfolder )
5623 struct knownfolder *kf;
5625 kf = HeapAlloc( GetProcessHeap(), 0, sizeof(*kf) );
5626 if (!kf) return E_OUTOFMEMORY;
5628 kf->IKnownFolder_iface.lpVtbl = &knownfolder_vtbl;
5629 kf->refs = 1;
5630 memset( &kf->id, 0, sizeof(kf->id) );
5631 kf->registryPath = NULL;
5633 *knownfolder = kf;
5635 TRACE("returning iface %p\n", &kf->IKnownFolder_iface);
5636 return S_OK;
5639 struct foldermanager
5641 IKnownFolderManager IKnownFolderManager_iface;
5642 LONG refs;
5643 UINT num_ids;
5644 KNOWNFOLDERID *ids;
5647 static inline struct foldermanager *impl_from_IKnownFolderManager( IKnownFolderManager *iface )
5649 return CONTAINING_RECORD( iface, struct foldermanager, IKnownFolderManager_iface );
5652 static ULONG WINAPI foldermanager_AddRef(
5653 IKnownFolderManager *iface )
5655 struct foldermanager *foldermanager = impl_from_IKnownFolderManager( iface );
5656 return InterlockedIncrement( &foldermanager->refs );
5659 static ULONG WINAPI foldermanager_Release(
5660 IKnownFolderManager *iface )
5662 struct foldermanager *foldermanager = impl_from_IKnownFolderManager( iface );
5663 LONG refs = InterlockedDecrement( &foldermanager->refs );
5664 if (!refs)
5666 TRACE("destroying %p\n", foldermanager);
5667 HeapFree( GetProcessHeap(), 0, foldermanager->ids );
5668 HeapFree( GetProcessHeap(), 0, foldermanager );
5670 return refs;
5673 static HRESULT WINAPI foldermanager_QueryInterface(
5674 IKnownFolderManager *iface,
5675 REFIID riid,
5676 void **ppv )
5678 struct foldermanager *This = impl_from_IKnownFolderManager( iface );
5680 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppv );
5682 *ppv = NULL;
5683 if ( IsEqualGUID( riid, &IID_IKnownFolderManager ) ||
5684 IsEqualGUID( riid, &IID_IUnknown ) )
5686 *ppv = iface;
5688 else if ( IsEqualGUID( riid, &IID_IMarshal ) )
5690 TRACE("IID_IMarshal returning NULL.\n");
5691 return E_NOINTERFACE;
5693 else
5695 FIXME("interface %s not implemented\n", debugstr_guid(riid));
5696 return E_NOINTERFACE;
5698 IKnownFolderManager_AddRef( iface );
5699 return S_OK;
5702 static HRESULT WINAPI foldermanager_FolderIdFromCsidl(
5703 IKnownFolderManager *iface,
5704 int nCsidl,
5705 KNOWNFOLDERID *pfid)
5707 TRACE("%d, %p\n", nCsidl, pfid);
5709 if (nCsidl >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
5710 return E_INVALIDARG;
5711 *pfid = *CSIDL_Data[nCsidl].id;
5712 return S_OK;
5715 static HRESULT WINAPI foldermanager_FolderIdToCsidl(
5716 IKnownFolderManager *iface,
5717 REFKNOWNFOLDERID rfid,
5718 int *pnCsidl)
5720 int csidl;
5722 TRACE("%s, %p\n", debugstr_guid(rfid), pnCsidl);
5724 csidl = csidl_from_id( rfid );
5725 if (csidl == -1) return E_INVALIDARG;
5726 *pnCsidl = csidl;
5727 return S_OK;
5730 static HRESULT WINAPI foldermanager_GetFolderIds(
5731 IKnownFolderManager *iface,
5732 KNOWNFOLDERID **ppKFId,
5733 UINT *pCount)
5735 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
5737 TRACE("%p, %p\n", ppKFId, pCount);
5739 *ppKFId = CoTaskMemAlloc(fm->num_ids * sizeof(KNOWNFOLDERID));
5740 memcpy(*ppKFId, fm->ids, fm->num_ids * sizeof(KNOWNFOLDERID));
5741 *pCount = fm->num_ids;
5742 return S_OK;
5745 static BOOL is_knownfolder( struct foldermanager *fm, const KNOWNFOLDERID *id )
5747 UINT i;
5748 HRESULT hr;
5749 LPWSTR registryPath = NULL;
5750 HKEY hKey;
5752 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
5753 for (i = 0; i < fm->num_ids; i++)
5754 if (IsEqualGUID( &fm->ids[i], id )) return TRUE;
5756 hr = get_known_folder_registry_path(id, NULL, &registryPath);
5757 if(SUCCEEDED(hr))
5759 hr = HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryPath, 0, 0, &hKey));
5760 HeapFree(GetProcessHeap(), 0, registryPath);
5763 if(SUCCEEDED(hr))
5765 hr = S_OK;
5766 RegCloseKey(hKey);
5769 return hr == S_OK;
5772 static HRESULT WINAPI foldermanager_GetFolder(
5773 IKnownFolderManager *iface,
5774 REFKNOWNFOLDERID rfid,
5775 IKnownFolder **ppkf)
5777 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
5778 struct knownfolder *kf;
5779 HRESULT hr;
5781 TRACE("%s, %p\n", debugstr_guid(rfid), ppkf);
5783 if (!is_knownfolder( fm, rfid ))
5785 WARN("unknown folder\n");
5786 return E_INVALIDARG;
5788 hr = knownfolder_create( &kf );
5789 if (SUCCEEDED( hr ))
5791 hr = knownfolder_set_id( kf, rfid );
5792 *ppkf = &kf->IKnownFolder_iface;
5794 else
5795 *ppkf = NULL;
5797 return hr;
5800 static HRESULT WINAPI foldermanager_GetFolderByName(
5801 IKnownFolderManager *iface,
5802 LPCWSTR pszCanonicalName,
5803 IKnownFolder **ppkf)
5805 struct foldermanager *fm = impl_from_IKnownFolderManager( iface );
5806 struct knownfolder *kf;
5807 BOOL found = FALSE;
5808 HRESULT hr;
5809 UINT i;
5811 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName), ppkf );
5813 for (i = 0; i < fm->num_ids; i++)
5815 WCHAR *path, *name;
5816 hr = get_known_folder_registry_path( &fm->ids[i], NULL, &path );
5817 if (FAILED( hr )) return hr;
5819 hr = get_known_folder_wstr( path, szName, &name );
5820 HeapFree( GetProcessHeap(), 0, path );
5821 if (FAILED( hr )) return hr;
5823 found = !strcmpiW( pszCanonicalName, name );
5824 CoTaskMemFree( name );
5825 if (found) break;
5828 if (found)
5830 hr = knownfolder_create( &kf );
5831 if (FAILED( hr )) return hr;
5833 hr = knownfolder_set_id( kf, &fm->ids[i] );
5834 if (FAILED( hr ))
5836 IKnownFolder_Release( &kf->IKnownFolder_iface );
5837 return hr;
5839 *ppkf = &kf->IKnownFolder_iface;
5841 else
5843 hr = HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
5844 *ppkf = NULL;
5847 return hr;
5850 static HRESULT register_folder(const KNOWNFOLDERID *rfid, const KNOWNFOLDER_DEFINITION *pKFD)
5852 HRESULT hr;
5853 HKEY hKey = NULL;
5854 DWORD dwDisp;
5855 LPWSTR registryPath = NULL;
5857 hr = get_known_folder_registry_path(rfid, NULL, &registryPath);
5858 TRACE("registry path: %s\n", debugstr_w(registryPath));
5860 if(SUCCEEDED(hr))
5861 hr = HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE, registryPath, 0, NULL, 0, KEY_WRITE, 0, &hKey, &dwDisp));
5863 if(SUCCEEDED(hr))
5865 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szCategory, 0, REG_DWORD, (LPBYTE)&pKFD->category, sizeof(pKFD->category)));
5867 if(SUCCEEDED(hr) && pKFD->dwAttributes != 0)
5868 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szAttributes, 0, REG_DWORD, (LPBYTE)&pKFD->dwAttributes, sizeof(pKFD->dwAttributes)));
5870 if(SUCCEEDED(hr))
5871 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szName, 0, REG_SZ, (LPBYTE)pKFD->pszName, (lstrlenW(pKFD->pszName)+1)*sizeof(WCHAR) ));
5873 if(SUCCEEDED(hr) && pKFD->pszParsingName)
5874 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szParsingName, 0, REG_SZ, (LPBYTE)pKFD->pszParsingName, (lstrlenW(pKFD->pszParsingName)+1)*sizeof(WCHAR) ));
5876 if(SUCCEEDED(hr) && !IsEqualGUID(&pKFD->fidParent, &GUID_NULL))
5878 WCHAR sParentGuid[39];
5879 StringFromGUID2(&pKFD->fidParent, sParentGuid, sizeof(sParentGuid)/sizeof(sParentGuid[0]));
5881 /* this known folder has parent folder */
5882 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szParentFolder, 0, REG_SZ, (LPBYTE)sParentGuid, sizeof(sParentGuid)));
5885 if(SUCCEEDED(hr) && pKFD->category != KF_CATEGORY_VIRTUAL && pKFD->pszRelativePath)
5886 hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szRelativePath, 0, REG_SZ, (LPBYTE)pKFD->pszRelativePath, (lstrlenW(pKFD->pszRelativePath)+1)*sizeof(WCHAR) ));
5888 RegCloseKey(hKey);
5890 if(FAILED(hr))
5891 SHDeleteKeyW(HKEY_LOCAL_MACHINE, registryPath);
5894 HeapFree(GetProcessHeap(), 0, registryPath);
5895 return hr;
5898 static HRESULT WINAPI foldermanager_RegisterFolder(
5899 IKnownFolderManager *iface,
5900 REFKNOWNFOLDERID rfid,
5901 KNOWNFOLDER_DEFINITION const *pKFD)
5903 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(rfid), pKFD);
5904 return register_folder(rfid, pKFD);
5907 static HRESULT WINAPI foldermanager_UnregisterFolder(
5908 IKnownFolderManager *iface,
5909 REFKNOWNFOLDERID rfid)
5911 HRESULT hr;
5912 LPWSTR registryPath = NULL;
5913 TRACE("(%p, %s)\n", iface, debugstr_guid(rfid));
5915 hr = get_known_folder_registry_path(rfid, NULL, &registryPath);
5917 if(SUCCEEDED(hr))
5918 hr = HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE, registryPath));
5920 HeapFree(GetProcessHeap(), 0, registryPath);
5921 return hr;
5924 static HRESULT WINAPI foldermanager_FindFolderFromPath(
5925 IKnownFolderManager *iface,
5926 LPCWSTR pszPath,
5927 FFFP_MODE mode,
5928 IKnownFolder **ppkf)
5930 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath), mode, ppkf);
5931 return E_NOTIMPL;
5934 static HRESULT WINAPI foldermanager_FindFolderFromIDList(
5935 IKnownFolderManager *iface,
5936 PCIDLIST_ABSOLUTE pidl,
5937 IKnownFolder **ppkf)
5939 FIXME("%p, %p\n", pidl, ppkf);
5940 return E_NOTIMPL;
5943 static HRESULT WINAPI foldermanager_Redirect(
5944 IKnownFolderManager *iface,
5945 REFKNOWNFOLDERID rfid,
5946 HWND hwnd,
5947 KF_REDIRECT_FLAGS flags,
5948 LPCWSTR pszTargetPath,
5949 UINT cFolders,
5950 KNOWNFOLDERID const *pExclusion,
5951 LPWSTR *ppszError)
5953 return redirect_known_folder(rfid, hwnd, flags, pszTargetPath, cFolders, pExclusion, ppszError);
5956 static const struct IKnownFolderManagerVtbl foldermanager_vtbl =
5958 foldermanager_QueryInterface,
5959 foldermanager_AddRef,
5960 foldermanager_Release,
5961 foldermanager_FolderIdFromCsidl,
5962 foldermanager_FolderIdToCsidl,
5963 foldermanager_GetFolderIds,
5964 foldermanager_GetFolder,
5965 foldermanager_GetFolderByName,
5966 foldermanager_RegisterFolder,
5967 foldermanager_UnregisterFolder,
5968 foldermanager_FindFolderFromPath,
5969 foldermanager_FindFolderFromIDList,
5970 foldermanager_Redirect
5973 static HRESULT foldermanager_create( void **ppv )
5975 UINT i, j;
5976 struct foldermanager *fm;
5978 fm = HeapAlloc( GetProcessHeap(), 0, sizeof(*fm) );
5979 if (!fm) return E_OUTOFMEMORY;
5981 fm->IKnownFolderManager_iface.lpVtbl = &foldermanager_vtbl;
5982 fm->refs = 1;
5983 fm->num_ids = 0;
5985 for (i = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); i++)
5987 if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL )) fm->num_ids++;
5989 fm->ids = HeapAlloc( GetProcessHeap(), 0, fm->num_ids * sizeof(KNOWNFOLDERID) );
5990 if (!fm->ids)
5992 HeapFree( GetProcessHeap(), 0, fm );
5993 return E_OUTOFMEMORY;
5995 for (i = j = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); i++)
5997 if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL ))
5999 fm->ids[j] = *CSIDL_Data[i].id;
6000 j++;
6003 TRACE("found %u known folders\n", fm->num_ids);
6004 *ppv = &fm->IKnownFolderManager_iface;
6006 TRACE("returning iface %p\n", *ppv);
6007 return S_OK;
6010 HRESULT WINAPI KnownFolderManager_Constructor( IUnknown *punk, REFIID riid, void **ppv )
6012 TRACE("%p, %s, %p\n", punk, debugstr_guid(riid), ppv);
6014 if (!ppv)
6015 return E_POINTER;
6016 if (punk)
6017 return CLASS_E_NOAGGREGATION;
6019 return foldermanager_create( ppv );
6022 HRESULT WINAPI SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE token, PIDLIST_ABSOLUTE *pidl)
6024 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid), flags, token, pidl);
6026 if (!pidl)
6027 return E_INVALIDARG;
6029 if (flags)
6030 FIXME("unsupported flags: 0x%08x\n", flags);
6032 if (token)
6033 FIXME("user token is not used.\n");
6035 *pidl = NULL;
6036 if (IsEqualIID(rfid, &FOLDERID_Desktop))
6037 *pidl = _ILCreateDesktop();
6038 else if (IsEqualIID(rfid, &FOLDERID_RecycleBinFolder))
6039 *pidl = _ILCreateBitBucket();
6040 else if (IsEqualIID(rfid, &FOLDERID_ComputerFolder))
6041 *pidl = _ILCreateMyComputer();
6042 else if (IsEqualIID(rfid, &FOLDERID_PrintersFolder))
6043 *pidl = _ILCreatePrinters();
6044 else if (IsEqualIID(rfid, &FOLDERID_ControlPanelFolder))
6045 *pidl = _ILCreateControlPanel();
6046 else if (IsEqualIID(rfid, &FOLDERID_NetworkFolder))
6047 *pidl = _ILCreateNetwork();
6048 else if (IsEqualIID(rfid, &FOLDERID_Documents))
6049 *pidl = _ILCreateMyDocuments();
6050 else
6052 DWORD attributes = 0;
6053 WCHAR *pathW;
6054 HRESULT hr;
6056 hr = SHGetKnownFolderPath(rfid, flags, token, &pathW);
6057 if (FAILED(hr))
6058 return hr;
6060 hr = SHILCreateFromPathW(pathW, pidl, &attributes);
6061 CoTaskMemFree(pathW);
6062 return hr;
6065 return *pidl ? S_OK : E_FAIL;
6068 HRESULT WINAPI SHGetKnownFolderItem(REFKNOWNFOLDERID rfid, KNOWN_FOLDER_FLAG flags, HANDLE hToken,
6069 REFIID riid, void **ppv)
6071 PIDLIST_ABSOLUTE pidl;
6072 HRESULT hr;
6074 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid), flags, hToken, debugstr_guid(riid), ppv);
6076 hr = SHGetKnownFolderIDList(rfid, flags, hToken, &pidl);
6077 if (FAILED(hr))
6079 *ppv = NULL;
6080 return hr;
6083 hr = SHCreateItemFromIDList(pidl, riid, ppv);
6084 CoTaskMemFree(pidl);
6085 return hr;
6088 static void register_system_knownfolders(void)
6090 int i;
6091 for(i = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); ++i){
6092 const CSIDL_DATA *folder = &CSIDL_Data[i];
6093 if(folder->pszName){
6094 KNOWNFOLDER_DEFINITION kfd;
6096 /* register_folder won't modify kfd, so cast away const instead of
6097 * reallocating */
6098 kfd.category = folder->category;
6099 kfd.pszName = (WCHAR*)folder->pszName;
6100 kfd.pszDescription = (WCHAR*)folder->pszDescription;
6101 memcpy(&kfd.fidParent, folder->fidParent, sizeof(KNOWNFOLDERID));
6102 kfd.pszRelativePath = (WCHAR*)folder->pszRelativePath;
6103 kfd.pszParsingName = (WCHAR*)folder->pszParsingName;
6104 kfd.pszTooltip = (WCHAR*)folder->pszTooltip;
6105 kfd.pszLocalizedName = (WCHAR*)folder->pszLocalizedName;
6106 kfd.pszIcon = (WCHAR*)folder->pszIcon;
6107 kfd.pszSecurity = (WCHAR*)folder->pszSecurity;
6108 kfd.dwAttributes = folder->dwAttributes;
6109 kfd.kfdFlags = folder->kfdFlags;
6110 memcpy(&kfd.ftidType, folder->ftidType, sizeof(FOLDERTYPEID));
6112 register_folder(folder->id, &kfd);
6117 HRESULT SHELL_RegisterShellFolders(void)
6119 HRESULT hr;
6121 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6122 * 'My Videos', 'My Music' and 'Desktop' in advance, so that the
6123 * _SHRegister*ShellFolders() functions will find everything nice and clean
6124 * and thus will not attempt to create them in the profile directory. */
6125 _SHCreateSymbolicLinks();
6127 hr = _SHRegisterUserShellFolders(TRUE);
6128 if (SUCCEEDED(hr))
6129 hr = _SHRegisterUserShellFolders(FALSE);
6130 if (SUCCEEDED(hr))
6131 hr = _SHRegisterCommonShellFolders();
6132 if (SUCCEEDED(hr))
6133 hr = create_extra_folders();
6134 if (SUCCEEDED(hr))
6135 hr = set_folder_attributes();
6136 if (SUCCEEDED(hr))
6137 register_system_knownfolders();
6138 return hr;