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
23 * Many of these functions are in SHLWAPI.DLL also
30 #include "wine/port.h"
36 #include "wine/debug.h"
47 #include "shell32_main.h"
48 #include "undocshell.h"
50 #include "wine/unicode.h"
54 #include "knownfolders.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(
73 if (SHELL_OsIsUnicode())
74 return PathAppendW(lpszPath1
, lpszPath2
);
75 return PathAppendA(lpszPath1
, lpszPath2
);
78 /*************************************************************************
79 * PathCombine [SHELL32.37]
81 LPVOID WINAPI
PathCombineAW(
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]
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
);
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
);
231 PathRemoveArgsA(lpszPath
);
234 /*************************************************************************
235 * PathRemoveExtension [SHELL32.250]
237 void WINAPI
PathRemoveExtensionAW(LPVOID lpszPath
)
239 if (SHELL_OsIsUnicode())
240 PathRemoveExtensionW(lpszPath
);
242 PathRemoveExtensionA(lpszPath
);
250 /*************************************************************************
251 * PathGetShortPathA [internal]
253 static void PathGetShortPathA(LPSTR pszPath
)
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
);
298 PathRemoveBlanksA(str
);
301 /*************************************************************************
302 * PathQuoteSpaces [SHELL32.55]
304 VOID WINAPI
PathQuoteSpacesAW (LPVOID lpszPath
)
306 if(SHELL_OsIsUnicode())
307 PathQuoteSpacesW(lpszPath
);
309 PathQuoteSpacesA(lpszPath
);
312 /*************************************************************************
313 * PathUnquoteSpaces [SHELL32.56]
315 VOID WINAPI
PathUnquoteSpacesAW(LPVOID str
)
317 if(SHELL_OsIsUnicode())
318 PathUnquoteSpacesW(str
);
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
);
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
;
384 /*************************************************************************
385 * PathIsExeW [internal]
387 static BOOL
PathIsExeW (LPCWSTR lpszPath
)
389 LPCWSTR lpszExtension
= PathGetExtensionW(lpszPath
);
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
;
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
)
461 if (!GetVolumeInformationA(lpszPath
, NULL
, 0, NULL
, &fnlen
, NULL
, NULL
, 0))
466 /*************************************************************************
467 * IsLFNDriveW [SHELL32.42]
469 BOOL WINAPI
IsLFNDriveW(LPCWSTR lpszPath
)
473 if (!GetVolumeInformationW(lpszPath
, NULL
, 0, NULL
, &fnlen
, NULL
, NULL
, 0))
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(
497 LPCSTR lpszShortName
,
501 FIXME("%p %u %s %s %s stub\n",
502 lpszBuffer
, dwBuffSize
, debugstr_a(lpszShortName
),
503 debugstr_a(lpszLongName
), debugstr_a(lpszPathName
));
507 /*************************************************************************
508 * PathMakeUniqueNameW [internal]
510 static BOOL
PathMakeUniqueNameW(
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
));
523 /*************************************************************************
524 * PathMakeUniqueName [SHELL32.47]
526 BOOL WINAPI
PathMakeUniqueNameAW(
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
;
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
);
565 strcpyW(buffer
, retW
);
566 TRACE("ret - %s\n", debugstr_w(buffer
));
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
)
596 if (SHELL_OsIsUnicode())
598 LPWSTR p
= lpszFileW
;
600 TRACE("Cleanup %s\n",debugstr_w(lpszFileW
));
603 length
= strlenW(lpszPathW
);
607 int gct
= PathGetCharTypeW(*p
);
608 if (gct
== GCT_INVALID
|| gct
== GCT_WILD
|| gct
== GCT_SEPARATOR
)
611 rc
|= PCS_REPLACEDCHAR
;
617 if (length
+ i
== MAX_PATH
)
619 rc
|= PCS_FATAL
| PCS_PATHTOOLONG
;
627 LPSTR lpszFileA
= (LPSTR
)lpszFileW
;
628 LPCSTR lpszPathA
= (LPCSTR
)lpszPathW
;
631 TRACE("Cleanup %s\n",debugstr_a(lpszFileA
));
634 length
= strlen(lpszPathA
);
638 int gct
= PathGetCharTypeA(*p
);
639 if (gct
== GCT_INVALID
|| gct
== GCT_WILD
|| gct
== GCT_SEPARATOR
)
642 rc
|= PCS_REPLACEDCHAR
;
648 if (length
+ i
== MAX_PATH
)
650 rc
|= PCS_FATAL
| PCS_PATHTOOLONG
;
659 /*************************************************************************
660 * PathQualifyA [SHELL32]
662 static BOOL
PathQualifyA(LPCSTR pszPath
)
664 FIXME("%s\n",pszPath
);
668 /*************************************************************************
669 * PathQualifyW [SHELL32]
671 static BOOL
PathQualifyW(LPCWSTR pszPath
)
673 FIXME("%s\n",debugstr_w(pszPath
));
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
);
693 static BOOL
PathResolveW(LPWSTR path
, LPCWSTR
*paths
, DWORD flags
)
695 FIXME("(%s,%p,0x%08x),stub!\n", debugstr_w(path
), paths
, flags
);
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
);
707 return PathResolveA(path
, (LPCSTR
*)paths
, flags
);
710 /*************************************************************************
711 * PathProcessCommandA
713 static LONG
PathProcessCommandA (
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 (
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 (
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
);
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_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};
856 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};
857 static const WCHAR MoviesW
[] = {'M','o','v','i','e','s','\0'};
858 static const WCHAR MusicW
[] = {'M','u','s','i','c','\0'};
859 static const WCHAR MusicLibraryW
[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
860 static const WCHAR Music_librarymsW
[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
861 static const WCHAR Music_PlaylistsW
[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
862 static const WCHAR Music_Sample_MusicW
[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
863 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'};
864 static const WCHAR My_MusicW
[] = {'M','y',' ','M','u','s','i','c','\0'};
865 static const WCHAR My_PicturesW
[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
866 static const WCHAR My_VideosW
[] = {'M','y',' ','V','i','d','e','o','s','\0'};
867 static const WCHAR My_VideoW
[] = {'M','y',' ','V','i','d','e','o','\0'};
868 static const WCHAR MyComputerFolderW
[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
869 static const WCHAR NetHoodW
[] = {'N','e','t','H','o','o','d','\0'};
870 static const WCHAR NetworkPlacesFolderW
[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
871 static const WCHAR OEM_LinksW
[] = {'O','E','M',' ','L','i','n','k','s','\0'};
872 static const WCHAR Original_ImagesW
[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
873 static const WCHAR PersonalW
[] = {'P','e','r','s','o','n','a','l','\0'};
874 static const WCHAR PhotoAlbumsW
[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
875 static const WCHAR PicturesW
[] = {'P','i','c','t','u','r','e','s','\0'};
876 static const WCHAR PicturesLibraryW
[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
877 static const WCHAR Pictures_librarymsW
[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
878 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'};
879 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'};
880 static const WCHAR PlaylistsW
[] = {'P','l','a','y','l','i','s','t','s',0};
881 static const WCHAR PrintersFolderW
[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
882 static const WCHAR PrintHoodW
[] = {'P','r','i','n','t','H','o','o','d','\0'};
883 static const WCHAR ProfileW
[] = {'P','r','o','f','i','l','e',0};
884 static const WCHAR Program_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
885 static const WCHAR ProgramFilesW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
886 static const WCHAR ProgramFilesX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
887 static const WCHAR ProgramFilesX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
888 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'};
889 static const WCHAR Program_Files_x86W
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
890 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'};
891 static const WCHAR ProgramFilesCommonW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
892 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};
893 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};
894 static const WCHAR ProgramFilesDirW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
895 static const WCHAR ProgramFilesDirX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
896 static const WCHAR ProgramsW
[] = {'P','r','o','g','r','a','m','s','\0'};
897 static const WCHAR PublicW
[] = {'P','u','b','l','i','c',0};
898 static const WCHAR PublicGameTasksW
[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
899 static const WCHAR PublicLibrariesW
[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
900 static const WCHAR Quick_LaunchW
[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
901 static const WCHAR RecentW
[] = {'R','e','c','e','n','t','\0'};
902 static const WCHAR RecordedTVLibraryW
[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
903 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};
904 static const WCHAR RecycleBinFolderW
[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
905 static const WCHAR ResourceDirW
[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
906 static const WCHAR ResourcesW
[] = {'R','e','s','o','u','r','c','e','s','\0'};
907 static const WCHAR RingtonesW
[] = {'R','i','n','g','t','o','n','e','s',0};
908 static const WCHAR SampleMusicW
[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
909 static const WCHAR Sample_MusicW
[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
910 static const WCHAR SamplePicturesW
[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
911 static const WCHAR Sample_PicturesW
[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
912 static const WCHAR SamplePlaylistsW
[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
913 static const WCHAR Sample_PlaylistsW
[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
914 static const WCHAR Sample_VideosW
[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
915 static const WCHAR SampleVideosW
[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
916 static const WCHAR Saved_GamesW
[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
917 static const WCHAR SavedGamesW
[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
918 static const WCHAR SearchesW
[] = {'S','e','a','r','c','h','e','s','\0'};
919 static const WCHAR SearchHomeFolderW
[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
920 static const WCHAR SendToW
[] = {'S','e','n','d','T','o','\0'};
921 static const WCHAR Slide_ShowsW
[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
922 static const WCHAR StartUpW
[] = {'S','t','a','r','t','U','p','\0'};
923 static const WCHAR StartupW
[] = {'S','t','a','r','t','u','p','\0'};
924 static const WCHAR Start_MenuW
[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
925 static const WCHAR Start_Menu_ProgramsW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
926 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'};
927 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'};
928 static const WCHAR SyncCenterFolderW
[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
929 static const WCHAR SyncResultsFolderW
[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
930 static const WCHAR SyncSetupFolderW
[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
931 static const WCHAR SystemW
[] = {'S','y','s','t','e','m',0};
932 static const WCHAR SystemX86W
[] = {'S','y','s','t','e','m','X','8','6',0};
933 static const WCHAR TemplatesW
[] = {'T','e','m','p','l','a','t','e','s','\0'};
934 static const WCHAR User_PinnedW
[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
935 static const WCHAR UsersW
[] = {'U','s','e','r','s','\0'};
936 static const WCHAR UsersFilesFolderW
[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
937 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};
938 static const WCHAR UserProfilesW
[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
939 static const WCHAR UserProgramFilesW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
940 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};
941 static const WCHAR UsersPublicW
[] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'};
942 static const WCHAR VideosW
[] = {'V','i','d','e','o','s','\0'};
943 static const WCHAR VideosLibraryW
[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
944 static const WCHAR Videos_librarymsW
[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
945 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'};
946 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
947 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};
948 static const WCHAR DefaultW
[] = {'.','D','e','f','a','u','l','t','\0'};
949 static const WCHAR AllUsersProfileW
[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
950 static const WCHAR UserProfileW
[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
951 static const WCHAR SystemDriveW
[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
952 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};
953 static const WCHAR ProfilesDirectoryW
[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
954 static const WCHAR AllUsersProfileValueW
[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
955 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'};
956 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'};
957 static const WCHAR szDefaultProfileDirW
[] = {'u','s','e','r','s',0};
958 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'};
959 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};
960 static const WCHAR AllUsersW
[] = {'P','u','b','l','i','c',0};
962 #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','}'
963 #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','}'
964 #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','}'
965 #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','}'
966 #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','}'
968 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};
969 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};
970 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};
971 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};
972 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};
973 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};
974 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};
975 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};
976 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};
977 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};
978 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};
979 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};
980 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};
981 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};
982 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};
983 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};
984 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};
985 static const WCHAR ChangeRemoveProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, 0};
986 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};
987 static const WCHAR SyncManagerFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, 0};
988 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};
989 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};
990 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};
991 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};
992 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};
993 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};
994 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};
995 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};
996 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};
997 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};
998 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};
999 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};
1000 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};
1001 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};
1002 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};
1004 typedef enum _CSIDL_Type
{
1006 CSIDL_Type_AllUsers
,
1008 CSIDL_Type_Disallowed
,
1009 CSIDL_Type_NonExistent
,
1010 CSIDL_Type_WindowsPath
,
1011 CSIDL_Type_SystemPath
,
1012 CSIDL_Type_SystemX86Path
,
1015 #define CSIDL_CONTACTS 0x0043
1016 #define CSIDL_DOWNLOADS 0x0047
1017 #define CSIDL_LINKS 0x004d
1018 #define CSIDL_APPDATA_LOCALLOW 0x004e
1019 #define CSIDL_SAVED_GAMES 0x0062
1020 #define CSIDL_SEARCHES 0x0063
1024 IApplicationDestinations IApplicationDestinations_iface
;
1026 } IApplicationDestinationsImpl
;
1028 static inline IApplicationDestinationsImpl
*impl_from_IApplicationDestinations( IApplicationDestinations
*iface
)
1030 return CONTAINING_RECORD(iface
, IApplicationDestinationsImpl
, IApplicationDestinations_iface
);
1033 static HRESULT WINAPI
ApplicationDestinations_QueryInterface(IApplicationDestinations
*iface
, REFIID riid
,
1036 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1038 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1043 if (IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IApplicationDestinations
, riid
))
1045 *ppv
= &This
->IApplicationDestinations_iface
;
1046 IUnknown_AddRef((IUnknown
*)*ppv
);
1048 TRACE("Returning IApplicationDestinations: %p\n", *ppv
);
1053 FIXME("(%p)->(%s, %p) interface not supported.\n", This
, debugstr_guid(riid
), ppv
);
1055 return E_NOINTERFACE
;
1058 static ULONG WINAPI
ApplicationDestinations_AddRef(IApplicationDestinations
*iface
)
1060 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1061 ULONG ref
= InterlockedIncrement(&This
->ref
);
1063 TRACE("(%p), new refcount=%i\n", This
, ref
);
1068 static ULONG WINAPI
ApplicationDestinations_Release(IApplicationDestinations
*iface
)
1070 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1071 ULONG ref
= InterlockedDecrement(&This
->ref
);
1073 TRACE("(%p), new refcount=%i\n", This
, ref
);
1076 HeapFree(GetProcessHeap(), 0, This
);
1081 static HRESULT WINAPI
ApplicationDestinations_SetAppID(IApplicationDestinations
*iface
, const WCHAR
*appid
)
1083 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1085 FIXME("(%p, %s) stub!\n", This
, debugstr_w(appid
));
1090 static HRESULT WINAPI
ApplicationDestinations_RemoveDestination(IApplicationDestinations
*iface
, IUnknown
*punk
)
1092 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1094 FIXME("(%p, %p) stub!\n", This
, punk
);
1099 static HRESULT WINAPI
ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations
*iface
)
1101 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1103 FIXME("(%p) stub!\n", This
);
1108 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl
=
1110 ApplicationDestinations_QueryInterface
,
1111 ApplicationDestinations_AddRef
,
1112 ApplicationDestinations_Release
,
1113 ApplicationDestinations_SetAppID
,
1114 ApplicationDestinations_RemoveDestination
,
1115 ApplicationDestinations_RemoveAllDestinations
1118 HRESULT WINAPI
ApplicationDestinations_Constructor(IUnknown
*outer
, REFIID riid
, LPVOID
*ppv
)
1120 IApplicationDestinationsImpl
*This
;
1123 TRACE("(%p, %s, %p)\n", outer
, debugstr_guid(riid
), ppv
);
1126 return CLASS_E_NOAGGREGATION
;
1128 if (!(This
= SHAlloc(sizeof(*This
))))
1129 return E_OUTOFMEMORY
;
1131 This
->IApplicationDestinations_iface
.lpVtbl
= &ApplicationDestinationsVtbl
;
1134 hr
= IUnknown_QueryInterface(&This
->IApplicationDestinations_iface
, riid
, ppv
);
1143 const KNOWNFOLDERID
*id
;
1145 LPCWSTR szValueName
;
1146 LPCWSTR szDefaultPath
; /* fallback string or resource ID */
1148 /* KNOWNFOLDER_DEFINITION fields */
1149 KF_CATEGORY category
;
1150 const WCHAR
*pszName
;
1151 const WCHAR
*pszDescription
;
1152 const KNOWNFOLDERID
*fidParent
;
1153 const WCHAR
*pszRelativePath
;
1154 const WCHAR
*pszParsingName
;
1155 const WCHAR
*pszTooltip
;
1156 const WCHAR
*pszLocalizedName
;
1157 const WCHAR
*pszIcon
;
1158 const WCHAR
*pszSecurity
;
1160 KF_DEFINITION_FLAGS kfdFlags
;
1161 const FOLDERTYPEID
*ftidType
;
1164 static const CSIDL_DATA CSIDL_Data
[] =
1166 { /* 0x00 - CSIDL_DESKTOP */
1170 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1172 KF_CATEGORY_PERUSER
, /* category */
1173 DesktopW
, /* name */
1174 NULL
, /* description */
1175 &GUID_NULL
, /* parent */
1176 DesktopW
, /* relative path */
1179 NULL
, /* localized */
1181 NULL
, /* security */
1182 FILE_ATTRIBUTE_READONLY
, /* attributes */
1184 &GUID_NULL
/* typeid */
1186 { /* 0x01 - CSIDL_INTERNET */
1187 &FOLDERID_InternetFolder
,
1188 CSIDL_Type_Disallowed
,
1192 KF_CATEGORY_VIRTUAL
, /* category */
1193 InternetFolderW
, /* name */
1194 NULL
, /* description */
1195 &GUID_NULL
, /* parent */
1196 NULL
, /* relative path */
1197 InternetFolderParsingNameW
, /* parsing */
1199 NULL
, /* localized */
1201 NULL
, /* security */
1204 &GUID_NULL
/* typeid */
1206 { /* 0x02 - CSIDL_PROGRAMS */
1210 Start_Menu_ProgramsW
,
1212 KF_CATEGORY_PERUSER
, /* category */
1213 ProgramsW
, /* name */
1214 NULL
, /* description */
1215 &GUID_NULL
, /* parent */
1216 ProgramsW
, /* relative path */
1219 NULL
, /* localized */
1221 NULL
, /* security */
1222 FILE_ATTRIBUTE_READONLY
, /* attributes */
1224 &GUID_NULL
/* typeid */
1226 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1227 &FOLDERID_ControlPanelFolder
,
1228 CSIDL_Type_SystemPath
,
1232 KF_CATEGORY_VIRTUAL
, /* category */
1233 ControlPanelFolderW
, /* name */
1234 NULL
, /* description */
1235 &GUID_NULL
, /* parent */
1236 ControlPanelFolderRelativePathW
, /* relative path */
1237 ControlPanelFolderParsingNameW
, /* parsing */
1239 NULL
, /* localized */
1241 NULL
, /* security */
1244 &GUID_NULL
/* typeid */
1246 { /* 0x04 - CSIDL_PRINTERS */
1247 &FOLDERID_PrintersFolder
,
1248 CSIDL_Type_SystemPath
,
1252 KF_CATEGORY_VIRTUAL
, /* category */
1253 PrintersFolderW
, /* name */
1254 NULL
, /* description */
1255 &GUID_NULL
, /* parent */
1256 NULL
, /* relative path */
1257 PrintersFolderParsingNameW
, /* parsing */
1259 NULL
, /* localized */
1261 NULL
, /* security */
1264 &GUID_NULL
/* typeid */
1266 { /* 0x05 - CSIDL_PERSONAL */
1267 &FOLDERID_Documents
,
1270 MAKEINTRESOURCEW(IDS_PERSONAL
),
1272 KF_CATEGORY_PERUSER
, /* category */
1273 PersonalW
, /* name */
1274 NULL
, /* description */
1275 &GUID_NULL
, /* parent */
1276 DocumentsW
, /* relative path */
1277 DocumentsParsingNameW
, /* parsing */
1279 NULL
, /* localized */
1281 NULL
, /* security */
1282 FILE_ATTRIBUTE_READONLY
, /* attributes */
1283 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1284 &GUID_NULL
/* typeid */
1286 { /* 0x06 - CSIDL_FAVORITES */
1287 &FOLDERID_Favorites
,
1292 KF_CATEGORY_PERUSER
, /* category */
1293 FavoritesW
, /* name */
1294 NULL
, /* description */
1295 &GUID_NULL
, /* parent */
1296 FavoritesW
, /* relative path */
1299 NULL
, /* localized */
1301 NULL
, /* security */
1302 FILE_ATTRIBUTE_READONLY
, /* attributes */
1303 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1304 &GUID_NULL
/* typeid */
1306 { /* 0x07 - CSIDL_STARTUP */
1310 Start_Menu_StartupW
,
1312 KF_CATEGORY_PERUSER
, /* category */
1313 StartupW
, /* name */
1314 NULL
, /* description */
1315 &GUID_NULL
, /* parent */
1316 StartUpW
, /* relative path */
1319 NULL
, /* localized */
1321 NULL
, /* security */
1322 FILE_ATTRIBUTE_READONLY
, /* attributes */
1323 KFDF_PRECREATE
, /* flags */
1324 &GUID_NULL
/* typeid */
1326 { /* 0x08 - CSIDL_RECENT */
1332 KF_CATEGORY_PERUSER
, /* category */
1334 NULL
, /* description */
1335 &FOLDERID_RoamingAppData
, /* parent */
1336 Microsoft_Windows_RecentW
, /* relative path */
1339 NULL
, /* localized */
1341 NULL
, /* security */
1342 FILE_ATTRIBUTE_READONLY
, /* attributes */
1343 KFDF_PRECREATE
, /* flags */
1344 &GUID_NULL
/* typeid */
1346 { /* 0x09 - CSIDL_SENDTO */
1352 KF_CATEGORY_PERUSER
, /* category */
1354 NULL
, /* description */
1355 &FOLDERID_RoamingAppData
, /* parent */
1356 Microsoft_Windows_SendToW
, /* relative path */
1359 NULL
, /* localized */
1361 NULL
, /* security */
1363 KFDF_PRECREATE
, /* flags */
1364 &GUID_NULL
/* typeid */
1366 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1367 &FOLDERID_RecycleBinFolder
,
1368 CSIDL_Type_Disallowed
,
1372 KF_CATEGORY_VIRTUAL
, /* category */
1373 RecycleBinFolderW
, /* name */
1374 NULL
, /* description */
1375 &GUID_NULL
, /* parent */
1376 NULL
, /* relative path */
1377 RecycleBinFolderParsingNameW
, /* parsing */
1379 NULL
, /* localized */
1381 NULL
, /* security */
1384 &GUID_NULL
/* typeid */
1386 { /* 0x0b - CSIDL_STARTMENU */
1387 &FOLDERID_StartMenu
,
1392 KF_CATEGORY_PERUSER
, /* category */
1393 Start_MenuW
, /* name */
1394 NULL
, /* description */
1395 &FOLDERID_RoamingAppData
, /* parent */
1396 Microsoft_Windows_Start_MenuW
, /* relative path */
1399 NULL
, /* localized */
1401 NULL
, /* security */
1402 FILE_ATTRIBUTE_READONLY
, /* attributes */
1403 KFDF_PRECREATE
, /* flags */
1404 &GUID_NULL
/* typeid */
1406 { /* 0x0c - CSIDL_MYDOCUMENTS */
1408 CSIDL_Type_Disallowed
, /* matches WinXP--can't get its path */
1412 { /* 0x0d - CSIDL_MYMUSIC */
1416 MAKEINTRESOURCEW(IDS_MYMUSIC
),
1418 KF_CATEGORY_PERUSER
, /* category */
1419 My_MusicW
, /* name */
1420 NULL
, /* description */
1421 &FOLDERID_Profile
, /* parent */
1422 MusicW
, /* relative path */
1423 MusicParsingNameW
, /* parsing */
1425 NULL
, /* localized */
1427 NULL
, /* security */
1428 FILE_ATTRIBUTE_READONLY
, /* attributes */
1429 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1430 &GUID_NULL
/* typeid */
1432 { /* 0x0e - CSIDL_MYVIDEO */
1436 MAKEINTRESOURCEW(IDS_MYVIDEOS
),
1438 KF_CATEGORY_PERUSER
, /* category */
1439 My_VideoW
, /* name */
1440 NULL
, /* description */
1441 &FOLDERID_Profile
, /* parent */
1442 VideosW
, /* relative path */
1443 VideosParsingNameW
, /* parsing */
1445 NULL
, /* localized */
1447 NULL
, /* security */
1448 FILE_ATTRIBUTE_READONLY
, /* attributes */
1449 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1450 &GUID_NULL
/* typeid */
1452 { /* 0x0f - unassigned */
1454 CSIDL_Type_Disallowed
,
1458 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1462 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1464 KF_CATEGORY_PERUSER
, /* category */
1465 DesktopW
, /* name */
1466 NULL
, /* description */
1467 &FOLDERID_Profile
, /* parent */
1468 DesktopW
, /* relative path */
1471 NULL
, /* localized */
1473 NULL
, /* security */
1474 FILE_ATTRIBUTE_READONLY
, /* attributes */
1475 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1476 &GUID_NULL
/* typeid */
1478 { /* 0x11 - CSIDL_DRIVES */
1479 &FOLDERID_ComputerFolder
,
1480 CSIDL_Type_Disallowed
,
1484 KF_CATEGORY_VIRTUAL
, /* category */
1485 MyComputerFolderW
, /* name */
1486 NULL
, /* description */
1487 &GUID_NULL
, /* parent */
1488 NULL
, /* relative path */
1489 ComputerFolderParsingNameW
, /* parsing */
1491 NULL
, /* localized */
1493 NULL
, /* security */
1496 &GUID_NULL
/* typeid */
1498 { /* 0x12 - CSIDL_NETWORK */
1499 &FOLDERID_NetworkFolder
,
1500 CSIDL_Type_Disallowed
,
1504 KF_CATEGORY_VIRTUAL
, /* category */
1505 NetworkPlacesFolderW
, /* name */
1506 NULL
, /* description */
1507 &GUID_NULL
, /* parent */
1508 NULL
, /* relative path */
1509 NetworkFolderParsingNameW
, /* parsing */
1511 NULL
, /* localized */
1513 NULL
, /* security */
1516 &GUID_NULL
/* typeid */
1518 { /* 0x13 - CSIDL_NETHOOD */
1524 KF_CATEGORY_PERUSER
, /* category */
1525 NetHoodW
, /* name */
1526 NULL
, /* description */
1527 &FOLDERID_RoamingAppData
, /* parent */
1528 Microsoft_Windows_Network_ShortcutsW
, /* relative path */
1531 NULL
, /* localized */
1533 NULL
, /* security */
1536 &GUID_NULL
/* typeid */
1538 { /* 0x14 - CSIDL_FONTS */
1540 CSIDL_Type_WindowsPath
,
1544 KF_CATEGORY_FIXED
, /* category */
1546 NULL
, /* description */
1547 &GUID_NULL
, /* parent */
1548 NULL
, /* relative path */
1551 NULL
, /* localized */
1553 NULL
, /* security */
1556 &FOLDERID_Windows
/* typeid */
1558 { /* 0x15 - CSIDL_TEMPLATES */
1559 &FOLDERID_Templates
,
1564 KF_CATEGORY_PERUSER
, /* category */
1565 TemplatesW
, /* name */
1566 NULL
, /* description */
1567 &FOLDERID_RoamingAppData
, /* parent */
1568 Microsoft_Windows_TemplatesW
, /* relative path */
1571 NULL
, /* localized */
1573 NULL
, /* security */
1576 &GUID_NULL
/* typeid */
1578 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1579 &FOLDERID_CommonStartMenu
,
1580 CSIDL_Type_AllUsers
,
1584 KF_CATEGORY_COMMON
, /* category */
1585 Common_Start_MenuW
, /* name */
1586 NULL
, /* description */
1587 &FOLDERID_ProgramData
, /* parent */
1588 Microsoft_Windows_Start_MenuW
, /* relative path */
1591 NULL
, /* localized */
1593 NULL
, /* security */
1594 FILE_ATTRIBUTE_READONLY
, /* attributes */
1596 &GUID_NULL
/* typeid */
1598 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1599 &FOLDERID_CommonPrograms
,
1600 CSIDL_Type_AllUsers
,
1602 Start_Menu_ProgramsW
,
1604 KF_CATEGORY_COMMON
, /* category */
1605 Common_ProgramsW
, /* name */
1606 NULL
, /* description */
1607 &FOLDERID_CommonStartMenu
, /* parent */
1608 ProgramsW
, /* relative path */
1611 NULL
, /* localized */
1613 NULL
, /* security */
1614 FILE_ATTRIBUTE_READONLY
, /* attributes */
1616 &GUID_NULL
/* typeid */
1618 { /* 0x18 - CSIDL_COMMON_STARTUP */
1619 &FOLDERID_CommonStartup
,
1620 CSIDL_Type_AllUsers
,
1622 Start_Menu_StartupW
,
1624 KF_CATEGORY_COMMON
, /* category */
1625 Common_StartupW
, /* name */
1626 NULL
, /* description */
1627 &FOLDERID_CommonPrograms
, /* parent */
1628 StartUpW
, /* relative path */
1631 NULL
, /* localized */
1633 NULL
, /* security */
1634 FILE_ATTRIBUTE_READONLY
, /* attributes */
1635 KFDF_PRECREATE
, /* flags */
1636 &GUID_NULL
/* typeid */
1638 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1639 &FOLDERID_PublicDesktop
,
1640 CSIDL_Type_AllUsers
,
1642 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1644 KF_CATEGORY_COMMON
, /* category */
1645 Common_DesktopW
, /* name */
1646 NULL
, /* description */
1647 &FOLDERID_Public
, /* parent */
1648 DesktopW
, /* relative path */
1651 NULL
, /* localized */
1653 NULL
, /* security */
1654 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
1655 KFDF_PRECREATE
, /* flags */
1656 &GUID_NULL
/* typeid */
1658 { /* 0x1a - CSIDL_APPDATA */
1659 &FOLDERID_RoamingAppData
,
1664 KF_CATEGORY_PERUSER
, /* category */
1665 AppDataW
, /* name */
1666 NULL
, /* description */
1667 &FOLDERID_Profile
, /* parent */
1668 AppData_RoamingW
, /* relative path */
1671 NULL
, /* localized */
1673 NULL
, /* security */
1676 &GUID_NULL
/* typeid */
1678 { /* 0x1b - CSIDL_PRINTHOOD */
1679 &FOLDERID_PrintHood
,
1684 KF_CATEGORY_PERUSER
, /* category */
1685 PrintHoodW
, /* name */
1686 NULL
, /* description */
1687 &FOLDERID_RoamingAppData
, /* parent */
1688 Microsoft_Windows_Printer_ShortcutsW
, /* relative path */
1691 NULL
, /* localized */
1693 NULL
, /* security */
1696 &GUID_NULL
/* typeid */
1698 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1699 &FOLDERID_LocalAppData
,
1702 Local_Settings_Application_DataW
,
1704 KF_CATEGORY_PERUSER
, /* category */
1705 Local_AppDataW
, /* name */
1706 NULL
, /* description */
1707 &FOLDERID_Profile
, /* parent */
1708 AppData_LocalW
, /* relative path */
1711 NULL
, /* localized */
1713 NULL
, /* security */
1715 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1716 &GUID_NULL
/* typeid */
1718 { /* 0x1d - CSIDL_ALTSTARTUP */
1720 CSIDL_Type_NonExistent
,
1724 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1726 CSIDL_Type_NonExistent
,
1730 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1731 &FOLDERID_Favorites
,
1732 CSIDL_Type_AllUsers
,
1736 KF_CATEGORY_PERUSER
, /* category */
1737 FavoritesW
, /* name */
1738 NULL
, /* description */
1739 &FOLDERID_Profile
, /* parent */
1740 FavoritesW
, /* relative path */
1743 NULL
, /* localized */
1745 NULL
, /* security */
1746 FILE_ATTRIBUTE_READONLY
, /* attributes */
1747 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1748 &GUID_NULL
/* typeid */
1750 { /* 0x20 - CSIDL_INTERNET_CACHE */
1751 &FOLDERID_InternetCache
,
1754 Local_Settings_Temporary_Internet_FilesW
,
1756 KF_CATEGORY_PERUSER
, /* category */
1758 NULL
, /* description */
1759 &FOLDERID_LocalAppData
, /* parent */
1760 Microsoft_Windows_Temporary_Internet_FilesW
, /* relative path */
1763 NULL
, /* localized */
1765 NULL
, /* security */
1767 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1768 &GUID_NULL
/* typeid */
1770 { /* 0x21 - CSIDL_COOKIES */
1776 KF_CATEGORY_PERUSER
, /* category */
1777 CookiesW
, /* name */
1778 NULL
, /* description */
1779 &FOLDERID_RoamingAppData
, /* parent */
1780 Microsoft_Windows_CookiesW
, /* relative path */
1783 NULL
, /* localized */
1785 NULL
, /* security */
1788 &GUID_NULL
/* typeid */
1790 { /* 0x22 - CSIDL_HISTORY */
1794 Local_Settings_HistoryW
,
1796 KF_CATEGORY_PERUSER
, /* category */
1797 HistoryW
, /* name */
1798 NULL
, /* description */
1799 &FOLDERID_LocalAppData
, /* parent */
1800 Microsoft_Windows_HistoryW
, /* relative path */
1803 NULL
, /* localized */
1805 NULL
, /* security */
1807 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1808 &GUID_NULL
/* typeid */
1810 { /* 0x23 - CSIDL_COMMON_APPDATA */
1811 &FOLDERID_ProgramData
,
1812 CSIDL_Type_AllUsers
,
1816 KF_CATEGORY_FIXED
, /* category */
1817 Common_AppDataW
, /* name */
1818 NULL
, /* description */
1819 &GUID_NULL
, /* parent */
1820 NULL
, /* relative path */
1823 NULL
, /* localized */
1825 NULL
, /* security */
1828 &GUID_NULL
/* typeid */
1830 { /* 0x24 - CSIDL_WINDOWS */
1832 CSIDL_Type_WindowsPath
,
1836 KF_CATEGORY_FIXED
, /* category */
1837 WindowsW
, /* name */
1838 NULL
, /* description */
1839 &GUID_NULL
, /* parent */
1840 NULL
, /* relative path */
1843 NULL
, /* localized */
1845 NULL
, /* security */
1848 &GUID_NULL
/* typeid */
1850 { /* 0x25 - CSIDL_SYSTEM */
1852 CSIDL_Type_SystemPath
,
1856 KF_CATEGORY_FIXED
, /* category */
1858 NULL
, /* description */
1859 &GUID_NULL
, /* parent */
1860 NULL
, /* relative path */
1863 NULL
, /* localized */
1865 NULL
, /* security */
1868 &GUID_NULL
/* typeid */
1870 { /* 0x26 - CSIDL_PROGRAM_FILES */
1871 &FOLDERID_ProgramFiles
,
1876 KF_CATEGORY_FIXED
, /* category */
1877 ProgramFilesW
, /* name */
1878 NULL
, /* description */
1879 &GUID_NULL
, /* parent */
1880 NULL
, /* relative path */
1883 NULL
, /* localized */
1885 NULL
, /* security */
1886 FILE_ATTRIBUTE_READONLY
, /* attributes */
1888 &GUID_NULL
/* typeid */
1890 { /* 0x27 - CSIDL_MYPICTURES */
1894 MAKEINTRESOURCEW(IDS_MYPICTURES
),
1896 KF_CATEGORY_PERUSER
, /* category */
1897 My_PicturesW
, /* name */
1898 NULL
, /* description */
1899 &FOLDERID_Profile
, /* parent */
1900 PicturesW
, /* relative path */
1901 PicturesParsingNameW
, /* parsing */
1903 NULL
, /* localized */
1905 NULL
, /* security */
1906 FILE_ATTRIBUTE_READONLY
, /* attributes */
1907 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1908 &GUID_NULL
/* typeid */
1910 { /* 0x28 - CSIDL_PROFILE */
1916 KF_CATEGORY_FIXED
, /* category */
1917 ProfileW
, /* name */
1918 NULL
, /* description */
1919 &GUID_NULL
, /* parent */
1920 NULL
, /* relative path */
1923 NULL
, /* localized */
1925 NULL
, /* security */
1928 &GUID_NULL
/* typeid */
1930 { /* 0x29 - CSIDL_SYSTEMX86 */
1931 &FOLDERID_SystemX86
,
1932 CSIDL_Type_SystemX86Path
,
1936 KF_CATEGORY_FIXED
, /* category */
1937 SystemX86W
, /* name */
1938 NULL
, /* description */
1939 &GUID_NULL
, /* parent */
1940 NULL
, /* relative path */
1943 NULL
, /* localized */
1945 NULL
, /* security */
1948 &GUID_NULL
/* typeid */
1950 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
1951 &FOLDERID_ProgramFilesX86
,
1953 ProgramFilesDirX86W
,
1956 KF_CATEGORY_FIXED
, /* category */
1957 ProgramFilesX86W
, /* name */
1958 NULL
, /* description */
1959 &GUID_NULL
, /* parent */
1960 NULL
, /* relative path */
1963 NULL
, /* localized */
1965 NULL
, /* security */
1966 FILE_ATTRIBUTE_READONLY
, /* attributes */
1968 &GUID_NULL
/* typeid */
1970 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
1971 &FOLDERID_ProgramFilesCommon
,
1974 Program_Files_Common_FilesW
,
1976 KF_CATEGORY_FIXED
, /* category */
1977 ProgramFilesCommonW
, /* name */
1978 NULL
, /* description */
1979 &GUID_NULL
, /* parent */
1980 NULL
, /* relative path */
1983 NULL
, /* localized */
1985 NULL
, /* security */
1988 &GUID_NULL
/* typeid */
1990 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
1991 &FOLDERID_ProgramFilesCommonX86
,
1994 Program_Files_x86_Common_FilesW
,
1996 KF_CATEGORY_FIXED
, /* category */
1997 ProgramFilesCommonX86W
, /* name */
1998 NULL
, /* description */
1999 &GUID_NULL
, /* parent */
2000 NULL
, /* relative path */
2003 NULL
, /* localized */
2005 NULL
, /* security */
2008 &GUID_NULL
/* typeid */
2010 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2011 &FOLDERID_CommonTemplates
,
2012 CSIDL_Type_AllUsers
,
2016 KF_CATEGORY_COMMON
, /* category */
2017 Common_TemplatesW
, /* name */
2018 NULL
, /* description */
2019 &FOLDERID_ProgramData
, /* parent */
2020 Microsoft_Windows_TemplatesW
, /* relative path */
2023 NULL
, /* localized */
2025 NULL
, /* security */
2028 &GUID_NULL
/* typeid */
2030 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2031 &FOLDERID_PublicDocuments
,
2032 CSIDL_Type_AllUsers
,
2036 KF_CATEGORY_COMMON
, /* category */
2037 Common_DocumentsW
, /* name */
2038 NULL
, /* description */
2039 &FOLDERID_Public
, /* parent */
2040 DocumentsW
, /* relative path */
2043 NULL
, /* localized */
2045 NULL
, /* security */
2046 FILE_ATTRIBUTE_READONLY
, /* attributes */
2047 KFDF_PRECREATE
, /* flags */
2048 &GUID_NULL
/* typeid */
2050 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2051 &FOLDERID_CommonAdminTools
,
2052 CSIDL_Type_AllUsers
,
2053 Common_Administrative_ToolsW
,
2054 Start_Menu_Admin_ToolsW
,
2056 KF_CATEGORY_COMMON
, /* category */
2057 Common_Administrative_ToolsW
, /* name */
2058 NULL
, /* description */
2059 &FOLDERID_CommonPrograms
, /* parent */
2060 Administrative_ToolsW
, /* relative path */
2063 NULL
, /* localized */
2065 NULL
, /* security */
2066 FILE_ATTRIBUTE_READONLY
, /* attributes */
2067 KFDF_PRECREATE
, /* flags */
2068 &GUID_NULL
/* typeid */
2070 { /* 0x30 - CSIDL_ADMINTOOLS */
2071 &FOLDERID_AdminTools
,
2073 Administrative_ToolsW
,
2074 Start_Menu_Admin_ToolsW
,
2076 KF_CATEGORY_PERUSER
, /* category */
2077 Administrative_ToolsW
, /* name */
2078 NULL
, /* description */
2079 &FOLDERID_Programs
, /* parent */
2080 Administrative_ToolsW
, /* relative path */
2083 NULL
, /* localized */
2085 NULL
, /* security */
2086 FILE_ATTRIBUTE_READONLY
, /* attributes */
2087 KFDF_PRECREATE
, /* flags */
2088 &GUID_NULL
/* typeid */
2090 { /* 0x31 - CSIDL_CONNECTIONS */
2091 &FOLDERID_ConnectionsFolder
,
2092 CSIDL_Type_Disallowed
,
2096 KF_CATEGORY_VIRTUAL
, /* category */
2097 ConnectionsFolderW
, /* name */
2098 NULL
, /* description */
2099 &GUID_NULL
, /* parent */
2100 Administrative_ToolsW
, /* relative path */
2101 ConnectionsFolderParsingNameW
, /* parsing */
2103 NULL
, /* localized */
2105 NULL
, /* security */
2108 &GUID_NULL
/* typeid */
2110 { /* 0x32 - unassigned */
2112 CSIDL_Type_Disallowed
,
2116 { /* 0x33 - unassigned */
2118 CSIDL_Type_Disallowed
,
2122 { /* 0x34 - unassigned */
2124 CSIDL_Type_Disallowed
,
2128 { /* 0x35 - CSIDL_COMMON_MUSIC */
2129 &FOLDERID_PublicMusic
,
2130 CSIDL_Type_AllUsers
,
2134 KF_CATEGORY_COMMON
, /* category */
2135 CommonMusicW
, /* name */
2136 NULL
, /* description */
2137 &FOLDERID_Public
, /* parent */
2138 MusicW
, /* relative path */
2141 NULL
, /* localized */
2143 NULL
, /* security */
2144 FILE_ATTRIBUTE_READONLY
, /* attributes */
2145 KFDF_PRECREATE
, /* flags */
2146 &GUID_NULL
/* typeid */
2148 { /* 0x36 - CSIDL_COMMON_PICTURES */
2149 &FOLDERID_PublicPictures
,
2150 CSIDL_Type_AllUsers
,
2154 KF_CATEGORY_COMMON
, /* category */
2155 CommonPicturesW
, /* name */
2156 NULL
, /* description */
2157 &FOLDERID_Public
, /* parent */
2158 PicturesW
, /* relative path */
2161 NULL
, /* localized */
2163 NULL
, /* security */
2164 FILE_ATTRIBUTE_READONLY
, /* attributes */
2165 KFDF_PRECREATE
, /* flags */
2166 &GUID_NULL
/* typeid */
2168 { /* 0x37 - CSIDL_COMMON_VIDEO */
2169 &FOLDERID_PublicVideos
,
2170 CSIDL_Type_AllUsers
,
2174 KF_CATEGORY_COMMON
, /* category */
2175 CommonVideoW
, /* name */
2176 NULL
, /* description */
2177 &FOLDERID_Public
, /* parent */
2178 VideosW
, /* relative path */
2181 NULL
, /* localized */
2183 NULL
, /* security */
2184 FILE_ATTRIBUTE_READONLY
, /* attributes */
2185 KFDF_PRECREATE
, /* flags */
2186 &GUID_NULL
/* typeid */
2188 { /* 0x38 - CSIDL_RESOURCES */
2189 &FOLDERID_ResourceDir
,
2190 CSIDL_Type_WindowsPath
,
2194 KF_CATEGORY_FIXED
, /* category */
2195 ResourceDirW
, /* name */
2196 NULL
, /* description */
2197 &GUID_NULL
, /* parent */
2198 NULL
, /* relative path */
2201 NULL
, /* localized */
2203 NULL
, /* security */
2206 &GUID_NULL
/* typeid */
2208 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2209 &FOLDERID_LocalizedResourcesDir
,
2210 CSIDL_Type_NonExistent
,
2214 KF_CATEGORY_FIXED
, /* category */
2215 LocalizedResourcesDirW
, /* name */
2216 NULL
, /* description */
2217 &GUID_NULL
, /* parent */
2218 NULL
, /* relative path */
2221 NULL
, /* localized */
2223 NULL
, /* security */
2226 &GUID_NULL
/* typeid */
2228 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2229 &FOLDERID_CommonOEMLinks
,
2230 CSIDL_Type_AllUsers
,
2234 KF_CATEGORY_COMMON
, /* category */
2235 OEM_LinksW
, /* name */
2236 NULL
, /* description */
2237 &FOLDERID_ProgramData
, /* parent */
2238 OEM_LinksW
, /* relative path */
2241 NULL
, /* localized */
2243 NULL
, /* security */
2246 &GUID_NULL
/* typeid */
2248 { /* 0x3b - CSIDL_CDBURN_AREA */
2249 &FOLDERID_CDBurning
,
2252 Local_Settings_CD_BurningW
,
2254 KF_CATEGORY_PERUSER
, /* category */
2255 CD_BurningW
, /* name */
2256 NULL
, /* description */
2257 &FOLDERID_LocalAppData
, /* parent */
2258 Microsoft_Windows_Burn_BurnW
, /* relative path */
2261 NULL
, /* localized */
2263 NULL
, /* security */
2264 FILE_ATTRIBUTE_READONLY
, /* attributes */
2265 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2266 &GUID_NULL
/* typeid */
2268 { /* 0x3c unassigned */
2270 CSIDL_Type_Disallowed
,
2274 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2276 CSIDL_Type_Disallowed
, /* FIXME */
2280 { /* 0x3e - CSIDL_PROFILES */
2282 CSIDL_Type_Disallowed
, /* oddly, this matches WinXP */
2287 &FOLDERID_AddNewPrograms
,
2288 CSIDL_Type_Disallowed
,
2292 KF_CATEGORY_VIRTUAL
, /* category */
2293 AddNewProgramsFolderW
, /* name */
2294 NULL
, /* description */
2295 &GUID_NULL
, /* parent */
2296 NULL
, /* relative path */
2297 AddNewProgramsParsingNameW
, /* parsing */
2299 NULL
, /* localized */
2301 NULL
, /* security */
2304 &GUID_NULL
/* typeid */
2307 &FOLDERID_AppUpdates
,
2308 CSIDL_Type_Disallowed
,
2312 KF_CATEGORY_VIRTUAL
, /* category */
2313 AppUpdatesFolderW
, /* name */
2314 NULL
, /* description */
2315 &GUID_NULL
, /* parent */
2316 NULL
, /* relative path */
2317 AppUpdatesParsingNameW
, /* parsing */
2319 NULL
, /* localized */
2321 NULL
, /* security */
2324 &GUID_NULL
/* typeid */
2327 &FOLDERID_ChangeRemovePrograms
,
2328 CSIDL_Type_Disallowed
,
2332 KF_CATEGORY_VIRTUAL
, /* category */
2333 ChangeRemoveProgramsFolderW
, /* name */
2334 NULL
, /* description */
2335 &GUID_NULL
, /* parent */
2336 NULL
, /* relative path */
2337 ChangeRemoveProgramsParsingNameW
, /* parsing */
2339 NULL
, /* localized */
2341 NULL
, /* security */
2344 &GUID_NULL
/* typeid */
2347 &FOLDERID_ConflictFolder
,
2348 CSIDL_Type_Disallowed
,
2352 KF_CATEGORY_VIRTUAL
, /* category */
2353 ConflictFolderW
, /* name */
2354 NULL
, /* description */
2355 &GUID_NULL
, /* parent */
2356 NULL
, /* relative path */
2357 ConflictFolderParsingNameW
, /* parsing */
2359 NULL
, /* localized */
2361 NULL
, /* security */
2364 &GUID_NULL
/* typeid */
2366 { /* 0x43 - CSIDL_CONTACTS */
2372 KF_CATEGORY_PERUSER
, /* category */
2373 ContactsW
, /* name */
2374 NULL
, /* description */
2375 &FOLDERID_Profile
, /* parent */
2376 ContactsW
, /* relative path */
2377 ContactsParsingNameW
, /* parsing */
2379 NULL
, /* localized */
2381 NULL
, /* security */
2382 FILE_ATTRIBUTE_READONLY
, /* attributes */
2383 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2384 &GUID_NULL
/* typeid */
2387 &FOLDERID_DeviceMetadataStore
,
2388 CSIDL_Type_Disallowed
, /* FIXME */
2392 KF_CATEGORY_COMMON
, /* category */
2393 Device_Metadata_StoreW
, /* name */
2394 NULL
, /* description */
2395 &FOLDERID_ProgramData
, /* parent */
2396 Microsoft_Windows_DeviceMetadataStoreW
, /* relative path */
2399 NULL
, /* localized */
2401 NULL
, /* security */
2404 &GUID_NULL
/* typeid */
2413 &FOLDERID_DocumentsLibrary
,
2414 CSIDL_Type_Disallowed
, /* FIXME */
2418 KF_CATEGORY_PERUSER
, /* category */
2419 DocumentsLibraryW
, /* name */
2420 NULL
, /* description */
2421 &FOLDERID_Libraries
, /* parent */
2422 Documents_librarymsW
, /* relative path */
2423 DocumentsLibraryParsingNameW
, /* parsing */
2425 NULL
, /* localized */
2427 NULL
, /* security */
2429 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2430 &GUID_NULL
/* typeid */
2432 { /* 0x47 - CSIDL_DOWNLOADS */
2433 &FOLDERID_Downloads
,
2438 KF_CATEGORY_PERUSER
, /* category */
2439 DownloadsW
, /* name */
2440 NULL
, /* description */
2441 &FOLDERID_Profile
, /* parent */
2442 DownloadsW
, /* relative path */
2445 NULL
, /* localized */
2447 NULL
, /* security */
2448 FILE_ATTRIBUTE_READONLY
, /* attributes */
2449 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2450 &GUID_NULL
/* typeid */
2454 CSIDL_Type_Disallowed
,
2458 KF_CATEGORY_VIRTUAL
, /* category */
2460 NULL
, /* description */
2461 &GUID_NULL
, /* parent */
2462 NULL
, /* relative path */
2463 GamesParsingNameW
, /* parsing */
2465 NULL
, /* localized */
2467 NULL
, /* security */
2470 &GUID_NULL
/* typeid */
2473 &FOLDERID_GameTasks
,
2474 CSIDL_Type_Disallowed
, /* FIXME */
2478 KF_CATEGORY_PERUSER
, /* category */
2479 GameTasksW
, /* name */
2480 NULL
, /* description */
2481 &FOLDERID_LocalAppData
, /* parent */
2482 Microsoft_Windows_GameExplorerW
, /* relative path */
2485 NULL
, /* localized */
2487 NULL
, /* security */
2489 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2490 &GUID_NULL
/* typeid */
2493 &FOLDERID_HomeGroup
,
2494 CSIDL_Type_Disallowed
,
2498 KF_CATEGORY_VIRTUAL
, /* category */
2499 HomeGroupFolderW
, /* name */
2500 NULL
, /* description */
2501 &GUID_NULL
, /* parent */
2502 NULL
, /* relative path */
2503 HomeGroupParsingNameW
, /* parsing */
2505 NULL
, /* localized */
2507 NULL
, /* security */
2510 &GUID_NULL
/* typeid */
2513 &FOLDERID_ImplicitAppShortcuts
,
2514 CSIDL_Type_Disallowed
, /* FIXME */
2518 KF_CATEGORY_PERUSER
, /* category */
2519 ImplicitAppShortcutsW
, /* name */
2520 NULL
, /* description */
2521 &FOLDERID_UserPinned
, /* parent */
2522 ImplicitAppShortcutsW
, /* relative path */
2525 NULL
, /* localized */
2527 NULL
, /* security */
2529 KFDF_PRECREATE
, /* flags */
2530 &GUID_NULL
/* typeid */
2533 &FOLDERID_Libraries
,
2534 CSIDL_Type_Disallowed
, /* FIXME */
2538 KF_CATEGORY_PERUSER
, /* category */
2539 LibrariesW
, /* name */
2540 NULL
, /* description */
2541 &FOLDERID_RoamingAppData
, /* parent */
2542 Microsoft_Windows_LibrariesW
, /* relative path */
2545 NULL
, /* localized */
2547 NULL
, /* security */
2549 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2550 &GUID_NULL
/* typeid */
2552 { /* 0x4d - CSIDL_LINKS */
2558 KF_CATEGORY_PERUSER
, /* category */
2560 NULL
, /* description */
2561 &FOLDERID_Profile
, /* parent */
2562 LinksW
, /* relative path */
2563 LinksParsingNameW
, /* parsing */
2565 NULL
, /* localized */
2567 NULL
, /* security */
2568 FILE_ATTRIBUTE_READONLY
, /* attributes */
2569 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2570 &GUID_NULL
/* typeid */
2572 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2573 &FOLDERID_LocalAppDataLow
,
2578 KF_CATEGORY_PERUSER
, /* category */
2579 LocalAppDataLowW
, /* name */
2580 NULL
, /* description */
2581 &FOLDERID_Profile
, /* parent */
2582 AppData_LocalLowW
, /* relative path */
2585 NULL
, /* localized */
2587 NULL
, /* security */
2588 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
, /* attributes */
2589 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2590 &GUID_NULL
/* typeid */
2593 &FOLDERID_MusicLibrary
,
2594 CSIDL_Type_Disallowed
, /* FIXME */
2598 KF_CATEGORY_PERUSER
, /* category */
2599 MusicLibraryW
, /* name */
2600 NULL
, /* description */
2601 &FOLDERID_Libraries
, /* parent */
2602 Music_librarymsW
, /* relative path */
2603 MusicLibraryParsingNameW
, /* parsing */
2605 NULL
, /* localized */
2607 NULL
, /* security */
2609 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2610 &GUID_NULL
/* typeid */
2613 &FOLDERID_OriginalImages
,
2614 CSIDL_Type_Disallowed
, /* FIXME */
2618 KF_CATEGORY_PERUSER
, /* category */
2619 Original_ImagesW
, /* name */
2620 NULL
, /* description */
2621 &FOLDERID_LocalAppData
, /* parent */
2622 Microsoft_Windows_Photo_Gallery_Original_ImagesW
, /* relative path */
2625 NULL
, /* localized */
2627 NULL
, /* security */
2630 &GUID_NULL
/* typeid */
2633 &FOLDERID_PhotoAlbums
,
2636 Pictures_Slide_ShowsW
,
2638 KF_CATEGORY_PERUSER
, /* category */
2639 PhotoAlbumsW
, /* name */
2640 NULL
, /* description */
2641 &FOLDERID_Pictures
, /* parent */
2642 Slide_ShowsW
, /* relative path */
2645 NULL
, /* localized */
2647 NULL
, /* security */
2648 FILE_ATTRIBUTE_READONLY
, /* attributes */
2650 &GUID_NULL
/* typeid */
2653 &FOLDERID_PicturesLibrary
,
2654 CSIDL_Type_Disallowed
, /* FIXME */
2658 KF_CATEGORY_PERUSER
, /* category */
2659 PicturesLibraryW
, /* name */
2660 NULL
, /* description */
2661 &FOLDERID_Libraries
, /* parent */
2662 Pictures_librarymsW
, /* relative path */
2663 PicturesLibraryParsingNameW
, /* parsing */
2665 NULL
, /* localized */
2667 NULL
, /* security */
2669 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2670 &GUID_NULL
/* typeid */
2673 &FOLDERID_Playlists
,
2678 KF_CATEGORY_PERUSER
, /* category */
2679 PlaylistsW
, /* name */
2680 NULL
, /* description */
2681 &FOLDERID_Music
, /* parent */
2682 PlaylistsW
, /* relative path */
2685 NULL
, /* localized */
2687 NULL
, /* security */
2688 FILE_ATTRIBUTE_READONLY
, /* attributes */
2690 &GUID_NULL
/* typeid */
2693 &FOLDERID_ProgramFilesX64
,
2694 CSIDL_Type_NonExistent
,
2698 KF_CATEGORY_FIXED
, /* category */
2699 ProgramFilesX64W
, /* name */
2700 NULL
, /* description */
2701 &GUID_NULL
, /* parent */
2702 NULL
, /* relative path */
2705 NULL
, /* localized */
2707 NULL
, /* security */
2710 &GUID_NULL
/* typeid */
2713 &FOLDERID_ProgramFilesCommonX64
,
2714 CSIDL_Type_NonExistent
,
2718 KF_CATEGORY_FIXED
, /* category */
2719 ProgramFilesCommonX64W
, /* name */
2720 NULL
, /* description */
2721 &GUID_NULL
, /* parent */
2722 NULL
, /* relative path */
2725 NULL
, /* localized */
2727 NULL
, /* security */
2730 &GUID_NULL
/* typeid */
2734 CSIDL_Type_CurrVer
, /* FIXME */
2738 KF_CATEGORY_FIXED
, /* category */
2740 NULL
, /* description */
2741 &GUID_NULL
, /* parent */
2742 NULL
, /* relative path */
2743 PublicParsingNameW
, /* parsing */
2745 NULL
, /* localized */
2747 NULL
, /* security */
2748 FILE_ATTRIBUTE_READONLY
, /* attributes */
2749 KFDF_PRECREATE
, /* flags */
2750 &GUID_NULL
/* typeid */
2753 &FOLDERID_PublicDownloads
,
2754 CSIDL_Type_AllUsers
,
2758 KF_CATEGORY_COMMON
, /* category */
2759 CommonDownloadsW
, /* name */
2760 NULL
, /* description */
2761 &FOLDERID_Public
, /* parent */
2762 DownloadsW
, /* relative path */
2765 NULL
, /* localized */
2767 NULL
, /* security */
2768 FILE_ATTRIBUTE_READONLY
, /* attributes */
2769 KFDF_PRECREATE
, /* flags */
2770 &GUID_NULL
/* typeid */
2773 &FOLDERID_PublicGameTasks
,
2774 CSIDL_Type_AllUsers
,
2776 Microsoft_Windows_GameExplorerW
,
2778 KF_CATEGORY_COMMON
, /* category */
2779 PublicGameTasksW
, /* name */
2780 NULL
, /* description */
2781 &FOLDERID_ProgramData
, /* parent */
2782 Microsoft_Windows_GameExplorerW
, /* relative path */
2785 NULL
, /* localized */
2787 NULL
, /* security */
2789 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2790 &GUID_NULL
/* typeid */
2793 &FOLDERID_PublicLibraries
,
2794 CSIDL_Type_AllUsers
,
2796 Microsoft_Windows_LibrariesW
,
2798 KF_CATEGORY_COMMON
, /* category */
2799 PublicLibrariesW
, /* name */
2800 NULL
, /* description */
2801 &FOLDERID_Public
, /* parent */
2802 LibrariesW
, /* relative path */
2805 NULL
, /* localized */
2807 NULL
, /* security */
2808 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
2809 KFDF_PRECREATE
, /* flags */
2810 &GUID_NULL
/* typeid */
2813 &FOLDERID_PublicRingtones
,
2814 CSIDL_Type_AllUsers
,
2816 Microsoft_Windows_RingtonesW
,
2818 KF_CATEGORY_COMMON
, /* category */
2819 CommonRingtonesW
, /* name */
2820 NULL
, /* description */
2821 &FOLDERID_ProgramData
, /* parent */
2822 Microsoft_Windows_RingtonesW
, /* relative path */
2825 NULL
, /* localized */
2827 NULL
, /* security */
2829 KFDF_PRECREATE
, /* flags */
2830 &GUID_NULL
/* typeid */
2833 &FOLDERID_QuickLaunch
,
2834 CSIDL_Type_Disallowed
, /* FIXME */
2838 KF_CATEGORY_PERUSER
, /* category */
2839 Quick_LaunchW
, /* name */
2840 NULL
, /* description */
2841 &FOLDERID_RoamingAppData
, /* parent */
2842 Microsoft_Internet_Explorer_Quick_LaunchW
, /* relative path */
2845 NULL
, /* localized */
2847 NULL
, /* security */
2850 &GUID_NULL
/* typeid */
2853 &FOLDERID_RecordedTVLibrary
,
2854 CSIDL_Type_Disallowed
, /* FIXME */
2858 KF_CATEGORY_COMMON
, /* category */
2859 RecordedTVLibraryW
, /* name */
2860 NULL
, /* description */
2861 &FOLDERID_PublicLibraries
, /* parent */
2862 RecordedTV_librarymsW
, /* relative path */
2865 NULL
, /* localized */
2867 NULL
, /* security */
2869 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2870 &GUID_NULL
/* typeid */
2873 &FOLDERID_Ringtones
,
2874 CSIDL_Type_Disallowed
, /* FIXME */
2878 KF_CATEGORY_PERUSER
, /* category */
2879 RingtonesW
, /* name */
2880 NULL
, /* description */
2881 &FOLDERID_LocalAppData
, /* parent */
2882 Microsoft_Windows_RingtonesW
, /* relative path */
2885 NULL
, /* localized */
2887 NULL
, /* security */
2889 KFDF_PRECREATE
, /* flags */
2890 &GUID_NULL
/* typeid */
2893 &FOLDERID_SampleMusic
,
2894 CSIDL_Type_AllUsers
,
2896 Music_Sample_MusicW
,
2898 KF_CATEGORY_COMMON
, /* category */
2899 SampleMusicW
, /* name */
2900 NULL
, /* description */
2901 &FOLDERID_PublicMusic
, /* parent */
2902 Sample_MusicW
, /* relative path */
2905 NULL
, /* localized */
2907 NULL
, /* security */
2908 FILE_ATTRIBUTE_READONLY
, /* attributes */
2909 KFDF_PRECREATE
, /* flags */
2910 &GUID_NULL
/* typeid */
2913 &FOLDERID_SamplePictures
,
2914 CSIDL_Type_AllUsers
,
2916 Pictures_Sample_PicturesW
,
2918 KF_CATEGORY_COMMON
, /* category */
2919 SamplePicturesW
, /* name */
2920 NULL
, /* description */
2921 &FOLDERID_PublicPictures
, /* parent */
2922 Sample_PicturesW
, /* relative path */
2925 NULL
, /* localized */
2927 NULL
, /* security */
2928 FILE_ATTRIBUTE_READONLY
, /* attributes */
2929 KFDF_PRECREATE
, /* flags */
2930 &GUID_NULL
/* typeid */
2933 &FOLDERID_SamplePlaylists
,
2934 CSIDL_Type_AllUsers
,
2936 Music_Sample_PlaylistsW
,
2938 KF_CATEGORY_COMMON
, /* category */
2939 SamplePlaylistsW
, /* name */
2940 NULL
, /* description */
2941 &FOLDERID_PublicMusic
, /* parent */
2942 Sample_PlaylistsW
, /* relative path */
2945 NULL
, /* localized */
2947 NULL
, /* security */
2948 FILE_ATTRIBUTE_READONLY
, /* attributes */
2949 KFDF_PRECREATE
, /* flags */
2950 &GUID_NULL
/* typeid */
2953 &FOLDERID_SampleVideos
,
2954 CSIDL_Type_AllUsers
,
2956 Videos_Sample_VideosW
,
2958 KF_CATEGORY_COMMON
, /* category */
2959 SampleVideosW
, /* name */
2960 NULL
, /* description */
2961 &FOLDERID_PublicVideos
, /* parent */
2962 Sample_VideosW
, /* relative path */
2965 NULL
, /* localized */
2967 NULL
, /* security */
2968 FILE_ATTRIBUTE_READONLY
, /* attributes */
2969 KFDF_PRECREATE
, /* flags */
2970 &GUID_NULL
/* typeid */
2972 { /* 0x62 - CSIDL_SAVED_GAMES */
2973 &FOLDERID_SavedGames
,
2978 KF_CATEGORY_PERUSER
, /* category */
2979 SavedGamesW
, /* name */
2980 NULL
, /* description */
2981 &FOLDERID_Profile
, /* parent */
2982 Saved_GamesW
, /* relative path */
2983 SavedGamesParsingNameW
, /* parsing */
2985 NULL
, /* localized */
2987 NULL
, /* security */
2988 FILE_ATTRIBUTE_READONLY
, /* attributes */
2989 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2990 &GUID_NULL
/* typeid */
2992 { /* 0x63 - CSIDL_SEARCHES */
2993 &FOLDERID_SavedSearches
,
2998 KF_CATEGORY_PERUSER
, /* category */
2999 SearchesW
, /* name */
3000 NULL
, /* description */
3001 &FOLDERID_Profile
, /* parent */
3002 SearchesW
, /* relative path */
3003 SavedSearchesParsingNameW
, /* parsing */
3005 NULL
, /* localized */
3007 NULL
, /* security */
3008 FILE_ATTRIBUTE_READONLY
, /* attributes */
3009 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
3010 &GUID_NULL
/* typeid */
3013 &FOLDERID_SEARCH_CSC
,
3014 CSIDL_Type_Disallowed
,
3018 KF_CATEGORY_VIRTUAL
, /* category */
3019 CSCFolderW
, /* name */
3020 NULL
, /* description */
3021 &GUID_NULL
, /* parent */
3022 NULL
, /* relative path */
3023 SEARCH_CSCParsingNameW
, /* parsing */
3025 NULL
, /* localized */
3027 NULL
, /* security */
3030 &GUID_NULL
/* typeid */
3033 &FOLDERID_SEARCH_MAPI
,
3034 CSIDL_Type_Disallowed
,
3038 KF_CATEGORY_VIRTUAL
, /* category */
3039 MAPIFolderW
, /* name */
3040 NULL
, /* description */
3041 &GUID_NULL
, /* parent */
3042 NULL
, /* relative path */
3043 SEARCH_MAPIParsingNameW
, /* parsing */
3045 NULL
, /* localized */
3047 NULL
, /* security */
3050 &GUID_NULL
/* typeid */
3053 &FOLDERID_SearchHome
,
3054 CSIDL_Type_Disallowed
,
3058 KF_CATEGORY_VIRTUAL
, /* category */
3059 SearchHomeFolderW
, /* name */
3060 NULL
, /* description */
3061 &GUID_NULL
, /* parent */
3062 NULL
, /* relative path */
3063 SearchHomeParsingNameW
, /* parsing */
3065 NULL
, /* localized */
3067 NULL
, /* security */
3070 &GUID_NULL
/* typeid */
3073 &FOLDERID_SidebarDefaultParts
,
3074 CSIDL_Type_Disallowed
, /* FIXME */
3078 KF_CATEGORY_COMMON
, /* category */
3079 Default_GadgetsW
, /* name */
3080 NULL
, /* description */
3081 &FOLDERID_ProgramFiles
, /* parent */
3082 Windows_Sidebar_GadgetsW
, /* relative path */
3085 NULL
, /* localized */
3087 NULL
, /* security */
3090 &GUID_NULL
/* typeid */
3093 &FOLDERID_SidebarParts
,
3094 CSIDL_Type_Disallowed
, /* FIXME */
3098 KF_CATEGORY_PERUSER
, /* category */
3099 GadgetsW
, /* name */
3100 NULL
, /* description */
3101 &FOLDERID_LocalAppData
, /* parent */
3102 Microsoft_Windows_Sidebar_GadgetsW
, /* relative path */
3105 NULL
, /* localized */
3107 NULL
, /* security */
3110 &GUID_NULL
/* typeid */
3113 &FOLDERID_SyncManagerFolder
,
3114 CSIDL_Type_Disallowed
,
3118 KF_CATEGORY_VIRTUAL
, /* category */
3119 SyncCenterFolderW
, /* name */
3120 NULL
, /* description */
3121 &GUID_NULL
, /* parent */
3122 NULL
, /* relative path */
3123 SyncManagerFolderParsingNameW
, /* parsing */
3125 NULL
, /* localized */
3127 NULL
, /* security */
3130 &GUID_NULL
/* typeid */
3133 &FOLDERID_SyncResultsFolder
,
3134 CSIDL_Type_Disallowed
,
3138 KF_CATEGORY_VIRTUAL
, /* category */
3139 SyncResultsFolderW
, /* name */
3140 NULL
, /* description */
3141 &GUID_NULL
, /* parent */
3142 NULL
, /* relative path */
3143 SyncResultsFolderParsingNameW
, /* parsing */
3145 NULL
, /* localized */
3147 NULL
, /* security */
3150 &GUID_NULL
/* typeid */
3153 &FOLDERID_SyncSetupFolder
,
3154 CSIDL_Type_Disallowed
,
3158 KF_CATEGORY_VIRTUAL
, /* category */
3159 SyncSetupFolderW
, /* name */
3160 NULL
, /* description */
3161 &GUID_NULL
, /* parent */
3162 NULL
, /* relative path */
3163 SyncSetupFolderParsingNameW
, /* parsing */
3165 NULL
, /* localized */
3167 NULL
, /* security */
3170 &GUID_NULL
/* typeid */
3173 &FOLDERID_UserPinned
,
3174 CSIDL_Type_Disallowed
, /* FIXME */
3178 KF_CATEGORY_PERUSER
, /* category */
3179 User_PinnedW
, /* name */
3180 NULL
, /* description */
3181 &FOLDERID_QuickLaunch
, /* parent */
3182 User_PinnedW
, /* relative path */
3185 NULL
, /* localized */
3187 NULL
, /* security */
3188 FILE_ATTRIBUTE_HIDDEN
, /* attributes */
3189 KFDF_PRECREATE
, /* flags */
3190 &GUID_NULL
/* typeid */
3193 &FOLDERID_UserProfiles
,
3198 KF_CATEGORY_FIXED
, /* category */
3199 UserProfilesW
, /* name */
3200 NULL
, /* description */
3201 &GUID_NULL
, /* parent */
3202 NULL
, /* relative path */
3205 NULL
, /* localized */
3207 NULL
, /* security */
3208 FILE_ATTRIBUTE_READONLY
, /* attributes */
3209 KFDF_PRECREATE
, /* flags */
3210 &GUID_NULL
/* typeid */
3213 &FOLDERID_UserProgramFiles
,
3214 CSIDL_Type_Disallowed
, /* FIXME */
3218 KF_CATEGORY_PERUSER
, /* category */
3219 UserProgramFilesW
, /* name */
3220 NULL
, /* description */
3221 &FOLDERID_LocalAppData
, /* parent */
3222 ProgramsW
, /* relative path */
3225 NULL
, /* localized */
3227 NULL
, /* security */
3230 &GUID_NULL
/* typeid */
3233 &FOLDERID_UserProgramFilesCommon
,
3234 CSIDL_Type_Disallowed
, /* FIXME */
3238 KF_CATEGORY_PERUSER
, /* category */
3239 UserProgramFilesCommonW
, /* name */
3240 NULL
, /* description */
3241 &FOLDERID_UserProgramFiles
, /* parent */
3242 CommonW
, /* relative path */
3245 NULL
, /* localized */
3247 NULL
, /* security */
3250 &GUID_NULL
/* typeid */
3253 &FOLDERID_UsersFiles
,
3254 CSIDL_Type_Disallowed
,
3258 KF_CATEGORY_VIRTUAL
, /* category */
3259 UsersFilesFolderW
, /* name */
3260 NULL
, /* description */
3261 &GUID_NULL
, /* parent */
3262 NULL
, /* relative path */
3263 UsersFilesParsingNameW
, /* parsing */
3265 NULL
, /* localized */
3267 NULL
, /* security */
3270 &GUID_NULL
/* typeid */
3273 &FOLDERID_UsersLibraries
,
3274 CSIDL_Type_Disallowed
,
3278 KF_CATEGORY_VIRTUAL
, /* category */
3279 UsersLibrariesFolderW
, /* name */
3280 NULL
, /* description */
3281 &GUID_NULL
, /* parent */
3282 NULL
, /* relative path */
3283 UsersLibrariesParsingNameW
, /* parsing */
3285 NULL
, /* localized */
3287 NULL
, /* security */
3290 &GUID_NULL
/* typeid */
3293 &FOLDERID_VideosLibrary
,
3294 CSIDL_Type_Disallowed
, /* FIXME */
3298 KF_CATEGORY_PERUSER
, /* category */
3299 VideosLibraryW
, /* name */
3300 NULL
, /* description */
3301 &GUID_NULL
, /* parent */
3302 Videos_librarymsW
, /* relative path */
3303 VideosLibraryParsingNameW
, /* parsing */
3305 NULL
, /* localized */
3307 NULL
, /* security */
3310 &GUID_NULL
/* typeid */
3314 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
);
3316 /* Gets the value named value from the registry key
3317 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3318 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3319 * is assumed to be MAX_PATH WCHARs in length.
3320 * If it exists, expands the value and writes the expanded value to
3321 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3322 * Returns successful error code if the value was retrieved from the registry,
3323 * and a failure otherwise.
3325 static HRESULT
_SHGetUserShellFolderPath(HKEY rootKey
, LPCWSTR userPrefix
,
3326 LPCWSTR value
, LPWSTR path
)
3329 WCHAR shellFolderPath
[MAX_PATH
], userShellFolderPath
[MAX_PATH
];
3330 LPCWSTR pShellFolderPath
, pUserShellFolderPath
;
3331 HKEY userShellFolderKey
, shellFolderKey
;
3332 DWORD dwType
, dwPathLen
;
3334 TRACE("%p,%s,%s,%p\n",rootKey
, debugstr_w(userPrefix
), debugstr_w(value
),
3339 strcpyW(shellFolderPath
, userPrefix
);
3340 PathAddBackslashW(shellFolderPath
);
3341 strcatW(shellFolderPath
, szSHFolders
);
3342 pShellFolderPath
= shellFolderPath
;
3343 strcpyW(userShellFolderPath
, userPrefix
);
3344 PathAddBackslashW(userShellFolderPath
);
3345 strcatW(userShellFolderPath
, szSHUserFolders
);
3346 pUserShellFolderPath
= userShellFolderPath
;
3350 pUserShellFolderPath
= szSHUserFolders
;
3351 pShellFolderPath
= szSHFolders
;
3354 if (RegCreateKeyW(rootKey
, pShellFolderPath
, &shellFolderKey
))
3356 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath
));
3359 if (RegCreateKeyW(rootKey
, pUserShellFolderPath
, &userShellFolderKey
))
3361 TRACE("Failed to create %s\n",
3362 debugstr_w(pUserShellFolderPath
));
3363 RegCloseKey(shellFolderKey
);
3367 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3368 if (!RegQueryValueExW(userShellFolderKey
, value
, NULL
, &dwType
,
3369 (LPBYTE
)path
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3373 path
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3374 if (dwType
== REG_EXPAND_SZ
&& path
[0] == '%')
3376 WCHAR szTemp
[MAX_PATH
];
3378 _SHExpandEnvironmentStrings(path
, szTemp
);
3379 lstrcpynW(path
, szTemp
, MAX_PATH
);
3381 ret
= RegSetValueExW(shellFolderKey
, value
, 0, REG_SZ
, (LPBYTE
)path
,
3382 (strlenW(path
) + 1) * sizeof(WCHAR
));
3383 if (ret
!= ERROR_SUCCESS
)
3384 hr
= HRESULT_FROM_WIN32(ret
);
3390 RegCloseKey(shellFolderKey
);
3391 RegCloseKey(userShellFolderKey
);
3392 TRACE("returning 0x%08x\n", hr
);
3396 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3397 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3398 * - The entry's szDefaultPath may be either a string value or an integer
3399 * resource identifier. In the latter case, the string value of the resource
3401 * - Depending on the entry's type, the path may begin with an (unexpanded)
3402 * environment variable name. The caller is responsible for expanding
3403 * environment strings if so desired.
3404 * The types that are prepended with environment variables are:
3405 * CSIDL_Type_User: %USERPROFILE%
3406 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3407 * CSIDL_Type_CurrVer: %SystemDrive%
3408 * (Others might make sense too, but as yet are unneeded.)
3410 static HRESULT
_SHGetDefaultValue(BYTE folder
, LPWSTR pszPath
)
3413 WCHAR resourcePath
[MAX_PATH
];
3414 LPCWSTR pDefaultPath
= NULL
;
3416 TRACE("0x%02x,%p\n", folder
, pszPath
);
3418 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3419 return E_INVALIDARG
;
3421 return E_INVALIDARG
;
3429 case CSIDL_PROGRAM_FILES
:
3430 case CSIDL_PROGRAM_FILESX86
:
3431 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3432 folder
= is_wow64
? CSIDL_PROGRAM_FILESX86
: CSIDL_PROGRAM_FILES
;
3434 case CSIDL_PROGRAM_FILES_COMMON
:
3435 case CSIDL_PROGRAM_FILES_COMMONX86
:
3436 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3437 folder
= is_wow64
? CSIDL_PROGRAM_FILES_COMMONX86
: CSIDL_PROGRAM_FILES_COMMON
;
3442 if (CSIDL_Data
[folder
].szDefaultPath
&&
3443 IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
))
3445 if (LoadStringW(shell32_hInstance
,
3446 LOWORD(CSIDL_Data
[folder
].szDefaultPath
), resourcePath
, MAX_PATH
))
3449 pDefaultPath
= resourcePath
;
3453 FIXME("(%d,%s), LoadString failed, missing translation?\n", folder
,
3454 debugstr_w(pszPath
));
3461 pDefaultPath
= CSIDL_Data
[folder
].szDefaultPath
;
3465 switch (CSIDL_Data
[folder
].type
)
3467 case CSIDL_Type_User
:
3468 strcpyW(pszPath
, UserProfileW
);
3470 case CSIDL_Type_AllUsers
:
3471 strcpyW(pszPath
, AllUsersProfileW
);
3473 case CSIDL_Type_CurrVer
:
3474 strcpyW(pszPath
, SystemDriveW
);
3477 ; /* no corresponding env. var, do nothing */
3481 PathAddBackslashW(pszPath
);
3482 strcatW(pszPath
, pDefaultPath
);
3485 TRACE("returning 0x%08x\n", hr
);
3489 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3490 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3491 * can be overridden in the HKLM\\szCurrentVersion key.
3492 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3493 * the registry, uses _SHGetDefaultValue to get the value.
3495 static HRESULT
_SHGetCurrentVersionPath(DWORD dwFlags
, BYTE folder
,
3500 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3502 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3503 return E_INVALIDARG
;
3504 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_CurrVer
)
3505 return E_INVALIDARG
;
3507 return E_INVALIDARG
;
3509 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3510 hr
= _SHGetDefaultValue(folder
, pszPath
);
3515 if (RegCreateKeyW(HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hKey
))
3519 DWORD dwType
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3521 if (RegQueryValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, NULL
,
3522 &dwType
, (LPBYTE
)pszPath
, &dwPathLen
) ||
3523 (dwType
!= REG_SZ
&& dwType
!= REG_EXPAND_SZ
))
3525 hr
= _SHGetDefaultValue(folder
, pszPath
);
3526 dwType
= REG_EXPAND_SZ
;
3529 case CSIDL_PROGRAM_FILESX86
:
3530 case CSIDL_PROGRAM_FILES_COMMONX86
:
3531 /* these two should never be set on 32-bit setups */
3535 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3536 if (!is_wow64
) break;
3540 RegSetValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, 0, dwType
,
3541 (LPBYTE
)pszPath
, (strlenW(pszPath
)+1)*sizeof(WCHAR
));
3546 pszPath
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3552 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3556 static LPWSTR
_GetUserSidStringFromToken(HANDLE Token
)
3558 char InfoBuffer
[64];
3559 PTOKEN_USER UserInfo
;
3563 UserInfo
= (PTOKEN_USER
) InfoBuffer
;
3564 if (! GetTokenInformation(Token
, TokenUser
, InfoBuffer
, sizeof(InfoBuffer
),
3567 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
3569 UserInfo
= HeapAlloc(GetProcessHeap(), 0, InfoSize
);
3570 if (UserInfo
== NULL
)
3572 if (! GetTokenInformation(Token
, TokenUser
, UserInfo
, InfoSize
,
3575 HeapFree(GetProcessHeap(), 0, UserInfo
);
3580 if (! ConvertSidToStringSidW(UserInfo
->User
.Sid
, &SidStr
))
3583 if (UserInfo
!= (PTOKEN_USER
) InfoBuffer
)
3584 HeapFree(GetProcessHeap(), 0, UserInfo
);
3589 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3590 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3591 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3592 * - if hToken is -1, looks in HKEY_USERS\.Default
3593 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3594 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3595 * calls _SHGetDefaultValue for it.
3597 static HRESULT
_SHGetUserProfilePath(HANDLE hToken
, DWORD dwFlags
, BYTE folder
,
3600 const WCHAR
*szValueName
;
3604 TRACE("%p,0x%08x,0x%02x,%p\n", hToken
, dwFlags
, folder
, pszPath
);
3606 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3607 return E_INVALIDARG
;
3608 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_User
)
3609 return E_INVALIDARG
;
3611 return E_INVALIDARG
;
3613 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3615 if (hToken
!= NULL
&& hToken
!= (HANDLE
)-1)
3617 FIXME("unsupported for user other than current or default\n");
3620 hr
= _SHGetDefaultValue(folder
, pszPath
);
3624 LPCWSTR userPrefix
= NULL
;
3627 if (hToken
== (HANDLE
)-1)
3629 hRootKey
= HKEY_USERS
;
3630 userPrefix
= DefaultW
;
3632 else if (hToken
== NULL
)
3633 hRootKey
= HKEY_CURRENT_USER
;
3636 hRootKey
= HKEY_USERS
;
3637 userPrefix
= _GetUserSidStringFromToken(hToken
);
3638 if (userPrefix
== NULL
)
3645 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3646 szValueName
= CSIDL_Data
[folder
].szValueName
;
3649 StringFromGUID2( CSIDL_Data
[folder
].id
, buffer
, 39 );
3650 szValueName
= &buffer
[0];
3653 hr
= _SHGetUserShellFolderPath(hRootKey
, userPrefix
, szValueName
, pszPath
);
3654 if (FAILED(hr
) && hRootKey
!= HKEY_LOCAL_MACHINE
)
3655 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
, szValueName
, pszPath
);
3657 hr
= _SHGetDefaultValue(folder
, pszPath
);
3658 if (userPrefix
!= NULL
&& userPrefix
!= DefaultW
)
3659 LocalFree((HLOCAL
) userPrefix
);
3662 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3666 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3667 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3668 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3669 * If this fails, falls back to _SHGetDefaultValue.
3671 static HRESULT
_SHGetAllUsersProfilePath(DWORD dwFlags
, BYTE folder
,
3676 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3678 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3679 return E_INVALIDARG
;
3680 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_AllUsers
)
3681 return E_INVALIDARG
;
3683 return E_INVALIDARG
;
3685 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3686 hr
= _SHGetDefaultValue(folder
, pszPath
);
3689 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
,
3690 CSIDL_Data
[folder
].szValueName
, pszPath
);
3692 hr
= _SHGetDefaultValue(folder
, pszPath
);
3694 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3698 static HRESULT
_SHOpenProfilesKey(PHKEY pKey
)
3703 lRet
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, ProfileListW
, 0, NULL
, 0,
3704 KEY_ALL_ACCESS
, NULL
, pKey
, &disp
);
3705 return HRESULT_FROM_WIN32(lRet
);
3708 /* Reads the value named szValueName from the key profilesKey (assumed to be
3709 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3710 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3711 * szDefault to the registry).
3713 static HRESULT
_SHGetProfilesValue(HKEY profilesKey
, LPCWSTR szValueName
,
3714 LPWSTR szValue
, LPCWSTR szDefault
)
3717 DWORD type
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3720 TRACE("%p,%s,%p,%s\n", profilesKey
, debugstr_w(szValueName
), szValue
,
3721 debugstr_w(szDefault
));
3722 lRet
= RegQueryValueExW(profilesKey
, szValueName
, NULL
, &type
,
3723 (LPBYTE
)szValue
, &dwPathLen
);
3724 if (!lRet
&& (type
== REG_SZ
|| type
== REG_EXPAND_SZ
) && dwPathLen
3727 dwPathLen
/= sizeof(WCHAR
);
3728 szValue
[dwPathLen
] = '\0';
3733 /* Missing or invalid value, set a default */
3734 lstrcpynW(szValue
, szDefault
, MAX_PATH
);
3735 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName
),
3736 debugstr_w(szValue
));
3737 lRet
= RegSetValueExW(profilesKey
, szValueName
, 0, REG_EXPAND_SZ
,
3739 (strlenW(szValue
) + 1) * sizeof(WCHAR
));
3741 hr
= HRESULT_FROM_WIN32(lRet
);
3745 TRACE("returning 0x%08x (output value is %s)\n", hr
, debugstr_w(szValue
));
3749 /* Attempts to expand environment variables from szSrc into szDest, which is
3750 * assumed to be MAX_PATH characters in length. Before referring to the
3751 * environment, handles a few variables directly, because the environment
3752 * variables may not be set when this is called (as during Wine's installation
3753 * when default values are being written to the registry).
3754 * The directly handled environment variables, and their source, are:
3755 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3756 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3758 * If one of the directly handled environment variables is expanded, only
3759 * expands a single variable, and only in the beginning of szSrc.
3761 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
)
3764 WCHAR szTemp
[MAX_PATH
], szProfilesPrefix
[MAX_PATH
] = { 0 };
3767 TRACE("%s, %p\n", debugstr_w(szSrc
), szDest
);
3769 if (!szSrc
|| !szDest
) return E_INVALIDARG
;
3771 /* short-circuit if there's nothing to expand */
3772 if (szSrc
[0] != '%')
3774 strcpyW(szDest
, szSrc
);
3778 /* Get the profile prefix, we'll probably be needing it */
3779 hr
= _SHOpenProfilesKey(&key
);
3782 WCHAR def_val
[MAX_PATH
];
3784 /* get the system drive */
3785 GetSystemDirectoryW(def_val
, MAX_PATH
);
3786 if (def_val
[1] == ':') strcpyW( def_val
+ 3, szDefaultProfileDirW
);
3787 else FIXME("non-drive system paths unsupported\n");
3789 hr
= _SHGetProfilesValue(key
, ProfilesDirectoryW
, szProfilesPrefix
, def_val
);
3793 strcpyW(szTemp
, szSrc
);
3794 while (SUCCEEDED(hr
) && szTemp
[0] == '%')
3796 if (!strncmpiW(szTemp
, AllUsersProfileW
, strlenW(AllUsersProfileW
)))
3798 WCHAR szAllUsers
[MAX_PATH
];
3800 strcpyW(szDest
, szProfilesPrefix
);
3801 hr
= _SHGetProfilesValue(key
, AllUsersProfileValueW
,
3802 szAllUsers
, AllUsersW
);
3803 PathAppendW(szDest
, szAllUsers
);
3804 PathAppendW(szDest
, szTemp
+ strlenW(AllUsersProfileW
));
3806 else if (!strncmpiW(szTemp
, UserProfileW
, strlenW(UserProfileW
)))
3808 WCHAR userName
[MAX_PATH
];
3809 DWORD userLen
= MAX_PATH
;
3811 strcpyW(szDest
, szProfilesPrefix
);
3812 GetUserNameW(userName
, &userLen
);
3813 PathAppendW(szDest
, userName
);
3814 PathAppendW(szDest
, szTemp
+ strlenW(UserProfileW
));
3816 else if (!strncmpiW(szTemp
, SystemDriveW
, strlenW(SystemDriveW
)))
3818 GetSystemDirectoryW(szDest
, MAX_PATH
);
3819 if (szDest
[1] != ':')
3821 FIXME("non-drive system paths unsupported\n");
3826 strcpyW(szDest
+ 3, szTemp
+ strlenW(SystemDriveW
) + 1);
3832 DWORD ret
= ExpandEnvironmentStringsW(szSrc
, szDest
, MAX_PATH
);
3835 hr
= E_NOT_SUFFICIENT_BUFFER
;
3837 hr
= HRESULT_FROM_WIN32(GetLastError());
3841 if (SUCCEEDED(hr
) && szDest
[0] == '%')
3842 strcpyW(szTemp
, szDest
);
3845 /* terminate loop */
3852 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr
,
3853 debugstr_w(szSrc
), debugstr_w(szDest
));
3857 /*************************************************************************
3858 * SHGetFolderPathW [SHELL32.@]
3860 * Convert nFolder to path.
3864 * Failure: standard HRESULT error codes.
3867 * Most values can be overridden in either
3868 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3869 * or in the same location in HKLM.
3870 * The "Shell Folders" registry key was used in NT4 and earlier systems.
3871 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
3872 * changes made to it are made to the former key too. This synchronization is
3873 * done on-demand: not until someone requests the value of one of these paths
3874 * (by calling one of the SHGet functions) is the value synchronized.
3875 * Furthermore, the HKCU paths take precedence over the HKLM paths.
3877 HRESULT WINAPI
SHGetFolderPathW(
3878 HWND hwndOwner
, /* [I] owner window */
3879 int nFolder
, /* [I] CSIDL identifying the folder */
3880 HANDLE hToken
, /* [I] access token */
3881 DWORD dwFlags
, /* [I] which path to return */
3882 LPWSTR pszPath
) /* [O] converted path */
3884 HRESULT hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, NULL
, pszPath
);
3885 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) == hr
)
3886 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
3890 HRESULT WINAPI
SHGetFolderPathAndSubDirA(
3891 HWND hwndOwner
, /* [I] owner window */
3892 int nFolder
, /* [I] CSIDL identifying the folder */
3893 HANDLE hToken
, /* [I] access token */
3894 DWORD dwFlags
, /* [I] which path to return */
3895 LPCSTR pszSubPath
, /* [I] sub directory of the specified folder */
3896 LPSTR pszPath
) /* [O] converted path */
3900 LPWSTR pszSubPathW
= NULL
;
3901 LPWSTR pszPathW
= NULL
;
3902 TRACE("%08x,%08x,%s\n",nFolder
, dwFlags
, debugstr_w(pszSubPathW
));
3905 pszPathW
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* sizeof(WCHAR
));
3907 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
3911 TRACE("%08x,%08x,%s\n",nFolder
, dwFlags
, debugstr_w(pszSubPathW
));
3913 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
3914 * set (null), or an empty string.therefore call it without the parameter set
3915 * if pszSubPath is an empty string
3917 if (pszSubPath
&& pszSubPath
[0]) {
3918 length
= MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, NULL
, 0);
3919 pszSubPathW
= HeapAlloc(GetProcessHeap(), 0, length
* sizeof(WCHAR
));
3921 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
3924 MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, pszSubPathW
, length
);
3927 hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, pszSubPathW
, pszPathW
);
3929 if (SUCCEEDED(hr
) && pszPath
)
3930 WideCharToMultiByte(CP_ACP
, 0, pszPathW
, -1, pszPath
, MAX_PATH
, NULL
, NULL
);
3933 HeapFree(GetProcessHeap(), 0, pszPathW
);
3934 HeapFree(GetProcessHeap(), 0, pszSubPathW
);
3938 /*************************************************************************
3939 * SHGetFolderPathAndSubDirW [SHELL32.@]
3941 HRESULT WINAPI
SHGetFolderPathAndSubDirW(
3942 HWND hwndOwner
, /* [I] owner window */
3943 int nFolder
, /* [I] CSIDL identifying the folder */
3944 HANDLE hToken
, /* [I] access token */
3945 DWORD dwFlags
, /* [I] which path to return */
3946 LPCWSTR pszSubPath
,/* [I] sub directory of the specified folder */
3947 LPWSTR pszPath
) /* [O] converted path */
3950 WCHAR szBuildPath
[MAX_PATH
], szTemp
[MAX_PATH
];
3951 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
3955 TRACE("%p,%p,nFolder=0x%04x,%s\n", hwndOwner
,pszPath
,nFolder
,debugstr_w(pszSubPath
));
3957 /* Windows always NULL-terminates the resulting path regardless of success
3958 * or failure, so do so first
3963 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3964 return E_INVALIDARG
;
3965 if ((SHGFP_TYPE_CURRENT
!= dwFlags
) && (SHGFP_TYPE_DEFAULT
!= dwFlags
))
3966 return E_INVALIDARG
;
3968 type
= CSIDL_Data
[folder
].type
;
3971 case CSIDL_Type_Disallowed
:
3974 case CSIDL_Type_NonExistent
:
3977 case CSIDL_Type_WindowsPath
:
3978 GetWindowsDirectoryW(szTemp
, MAX_PATH
);
3979 if (CSIDL_Data
[folder
].szDefaultPath
&&
3980 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
3981 *CSIDL_Data
[folder
].szDefaultPath
)
3983 PathAddBackslashW(szTemp
);
3984 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
3988 case CSIDL_Type_SystemPath
:
3989 GetSystemDirectoryW(szTemp
, MAX_PATH
);
3990 if (CSIDL_Data
[folder
].szDefaultPath
&&
3991 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
3992 *CSIDL_Data
[folder
].szDefaultPath
)
3994 PathAddBackslashW(szTemp
);
3995 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
3999 case CSIDL_Type_SystemX86Path
:
4000 if (!GetSystemWow64DirectoryW(szTemp
, MAX_PATH
)) GetSystemDirectoryW(szTemp
, MAX_PATH
);
4001 if (CSIDL_Data
[folder
].szDefaultPath
&&
4002 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4003 *CSIDL_Data
[folder
].szDefaultPath
)
4005 PathAddBackslashW(szTemp
);
4006 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4010 case CSIDL_Type_CurrVer
:
4011 hr
= _SHGetCurrentVersionPath(dwFlags
, folder
, szTemp
);
4013 case CSIDL_Type_User
:
4014 hr
= _SHGetUserProfilePath(hToken
, dwFlags
, folder
, szTemp
);
4016 case CSIDL_Type_AllUsers
:
4017 hr
= _SHGetAllUsersProfilePath(dwFlags
, folder
, szTemp
);
4020 FIXME("bogus type %d, please fix\n", type
);
4025 /* Expand environment strings if necessary */
4027 hr
= _SHExpandEnvironmentStrings(szTemp
, szBuildPath
);
4029 strcpyW(szBuildPath
, szTemp
);
4031 if (FAILED(hr
)) goto end
;
4034 /* make sure the new path does not exceed the buffer length
4035 * and remember to backslash and terminate it */
4036 if(MAX_PATH
< (lstrlenW(szBuildPath
) + lstrlenW(pszSubPath
) + 2)) {
4037 hr
= HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE
);
4040 PathAppendW(szBuildPath
, pszSubPath
);
4041 PathRemoveBackslashW(szBuildPath
);
4043 /* Copy the path if it's available before we might return */
4044 if (SUCCEEDED(hr
) && pszPath
)
4045 strcpyW(pszPath
, szBuildPath
);
4047 /* if we don't care about existing directories we are ready */
4048 if(nFolder
& CSIDL_FLAG_DONT_VERIFY
) goto end
;
4050 if (PathFileExistsW(szBuildPath
)) goto end
;
4052 /* not existing but we are not allowed to create it. The return value
4053 * is verified against shell32 version 6.0.
4055 if (!(nFolder
& CSIDL_FLAG_CREATE
))
4057 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4061 /* create directory/directories */
4062 ret
= SHCreateDirectoryExW(hwndOwner
, szBuildPath
, NULL
);
4063 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4065 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath
));
4070 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath
));
4072 TRACE("returning 0x%08x (final path is %s)\n", hr
, debugstr_w(szBuildPath
));
4076 /*************************************************************************
4077 * SHGetFolderPathA [SHELL32.@]
4079 * See SHGetFolderPathW.
4081 HRESULT WINAPI
SHGetFolderPathA(
4088 WCHAR szTemp
[MAX_PATH
];
4091 TRACE("%p,%p,nFolder=0x%04x\n",hwndOwner
,pszPath
,nFolder
);
4095 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
, dwFlags
, szTemp
);
4096 if (SUCCEEDED(hr
) && pszPath
)
4097 WideCharToMultiByte(CP_ACP
, 0, szTemp
, -1, pszPath
, MAX_PATH
, NULL
,
4103 /* For each folder in folders, if its value has not been set in the registry,
4104 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4105 * folder's type) to get the unexpanded value first.
4106 * Writes the unexpanded value to User Shell Folders, and queries it with
4107 * SHGetFolderPathW to force the creation of the directory if it doesn't
4108 * already exist. SHGetFolderPathW also returns the expanded value, which
4109 * this then writes to Shell Folders.
4111 static HRESULT
_SHRegisterFolders(HKEY hRootKey
, HANDLE hToken
,
4112 LPCWSTR szUserShellFolderPath
, LPCWSTR szShellFolderPath
, const UINT folders
[],
4115 const WCHAR
*szValueName
;
4118 WCHAR path
[MAX_PATH
];
4120 HKEY hUserKey
= NULL
, hKey
= NULL
;
4121 DWORD dwType
, dwPathLen
;
4124 TRACE("%p,%p,%s,%p,%u\n", hRootKey
, hToken
,
4125 debugstr_w(szUserShellFolderPath
), folders
, foldersLen
);
4127 ret
= RegCreateKeyW(hRootKey
, szUserShellFolderPath
, &hUserKey
);
4129 hr
= HRESULT_FROM_WIN32(ret
);
4132 ret
= RegCreateKeyW(hRootKey
, szShellFolderPath
, &hKey
);
4134 hr
= HRESULT_FROM_WIN32(ret
);
4136 for (i
= 0; SUCCEEDED(hr
) && i
< foldersLen
; i
++)
4138 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
4140 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4141 szValueName
= CSIDL_Data
[folders
[i
]].szValueName
;
4142 if (!szValueName
&& CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4144 StringFromGUID2( CSIDL_Data
[folders
[i
]].id
, buffer
, 39 );
4145 szValueName
= &buffer
[0];
4148 if (RegQueryValueExW(hUserKey
, szValueName
, NULL
,
4149 &dwType
, (LPBYTE
)path
, &dwPathLen
) || (dwType
!= REG_SZ
&&
4150 dwType
!= REG_EXPAND_SZ
))
4153 if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4154 _SHGetUserProfilePath(hToken
, SHGFP_TYPE_DEFAULT
, folders
[i
],
4156 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_AllUsers
)
4157 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT
, folders
[i
], path
);
4158 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_WindowsPath
)
4160 GetWindowsDirectoryW(path
, MAX_PATH
);
4161 if (CSIDL_Data
[folders
[i
]].szDefaultPath
&&
4162 !IS_INTRESOURCE(CSIDL_Data
[folders
[i
]].szDefaultPath
))
4164 PathAddBackslashW(path
);
4165 strcatW(path
, CSIDL_Data
[folders
[i
]].szDefaultPath
);
4172 ret
= RegSetValueExW(hUserKey
, szValueName
, 0, REG_EXPAND_SZ
,
4173 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4175 hr
= HRESULT_FROM_WIN32(ret
);
4178 hr
= SHGetFolderPathW(NULL
, folders
[i
] | CSIDL_FLAG_CREATE
,
4179 hToken
, SHGFP_TYPE_DEFAULT
, path
);
4180 ret
= RegSetValueExW(hKey
, szValueName
, 0, REG_SZ
,
4181 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4183 hr
= HRESULT_FROM_WIN32(ret
);
4189 RegCloseKey(hUserKey
);
4193 TRACE("returning 0x%08x\n", hr
);
4197 static HRESULT
_SHRegisterUserShellFolders(BOOL bDefault
)
4199 static const UINT folders
[] = {
4210 CSIDL_DESKTOPDIRECTORY
,
4214 CSIDL_LOCAL_APPDATA
,
4215 CSIDL_INTERNET_CACHE
,
4224 CSIDL_APPDATA_LOCALLOW
,
4228 WCHAR userShellFolderPath
[MAX_PATH
], shellFolderPath
[MAX_PATH
];
4229 LPCWSTR pUserShellFolderPath
, pShellFolderPath
;
4234 TRACE("%s\n", bDefault
? "TRUE" : "FALSE");
4237 hToken
= (HANDLE
)-1;
4238 hRootKey
= HKEY_USERS
;
4239 strcpyW(userShellFolderPath
, DefaultW
);
4240 PathAddBackslashW(userShellFolderPath
);
4241 strcatW(userShellFolderPath
, szSHUserFolders
);
4242 pUserShellFolderPath
= userShellFolderPath
;
4243 strcpyW(shellFolderPath
, DefaultW
);
4244 PathAddBackslashW(shellFolderPath
);
4245 strcatW(shellFolderPath
, szSHFolders
);
4246 pShellFolderPath
= shellFolderPath
;
4251 hRootKey
= HKEY_CURRENT_USER
;
4252 pUserShellFolderPath
= szSHUserFolders
;
4253 pShellFolderPath
= szSHFolders
;
4256 hr
= _SHRegisterFolders(hRootKey
, hToken
, pUserShellFolderPath
,
4257 pShellFolderPath
, folders
, sizeof(folders
) / sizeof(folders
[0]));
4258 TRACE("returning 0x%08x\n", hr
);
4262 static HRESULT
_SHRegisterCommonShellFolders(void)
4264 static const UINT folders
[] = {
4265 CSIDL_COMMON_STARTMENU
,
4266 CSIDL_COMMON_PROGRAMS
,
4267 CSIDL_COMMON_STARTUP
,
4268 CSIDL_COMMON_DESKTOPDIRECTORY
,
4269 CSIDL_COMMON_FAVORITES
,
4270 CSIDL_COMMON_APPDATA
,
4271 CSIDL_COMMON_TEMPLATES
,
4272 CSIDL_COMMON_DOCUMENTS
,
4273 CSIDL_COMMON_ADMINTOOLS
,
4275 CSIDL_COMMON_PICTURES
,
4281 hr
= _SHRegisterFolders(HKEY_LOCAL_MACHINE
, NULL
, szSHUserFolders
,
4282 szSHFolders
, folders
, sizeof(folders
) / sizeof(folders
[0]));
4283 TRACE("returning 0x%08x\n", hr
);
4287 /******************************************************************************
4288 * _SHAppendToUnixPath [Internal]
4290 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
4291 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
4292 * and replaces backslashes with slashes.
4295 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
4296 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
4302 static inline BOOL
_SHAppendToUnixPath(char *szBasePath
, LPCWSTR pwszSubPath
) {
4303 WCHAR wszSubPath
[MAX_PATH
];
4304 int cLen
= strlen(szBasePath
);
4307 if (IS_INTRESOURCE(pwszSubPath
)) {
4308 if (!LoadStringW(shell32_hInstance
, LOWORD(pwszSubPath
), wszSubPath
, MAX_PATH
)) {
4309 /* Fall back to hard coded defaults. */
4310 switch (LOWORD(pwszSubPath
)) {
4312 lstrcpyW(wszSubPath
, DocumentsW
);
4315 lstrcpyW(wszSubPath
, My_MusicW
);
4317 case IDS_MYPICTURES
:
4318 lstrcpyW(wszSubPath
, My_PicturesW
);
4321 lstrcpyW(wszSubPath
, My_VideosW
);
4324 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath
));
4329 lstrcpyW(wszSubPath
, pwszSubPath
);
4332 if (szBasePath
[cLen
-1] != '/') szBasePath
[cLen
++] = '/';
4334 if (!WideCharToMultiByte(CP_UNIXCP
, 0, wszSubPath
, -1, szBasePath
+ cLen
,
4335 FILENAME_MAX
- cLen
, NULL
, NULL
))
4340 pBackslash
= szBasePath
+ cLen
;
4341 while ((pBackslash
= strchr(pBackslash
, '\\'))) *pBackslash
= '/';
4346 /******************************************************************************
4347 * _SHCreateSymbolicLinks [Internal]
4349 * Sets up symbol links for various shell folders to point into the users home
4350 * directory. We do an educated guess about what the user would probably want:
4351 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4352 * wine's 'My Documents' to point there. Furthermore, we imply that the user
4353 * is a Windows lover and has no problem with wine creating 'My Pictures',
4354 * 'My Music' and 'My Videos' subfolders under '$HOME/My Documents', if those
4355 * do not already exits. We put appropriate symbolic links in place for those,
4357 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4358 * point directly to $HOME. We assume the user to be a unix hacker who does not
4359 * want wine to create anything anywhere besides the .wine directory. So, if
4360 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4361 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4362 * directory, and try to link to that. If that fails, then we symlink to
4363 * $HOME directly. The same holds fo 'My Pictures' and 'My Videos'.
4364 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4365 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4367 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4369 static void _SHCreateSymbolicLinks(void)
4371 UINT aidsMyStuff
[] = { IDS_MYPICTURES
, IDS_MYVIDEOS
, IDS_MYMUSIC
}, i
;
4372 const WCHAR
* MyOSXStuffW
[] = { PicturesW
, MoviesW
, MusicW
};
4373 int acsidlMyStuff
[] = { CSIDL_MYPICTURES
, CSIDL_MYVIDEO
, CSIDL_MYMUSIC
};
4374 static const char * const xdg_dirs
[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" };
4375 static const unsigned int num
= sizeof(xdg_dirs
) / sizeof(xdg_dirs
[0]);
4376 WCHAR wszTempPath
[MAX_PATH
];
4377 char szPersonalTarget
[FILENAME_MAX
], *pszPersonal
;
4378 char szMyStuffTarget
[FILENAME_MAX
], *pszMyStuff
;
4379 char szDesktopTarget
[FILENAME_MAX
], *pszDesktop
;
4380 struct stat statFolder
;
4381 const char *pszHome
;
4383 char ** xdg_results
;
4384 char * xdg_desktop_dir
;
4386 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4387 hr
= SHGetFolderPathW(NULL
, CSIDL_PERSONAL
|CSIDL_FLAG_CREATE
, NULL
,
4388 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4389 if (FAILED(hr
)) return;
4390 pszPersonal
= wine_get_unix_file_name(wszTempPath
);
4391 if (!pszPersonal
) return;
4393 hr
= XDG_UserDirLookup(xdg_dirs
, num
, &xdg_results
);
4394 if (FAILED(hr
)) xdg_results
= NULL
;
4396 pszHome
= getenv("HOME");
4397 if (pszHome
&& !stat(pszHome
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4401 /* Check if there's already a Wine-specific 'My Documents' folder */
4402 strcpy(szPersonalTarget
, pszHome
);
4403 if (_SHAppendToUnixPath(szPersonalTarget
, MAKEINTRESOURCEW(IDS_PERSONAL
)) &&
4404 !stat(szPersonalTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4406 /* '$HOME/My Documents' exists. Create 'My Pictures',
4407 * 'My Videos' and 'My Music' subfolders or fail silently if
4408 * they already exist.
4410 for (i
= 0; i
< sizeof(aidsMyStuff
)/sizeof(*aidsMyStuff
); i
++)
4412 strcpy(szMyStuffTarget
, szPersonalTarget
);
4413 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4414 mkdir(szMyStuffTarget
, 0777);
4419 /* Try to point to the XDG Documents folder */
4420 if (xdg_results
&& xdg_results
[num
-2] &&
4421 !stat(xdg_results
[num
-2], &statFolder
) &&
4422 S_ISDIR(statFolder
.st_mode
))
4424 strcpy(szPersonalTarget
, xdg_results
[num
-2]);
4428 /* Or the hardcoded / OS X Documents folder */
4429 strcpy(szPersonalTarget
, pszHome
);
4430 if (_SHAppendToUnixPath(szPersonalTarget
, DocumentsW
) &&
4431 !stat(szPersonalTarget
, &statFolder
) &&
4432 S_ISDIR(statFolder
.st_mode
))
4435 /* As a last resort point to $HOME. */
4436 strcpy(szPersonalTarget
, pszHome
);
4440 /* Replace 'My Documents' directory with a symlink or fail silently if not empty. */
4441 remove(pszPersonal
);
4442 symlink(szPersonalTarget
, pszPersonal
);
4446 /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs
4447 * in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */
4449 strcpy(szPersonalTarget
, pszPersonal
);
4450 for (i
= 0; i
< sizeof(aidsMyStuff
)/sizeof(aidsMyStuff
[0]); i
++) {
4451 strcpy(szMyStuffTarget
, szPersonalTarget
);
4452 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4453 mkdir(szMyStuffTarget
, 0777);
4457 /* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
4458 for (i
=0; i
< sizeof(aidsMyStuff
)/sizeof(aidsMyStuff
[0]); i
++)
4460 /* Create the current 'My Whatever' folder and get its unix path. */
4461 hr
= SHGetFolderPathW(NULL
, acsidlMyStuff
[i
]|CSIDL_FLAG_CREATE
, NULL
,
4462 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4463 if (FAILED(hr
)) continue;
4465 pszMyStuff
= wine_get_unix_file_name(wszTempPath
);
4466 if (!pszMyStuff
) continue;
4470 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4471 strcpy(szMyStuffTarget
, szPersonalTarget
);
4472 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])) &&
4473 !stat(szMyStuffTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4476 /* Try the XDG_XXX_DIR folder */
4477 if (xdg_results
&& xdg_results
[i
])
4479 strcpy(szMyStuffTarget
, xdg_results
[i
]);
4483 /* Or the OS X folder (these are never localized) */
4486 strcpy(szMyStuffTarget
, pszHome
);
4487 if (_SHAppendToUnixPath(szMyStuffTarget
, MyOSXStuffW
[i
]) &&
4488 !stat(szMyStuffTarget
, &statFolder
) &&
4489 S_ISDIR(statFolder
.st_mode
))
4493 /* As a last resort point to the same location as 'My Documents' */
4494 strcpy(szMyStuffTarget
, szPersonalTarget
);
4498 symlink(szMyStuffTarget
, pszMyStuff
);
4499 HeapFree(GetProcessHeap(), 0, pszMyStuff
);
4502 /* Last but not least, the Desktop folder */
4504 strcpy(szDesktopTarget
, pszHome
);
4506 strcpy(szDesktopTarget
, pszPersonal
);
4507 HeapFree(GetProcessHeap(), 0, pszPersonal
);
4509 xdg_desktop_dir
= xdg_results
? xdg_results
[num
- 1] : NULL
;
4510 if (xdg_desktop_dir
||
4511 (_SHAppendToUnixPath(szDesktopTarget
, DesktopW
) &&
4512 !stat(szDesktopTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
)))
4514 hr
= SHGetFolderPathW(NULL
, CSIDL_DESKTOPDIRECTORY
|CSIDL_FLAG_CREATE
, NULL
,
4515 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4516 if (SUCCEEDED(hr
) && (pszDesktop
= wine_get_unix_file_name(wszTempPath
)))
4519 if (xdg_desktop_dir
)
4520 symlink(xdg_desktop_dir
, pszDesktop
);
4522 symlink(szDesktopTarget
, pszDesktop
);
4523 HeapFree(GetProcessHeap(), 0, pszDesktop
);
4527 /* Free resources allocated by XDG_UserDirLookup() */
4530 for (i
= 0; i
< num
; i
++)
4531 HeapFree(GetProcessHeap(), 0, xdg_results
[i
]);
4532 HeapFree(GetProcessHeap(), 0, xdg_results
);
4536 /******************************************************************************
4537 * create_extra_folders [Internal]
4539 * Create some extra folders that don't have a standard CSIDL definition.
4541 static HRESULT
create_extra_folders(void)
4543 static const WCHAR environW
[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4544 static const WCHAR microsoftW
[] = {'M','i','c','r','o','s','o','f','t',0};
4545 static const WCHAR TempW
[] = {'T','e','m','p',0};
4546 static const WCHAR TEMPW
[] = {'T','E','M','P',0};
4547 static const WCHAR TMPW
[] = {'T','M','P',0};
4548 WCHAR path
[MAX_PATH
+5];
4551 DWORD type
, size
, ret
;
4553 ret
= RegCreateKeyW( HKEY_CURRENT_USER
, environW
, &hkey
);
4554 if (ret
) return HRESULT_FROM_WIN32( ret
);
4556 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4557 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE
| CSIDL_FLAG_CREATE
, NULL
,
4558 SHGFP_TYPE_DEFAULT
, TempW
, path
);
4561 size
= sizeof(path
);
4562 if (RegQueryValueExW( hkey
, TEMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4563 RegSetValueExW( hkey
, TEMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4564 size
= sizeof(path
);
4565 if (RegQueryValueExW( hkey
, TMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4566 RegSetValueExW( hkey
, TMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4568 RegCloseKey( hkey
);
4572 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4573 SHGFP_TYPE_DEFAULT
, microsoftW
, path
);
4579 /******************************************************************************
4580 * set_folder_attributes
4582 * Set the various folder attributes registry keys.
4584 static HRESULT
set_folder_attributes(void)
4586 static const WCHAR clsidW
[] = {'C','L','S','I','D','\\',0 };
4587 static const WCHAR shellfolderW
[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4588 static const WCHAR wfparsingW
[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4589 static const WCHAR wfdisplayW
[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4590 static const WCHAR hideasdeleteW
[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4591 static const WCHAR cfattributesW
[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4592 static const WCHAR emptyW
[] = {0};
4601 DWORD call_for_attr
;
4604 { &CLSID_UnixFolder
, TRUE
, FALSE
, FALSE
},
4605 { &CLSID_UnixDosFolder
, TRUE
, FALSE
, FALSE
,
4606 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4607 { &CLSID_FolderShortcut
, FALSE
, FALSE
, FALSE
,
4608 SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_LINK
,
4609 SFGAO_HASSUBFOLDER
|SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_FILESYSANCESTOR
},
4610 { &CLSID_MyDocuments
, TRUE
, FALSE
, FALSE
,
4611 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4612 { &CLSID_RecycleBin
, FALSE
, FALSE
, FALSE
,
4613 SFGAO_FOLDER
|SFGAO_DROPTARGET
|SFGAO_HASPROPSHEET
},
4614 { &CLSID_ControlPanel
, FALSE
, TRUE
, TRUE
,
4615 SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
}
4619 WCHAR buffer
[39 + (sizeof(clsidW
) + sizeof(shellfolderW
)) / sizeof(WCHAR
)];
4623 for (i
= 0; i
< sizeof(folders
)/sizeof(folders
[0]); i
++)
4625 strcpyW( buffer
, clsidW
);
4626 StringFromGUID2( folders
[i
].clsid
, buffer
+ strlenW(buffer
), 39 );
4627 strcatW( buffer
, shellfolderW
);
4628 res
= RegCreateKeyExW( HKEY_CLASSES_ROOT
, buffer
, 0, NULL
, 0,
4629 KEY_READ
| KEY_WRITE
, NULL
, &hkey
, NULL
);
4630 if (res
) return HRESULT_FROM_WIN32( res
);
4631 if (folders
[i
].wfparsing
)
4632 res
= RegSetValueExW( hkey
, wfparsingW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4633 if (folders
[i
].wfdisplay
)
4634 res
= RegSetValueExW( hkey
, wfdisplayW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4635 if (folders
[i
].hideasdel
)
4636 res
= RegSetValueExW( hkey
, hideasdeleteW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4637 if (folders
[i
].attr
)
4638 res
= RegSetValueExW( hkey
, szAttributes
, 0, REG_DWORD
,
4639 (const BYTE
*)&folders
[i
].attr
, sizeof(DWORD
));
4640 if (folders
[i
].call_for_attr
)
4641 res
= RegSetValueExW( hkey
, cfattributesW
, 0, REG_DWORD
,
4642 (const BYTE
*)&folders
[i
].call_for_attr
, sizeof(DWORD
));
4643 RegCloseKey( hkey
);
4648 /*************************************************************************
4649 * SHGetSpecialFolderPathA [SHELL32.@]
4651 BOOL WINAPI
SHGetSpecialFolderPathA (
4657 return SHGetFolderPathA(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4661 /*************************************************************************
4662 * SHGetSpecialFolderPathW
4664 BOOL WINAPI
SHGetSpecialFolderPathW (
4670 return SHGetFolderPathW(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4674 /*************************************************************************
4675 * SHGetSpecialFolderPath (SHELL32.175)
4677 BOOL WINAPI
SHGetSpecialFolderPathAW (
4684 if (SHELL_OsIsUnicode())
4685 return SHGetSpecialFolderPathW (hwndOwner
, szPath
, nFolder
, bCreate
);
4686 return SHGetSpecialFolderPathA (hwndOwner
, szPath
, nFolder
, bCreate
);
4689 /*************************************************************************
4690 * SHGetFolderLocation [SHELL32.@]
4692 * Gets the folder locations from the registry and creates a pidl.
4696 * nFolder [I] CSIDL_xxxxx
4697 * hToken [I] token representing user, or NULL for current user, or -1 for
4699 * dwReserved [I] must be zero
4700 * ppidl [O] PIDL of a special folder
4704 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
4707 * Creates missing reg keys and directories.
4708 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
4709 * virtual folders that are handled here.
4711 HRESULT WINAPI
SHGetFolderLocation(
4716 LPITEMIDLIST
*ppidl
)
4718 HRESULT hr
= E_INVALIDARG
;
4720 TRACE("%p 0x%08x %p 0x%08x %p\n",
4721 hwndOwner
, nFolder
, hToken
, dwReserved
, ppidl
);
4724 return E_INVALIDARG
;
4726 return E_INVALIDARG
;
4728 /* The virtual folders' locations are not user-dependent */
4730 switch (nFolder
& CSIDL_FOLDER_MASK
)
4733 *ppidl
= _ILCreateDesktop();
4736 case CSIDL_PERSONAL
:
4737 *ppidl
= _ILCreateMyDocuments();
4740 case CSIDL_INTERNET
:
4741 *ppidl
= _ILCreateIExplore();
4744 case CSIDL_CONTROLS
:
4745 *ppidl
= _ILCreateControlPanel();
4748 case CSIDL_PRINTERS
:
4749 *ppidl
= _ILCreatePrinters();
4752 case CSIDL_BITBUCKET
:
4753 *ppidl
= _ILCreateBitBucket();
4757 *ppidl
= _ILCreateMyComputer();
4761 *ppidl
= _ILCreateNetwork();
4766 WCHAR szPath
[MAX_PATH
];
4768 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
,
4769 SHGFP_TYPE_CURRENT
, szPath
);
4774 TRACE("Value=%s\n", debugstr_w(szPath
));
4775 hr
= SHILCreateFromPathW(szPath
, ppidl
, &attributes
);
4777 else if (hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
))
4779 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
4780 * version 6.0 returns E_FAIL for nonexistent paths
4789 TRACE("-- (new pidl %p)\n",*ppidl
);
4793 /*************************************************************************
4794 * SHGetSpecialFolderLocation [SHELL32.@]
4797 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
4800 HRESULT WINAPI
SHGetSpecialFolderLocation(
4803 LPITEMIDLIST
* ppidl
)
4805 HRESULT hr
= E_INVALIDARG
;
4807 TRACE("(%p,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
4810 return E_INVALIDARG
;
4812 hr
= SHGetFolderLocation(hwndOwner
, nFolder
, NULL
, 0, ppidl
);
4816 static int csidl_from_id( const KNOWNFOLDERID
*id
)
4819 for (i
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); i
++)
4820 if (IsEqualGUID( CSIDL_Data
[i
].id
, id
)) return i
;
4824 /*************************************************************************
4825 * SHGetKnownFolderPath [SHELL32.@]
4827 HRESULT WINAPI
SHGetKnownFolderPath(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, WCHAR
**ret_path
)
4829 WCHAR pathW
[MAX_PATH
], tempW
[MAX_PATH
];
4833 int folder
= csidl_from_id(rfid
), shgfp_flags
;
4835 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, ret_path
);
4840 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
4842 if (flags
& ~(KF_FLAG_CREATE
|KF_FLAG_DONT_VERIFY
|KF_FLAG_NO_ALIAS
|
4843 KF_FLAG_INIT
|KF_FLAG_DEFAULT_PATH
))
4845 FIXME("flags 0x%08x not supported\n", flags
);
4846 return E_INVALIDARG
;
4849 shgfp_flags
= flags
& KF_FLAG_DEFAULT_PATH
? SHGFP_TYPE_DEFAULT
: SHGFP_TYPE_CURRENT
;
4851 type
= CSIDL_Data
[folder
].type
;
4854 case CSIDL_Type_Disallowed
:
4857 case CSIDL_Type_NonExistent
:
4861 case CSIDL_Type_WindowsPath
:
4862 GetWindowsDirectoryW(tempW
, MAX_PATH
);
4863 if (CSIDL_Data
[folder
].szDefaultPath
&&
4864 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4865 *CSIDL_Data
[folder
].szDefaultPath
)
4867 PathAddBackslashW(tempW
);
4868 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4872 case CSIDL_Type_SystemPath
:
4873 GetSystemDirectoryW(tempW
, MAX_PATH
);
4874 if (CSIDL_Data
[folder
].szDefaultPath
&&
4875 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4876 *CSIDL_Data
[folder
].szDefaultPath
)
4878 PathAddBackslashW(tempW
);
4879 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4883 case CSIDL_Type_SystemX86Path
:
4884 if (!GetSystemWow64DirectoryW(tempW
, MAX_PATH
)) GetSystemDirectoryW(tempW
, MAX_PATH
);
4885 if (CSIDL_Data
[folder
].szDefaultPath
&&
4886 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4887 *CSIDL_Data
[folder
].szDefaultPath
)
4889 PathAddBackslashW(tempW
);
4890 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4894 case CSIDL_Type_CurrVer
:
4895 hr
= _SHGetCurrentVersionPath(shgfp_flags
, folder
, tempW
);
4897 case CSIDL_Type_User
:
4898 hr
= _SHGetUserProfilePath(token
, shgfp_flags
, folder
, tempW
);
4900 case CSIDL_Type_AllUsers
:
4901 hr
= _SHGetAllUsersProfilePath(shgfp_flags
, folder
, tempW
);
4904 FIXME("bogus type %d, please fix\n", type
);
4912 /* Expand environment strings if necessary */
4915 hr
= _SHExpandEnvironmentStrings(tempW
, pathW
);
4920 strcpyW(pathW
, tempW
);
4922 /* if we don't care about existing directories we are ready */
4923 if (flags
& KF_FLAG_DONT_VERIFY
) goto done
;
4925 if (PathFileExistsW(pathW
)) goto done
;
4927 /* Does not exist but we are not allowed to create it. The return value
4928 * is verified against shell32 version 6.0.
4930 if (!(flags
& KF_FLAG_CREATE
))
4932 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4936 /* create directory/directories */
4937 ret
= SHCreateDirectoryExW(NULL
, pathW
, NULL
);
4938 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4940 ERR("Failed to create directory %s.\n", debugstr_w(pathW
));
4945 TRACE("Created missing system directory %s\n", debugstr_w(pathW
));
4948 TRACE("Final path is %s, %#x\n", debugstr_w(pathW
), hr
);
4950 *ret_path
= CoTaskMemAlloc((strlenW(pathW
) + 1) * sizeof(WCHAR
));
4952 return E_OUTOFMEMORY
;
4953 strcpyW(*ret_path
, pathW
);
4958 TRACE("Failed to get folder path, %#x.\n", hr
);
4963 /*************************************************************************
4964 * SHGetFolderPathEx [SHELL32.@]
4966 HRESULT WINAPI
SHGetFolderPathEx(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, LPWSTR path
, DWORD len
)
4971 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid
), flags
, token
, path
, len
);
4973 if (!path
|| !len
) return E_INVALIDARG
;
4975 hr
= SHGetKnownFolderPath( rfid
, flags
, token
, &buffer
);
4976 if (SUCCEEDED( hr
))
4978 if (strlenW( buffer
) + 1 > len
)
4980 CoTaskMemFree( buffer
);
4981 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER
);
4983 strcpyW( path
, buffer
);
4984 CoTaskMemFree( buffer
);
4990 * Internal function to convert known folder identifier to path of registry key
4991 * associated with known folder.
4994 * rfid [I] pointer to known folder identifier (may be NULL)
4995 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
4996 * lpPath [O] place to store string address. String should be
4997 * later freed using HeapFree(GetProcessHeap(),0, ... )
4999 static HRESULT
get_known_folder_registry_path(
5000 REFKNOWNFOLDERID rfid
,
5001 LPWSTR lpStringGuid
,
5004 static const WCHAR sBackslash
[] = {'\\',0};
5009 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid
), debugstr_w(lpStringGuid
), lpPath
);
5012 StringFromGUID2(rfid
, sGuid
, sizeof(sGuid
)/sizeof(sGuid
[0]));
5014 lstrcpyW(sGuid
, lpStringGuid
);
5016 length
= lstrlenW(szKnownFolderDescriptions
)+51;
5017 *lpPath
= HeapAlloc(GetProcessHeap(), 0, length
*sizeof(WCHAR
));
5023 lstrcpyW(*lpPath
, szKnownFolderDescriptions
);
5024 lstrcatW(*lpPath
, sBackslash
);
5025 lstrcatW(*lpPath
, sGuid
);
5031 static HRESULT
get_known_folder_wstr(const WCHAR
*regpath
, const WCHAR
*value
, WCHAR
**out
)
5037 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
));
5041 *out
= CoTaskMemAlloc(size
);
5043 return E_OUTOFMEMORY
;
5045 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, *out
, &size
));
5047 CoTaskMemFree(*out
);
5054 static HRESULT
get_known_folder_dword(const WCHAR
*registryPath
, const WCHAR
*value
, DWORD
*out
)
5056 DWORD dwSize
= sizeof(DWORD
);
5058 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, value
, RRF_RT_DWORD
, &dwType
, out
, &dwSize
));
5062 * Internal function to get place where folder redirection information are stored.
5065 * rfid [I] pointer to known folder identifier (may be NULL)
5066 * rootKey [O] root key where the redirection information are stored
5067 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5068 * However, besides root key, path is always that same, and is stored
5069 * as "szKnownFolderRedirections" constant
5071 static HRESULT
get_known_folder_redirection_place(
5072 REFKNOWNFOLDERID rfid
,
5076 LPWSTR lpRegistryPath
= NULL
;
5077 KF_CATEGORY category
;
5079 /* first, get known folder's category */
5080 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5083 hr
= get_known_folder_dword(lpRegistryPath
, szCategory
, &category
);
5087 if(category
== KF_CATEGORY_COMMON
)
5089 *rootKey
= HKEY_LOCAL_MACHINE
;
5092 else if(category
== KF_CATEGORY_PERUSER
)
5094 *rootKey
= HKEY_CURRENT_USER
;
5101 HeapFree(GetProcessHeap(), 0, lpRegistryPath
);
5105 static HRESULT
get_known_folder_path_by_id(REFKNOWNFOLDERID folderId
, LPWSTR lpRegistryPath
, DWORD dwFlags
, LPWSTR
*ppszPath
);
5107 static HRESULT
redirect_known_folder(
5108 REFKNOWNFOLDERID rfid
,
5110 KF_REDIRECT_FLAGS flags
,
5111 LPCWSTR pszTargetPath
,
5113 KNOWNFOLDERID
const *pExclusion
,
5117 HKEY rootKey
= HKEY_LOCAL_MACHINE
, hKey
;
5119 LPWSTR lpRegistryPath
= NULL
, lpSrcPath
= NULL
;
5120 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid
), hwnd
, flags
, debugstr_w(pszTargetPath
), cFolders
, pExclusion
, ppszError
);
5122 if (ppszError
) *ppszError
= NULL
;
5124 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5127 hr
= get_known_folder_path_by_id(rfid
, lpRegistryPath
, 0, &lpSrcPath
);
5129 HeapFree(GetProcessHeap(), 0, lpRegistryPath
);
5131 /* get path to redirection storage */
5133 hr
= get_known_folder_redirection_place(rfid
, &rootKey
);
5135 /* write redirection information */
5137 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey
, szKnownFolderRedirections
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
));
5141 StringFromGUID2(rfid
, sGuid
, sizeof(sGuid
)/sizeof(sGuid
[0]));
5143 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, sGuid
, 0, REG_SZ
, (LPBYTE
)pszTargetPath
, (lstrlenW(pszTargetPath
)+1)*sizeof(WCHAR
)));
5148 /* make sure destination path exists */
5149 SHCreateDirectory(NULL
, pszTargetPath
);
5151 /* copy content if required */
5152 if(SUCCEEDED(hr
) && (flags
& KF_REDIRECT_COPY_CONTENTS
) )
5154 static const WCHAR sWildcard
[] = {'\\','*',0};
5155 WCHAR srcPath
[MAX_PATH
+1], dstPath
[MAX_PATH
+1];
5156 SHFILEOPSTRUCTW fileOp
;
5158 ZeroMemory(srcPath
, sizeof(srcPath
));
5159 lstrcpyW(srcPath
, lpSrcPath
);
5160 lstrcatW(srcPath
, sWildcard
);
5162 ZeroMemory(dstPath
, sizeof(dstPath
));
5163 lstrcpyW(dstPath
, pszTargetPath
);
5165 ZeroMemory(&fileOp
, sizeof(fileOp
));
5167 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5168 fileOp
.wFunc
= FO_MOVE
;
5170 fileOp
.wFunc
= FO_COPY
;
5172 fileOp
.pFrom
= srcPath
;
5173 fileOp
.pTo
= dstPath
;
5174 fileOp
.fFlags
= FOF_NO_UI
;
5176 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5178 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5180 ZeroMemory(srcPath
, sizeof(srcPath
));
5181 lstrcpyW(srcPath
, lpSrcPath
);
5183 ZeroMemory(&fileOp
, sizeof(fileOp
));
5184 fileOp
.wFunc
= FO_DELETE
;
5185 fileOp
.pFrom
= srcPath
;
5186 fileOp
.fFlags
= FOF_NO_UI
;
5188 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5192 CoTaskMemFree(lpSrcPath
);
5200 IKnownFolder IKnownFolder_iface
;
5203 LPWSTR registryPath
;
5206 static inline struct knownfolder
*impl_from_IKnownFolder( IKnownFolder
*iface
)
5208 return CONTAINING_RECORD( iface
, struct knownfolder
, IKnownFolder_iface
);
5211 static ULONG WINAPI
knownfolder_AddRef(
5212 IKnownFolder
*iface
)
5214 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5215 return InterlockedIncrement( &knownfolder
->refs
);
5218 static ULONG WINAPI
knownfolder_Release(
5219 IKnownFolder
*iface
)
5221 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5222 LONG refs
= InterlockedDecrement( &knownfolder
->refs
);
5225 TRACE("destroying %p\n", knownfolder
);
5226 HeapFree( GetProcessHeap(), 0, knownfolder
->registryPath
);
5227 HeapFree( GetProcessHeap(), 0, knownfolder
);
5232 static HRESULT WINAPI
knownfolder_QueryInterface(
5233 IKnownFolder
*iface
,
5237 struct knownfolder
*This
= impl_from_IKnownFolder( iface
);
5239 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5242 if ( IsEqualGUID( riid
, &IID_IKnownFolder
) ||
5243 IsEqualGUID( riid
, &IID_IUnknown
) )
5247 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5249 TRACE("IID_IMarshal returning NULL.\n");
5250 return E_NOINTERFACE
;
5254 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5255 return E_NOINTERFACE
;
5257 IKnownFolder_AddRef( iface
);
5261 static HRESULT
knownfolder_set_id(
5262 struct knownfolder
*knownfolder
,
5263 const KNOWNFOLDERID
*kfid
)
5268 TRACE("%s\n", debugstr_guid(kfid
));
5270 knownfolder
->id
= *kfid
;
5272 /* check is it registry-registered folder */
5273 hr
= get_known_folder_registry_path(kfid
, NULL
, &knownfolder
->registryPath
);
5275 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, 0, 0, &hKey
));
5284 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5285 HeapFree(GetProcessHeap(), 0, knownfolder
->registryPath
);
5286 knownfolder
->registryPath
= NULL
;
5293 static HRESULT WINAPI
knownfolder_GetId(
5294 IKnownFolder
*iface
,
5295 KNOWNFOLDERID
*pkfid
)
5297 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5299 TRACE("%p\n", pkfid
);
5301 *pkfid
= knownfolder
->id
;
5305 static HRESULT WINAPI
knownfolder_GetCategory(
5306 IKnownFolder
*iface
,
5307 KF_CATEGORY
*pCategory
)
5309 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5312 TRACE("%p, %p\n", knownfolder
, pCategory
);
5314 /* we cannot get a category for a folder which is not registered */
5315 if(!knownfolder
->registryPath
)
5319 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, pCategory
);
5324 static HRESULT WINAPI
knownfolder_GetShellItem(
5325 IKnownFolder
*iface
,
5330 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5331 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder
, flags
, debugstr_guid(riid
), ppv
);
5332 return SHGetKnownFolderItem(&knownfolder
->id
, flags
, NULL
, riid
, ppv
);
5335 static HRESULT
get_known_folder_path(
5337 LPWSTR registryPath
,
5340 static const WCHAR sBackslash
[] = {'\\',0};
5342 DWORD dwSize
, dwType
;
5343 WCHAR path
[MAX_PATH
] = {0};
5344 WCHAR parentGuid
[39];
5345 KF_CATEGORY category
;
5346 LPWSTR parentRegistryPath
, parentPath
;
5347 HKEY hRedirectionRootKey
= NULL
;
5349 TRACE("(%s, %p)\n", debugstr_w(registryPath
), ppszPath
);
5352 /* check if folder has parent */
5353 dwSize
= sizeof(parentGuid
);
5354 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szParentFolder
, RRF_RT_REG_SZ
, &dwType
, parentGuid
, &dwSize
));
5355 if(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)) hr
= S_FALSE
;
5359 /* get parent's known folder path (recursive) */
5360 hr
= get_known_folder_registry_path(NULL
, parentGuid
, &parentRegistryPath
);
5361 if(FAILED(hr
)) return hr
;
5363 hr
= get_known_folder_path(parentGuid
, parentRegistryPath
, &parentPath
);
5365 HeapFree(GetProcessHeap(), 0, parentRegistryPath
);
5369 lstrcatW(path
, parentPath
);
5370 lstrcatW(path
, sBackslash
);
5372 HeapFree(GetProcessHeap(), 0, parentRegistryPath
);
5373 HeapFree(GetProcessHeap(), 0, parentPath
);
5376 /* check, if folder was redirected */
5378 hr
= get_known_folder_dword(registryPath
, szCategory
, &category
);
5382 if(category
== KF_CATEGORY_COMMON
)
5383 hRedirectionRootKey
= HKEY_LOCAL_MACHINE
;
5384 else if(category
== KF_CATEGORY_PERUSER
)
5385 hRedirectionRootKey
= HKEY_CURRENT_USER
;
5387 if(hRedirectionRootKey
)
5389 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, NULL
, &dwSize
));
5393 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5394 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5399 lstrcpyW(*ppszPath
, path
);
5400 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5406 /* no redirection, use previous way - read the relative path from folder definition */
5407 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, NULL
, &dwSize
));
5411 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5412 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5417 lstrcpyW(*ppszPath
, path
);
5418 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5423 TRACE("returning path: %s\n", debugstr_w(*ppszPath
));
5427 static HRESULT
get_known_folder_path_by_id(
5428 REFKNOWNFOLDERID folderId
,
5429 LPWSTR lpRegistryPath
,
5433 HRESULT hr
= E_FAIL
;
5437 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId
), debugstr_w(lpRegistryPath
), dwFlags
, ppszPath
);
5439 /* if this is registry-registered known folder, get path from registry */
5442 StringFromGUID2(folderId
, sGuid
, sizeof(sGuid
)/sizeof(sGuid
[0]));
5444 hr
= get_known_folder_path(sGuid
, lpRegistryPath
, ppszPath
);
5446 /* in other case, use older way */
5449 hr
= SHGetKnownFolderPath( folderId
, dwFlags
, NULL
, ppszPath
);
5451 if (FAILED(hr
)) return hr
;
5453 /* check if known folder really exists */
5454 dwAttributes
= GetFileAttributesW(*ppszPath
);
5455 if(dwAttributes
== INVALID_FILE_ATTRIBUTES
|| !(dwAttributes
& FILE_ATTRIBUTE_DIRECTORY
) )
5457 TRACE("directory %s not found\n", debugstr_w(*ppszPath
));
5458 CoTaskMemFree(*ppszPath
);
5460 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
5466 static HRESULT WINAPI
knownfolder_GetPath(
5467 IKnownFolder
*iface
,
5471 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5472 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, dwFlags
, ppszPath
);
5474 return get_known_folder_path_by_id(&knownfolder
->id
, knownfolder
->registryPath
, dwFlags
, ppszPath
);
5477 static HRESULT WINAPI
knownfolder_SetPath(
5478 IKnownFolder
*iface
,
5482 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5485 TRACE("(%p, 0x%08x, %s)\n", knownfolder
, dwFlags
, debugstr_w(pszPath
));
5487 /* check if the known folder is registered */
5488 if(!knownfolder
->registryPath
)
5492 hr
= redirect_known_folder(&knownfolder
->id
, NULL
, 0, pszPath
, 0, NULL
, NULL
);
5497 static HRESULT WINAPI
knownfolder_GetIDList(
5498 IKnownFolder
*iface
,
5500 PIDLIST_ABSOLUTE
*ppidl
)
5502 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5503 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, flags
, ppidl
);
5504 return SHGetKnownFolderIDList(&knownfolder
->id
, flags
, NULL
, ppidl
);
5507 static HRESULT WINAPI
knownfolder_GetFolderType(
5508 IKnownFolder
*iface
,
5509 FOLDERTYPEID
*pftid
)
5511 FIXME("%p\n", pftid
);
5515 static HRESULT WINAPI
knownfolder_GetRedirectionCapabilities(
5516 IKnownFolder
*iface
,
5517 KF_REDIRECTION_CAPABILITIES
*pCapabilities
)
5519 FIXME("%p\n", pCapabilities
);
5523 static HRESULT WINAPI
knownfolder_GetFolderDefinition(
5524 IKnownFolder
*iface
,
5525 KNOWNFOLDER_DEFINITION
*pKFD
)
5527 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5530 WCHAR parentGuid
[39];
5531 TRACE("(%p, %p)\n", knownfolder
, pKFD
);
5533 if(!pKFD
) return E_INVALIDARG
;
5535 ZeroMemory(pKFD
, sizeof(*pKFD
));
5537 /* required fields */
5538 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, &pKFD
->category
);
5542 hr
= get_known_folder_wstr(knownfolder
->registryPath
, szName
, &pKFD
->pszName
);
5546 /* optional fields */
5547 dwSize
= sizeof(parentGuid
);
5548 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, szParentFolder
,
5549 RRF_RT_REG_SZ
, NULL
, parentGuid
, &dwSize
));
5552 hr
= IIDFromString(parentGuid
, &pKFD
->fidParent
);
5557 get_known_folder_dword(knownfolder
->registryPath
, szAttributes
, &pKFD
->dwAttributes
);
5559 get_known_folder_wstr(knownfolder
->registryPath
, szRelativePath
, &pKFD
->pszRelativePath
);
5561 get_known_folder_wstr(knownfolder
->registryPath
, szParsingName
, &pKFD
->pszParsingName
);
5566 static const struct IKnownFolderVtbl knownfolder_vtbl
=
5568 knownfolder_QueryInterface
,
5570 knownfolder_Release
,
5572 knownfolder_GetCategory
,
5573 knownfolder_GetShellItem
,
5574 knownfolder_GetPath
,
5575 knownfolder_SetPath
,
5576 knownfolder_GetIDList
,
5577 knownfolder_GetFolderType
,
5578 knownfolder_GetRedirectionCapabilities
,
5579 knownfolder_GetFolderDefinition
5582 static HRESULT
knownfolder_create( struct knownfolder
**knownfolder
)
5584 struct knownfolder
*kf
;
5586 kf
= HeapAlloc( GetProcessHeap(), 0, sizeof(*kf
) );
5587 if (!kf
) return E_OUTOFMEMORY
;
5589 kf
->IKnownFolder_iface
.lpVtbl
= &knownfolder_vtbl
;
5591 memset( &kf
->id
, 0, sizeof(kf
->id
) );
5592 kf
->registryPath
= NULL
;
5596 TRACE("returning iface %p\n", &kf
->IKnownFolder_iface
);
5600 struct foldermanager
5602 IKnownFolderManager IKnownFolderManager_iface
;
5608 static inline struct foldermanager
*impl_from_IKnownFolderManager( IKnownFolderManager
*iface
)
5610 return CONTAINING_RECORD( iface
, struct foldermanager
, IKnownFolderManager_iface
);
5613 static ULONG WINAPI
foldermanager_AddRef(
5614 IKnownFolderManager
*iface
)
5616 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5617 return InterlockedIncrement( &foldermanager
->refs
);
5620 static ULONG WINAPI
foldermanager_Release(
5621 IKnownFolderManager
*iface
)
5623 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5624 LONG refs
= InterlockedDecrement( &foldermanager
->refs
);
5627 TRACE("destroying %p\n", foldermanager
);
5628 HeapFree( GetProcessHeap(), 0, foldermanager
->ids
);
5629 HeapFree( GetProcessHeap(), 0, foldermanager
);
5634 static HRESULT WINAPI
foldermanager_QueryInterface(
5635 IKnownFolderManager
*iface
,
5639 struct foldermanager
*This
= impl_from_IKnownFolderManager( iface
);
5641 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5644 if ( IsEqualGUID( riid
, &IID_IKnownFolderManager
) ||
5645 IsEqualGUID( riid
, &IID_IUnknown
) )
5649 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5651 TRACE("IID_IMarshal returning NULL.\n");
5652 return E_NOINTERFACE
;
5656 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5657 return E_NOINTERFACE
;
5659 IKnownFolderManager_AddRef( iface
);
5663 static HRESULT WINAPI
foldermanager_FolderIdFromCsidl(
5664 IKnownFolderManager
*iface
,
5666 KNOWNFOLDERID
*pfid
)
5668 TRACE("%d, %p\n", nCsidl
, pfid
);
5670 if (nCsidl
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
5671 return E_INVALIDARG
;
5672 *pfid
= *CSIDL_Data
[nCsidl
].id
;
5676 static HRESULT WINAPI
foldermanager_FolderIdToCsidl(
5677 IKnownFolderManager
*iface
,
5678 REFKNOWNFOLDERID rfid
,
5683 TRACE("%s, %p\n", debugstr_guid(rfid
), pnCsidl
);
5685 csidl
= csidl_from_id( rfid
);
5686 if (csidl
== -1) return E_INVALIDARG
;
5691 static HRESULT WINAPI
foldermanager_GetFolderIds(
5692 IKnownFolderManager
*iface
,
5693 KNOWNFOLDERID
**ppKFId
,
5696 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5698 TRACE("%p, %p\n", ppKFId
, pCount
);
5700 *ppKFId
= CoTaskMemAlloc(fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5701 memcpy(*ppKFId
, fm
->ids
, fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5702 *pCount
= fm
->num_ids
;
5706 static BOOL
is_knownfolder( struct foldermanager
*fm
, const KNOWNFOLDERID
*id
)
5710 LPWSTR registryPath
= NULL
;
5713 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
5714 for (i
= 0; i
< fm
->num_ids
; i
++)
5715 if (IsEqualGUID( &fm
->ids
[i
], id
)) return TRUE
;
5717 hr
= get_known_folder_registry_path(id
, NULL
, ®istryPath
);
5720 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, 0, &hKey
));
5721 HeapFree(GetProcessHeap(), 0, registryPath
);
5733 static HRESULT WINAPI
foldermanager_GetFolder(
5734 IKnownFolderManager
*iface
,
5735 REFKNOWNFOLDERID rfid
,
5736 IKnownFolder
**ppkf
)
5738 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5739 struct knownfolder
*kf
;
5742 TRACE("%s, %p\n", debugstr_guid(rfid
), ppkf
);
5744 if (!is_knownfolder( fm
, rfid
))
5746 WARN("unknown folder\n");
5747 return E_INVALIDARG
;
5749 hr
= knownfolder_create( &kf
);
5750 if (SUCCEEDED( hr
))
5752 hr
= knownfolder_set_id( kf
, rfid
);
5753 *ppkf
= &kf
->IKnownFolder_iface
;
5761 static HRESULT WINAPI
foldermanager_GetFolderByName(
5762 IKnownFolderManager
*iface
,
5763 LPCWSTR pszCanonicalName
,
5764 IKnownFolder
**ppkf
)
5766 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5767 struct knownfolder
*kf
;
5772 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName
), ppkf
);
5774 for (i
= 0; i
< fm
->num_ids
; i
++)
5777 hr
= get_known_folder_registry_path( &fm
->ids
[i
], NULL
, &path
);
5778 if (FAILED( hr
)) return hr
;
5780 hr
= get_known_folder_wstr( path
, szName
, &name
);
5781 HeapFree( GetProcessHeap(), 0, path
);
5782 if (FAILED( hr
)) return hr
;
5784 found
= !strcmpiW( pszCanonicalName
, name
);
5785 CoTaskMemFree( name
);
5791 hr
= knownfolder_create( &kf
);
5792 if (FAILED( hr
)) return hr
;
5794 hr
= knownfolder_set_id( kf
, &fm
->ids
[i
] );
5797 IKnownFolder_Release( &kf
->IKnownFolder_iface
);
5800 *ppkf
= &kf
->IKnownFolder_iface
;
5804 hr
= HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
5811 static HRESULT
register_folder(const KNOWNFOLDERID
*rfid
, const KNOWNFOLDER_DEFINITION
*pKFD
)
5816 LPWSTR registryPath
= NULL
;
5818 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
5819 TRACE("registry path: %s\n", debugstr_w(registryPath
));
5822 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, NULL
, 0, KEY_WRITE
, 0, &hKey
, &dwDisp
));
5826 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szCategory
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->category
, sizeof(pKFD
->category
)));
5828 if(SUCCEEDED(hr
) && pKFD
->dwAttributes
!= 0)
5829 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szAttributes
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->dwAttributes
, sizeof(pKFD
->dwAttributes
)));
5832 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszName
, (lstrlenW(pKFD
->pszName
)+1)*sizeof(WCHAR
) ));
5834 if(SUCCEEDED(hr
) && pKFD
->pszParsingName
)
5835 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParsingName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszParsingName
, (lstrlenW(pKFD
->pszParsingName
)+1)*sizeof(WCHAR
) ));
5837 if(SUCCEEDED(hr
) && !IsEqualGUID(&pKFD
->fidParent
, &GUID_NULL
))
5839 WCHAR sParentGuid
[39];
5840 StringFromGUID2(&pKFD
->fidParent
, sParentGuid
, sizeof(sParentGuid
)/sizeof(sParentGuid
[0]));
5842 /* this known folder has parent folder */
5843 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParentFolder
, 0, REG_SZ
, (LPBYTE
)sParentGuid
, sizeof(sParentGuid
)));
5846 if(SUCCEEDED(hr
) && pKFD
->category
!= KF_CATEGORY_VIRTUAL
&& pKFD
->pszRelativePath
)
5847 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szRelativePath
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszRelativePath
, (lstrlenW(pKFD
->pszRelativePath
)+1)*sizeof(WCHAR
) ));
5852 SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
);
5855 HeapFree(GetProcessHeap(), 0, registryPath
);
5859 static HRESULT WINAPI
foldermanager_RegisterFolder(
5860 IKnownFolderManager
*iface
,
5861 REFKNOWNFOLDERID rfid
,
5862 KNOWNFOLDER_DEFINITION
const *pKFD
)
5864 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(rfid
), pKFD
);
5865 return register_folder(rfid
, pKFD
);
5868 static HRESULT WINAPI
foldermanager_UnregisterFolder(
5869 IKnownFolderManager
*iface
,
5870 REFKNOWNFOLDERID rfid
)
5873 LPWSTR registryPath
= NULL
;
5874 TRACE("(%p, %s)\n", iface
, debugstr_guid(rfid
));
5876 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
5879 hr
= HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
));
5881 HeapFree(GetProcessHeap(), 0, registryPath
);
5885 static HRESULT WINAPI
foldermanager_FindFolderFromPath(
5886 IKnownFolderManager
*iface
,
5889 IKnownFolder
**ppkf
)
5891 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath
), mode
, ppkf
);
5895 static HRESULT WINAPI
foldermanager_FindFolderFromIDList(
5896 IKnownFolderManager
*iface
,
5897 PCIDLIST_ABSOLUTE pidl
,
5898 IKnownFolder
**ppkf
)
5900 FIXME("%p, %p\n", pidl
, ppkf
);
5904 static HRESULT WINAPI
foldermanager_Redirect(
5905 IKnownFolderManager
*iface
,
5906 REFKNOWNFOLDERID rfid
,
5908 KF_REDIRECT_FLAGS flags
,
5909 LPCWSTR pszTargetPath
,
5911 KNOWNFOLDERID
const *pExclusion
,
5914 return redirect_known_folder(rfid
, hwnd
, flags
, pszTargetPath
, cFolders
, pExclusion
, ppszError
);
5917 static const struct IKnownFolderManagerVtbl foldermanager_vtbl
=
5919 foldermanager_QueryInterface
,
5920 foldermanager_AddRef
,
5921 foldermanager_Release
,
5922 foldermanager_FolderIdFromCsidl
,
5923 foldermanager_FolderIdToCsidl
,
5924 foldermanager_GetFolderIds
,
5925 foldermanager_GetFolder
,
5926 foldermanager_GetFolderByName
,
5927 foldermanager_RegisterFolder
,
5928 foldermanager_UnregisterFolder
,
5929 foldermanager_FindFolderFromPath
,
5930 foldermanager_FindFolderFromIDList
,
5931 foldermanager_Redirect
5934 static HRESULT
foldermanager_create( void **ppv
)
5937 struct foldermanager
*fm
;
5939 fm
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fm
) );
5940 if (!fm
) return E_OUTOFMEMORY
;
5942 fm
->IKnownFolderManager_iface
.lpVtbl
= &foldermanager_vtbl
;
5946 for (i
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); i
++)
5948 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
)) fm
->num_ids
++;
5950 fm
->ids
= HeapAlloc( GetProcessHeap(), 0, fm
->num_ids
* sizeof(KNOWNFOLDERID
) );
5953 HeapFree( GetProcessHeap(), 0, fm
);
5954 return E_OUTOFMEMORY
;
5956 for (i
= j
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); i
++)
5958 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
))
5960 fm
->ids
[j
] = *CSIDL_Data
[i
].id
;
5964 TRACE("found %u known folders\n", fm
->num_ids
);
5965 *ppv
= &fm
->IKnownFolderManager_iface
;
5967 TRACE("returning iface %p\n", *ppv
);
5971 HRESULT WINAPI
KnownFolderManager_Constructor( IUnknown
*punk
, REFIID riid
, void **ppv
)
5973 TRACE("%p, %s, %p\n", punk
, debugstr_guid(riid
), ppv
);
5978 return CLASS_E_NOAGGREGATION
;
5980 return foldermanager_create( ppv
);
5983 HRESULT WINAPI
SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, PIDLIST_ABSOLUTE
*pidl
)
5985 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, pidl
);
5988 return E_INVALIDARG
;
5991 FIXME("unsupported flags: 0x%08x\n", flags
);
5994 FIXME("user token is not used.\n");
5997 if (IsEqualIID(rfid
, &FOLDERID_Desktop
))
5998 *pidl
= _ILCreateDesktop();
5999 else if (IsEqualIID(rfid
, &FOLDERID_RecycleBinFolder
))
6000 *pidl
= _ILCreateBitBucket();
6001 else if (IsEqualIID(rfid
, &FOLDERID_ComputerFolder
))
6002 *pidl
= _ILCreateMyComputer();
6003 else if (IsEqualIID(rfid
, &FOLDERID_PrintersFolder
))
6004 *pidl
= _ILCreatePrinters();
6005 else if (IsEqualIID(rfid
, &FOLDERID_ControlPanelFolder
))
6006 *pidl
= _ILCreateControlPanel();
6007 else if (IsEqualIID(rfid
, &FOLDERID_NetworkFolder
))
6008 *pidl
= _ILCreateNetwork();
6009 else if (IsEqualIID(rfid
, &FOLDERID_Documents
))
6010 *pidl
= _ILCreateMyDocuments();
6013 DWORD attributes
= 0;
6017 hr
= SHGetKnownFolderPath(rfid
, flags
, token
, &pathW
);
6021 hr
= SHILCreateFromPathW(pathW
, pidl
, &attributes
);
6022 CoTaskMemFree(pathW
);
6026 return *pidl
? S_OK
: E_FAIL
;
6029 HRESULT WINAPI
SHGetKnownFolderItem(REFKNOWNFOLDERID rfid
, KNOWN_FOLDER_FLAG flags
, HANDLE hToken
,
6030 REFIID riid
, void **ppv
)
6032 PIDLIST_ABSOLUTE pidl
;
6035 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid
), flags
, hToken
, debugstr_guid(riid
), ppv
);
6037 hr
= SHGetKnownFolderIDList(rfid
, flags
, hToken
, &pidl
);
6044 hr
= SHCreateItemFromIDList(pidl
, riid
, ppv
);
6045 CoTaskMemFree(pidl
);
6049 static void register_system_knownfolders(void)
6052 for(i
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); ++i
){
6053 const CSIDL_DATA
*folder
= &CSIDL_Data
[i
];
6054 if(folder
->pszName
){
6055 KNOWNFOLDER_DEFINITION kfd
;
6057 /* register_folder won't modify kfd, so cast away const instead of
6059 kfd
.category
= folder
->category
;
6060 kfd
.pszName
= (WCHAR
*)folder
->pszName
;
6061 kfd
.pszDescription
= (WCHAR
*)folder
->pszDescription
;
6062 memcpy(&kfd
.fidParent
, folder
->fidParent
, sizeof(KNOWNFOLDERID
));
6063 kfd
.pszRelativePath
= (WCHAR
*)folder
->pszRelativePath
;
6064 kfd
.pszParsingName
= (WCHAR
*)folder
->pszParsingName
;
6065 kfd
.pszTooltip
= (WCHAR
*)folder
->pszTooltip
;
6066 kfd
.pszLocalizedName
= (WCHAR
*)folder
->pszLocalizedName
;
6067 kfd
.pszIcon
= (WCHAR
*)folder
->pszIcon
;
6068 kfd
.pszSecurity
= (WCHAR
*)folder
->pszSecurity
;
6069 kfd
.dwAttributes
= folder
->dwAttributes
;
6070 kfd
.kfdFlags
= folder
->kfdFlags
;
6071 memcpy(&kfd
.ftidType
, folder
->ftidType
, sizeof(FOLDERTYPEID
));
6073 register_folder(folder
->id
, &kfd
);
6078 HRESULT
SHELL_RegisterShellFolders(void)
6082 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6083 * 'My Videos', 'My Music' and 'Desktop' in advance, so that the
6084 * _SHRegister*ShellFolders() functions will find everything nice and clean
6085 * and thus will not attempt to create them in the profile directory. */
6086 _SHCreateSymbolicLinks();
6088 hr
= _SHRegisterUserShellFolders(TRUE
);
6090 hr
= _SHRegisterUserShellFolders(FALSE
);
6092 hr
= _SHRegisterCommonShellFolders();
6094 hr
= create_extra_folders();
6096 hr
= set_folder_attributes();
6098 register_system_knownfolders();