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_Start_Menu_ProgramsW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
856 static const WCHAR Microsoft_Windows_Start_Menu_Admin_ToolsW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
857 static const WCHAR Microsoft_Windows_Start_Menu_StartupW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
858 static const WCHAR Microsoft_Windows_TemplatesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','l','a','t','e','s',0};
859 static const WCHAR Microsoft_Windows_Temporary_Internet_FilesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s',0};
860 static const WCHAR Microsoft_Windows_ThemesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','h','e','m','e','s',0};
861 static const WCHAR MoviesW
[] = {'M','o','v','i','e','s','\0'};
862 static const WCHAR MusicW
[] = {'M','u','s','i','c','\0'};
863 static const WCHAR MusicLibraryW
[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
864 static const WCHAR Music_librarymsW
[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
865 static const WCHAR Music_PlaylistsW
[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
866 static const WCHAR Music_Sample_MusicW
[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
867 static const WCHAR Music_Sample_PlaylistsW
[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s','\0'};
868 static const WCHAR My_MusicW
[] = {'M','y',' ','M','u','s','i','c','\0'};
869 static const WCHAR My_PicturesW
[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
870 static const WCHAR My_VideosW
[] = {'M','y',' ','V','i','d','e','o','s','\0'};
871 static const WCHAR My_VideoW
[] = {'M','y',' ','V','i','d','e','o','\0'};
872 static const WCHAR MyComputerFolderW
[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
873 static const WCHAR NetHoodW
[] = {'N','e','t','H','o','o','d','\0'};
874 static const WCHAR NetworkPlacesFolderW
[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
875 static const WCHAR OEM_LinksW
[] = {'O','E','M',' ','L','i','n','k','s','\0'};
876 static const WCHAR Original_ImagesW
[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
877 static const WCHAR PersonalW
[] = {'P','e','r','s','o','n','a','l','\0'};
878 static const WCHAR PhotoAlbumsW
[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
879 static const WCHAR PicturesW
[] = {'P','i','c','t','u','r','e','s','\0'};
880 static const WCHAR PicturesLibraryW
[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
881 static const WCHAR Pictures_librarymsW
[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
882 static const WCHAR Pictures_Sample_PicturesW
[] = {'P','i','c','t','u','r','e','s','\\','S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s','\0'};
883 static const WCHAR Pictures_Slide_ShowsW
[] = {'P','i','c','t','u','r','e','s','\\','S','l','i','d','e',' ','S','h','o','w','s','\0'};
884 static const WCHAR PlaylistsW
[] = {'P','l','a','y','l','i','s','t','s',0};
885 static const WCHAR PrintersFolderW
[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
886 static const WCHAR PrintHoodW
[] = {'P','r','i','n','t','H','o','o','d','\0'};
887 static const WCHAR ProfileW
[] = {'P','r','o','f','i','l','e',0};
888 static const WCHAR ProgramDataW
[] = {'P','r','o','g','r','a','m','D','a','t','a','\0'};
889 static const WCHAR Program_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
890 static const WCHAR ProgramFilesW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
891 static const WCHAR ProgramFilesX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
892 static const WCHAR ProgramFilesX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
893 static const WCHAR Program_Files_Common_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
894 static const WCHAR Program_Files_x86W
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
895 static const WCHAR Program_Files_x86_Common_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
896 static const WCHAR ProgramFilesCommonW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
897 static const WCHAR ProgramFilesCommonX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','8','6',0};
898 static const WCHAR ProgramFilesCommonX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','6','4',0};
899 static const WCHAR ProgramFilesDirW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
900 static const WCHAR ProgramFilesDirX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
901 static const WCHAR ProgramsW
[] = {'P','r','o','g','r','a','m','s','\0'};
902 static const WCHAR PublicW
[] = {'P','u','b','l','i','c',0};
903 static const WCHAR PublicGameTasksW
[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
904 static const WCHAR PublicLibrariesW
[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
905 static const WCHAR Quick_LaunchW
[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
906 static const WCHAR RecentW
[] = {'R','e','c','e','n','t','\0'};
907 static const WCHAR RecordedTVLibraryW
[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
908 static const WCHAR RecordedTV_librarymsW
[] = {'R','e','c','o','r','d','e','d','T','V','.','l','i','b','r','a','r','y','-','m','s',0};
909 static const WCHAR RecycleBinFolderW
[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
910 static const WCHAR ResourceDirW
[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
911 static const WCHAR ResourcesW
[] = {'R','e','s','o','u','r','c','e','s','\0'};
912 static const WCHAR RingtonesW
[] = {'R','i','n','g','t','o','n','e','s',0};
913 static const WCHAR SampleMusicW
[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
914 static const WCHAR Sample_MusicW
[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
915 static const WCHAR SamplePicturesW
[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
916 static const WCHAR Sample_PicturesW
[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
917 static const WCHAR SamplePlaylistsW
[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
918 static const WCHAR Sample_PlaylistsW
[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
919 static const WCHAR Sample_VideosW
[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
920 static const WCHAR SampleVideosW
[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
921 static const WCHAR Saved_GamesW
[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
922 static const WCHAR SavedGamesW
[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
923 static const WCHAR SearchesW
[] = {'S','e','a','r','c','h','e','s','\0'};
924 static const WCHAR SearchHomeFolderW
[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
925 static const WCHAR SendToW
[] = {'S','e','n','d','T','o','\0'};
926 static const WCHAR Slide_ShowsW
[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
927 static const WCHAR StartUpW
[] = {'S','t','a','r','t','U','p','\0'};
928 static const WCHAR StartupW
[] = {'S','t','a','r','t','u','p','\0'};
929 static const WCHAR Start_MenuW
[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
930 static const WCHAR Start_Menu_ProgramsW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
931 static const WCHAR Start_Menu_Admin_ToolsW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
932 static const WCHAR Start_Menu_StartupW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
933 static const WCHAR SyncCenterFolderW
[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
934 static const WCHAR SyncResultsFolderW
[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
935 static const WCHAR SyncSetupFolderW
[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
936 static const WCHAR SystemW
[] = {'S','y','s','t','e','m',0};
937 static const WCHAR SystemX86W
[] = {'S','y','s','t','e','m','X','8','6',0};
938 static const WCHAR TemplatesW
[] = {'T','e','m','p','l','a','t','e','s','\0'};
939 static const WCHAR User_PinnedW
[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
940 static const WCHAR UsersW
[] = {'U','s','e','r','s','\0'};
941 static const WCHAR UsersFilesFolderW
[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
942 static const WCHAR UsersLibrariesFolderW
[] = {'U','s','e','r','s','L','i','b','r','a','r','i','e','s','F','o','l','d','e','r',0};
943 static const WCHAR UserProfilesW
[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
944 static const WCHAR UserProgramFilesW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
945 static const WCHAR UserProgramFilesCommonW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
946 static const WCHAR UsersPublicW
[] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'};
947 static const WCHAR VideosW
[] = {'V','i','d','e','o','s','\0'};
948 static const WCHAR VideosLibraryW
[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
949 static const WCHAR Videos_librarymsW
[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
950 static const WCHAR Videos_Sample_VideosW
[] = {'V','i','d','e','o','s','\\','S','a','m','p','l','e',' ','V','i','d','e','o','s','\0'};
951 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
952 static const WCHAR Windows_Sidebar_GadgetsW
[] = {'W','i','n','d','o','w','s',' ','S','i','d','e','b','a','r','\\','G','a','d','g','e','t','s',0};
953 static const WCHAR DefaultW
[] = {'.','D','e','f','a','u','l','t','\0'};
954 static const WCHAR AllUsersProfileW
[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
955 static const WCHAR UserProfileW
[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
956 static const WCHAR ProgramDataVarW
[] = {'%','P','r','o','g','r','a','m','D','a','t','a','%','\0'};
957 static const WCHAR SystemDriveW
[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
958 static const WCHAR ProfileListW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0};
959 static const WCHAR ProfilesDirectoryW
[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
960 static const WCHAR AllUsersProfileValueW
[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
961 static const WCHAR szSHFolders
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
962 static const WCHAR szSHUserFolders
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
963 static const WCHAR szDefaultProfileDirW
[] = {'u','s','e','r','s',0};
964 static const WCHAR szKnownFolderDescriptions
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','F','o','l','d','e','r','D','e','s','c','r','i','p','t','i','o','n','s','\0'};
965 static const WCHAR szKnownFolderRedirections
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s',0};
966 static const WCHAR AllUsersW
[] = {'P','u','b','l','i','c',0};
968 #define CHANGEREMOVEPROGRAMS_PARSING_GUID '{','7','b','8','1','b','e','6','a','-','c','e','2','b','-','4','6','7','6','-','a','2','9','e','-','e','b','9','0','7','a','5','1','2','6','c','5','}'
969 #define SYNCMANAGER_PARSING_GUID '{','9','C','7','3','F','5','E','5','-','7','A','E','7','-','4','E','3','2','-','A','8','E','8','-','8','D','2','3','B','8','5','2','5','5','B','F','}'
970 #define SYSTEMFOLDERS_PARSING_GUID '{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}'
971 #define USERFOLDERS_PARSING_GUID '{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}'
972 #define USERSLIBRARIES_PARSING_GUID '{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}'
974 static const WCHAR ComputerFolderParsingNameW
[] = {':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
975 static const WCHAR ControlPanelFolderParsingNameW
[] = {':',':','{','2','6','E','E','0','6','6','8','-','A','0','0','A','-','4','4','D','7','-','9','3','7','1','-','B','E','B','0','6','4','C','9','8','6','8','3','}','\\','0',0};
976 static const WCHAR ControlPanelFolderRelativePathW
[] = {':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
977 static const WCHAR GamesParsingNameW
[] = {':',':','{','E','D','2','2','8','F','D','F','-','9','E','A','8','-','4','8','7','0','-','8','3','b','1','-','9','6','b','0','2','C','F','E','0','D','5','2','}',0};
978 static const WCHAR HomeGroupParsingNameW
[] = {':',':','{','B','4','F','B','3','F','9','8','-','C','1','E','A','-','4','2','8','d','-','A','7','8','A','-','D','1','F','5','6','5','9','C','B','A','9','3','}',0};
979 static const WCHAR InternetFolderParsingNameW
[] = {':',':','{','8','7','1','C','5','3','8','0','-','4','2','A','0','-','1','0','6','9','-','A','2','E','A','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
980 static const WCHAR NetworkFolderParsingNameW
[] = {':',':','{','F','0','2','C','1','A','0','D','-','B','E','2','1','-','4','3','5','0','-','8','8','B','0','-','7','3','6','7','F','C','9','6','E','F','3','C','}',0};
981 static const WCHAR PublicParsingNameW
[] = {':',':','{','4','3','3','6','a','5','4','d','-','0','3','8','b','-','4','6','8','5','-','a','b','0','2','-','9','9','b','b','5','2','d','3','f','b','8','b','}',0};
982 static const WCHAR RecycleBinFolderParsingNameW
[] = {':',':','{','6','4','5','F','F','0','4','0','-','5','0','8','1','-','1','0','1','B','-','9','F','0','8','-','0','0','A','A','0','0','2','F','9','5','4','E','}',0};
983 static const WCHAR SearchHomeParsingNameW
[] = {':',':','{','9','3','4','3','8','1','2','e','-','1','c','3','7','-','4','a','4','9','-','a','1','2','e','-','4','b','2','d','8','1','0','d','9','5','6','b','}',0};
984 static const WCHAR SEARCH_CSCParsingNameW
[] = {'s','h','e','l','l',':',':',':','{','B','D','7','A','2','E','7','B','-','2','1','C','B','-','4','1','b','2','-','A','0','8','6','-','B','3','0','9','6','8','0','C','6','B','7','E','}','\\','*',0};
985 static const WCHAR SEARCH_MAPIParsingNameW
[] = {'s','h','e','l','l',':',':',':','{','8','9','D','8','3','5','7','6','-','6','B','D','1','-','4','C','8','6','-','9','4','5','4','-','B','E','B','0','4','E','9','4','C','8','1','9','}','\\','*',0};
986 static const WCHAR UsersFilesParsingNameW
[] = {':',':','{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}',0};
987 static const WCHAR UsersLibrariesParsingNameW
[] = {':',':','{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}',0};
988 static const WCHAR AddNewProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','1','5','e','a','e','9','2','e','-','f','1','7','a','-','4','4','3','1','-','9','f','2','8','-','8','0','5','e','4','8','2','d','a','f','d','4','}',0};
989 static const WCHAR ConnectionsFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','7','0','0','7','A','C','C','7','-','3','2','0','2','-','1','1','D','1','-','A','A','D','2','-','0','0','8','0','5','F','C','1','2','7','0','E','}',0};
990 static const WCHAR PrintersFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','2','2','2','7','A','2','8','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','E','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
991 static const WCHAR ChangeRemoveProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, 0};
992 static const WCHAR AppUpdatesParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, '\\',':',':','{','d','4','5','0','a','8','a','1','-','9','5','6','8','-','4','5','c','7','-','9','c','0','e','-','b','4','f','9','f','b','4','5','3','7','b','d','}',0};
993 static const WCHAR SyncManagerFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, 0};
994 static const WCHAR ConflictFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','E','4','1','3','D','0','4','0','-','6','7','8','8','-','4','C','2','2','-','9','5','7','E','-','1','7','5','D','1','C','5','1','3','A','3','4','}',',',0};
995 static const WCHAR SyncResultsFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','B','C','4','8','B','3','2','F','-','5','9','1','0','-','4','7','F','5','-','8','5','7','0','-','5','0','7','4','A','8','A','5','6','3','6','A','}',',',0};
996 static const WCHAR SyncSetupFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','F','1','3','9','0','A','9','A','-','A','3','F','4','-','4','E','5','D','-','9','C','5','F','-','9','8','F','3','B','D','8','D','9','3','5','C','}',',',0};
997 static const WCHAR ContactsParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','5','6','7','8','4','8','5','4','-','C','6','C','B','-','4','6','2','B','-','8','1','6','9','-','8','8','E','3','5','0','A','C','B','8','8','2','}',0};
998 static const WCHAR DocumentsParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','F','D','D','3','9','A','D','0','-','2','3','8','F','-','4','6','A','F','-','A','D','B','4','-','6','C','8','5','4','8','0','3','6','9','C','7','}',0};
999 static const WCHAR LinksParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','b','f','b','9','d','5','e','0','-','c','6','a','9','-','4','0','4','c','-','b','2','b','2','-','a','e','6','d','b','6','a','f','4','9','6','8','}',0};
1000 static const WCHAR MusicParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','4','B','D','8','D','5','7','1','-','6','D','1','9','-','4','8','D','3','-','B','E','9','7','-','4','2','2','2','2','0','0','8','0','E','4','3','}',0};
1001 static const WCHAR PicturesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','3','3','E','2','8','1','3','0','-','4','E','1','E','-','4','6','7','6','-','8','3','5','A','-','9','8','3','9','5','C','3','B','C','3','B','B','}',0};
1002 static const WCHAR SavedGamesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','4','C','5','C','3','2','F','F','-','B','B','9','D','-','4','3','b','0','-','B','5','B','4','-','2','D','7','2','E','5','4','E','A','A','A','4','}',0};
1003 static const WCHAR SavedSearchesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','7','d','1','d','3','a','0','4','-','d','e','b','b','-','4','1','1','5','-','9','5','c','f','-','2','f','2','9','d','a','2','9','2','0','d','a','}',0};
1004 static const WCHAR VideosParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','1','8','9','8','9','B','1','D','-','9','9','B','5','-','4','5','5','B','-','8','4','1','C','-','A','B','7','C','7','4','E','4','D','D','F','C','}',0};
1005 static const WCHAR DocumentsLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','7','b','0','d','b','1','7','d','-','9','c','d','2','-','4','a','9','3','-','9','7','3','3','-','4','6','c','c','8','9','0','2','2','e','7','c','}',0};
1006 static const WCHAR MusicLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','2','1','1','2','A','B','0','A','-','C','8','6','A','-','4','f','f','e','-','A','3','6','8','-','0','D','E','9','6','E','4','7','0','1','2','E','}',0};
1007 static const WCHAR PicturesLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','A','9','9','0','A','E','9','F','-','A','0','3','B','-','4','e','8','0','-','9','4','B','C','-','9','9','1','2','D','7','5','0','4','1','0','4','}',0};
1008 static const WCHAR VideosLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','4','9','1','E','9','2','2','F','-','5','6','4','3','-','4','a','f','4','-','A','7','E','B','-','4','E','7','A','1','3','8','D','8','1','7','4','}',0};
1010 typedef enum _CSIDL_Type
{
1012 CSIDL_Type_AllUsers
,
1014 CSIDL_Type_Disallowed
,
1015 CSIDL_Type_NonExistent
,
1016 CSIDL_Type_WindowsPath
,
1017 CSIDL_Type_SystemPath
,
1018 CSIDL_Type_SystemX86Path
,
1019 CSIDL_Type_ProgramData
,
1022 #define CSIDL_CONTACTS 0x0043
1023 #define CSIDL_DOWNLOADS 0x0047
1024 #define CSIDL_LINKS 0x004d
1025 #define CSIDL_APPDATA_LOCALLOW 0x004e
1026 #define CSIDL_SAVED_GAMES 0x0062
1027 #define CSIDL_SEARCHES 0x0063
1031 IApplicationDestinations IApplicationDestinations_iface
;
1033 } IApplicationDestinationsImpl
;
1035 static inline IApplicationDestinationsImpl
*impl_from_IApplicationDestinations( IApplicationDestinations
*iface
)
1037 return CONTAINING_RECORD(iface
, IApplicationDestinationsImpl
, IApplicationDestinations_iface
);
1040 static HRESULT WINAPI
ApplicationDestinations_QueryInterface(IApplicationDestinations
*iface
, REFIID riid
,
1043 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1045 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1050 if (IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IApplicationDestinations
, riid
))
1052 *ppv
= &This
->IApplicationDestinations_iface
;
1053 IUnknown_AddRef((IUnknown
*)*ppv
);
1055 TRACE("Returning IApplicationDestinations: %p\n", *ppv
);
1060 FIXME("(%p)->(%s, %p) interface not supported.\n", This
, debugstr_guid(riid
), ppv
);
1062 return E_NOINTERFACE
;
1065 static ULONG WINAPI
ApplicationDestinations_AddRef(IApplicationDestinations
*iface
)
1067 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1068 ULONG ref
= InterlockedIncrement(&This
->ref
);
1070 TRACE("(%p), new refcount=%i\n", This
, ref
);
1075 static ULONG WINAPI
ApplicationDestinations_Release(IApplicationDestinations
*iface
)
1077 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1078 ULONG ref
= InterlockedDecrement(&This
->ref
);
1080 TRACE("(%p), new refcount=%i\n", This
, ref
);
1088 static HRESULT WINAPI
ApplicationDestinations_SetAppID(IApplicationDestinations
*iface
, const WCHAR
*appid
)
1090 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1092 FIXME("(%p, %s) stub!\n", This
, debugstr_w(appid
));
1097 static HRESULT WINAPI
ApplicationDestinations_RemoveDestination(IApplicationDestinations
*iface
, IUnknown
*punk
)
1099 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1101 FIXME("(%p, %p) stub!\n", This
, punk
);
1106 static HRESULT WINAPI
ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations
*iface
)
1108 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1110 FIXME("(%p) stub!\n", This
);
1115 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl
=
1117 ApplicationDestinations_QueryInterface
,
1118 ApplicationDestinations_AddRef
,
1119 ApplicationDestinations_Release
,
1120 ApplicationDestinations_SetAppID
,
1121 ApplicationDestinations_RemoveDestination
,
1122 ApplicationDestinations_RemoveAllDestinations
1125 HRESULT WINAPI
ApplicationDestinations_Constructor(IUnknown
*outer
, REFIID riid
, LPVOID
*ppv
)
1127 IApplicationDestinationsImpl
*This
;
1130 TRACE("(%p, %s, %p)\n", outer
, debugstr_guid(riid
), ppv
);
1133 return CLASS_E_NOAGGREGATION
;
1135 if (!(This
= SHAlloc(sizeof(*This
))))
1136 return E_OUTOFMEMORY
;
1138 This
->IApplicationDestinations_iface
.lpVtbl
= &ApplicationDestinationsVtbl
;
1141 hr
= IUnknown_QueryInterface(&This
->IApplicationDestinations_iface
, riid
, ppv
);
1150 const KNOWNFOLDERID
*id
;
1152 LPCWSTR szValueName
;
1153 LPCWSTR szDefaultPath
; /* fallback string or resource ID */
1155 /* KNOWNFOLDER_DEFINITION fields */
1156 KF_CATEGORY category
;
1157 const WCHAR
*pszName
;
1158 const WCHAR
*pszDescription
;
1159 const KNOWNFOLDERID
*fidParent
;
1160 const WCHAR
*pszRelativePath
;
1161 const WCHAR
*pszParsingName
;
1162 const WCHAR
*pszTooltip
;
1163 const WCHAR
*pszLocalizedName
;
1164 const WCHAR
*pszIcon
;
1165 const WCHAR
*pszSecurity
;
1167 KF_DEFINITION_FLAGS kfdFlags
;
1168 const FOLDERTYPEID
*ftidType
;
1171 static const CSIDL_DATA CSIDL_Data
[] =
1173 { /* 0x00 - CSIDL_DESKTOP */
1177 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1179 KF_CATEGORY_PERUSER
, /* category */
1180 DesktopW
, /* name */
1181 NULL
, /* description */
1182 &GUID_NULL
, /* parent */
1183 DesktopW
, /* relative path */
1186 NULL
, /* localized */
1188 NULL
, /* security */
1189 FILE_ATTRIBUTE_READONLY
, /* attributes */
1191 &GUID_NULL
/* typeid */
1193 { /* 0x01 - CSIDL_INTERNET */
1194 &FOLDERID_InternetFolder
,
1195 CSIDL_Type_Disallowed
,
1199 KF_CATEGORY_VIRTUAL
, /* category */
1200 InternetFolderW
, /* name */
1201 NULL
, /* description */
1202 &GUID_NULL
, /* parent */
1203 NULL
, /* relative path */
1204 InternetFolderParsingNameW
, /* parsing */
1206 NULL
, /* localized */
1208 NULL
, /* security */
1211 &GUID_NULL
/* typeid */
1213 { /* 0x02 - CSIDL_PROGRAMS */
1217 Start_Menu_ProgramsW
,
1219 KF_CATEGORY_PERUSER
, /* category */
1220 ProgramsW
, /* name */
1221 NULL
, /* description */
1222 &GUID_NULL
, /* parent */
1223 ProgramsW
, /* relative path */
1226 NULL
, /* localized */
1228 NULL
, /* security */
1229 FILE_ATTRIBUTE_READONLY
, /* attributes */
1231 &GUID_NULL
/* typeid */
1233 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1234 &FOLDERID_ControlPanelFolder
,
1235 CSIDL_Type_SystemPath
,
1239 KF_CATEGORY_VIRTUAL
, /* category */
1240 ControlPanelFolderW
, /* name */
1241 NULL
, /* description */
1242 &GUID_NULL
, /* parent */
1243 ControlPanelFolderRelativePathW
, /* relative path */
1244 ControlPanelFolderParsingNameW
, /* parsing */
1246 NULL
, /* localized */
1248 NULL
, /* security */
1251 &GUID_NULL
/* typeid */
1253 { /* 0x04 - CSIDL_PRINTERS */
1254 &FOLDERID_PrintersFolder
,
1255 CSIDL_Type_SystemPath
,
1259 KF_CATEGORY_VIRTUAL
, /* category */
1260 PrintersFolderW
, /* name */
1261 NULL
, /* description */
1262 &GUID_NULL
, /* parent */
1263 NULL
, /* relative path */
1264 PrintersFolderParsingNameW
, /* parsing */
1266 NULL
, /* localized */
1268 NULL
, /* security */
1271 &GUID_NULL
/* typeid */
1273 { /* 0x05 - CSIDL_PERSONAL */
1274 &FOLDERID_Documents
,
1277 MAKEINTRESOURCEW(IDS_PERSONAL
),
1279 KF_CATEGORY_PERUSER
, /* category */
1280 PersonalW
, /* name */
1281 NULL
, /* description */
1282 &GUID_NULL
, /* parent */
1283 DocumentsW
, /* relative path */
1284 DocumentsParsingNameW
, /* parsing */
1286 NULL
, /* localized */
1288 NULL
, /* security */
1289 FILE_ATTRIBUTE_READONLY
, /* attributes */
1290 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1291 &GUID_NULL
/* typeid */
1293 { /* 0x06 - CSIDL_FAVORITES */
1294 &FOLDERID_Favorites
,
1299 KF_CATEGORY_PERUSER
, /* category */
1300 FavoritesW
, /* name */
1301 NULL
, /* description */
1302 &GUID_NULL
, /* parent */
1303 FavoritesW
, /* relative path */
1306 NULL
, /* localized */
1308 NULL
, /* security */
1309 FILE_ATTRIBUTE_READONLY
, /* attributes */
1310 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1311 &GUID_NULL
/* typeid */
1313 { /* 0x07 - CSIDL_STARTUP */
1317 Start_Menu_StartupW
,
1319 KF_CATEGORY_PERUSER
, /* category */
1320 StartupW
, /* name */
1321 NULL
, /* description */
1322 &GUID_NULL
, /* parent */
1323 StartUpW
, /* relative path */
1326 NULL
, /* localized */
1328 NULL
, /* security */
1329 FILE_ATTRIBUTE_READONLY
, /* attributes */
1330 KFDF_PRECREATE
, /* flags */
1331 &GUID_NULL
/* typeid */
1333 { /* 0x08 - CSIDL_RECENT */
1339 KF_CATEGORY_PERUSER
, /* category */
1341 NULL
, /* description */
1342 &FOLDERID_RoamingAppData
, /* parent */
1343 Microsoft_Windows_RecentW
, /* relative path */
1346 NULL
, /* localized */
1348 NULL
, /* security */
1349 FILE_ATTRIBUTE_READONLY
, /* attributes */
1350 KFDF_PRECREATE
, /* flags */
1351 &GUID_NULL
/* typeid */
1353 { /* 0x09 - CSIDL_SENDTO */
1359 KF_CATEGORY_PERUSER
, /* category */
1361 NULL
, /* description */
1362 &FOLDERID_RoamingAppData
, /* parent */
1363 Microsoft_Windows_SendToW
, /* relative path */
1366 NULL
, /* localized */
1368 NULL
, /* security */
1370 KFDF_PRECREATE
, /* flags */
1371 &GUID_NULL
/* typeid */
1373 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1374 &FOLDERID_RecycleBinFolder
,
1375 CSIDL_Type_Disallowed
,
1379 KF_CATEGORY_VIRTUAL
, /* category */
1380 RecycleBinFolderW
, /* name */
1381 NULL
, /* description */
1382 &GUID_NULL
, /* parent */
1383 NULL
, /* relative path */
1384 RecycleBinFolderParsingNameW
, /* parsing */
1386 NULL
, /* localized */
1388 NULL
, /* security */
1391 &GUID_NULL
/* typeid */
1393 { /* 0x0b - CSIDL_STARTMENU */
1394 &FOLDERID_StartMenu
,
1399 KF_CATEGORY_PERUSER
, /* category */
1400 Start_MenuW
, /* name */
1401 NULL
, /* description */
1402 &FOLDERID_RoamingAppData
, /* parent */
1403 Microsoft_Windows_Start_MenuW
, /* relative path */
1406 NULL
, /* localized */
1408 NULL
, /* security */
1409 FILE_ATTRIBUTE_READONLY
, /* attributes */
1410 KFDF_PRECREATE
, /* flags */
1411 &GUID_NULL
/* typeid */
1413 { /* 0x0c - CSIDL_MYDOCUMENTS */
1415 CSIDL_Type_Disallowed
, /* matches WinXP--can't get its path */
1419 { /* 0x0d - CSIDL_MYMUSIC */
1423 MAKEINTRESOURCEW(IDS_MYMUSIC
),
1425 KF_CATEGORY_PERUSER
, /* category */
1426 My_MusicW
, /* name */
1427 NULL
, /* description */
1428 &FOLDERID_Profile
, /* parent */
1429 MusicW
, /* relative path */
1430 MusicParsingNameW
, /* parsing */
1432 NULL
, /* localized */
1434 NULL
, /* security */
1435 FILE_ATTRIBUTE_READONLY
, /* attributes */
1436 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1437 &GUID_NULL
/* typeid */
1439 { /* 0x0e - CSIDL_MYVIDEO */
1443 MAKEINTRESOURCEW(IDS_MYVIDEOS
),
1445 KF_CATEGORY_PERUSER
, /* category */
1446 My_VideoW
, /* name */
1447 NULL
, /* description */
1448 &FOLDERID_Profile
, /* parent */
1449 VideosW
, /* relative path */
1450 VideosParsingNameW
, /* parsing */
1452 NULL
, /* localized */
1454 NULL
, /* security */
1455 FILE_ATTRIBUTE_READONLY
, /* attributes */
1456 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1457 &GUID_NULL
/* typeid */
1459 { /* 0x0f - unassigned */
1461 CSIDL_Type_Disallowed
,
1465 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1469 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1471 KF_CATEGORY_PERUSER
, /* category */
1472 DesktopW
, /* name */
1473 NULL
, /* description */
1474 &FOLDERID_Profile
, /* parent */
1475 DesktopW
, /* relative path */
1478 NULL
, /* localized */
1480 NULL
, /* security */
1481 FILE_ATTRIBUTE_READONLY
, /* attributes */
1482 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1483 &GUID_NULL
/* typeid */
1485 { /* 0x11 - CSIDL_DRIVES */
1486 &FOLDERID_ComputerFolder
,
1487 CSIDL_Type_Disallowed
,
1491 KF_CATEGORY_VIRTUAL
, /* category */
1492 MyComputerFolderW
, /* name */
1493 NULL
, /* description */
1494 &GUID_NULL
, /* parent */
1495 NULL
, /* relative path */
1496 ComputerFolderParsingNameW
, /* parsing */
1498 NULL
, /* localized */
1500 NULL
, /* security */
1503 &GUID_NULL
/* typeid */
1505 { /* 0x12 - CSIDL_NETWORK */
1506 &FOLDERID_NetworkFolder
,
1507 CSIDL_Type_Disallowed
,
1511 KF_CATEGORY_VIRTUAL
, /* category */
1512 NetworkPlacesFolderW
, /* name */
1513 NULL
, /* description */
1514 &GUID_NULL
, /* parent */
1515 NULL
, /* relative path */
1516 NetworkFolderParsingNameW
, /* parsing */
1518 NULL
, /* localized */
1520 NULL
, /* security */
1523 &GUID_NULL
/* typeid */
1525 { /* 0x13 - CSIDL_NETHOOD */
1531 KF_CATEGORY_PERUSER
, /* category */
1532 NetHoodW
, /* name */
1533 NULL
, /* description */
1534 &FOLDERID_RoamingAppData
, /* parent */
1535 Microsoft_Windows_Network_ShortcutsW
, /* relative path */
1538 NULL
, /* localized */
1540 NULL
, /* security */
1543 &GUID_NULL
/* typeid */
1545 { /* 0x14 - CSIDL_FONTS */
1547 CSIDL_Type_WindowsPath
,
1551 KF_CATEGORY_FIXED
, /* category */
1553 NULL
, /* description */
1554 &GUID_NULL
, /* parent */
1555 NULL
, /* relative path */
1558 NULL
, /* localized */
1560 NULL
, /* security */
1563 &FOLDERID_Windows
/* typeid */
1565 { /* 0x15 - CSIDL_TEMPLATES */
1566 &FOLDERID_Templates
,
1571 KF_CATEGORY_PERUSER
, /* category */
1572 TemplatesW
, /* name */
1573 NULL
, /* description */
1574 &FOLDERID_RoamingAppData
, /* parent */
1575 Microsoft_Windows_TemplatesW
, /* relative path */
1578 NULL
, /* localized */
1580 NULL
, /* security */
1583 &GUID_NULL
/* typeid */
1585 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1586 &FOLDERID_CommonStartMenu
,
1587 CSIDL_Type_ProgramData
,
1589 Microsoft_Windows_Start_MenuW
,
1591 KF_CATEGORY_COMMON
, /* category */
1592 Common_Start_MenuW
, /* name */
1593 NULL
, /* description */
1594 &FOLDERID_ProgramData
, /* parent */
1595 Microsoft_Windows_Start_MenuW
, /* relative path */
1598 NULL
, /* localized */
1600 NULL
, /* security */
1601 FILE_ATTRIBUTE_READONLY
, /* attributes */
1603 &GUID_NULL
/* typeid */
1605 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1606 &FOLDERID_CommonPrograms
,
1607 CSIDL_Type_ProgramData
,
1609 Microsoft_Windows_Start_Menu_ProgramsW
,
1611 KF_CATEGORY_COMMON
, /* category */
1612 Common_ProgramsW
, /* name */
1613 NULL
, /* description */
1614 &FOLDERID_CommonStartMenu
, /* parent */
1615 ProgramsW
, /* relative path */
1618 NULL
, /* localized */
1620 NULL
, /* security */
1621 FILE_ATTRIBUTE_READONLY
, /* attributes */
1623 &GUID_NULL
/* typeid */
1625 { /* 0x18 - CSIDL_COMMON_STARTUP */
1626 &FOLDERID_CommonStartup
,
1627 CSIDL_Type_ProgramData
,
1629 Microsoft_Windows_Start_Menu_StartupW
,
1631 KF_CATEGORY_COMMON
, /* category */
1632 Common_StartupW
, /* name */
1633 NULL
, /* description */
1634 &FOLDERID_CommonPrograms
, /* parent */
1635 StartUpW
, /* relative path */
1638 NULL
, /* localized */
1640 NULL
, /* security */
1641 FILE_ATTRIBUTE_READONLY
, /* attributes */
1642 KFDF_PRECREATE
, /* flags */
1643 &GUID_NULL
/* typeid */
1645 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1646 &FOLDERID_PublicDesktop
,
1647 CSIDL_Type_AllUsers
,
1649 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1651 KF_CATEGORY_COMMON
, /* category */
1652 Common_DesktopW
, /* name */
1653 NULL
, /* description */
1654 &FOLDERID_Public
, /* parent */
1655 DesktopW
, /* relative path */
1658 NULL
, /* localized */
1660 NULL
, /* security */
1661 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
1662 KFDF_PRECREATE
, /* flags */
1663 &GUID_NULL
/* typeid */
1665 { /* 0x1a - CSIDL_APPDATA */
1666 &FOLDERID_RoamingAppData
,
1671 KF_CATEGORY_PERUSER
, /* category */
1672 AppDataW
, /* name */
1673 NULL
, /* description */
1674 &FOLDERID_Profile
, /* parent */
1675 AppData_RoamingW
, /* relative path */
1678 NULL
, /* localized */
1680 NULL
, /* security */
1683 &GUID_NULL
/* typeid */
1685 { /* 0x1b - CSIDL_PRINTHOOD */
1686 &FOLDERID_PrintHood
,
1691 KF_CATEGORY_PERUSER
, /* category */
1692 PrintHoodW
, /* name */
1693 NULL
, /* description */
1694 &FOLDERID_RoamingAppData
, /* parent */
1695 Microsoft_Windows_Printer_ShortcutsW
, /* relative path */
1698 NULL
, /* localized */
1700 NULL
, /* security */
1703 &GUID_NULL
/* typeid */
1705 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1706 &FOLDERID_LocalAppData
,
1709 Local_Settings_Application_DataW
,
1711 KF_CATEGORY_PERUSER
, /* category */
1712 Local_AppDataW
, /* name */
1713 NULL
, /* description */
1714 &FOLDERID_Profile
, /* parent */
1715 AppData_LocalW
, /* relative path */
1718 NULL
, /* localized */
1720 NULL
, /* security */
1722 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1723 &GUID_NULL
/* typeid */
1725 { /* 0x1d - CSIDL_ALTSTARTUP */
1727 CSIDL_Type_NonExistent
,
1731 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1733 CSIDL_Type_NonExistent
,
1737 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1738 &FOLDERID_Favorites
,
1739 CSIDL_Type_AllUsers
,
1743 KF_CATEGORY_PERUSER
, /* category */
1744 FavoritesW
, /* name */
1745 NULL
, /* description */
1746 &FOLDERID_Profile
, /* parent */
1747 FavoritesW
, /* relative path */
1750 NULL
, /* localized */
1752 NULL
, /* security */
1753 FILE_ATTRIBUTE_READONLY
, /* attributes */
1754 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1755 &GUID_NULL
/* typeid */
1757 { /* 0x20 - CSIDL_INTERNET_CACHE */
1758 &FOLDERID_InternetCache
,
1761 Local_Settings_Temporary_Internet_FilesW
,
1763 KF_CATEGORY_PERUSER
, /* category */
1765 NULL
, /* description */
1766 &FOLDERID_LocalAppData
, /* parent */
1767 Microsoft_Windows_Temporary_Internet_FilesW
, /* relative path */
1770 NULL
, /* localized */
1772 NULL
, /* security */
1774 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1775 &GUID_NULL
/* typeid */
1777 { /* 0x21 - CSIDL_COOKIES */
1783 KF_CATEGORY_PERUSER
, /* category */
1784 CookiesW
, /* name */
1785 NULL
, /* description */
1786 &FOLDERID_RoamingAppData
, /* parent */
1787 Microsoft_Windows_CookiesW
, /* relative path */
1790 NULL
, /* localized */
1792 NULL
, /* security */
1795 &GUID_NULL
/* typeid */
1797 { /* 0x22 - CSIDL_HISTORY */
1801 Local_Settings_HistoryW
,
1803 KF_CATEGORY_PERUSER
, /* category */
1804 HistoryW
, /* name */
1805 NULL
, /* description */
1806 &FOLDERID_LocalAppData
, /* parent */
1807 Microsoft_Windows_HistoryW
, /* relative path */
1810 NULL
, /* localized */
1812 NULL
, /* security */
1814 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1815 &GUID_NULL
/* typeid */
1817 { /* 0x23 - CSIDL_COMMON_APPDATA */
1818 &FOLDERID_ProgramData
,
1819 CSIDL_Type_ProgramData
,
1823 KF_CATEGORY_FIXED
, /* category */
1824 Common_AppDataW
, /* name */
1825 NULL
, /* description */
1826 &GUID_NULL
, /* parent */
1827 NULL
, /* relative path */
1830 NULL
, /* localized */
1832 NULL
, /* security */
1835 &GUID_NULL
/* typeid */
1837 { /* 0x24 - CSIDL_WINDOWS */
1839 CSIDL_Type_WindowsPath
,
1843 KF_CATEGORY_FIXED
, /* category */
1844 WindowsW
, /* name */
1845 NULL
, /* description */
1846 &GUID_NULL
, /* parent */
1847 NULL
, /* relative path */
1850 NULL
, /* localized */
1852 NULL
, /* security */
1855 &GUID_NULL
/* typeid */
1857 { /* 0x25 - CSIDL_SYSTEM */
1859 CSIDL_Type_SystemPath
,
1863 KF_CATEGORY_FIXED
, /* category */
1865 NULL
, /* description */
1866 &GUID_NULL
, /* parent */
1867 NULL
, /* relative path */
1870 NULL
, /* localized */
1872 NULL
, /* security */
1875 &GUID_NULL
/* typeid */
1877 { /* 0x26 - CSIDL_PROGRAM_FILES */
1878 &FOLDERID_ProgramFiles
,
1883 KF_CATEGORY_FIXED
, /* category */
1884 ProgramFilesW
, /* name */
1885 NULL
, /* description */
1886 &GUID_NULL
, /* parent */
1887 NULL
, /* relative path */
1890 NULL
, /* localized */
1892 NULL
, /* security */
1893 FILE_ATTRIBUTE_READONLY
, /* attributes */
1895 &GUID_NULL
/* typeid */
1897 { /* 0x27 - CSIDL_MYPICTURES */
1901 MAKEINTRESOURCEW(IDS_MYPICTURES
),
1903 KF_CATEGORY_PERUSER
, /* category */
1904 My_PicturesW
, /* name */
1905 NULL
, /* description */
1906 &FOLDERID_Profile
, /* parent */
1907 PicturesW
, /* relative path */
1908 PicturesParsingNameW
, /* parsing */
1910 NULL
, /* localized */
1912 NULL
, /* security */
1913 FILE_ATTRIBUTE_READONLY
, /* attributes */
1914 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1915 &GUID_NULL
/* typeid */
1917 { /* 0x28 - CSIDL_PROFILE */
1923 KF_CATEGORY_FIXED
, /* category */
1924 ProfileW
, /* name */
1925 NULL
, /* description */
1926 &GUID_NULL
, /* parent */
1927 NULL
, /* relative path */
1930 NULL
, /* localized */
1932 NULL
, /* security */
1935 &GUID_NULL
/* typeid */
1937 { /* 0x29 - CSIDL_SYSTEMX86 */
1938 &FOLDERID_SystemX86
,
1939 CSIDL_Type_SystemX86Path
,
1943 KF_CATEGORY_FIXED
, /* category */
1944 SystemX86W
, /* name */
1945 NULL
, /* description */
1946 &GUID_NULL
, /* parent */
1947 NULL
, /* relative path */
1950 NULL
, /* localized */
1952 NULL
, /* security */
1955 &GUID_NULL
/* typeid */
1957 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
1958 &FOLDERID_ProgramFilesX86
,
1960 ProgramFilesDirX86W
,
1963 KF_CATEGORY_FIXED
, /* category */
1964 ProgramFilesX86W
, /* name */
1965 NULL
, /* description */
1966 &GUID_NULL
, /* parent */
1967 NULL
, /* relative path */
1970 NULL
, /* localized */
1972 NULL
, /* security */
1973 FILE_ATTRIBUTE_READONLY
, /* attributes */
1975 &GUID_NULL
/* typeid */
1977 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
1978 &FOLDERID_ProgramFilesCommon
,
1981 Program_Files_Common_FilesW
,
1983 KF_CATEGORY_FIXED
, /* category */
1984 ProgramFilesCommonW
, /* name */
1985 NULL
, /* description */
1986 &GUID_NULL
, /* parent */
1987 NULL
, /* relative path */
1990 NULL
, /* localized */
1992 NULL
, /* security */
1995 &GUID_NULL
/* typeid */
1997 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
1998 &FOLDERID_ProgramFilesCommonX86
,
2001 Program_Files_x86_Common_FilesW
,
2003 KF_CATEGORY_FIXED
, /* category */
2004 ProgramFilesCommonX86W
, /* name */
2005 NULL
, /* description */
2006 &GUID_NULL
, /* parent */
2007 NULL
, /* relative path */
2010 NULL
, /* localized */
2012 NULL
, /* security */
2015 &GUID_NULL
/* typeid */
2017 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2018 &FOLDERID_CommonTemplates
,
2019 CSIDL_Type_ProgramData
,
2021 Microsoft_Windows_TemplatesW
,
2023 KF_CATEGORY_COMMON
, /* category */
2024 Common_TemplatesW
, /* name */
2025 NULL
, /* description */
2026 &FOLDERID_ProgramData
, /* parent */
2027 Microsoft_Windows_TemplatesW
, /* relative path */
2030 NULL
, /* localized */
2032 NULL
, /* security */
2035 &GUID_NULL
/* typeid */
2037 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2038 &FOLDERID_PublicDocuments
,
2039 CSIDL_Type_AllUsers
,
2043 KF_CATEGORY_COMMON
, /* category */
2044 Common_DocumentsW
, /* name */
2045 NULL
, /* description */
2046 &FOLDERID_Public
, /* parent */
2047 DocumentsW
, /* relative path */
2050 NULL
, /* localized */
2052 NULL
, /* security */
2053 FILE_ATTRIBUTE_READONLY
, /* attributes */
2054 KFDF_PRECREATE
, /* flags */
2055 &GUID_NULL
/* typeid */
2057 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2058 &FOLDERID_CommonAdminTools
,
2059 CSIDL_Type_ProgramData
,
2060 Common_Administrative_ToolsW
,
2061 Microsoft_Windows_Start_Menu_Admin_ToolsW
,
2063 KF_CATEGORY_COMMON
, /* category */
2064 Common_Administrative_ToolsW
, /* name */
2065 NULL
, /* description */
2066 &FOLDERID_CommonPrograms
, /* parent */
2067 Administrative_ToolsW
, /* relative path */
2070 NULL
, /* localized */
2072 NULL
, /* security */
2073 FILE_ATTRIBUTE_READONLY
, /* attributes */
2074 KFDF_PRECREATE
, /* flags */
2075 &GUID_NULL
/* typeid */
2077 { /* 0x30 - CSIDL_ADMINTOOLS */
2078 &FOLDERID_AdminTools
,
2080 Administrative_ToolsW
,
2081 Start_Menu_Admin_ToolsW
,
2083 KF_CATEGORY_PERUSER
, /* category */
2084 Administrative_ToolsW
, /* name */
2085 NULL
, /* description */
2086 &FOLDERID_Programs
, /* parent */
2087 Administrative_ToolsW
, /* relative path */
2090 NULL
, /* localized */
2092 NULL
, /* security */
2093 FILE_ATTRIBUTE_READONLY
, /* attributes */
2094 KFDF_PRECREATE
, /* flags */
2095 &GUID_NULL
/* typeid */
2097 { /* 0x31 - CSIDL_CONNECTIONS */
2098 &FOLDERID_ConnectionsFolder
,
2099 CSIDL_Type_Disallowed
,
2103 KF_CATEGORY_VIRTUAL
, /* category */
2104 ConnectionsFolderW
, /* name */
2105 NULL
, /* description */
2106 &GUID_NULL
, /* parent */
2107 Administrative_ToolsW
, /* relative path */
2108 ConnectionsFolderParsingNameW
, /* parsing */
2110 NULL
, /* localized */
2112 NULL
, /* security */
2115 &GUID_NULL
/* typeid */
2117 { /* 0x32 - unassigned */
2119 CSIDL_Type_Disallowed
,
2123 { /* 0x33 - unassigned */
2125 CSIDL_Type_Disallowed
,
2129 { /* 0x34 - unassigned */
2131 CSIDL_Type_Disallowed
,
2135 { /* 0x35 - CSIDL_COMMON_MUSIC */
2136 &FOLDERID_PublicMusic
,
2137 CSIDL_Type_AllUsers
,
2141 KF_CATEGORY_COMMON
, /* category */
2142 CommonMusicW
, /* name */
2143 NULL
, /* description */
2144 &FOLDERID_Public
, /* parent */
2145 MusicW
, /* relative path */
2148 NULL
, /* localized */
2150 NULL
, /* security */
2151 FILE_ATTRIBUTE_READONLY
, /* attributes */
2152 KFDF_PRECREATE
, /* flags */
2153 &GUID_NULL
/* typeid */
2155 { /* 0x36 - CSIDL_COMMON_PICTURES */
2156 &FOLDERID_PublicPictures
,
2157 CSIDL_Type_AllUsers
,
2161 KF_CATEGORY_COMMON
, /* category */
2162 CommonPicturesW
, /* name */
2163 NULL
, /* description */
2164 &FOLDERID_Public
, /* parent */
2165 PicturesW
, /* relative path */
2168 NULL
, /* localized */
2170 NULL
, /* security */
2171 FILE_ATTRIBUTE_READONLY
, /* attributes */
2172 KFDF_PRECREATE
, /* flags */
2173 &GUID_NULL
/* typeid */
2175 { /* 0x37 - CSIDL_COMMON_VIDEO */
2176 &FOLDERID_PublicVideos
,
2177 CSIDL_Type_AllUsers
,
2181 KF_CATEGORY_COMMON
, /* category */
2182 CommonVideoW
, /* name */
2183 NULL
, /* description */
2184 &FOLDERID_Public
, /* parent */
2185 VideosW
, /* relative path */
2188 NULL
, /* localized */
2190 NULL
, /* security */
2191 FILE_ATTRIBUTE_READONLY
, /* attributes */
2192 KFDF_PRECREATE
, /* flags */
2193 &GUID_NULL
/* typeid */
2195 { /* 0x38 - CSIDL_RESOURCES */
2196 &FOLDERID_ResourceDir
,
2197 CSIDL_Type_WindowsPath
,
2201 KF_CATEGORY_FIXED
, /* category */
2202 ResourceDirW
, /* name */
2203 NULL
, /* description */
2204 &GUID_NULL
, /* parent */
2205 NULL
, /* relative path */
2208 NULL
, /* localized */
2210 NULL
, /* security */
2213 &GUID_NULL
/* typeid */
2215 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2216 &FOLDERID_LocalizedResourcesDir
,
2217 CSIDL_Type_NonExistent
,
2221 KF_CATEGORY_FIXED
, /* category */
2222 LocalizedResourcesDirW
, /* name */
2223 NULL
, /* description */
2224 &GUID_NULL
, /* parent */
2225 NULL
, /* relative path */
2228 NULL
, /* localized */
2230 NULL
, /* security */
2233 &GUID_NULL
/* typeid */
2235 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2236 &FOLDERID_CommonOEMLinks
,
2237 CSIDL_Type_ProgramData
,
2241 KF_CATEGORY_COMMON
, /* category */
2242 OEM_LinksW
, /* name */
2243 NULL
, /* description */
2244 &FOLDERID_ProgramData
, /* parent */
2245 OEM_LinksW
, /* relative path */
2248 NULL
, /* localized */
2250 NULL
, /* security */
2253 &GUID_NULL
/* typeid */
2255 { /* 0x3b - CSIDL_CDBURN_AREA */
2256 &FOLDERID_CDBurning
,
2259 Local_Settings_CD_BurningW
,
2261 KF_CATEGORY_PERUSER
, /* category */
2262 CD_BurningW
, /* name */
2263 NULL
, /* description */
2264 &FOLDERID_LocalAppData
, /* parent */
2265 Microsoft_Windows_Burn_BurnW
, /* relative path */
2268 NULL
, /* localized */
2270 NULL
, /* security */
2271 FILE_ATTRIBUTE_READONLY
, /* attributes */
2272 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2273 &GUID_NULL
/* typeid */
2275 { /* 0x3c unassigned */
2277 CSIDL_Type_Disallowed
,
2281 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2283 CSIDL_Type_Disallowed
, /* FIXME */
2287 { /* 0x3e - CSIDL_PROFILES */
2289 CSIDL_Type_Disallowed
, /* oddly, this matches WinXP */
2294 &FOLDERID_AddNewPrograms
,
2295 CSIDL_Type_Disallowed
,
2299 KF_CATEGORY_VIRTUAL
, /* category */
2300 AddNewProgramsFolderW
, /* name */
2301 NULL
, /* description */
2302 &GUID_NULL
, /* parent */
2303 NULL
, /* relative path */
2304 AddNewProgramsParsingNameW
, /* parsing */
2306 NULL
, /* localized */
2308 NULL
, /* security */
2311 &GUID_NULL
/* typeid */
2314 &FOLDERID_AppUpdates
,
2315 CSIDL_Type_Disallowed
,
2319 KF_CATEGORY_VIRTUAL
, /* category */
2320 AppUpdatesFolderW
, /* name */
2321 NULL
, /* description */
2322 &GUID_NULL
, /* parent */
2323 NULL
, /* relative path */
2324 AppUpdatesParsingNameW
, /* parsing */
2326 NULL
, /* localized */
2328 NULL
, /* security */
2331 &GUID_NULL
/* typeid */
2334 &FOLDERID_ChangeRemovePrograms
,
2335 CSIDL_Type_Disallowed
,
2339 KF_CATEGORY_VIRTUAL
, /* category */
2340 ChangeRemoveProgramsFolderW
, /* name */
2341 NULL
, /* description */
2342 &GUID_NULL
, /* parent */
2343 NULL
, /* relative path */
2344 ChangeRemoveProgramsParsingNameW
, /* parsing */
2346 NULL
, /* localized */
2348 NULL
, /* security */
2351 &GUID_NULL
/* typeid */
2354 &FOLDERID_ConflictFolder
,
2355 CSIDL_Type_Disallowed
,
2359 KF_CATEGORY_VIRTUAL
, /* category */
2360 ConflictFolderW
, /* name */
2361 NULL
, /* description */
2362 &GUID_NULL
, /* parent */
2363 NULL
, /* relative path */
2364 ConflictFolderParsingNameW
, /* parsing */
2366 NULL
, /* localized */
2368 NULL
, /* security */
2371 &GUID_NULL
/* typeid */
2373 { /* 0x43 - CSIDL_CONTACTS */
2379 KF_CATEGORY_PERUSER
, /* category */
2380 ContactsW
, /* name */
2381 NULL
, /* description */
2382 &FOLDERID_Profile
, /* parent */
2383 ContactsW
, /* relative path */
2384 ContactsParsingNameW
, /* parsing */
2386 NULL
, /* localized */
2388 NULL
, /* security */
2389 FILE_ATTRIBUTE_READONLY
, /* attributes */
2390 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2391 &GUID_NULL
/* typeid */
2394 &FOLDERID_DeviceMetadataStore
,
2395 CSIDL_Type_Disallowed
, /* FIXME */
2399 KF_CATEGORY_COMMON
, /* category */
2400 Device_Metadata_StoreW
, /* name */
2401 NULL
, /* description */
2402 &FOLDERID_ProgramData
, /* parent */
2403 Microsoft_Windows_DeviceMetadataStoreW
, /* relative path */
2406 NULL
, /* localized */
2408 NULL
, /* security */
2411 &GUID_NULL
/* typeid */
2420 &FOLDERID_DocumentsLibrary
,
2421 CSIDL_Type_Disallowed
, /* FIXME */
2425 KF_CATEGORY_PERUSER
, /* category */
2426 DocumentsLibraryW
, /* name */
2427 NULL
, /* description */
2428 &FOLDERID_Libraries
, /* parent */
2429 Documents_librarymsW
, /* relative path */
2430 DocumentsLibraryParsingNameW
, /* parsing */
2432 NULL
, /* localized */
2434 NULL
, /* security */
2436 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2437 &GUID_NULL
/* typeid */
2439 { /* 0x47 - CSIDL_DOWNLOADS */
2440 &FOLDERID_Downloads
,
2445 KF_CATEGORY_PERUSER
, /* category */
2446 DownloadsW
, /* name */
2447 NULL
, /* description */
2448 &FOLDERID_Profile
, /* parent */
2449 DownloadsW
, /* relative path */
2452 NULL
, /* localized */
2454 NULL
, /* security */
2455 FILE_ATTRIBUTE_READONLY
, /* attributes */
2456 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2457 &GUID_NULL
/* typeid */
2461 CSIDL_Type_Disallowed
,
2465 KF_CATEGORY_VIRTUAL
, /* category */
2467 NULL
, /* description */
2468 &GUID_NULL
, /* parent */
2469 NULL
, /* relative path */
2470 GamesParsingNameW
, /* parsing */
2472 NULL
, /* localized */
2474 NULL
, /* security */
2477 &GUID_NULL
/* typeid */
2480 &FOLDERID_GameTasks
,
2481 CSIDL_Type_Disallowed
, /* FIXME */
2485 KF_CATEGORY_PERUSER
, /* category */
2486 GameTasksW
, /* name */
2487 NULL
, /* description */
2488 &FOLDERID_LocalAppData
, /* parent */
2489 Microsoft_Windows_GameExplorerW
, /* relative path */
2492 NULL
, /* localized */
2494 NULL
, /* security */
2496 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2497 &GUID_NULL
/* typeid */
2500 &FOLDERID_HomeGroup
,
2501 CSIDL_Type_Disallowed
,
2505 KF_CATEGORY_VIRTUAL
, /* category */
2506 HomeGroupFolderW
, /* name */
2507 NULL
, /* description */
2508 &GUID_NULL
, /* parent */
2509 NULL
, /* relative path */
2510 HomeGroupParsingNameW
, /* parsing */
2512 NULL
, /* localized */
2514 NULL
, /* security */
2517 &GUID_NULL
/* typeid */
2520 &FOLDERID_ImplicitAppShortcuts
,
2521 CSIDL_Type_Disallowed
, /* FIXME */
2525 KF_CATEGORY_PERUSER
, /* category */
2526 ImplicitAppShortcutsW
, /* name */
2527 NULL
, /* description */
2528 &FOLDERID_UserPinned
, /* parent */
2529 ImplicitAppShortcutsW
, /* relative path */
2532 NULL
, /* localized */
2534 NULL
, /* security */
2536 KFDF_PRECREATE
, /* flags */
2537 &GUID_NULL
/* typeid */
2540 &FOLDERID_Libraries
,
2541 CSIDL_Type_Disallowed
, /* FIXME */
2545 KF_CATEGORY_PERUSER
, /* category */
2546 LibrariesW
, /* name */
2547 NULL
, /* description */
2548 &FOLDERID_RoamingAppData
, /* parent */
2549 Microsoft_Windows_LibrariesW
, /* relative path */
2552 NULL
, /* localized */
2554 NULL
, /* security */
2556 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2557 &GUID_NULL
/* typeid */
2559 { /* 0x4d - CSIDL_LINKS */
2565 KF_CATEGORY_PERUSER
, /* category */
2567 NULL
, /* description */
2568 &FOLDERID_Profile
, /* parent */
2569 LinksW
, /* relative path */
2570 LinksParsingNameW
, /* parsing */
2572 NULL
, /* localized */
2574 NULL
, /* security */
2575 FILE_ATTRIBUTE_READONLY
, /* attributes */
2576 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2577 &GUID_NULL
/* typeid */
2579 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2580 &FOLDERID_LocalAppDataLow
,
2585 KF_CATEGORY_PERUSER
, /* category */
2586 LocalAppDataLowW
, /* name */
2587 NULL
, /* description */
2588 &FOLDERID_Profile
, /* parent */
2589 AppData_LocalLowW
, /* relative path */
2592 NULL
, /* localized */
2594 NULL
, /* security */
2595 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
, /* attributes */
2596 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2597 &GUID_NULL
/* typeid */
2600 &FOLDERID_MusicLibrary
,
2601 CSIDL_Type_Disallowed
, /* FIXME */
2605 KF_CATEGORY_PERUSER
, /* category */
2606 MusicLibraryW
, /* name */
2607 NULL
, /* description */
2608 &FOLDERID_Libraries
, /* parent */
2609 Music_librarymsW
, /* relative path */
2610 MusicLibraryParsingNameW
, /* parsing */
2612 NULL
, /* localized */
2614 NULL
, /* security */
2616 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2617 &GUID_NULL
/* typeid */
2620 &FOLDERID_OriginalImages
,
2621 CSIDL_Type_Disallowed
, /* FIXME */
2625 KF_CATEGORY_PERUSER
, /* category */
2626 Original_ImagesW
, /* name */
2627 NULL
, /* description */
2628 &FOLDERID_LocalAppData
, /* parent */
2629 Microsoft_Windows_Photo_Gallery_Original_ImagesW
, /* relative path */
2632 NULL
, /* localized */
2634 NULL
, /* security */
2637 &GUID_NULL
/* typeid */
2640 &FOLDERID_PhotoAlbums
,
2643 Pictures_Slide_ShowsW
,
2645 KF_CATEGORY_PERUSER
, /* category */
2646 PhotoAlbumsW
, /* name */
2647 NULL
, /* description */
2648 &FOLDERID_Pictures
, /* parent */
2649 Slide_ShowsW
, /* relative path */
2652 NULL
, /* localized */
2654 NULL
, /* security */
2655 FILE_ATTRIBUTE_READONLY
, /* attributes */
2657 &GUID_NULL
/* typeid */
2660 &FOLDERID_PicturesLibrary
,
2661 CSIDL_Type_Disallowed
, /* FIXME */
2665 KF_CATEGORY_PERUSER
, /* category */
2666 PicturesLibraryW
, /* name */
2667 NULL
, /* description */
2668 &FOLDERID_Libraries
, /* parent */
2669 Pictures_librarymsW
, /* relative path */
2670 PicturesLibraryParsingNameW
, /* parsing */
2672 NULL
, /* localized */
2674 NULL
, /* security */
2676 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2677 &GUID_NULL
/* typeid */
2680 &FOLDERID_Playlists
,
2685 KF_CATEGORY_PERUSER
, /* category */
2686 PlaylistsW
, /* name */
2687 NULL
, /* description */
2688 &FOLDERID_Music
, /* parent */
2689 PlaylistsW
, /* relative path */
2692 NULL
, /* localized */
2694 NULL
, /* security */
2695 FILE_ATTRIBUTE_READONLY
, /* attributes */
2697 &GUID_NULL
/* typeid */
2700 &FOLDERID_ProgramFilesX64
,
2701 CSIDL_Type_NonExistent
,
2705 KF_CATEGORY_FIXED
, /* category */
2706 ProgramFilesX64W
, /* name */
2707 NULL
, /* description */
2708 &GUID_NULL
, /* parent */
2709 NULL
, /* relative path */
2712 NULL
, /* localized */
2714 NULL
, /* security */
2717 &GUID_NULL
/* typeid */
2720 &FOLDERID_ProgramFilesCommonX64
,
2721 CSIDL_Type_NonExistent
,
2725 KF_CATEGORY_FIXED
, /* category */
2726 ProgramFilesCommonX64W
, /* name */
2727 NULL
, /* description */
2728 &GUID_NULL
, /* parent */
2729 NULL
, /* relative path */
2732 NULL
, /* localized */
2734 NULL
, /* security */
2737 &GUID_NULL
/* typeid */
2741 CSIDL_Type_CurrVer
, /* FIXME */
2745 KF_CATEGORY_FIXED
, /* category */
2747 NULL
, /* description */
2748 &GUID_NULL
, /* parent */
2749 NULL
, /* relative path */
2750 PublicParsingNameW
, /* parsing */
2752 NULL
, /* localized */
2754 NULL
, /* security */
2755 FILE_ATTRIBUTE_READONLY
, /* attributes */
2756 KFDF_PRECREATE
, /* flags */
2757 &GUID_NULL
/* typeid */
2760 &FOLDERID_PublicDownloads
,
2761 CSIDL_Type_AllUsers
,
2765 KF_CATEGORY_COMMON
, /* category */
2766 CommonDownloadsW
, /* name */
2767 NULL
, /* description */
2768 &FOLDERID_Public
, /* parent */
2769 DownloadsW
, /* relative path */
2772 NULL
, /* localized */
2774 NULL
, /* security */
2775 FILE_ATTRIBUTE_READONLY
, /* attributes */
2776 KFDF_PRECREATE
, /* flags */
2777 &GUID_NULL
/* typeid */
2780 &FOLDERID_PublicGameTasks
,
2781 CSIDL_Type_ProgramData
,
2783 Microsoft_Windows_GameExplorerW
,
2785 KF_CATEGORY_COMMON
, /* category */
2786 PublicGameTasksW
, /* name */
2787 NULL
, /* description */
2788 &FOLDERID_ProgramData
, /* parent */
2789 Microsoft_Windows_GameExplorerW
, /* relative path */
2792 NULL
, /* localized */
2794 NULL
, /* security */
2796 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2797 &GUID_NULL
/* typeid */
2800 &FOLDERID_PublicLibraries
,
2801 CSIDL_Type_AllUsers
,
2803 Microsoft_Windows_LibrariesW
,
2805 KF_CATEGORY_COMMON
, /* category */
2806 PublicLibrariesW
, /* name */
2807 NULL
, /* description */
2808 &FOLDERID_Public
, /* parent */
2809 LibrariesW
, /* relative path */
2812 NULL
, /* localized */
2814 NULL
, /* security */
2815 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
2816 KFDF_PRECREATE
, /* flags */
2817 &GUID_NULL
/* typeid */
2820 &FOLDERID_PublicRingtones
,
2821 CSIDL_Type_ProgramData
,
2823 Microsoft_Windows_RingtonesW
,
2825 KF_CATEGORY_COMMON
, /* category */
2826 CommonRingtonesW
, /* name */
2827 NULL
, /* description */
2828 &FOLDERID_ProgramData
, /* parent */
2829 Microsoft_Windows_RingtonesW
, /* relative path */
2832 NULL
, /* localized */
2834 NULL
, /* security */
2836 KFDF_PRECREATE
, /* flags */
2837 &GUID_NULL
/* typeid */
2840 &FOLDERID_QuickLaunch
,
2841 CSIDL_Type_Disallowed
, /* FIXME */
2845 KF_CATEGORY_PERUSER
, /* category */
2846 Quick_LaunchW
, /* name */
2847 NULL
, /* description */
2848 &FOLDERID_RoamingAppData
, /* parent */
2849 Microsoft_Internet_Explorer_Quick_LaunchW
, /* relative path */
2852 NULL
, /* localized */
2854 NULL
, /* security */
2857 &GUID_NULL
/* typeid */
2860 &FOLDERID_RecordedTVLibrary
,
2861 CSIDL_Type_Disallowed
, /* FIXME */
2865 KF_CATEGORY_COMMON
, /* category */
2866 RecordedTVLibraryW
, /* name */
2867 NULL
, /* description */
2868 &FOLDERID_PublicLibraries
, /* parent */
2869 RecordedTV_librarymsW
, /* relative path */
2872 NULL
, /* localized */
2874 NULL
, /* security */
2876 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2877 &GUID_NULL
/* typeid */
2880 &FOLDERID_Ringtones
,
2881 CSIDL_Type_Disallowed
, /* FIXME */
2885 KF_CATEGORY_PERUSER
, /* category */
2886 RingtonesW
, /* name */
2887 NULL
, /* description */
2888 &FOLDERID_LocalAppData
, /* parent */
2889 Microsoft_Windows_RingtonesW
, /* relative path */
2892 NULL
, /* localized */
2894 NULL
, /* security */
2896 KFDF_PRECREATE
, /* flags */
2897 &GUID_NULL
/* typeid */
2900 &FOLDERID_SampleMusic
,
2901 CSIDL_Type_AllUsers
,
2903 Music_Sample_MusicW
,
2905 KF_CATEGORY_COMMON
, /* category */
2906 SampleMusicW
, /* name */
2907 NULL
, /* description */
2908 &FOLDERID_PublicMusic
, /* parent */
2909 Sample_MusicW
, /* relative path */
2912 NULL
, /* localized */
2914 NULL
, /* security */
2915 FILE_ATTRIBUTE_READONLY
, /* attributes */
2916 KFDF_PRECREATE
, /* flags */
2917 &GUID_NULL
/* typeid */
2920 &FOLDERID_SamplePictures
,
2921 CSIDL_Type_AllUsers
,
2923 Pictures_Sample_PicturesW
,
2925 KF_CATEGORY_COMMON
, /* category */
2926 SamplePicturesW
, /* name */
2927 NULL
, /* description */
2928 &FOLDERID_PublicPictures
, /* parent */
2929 Sample_PicturesW
, /* relative path */
2932 NULL
, /* localized */
2934 NULL
, /* security */
2935 FILE_ATTRIBUTE_READONLY
, /* attributes */
2936 KFDF_PRECREATE
, /* flags */
2937 &GUID_NULL
/* typeid */
2940 &FOLDERID_SamplePlaylists
,
2941 CSIDL_Type_AllUsers
,
2943 Music_Sample_PlaylistsW
,
2945 KF_CATEGORY_COMMON
, /* category */
2946 SamplePlaylistsW
, /* name */
2947 NULL
, /* description */
2948 &FOLDERID_PublicMusic
, /* parent */
2949 Sample_PlaylistsW
, /* relative path */
2952 NULL
, /* localized */
2954 NULL
, /* security */
2955 FILE_ATTRIBUTE_READONLY
, /* attributes */
2956 KFDF_PRECREATE
, /* flags */
2957 &GUID_NULL
/* typeid */
2960 &FOLDERID_SampleVideos
,
2961 CSIDL_Type_AllUsers
,
2963 Videos_Sample_VideosW
,
2965 KF_CATEGORY_COMMON
, /* category */
2966 SampleVideosW
, /* name */
2967 NULL
, /* description */
2968 &FOLDERID_PublicVideos
, /* parent */
2969 Sample_VideosW
, /* relative path */
2972 NULL
, /* localized */
2974 NULL
, /* security */
2975 FILE_ATTRIBUTE_READONLY
, /* attributes */
2976 KFDF_PRECREATE
, /* flags */
2977 &GUID_NULL
/* typeid */
2979 { /* 0x62 - CSIDL_SAVED_GAMES */
2980 &FOLDERID_SavedGames
,
2985 KF_CATEGORY_PERUSER
, /* category */
2986 SavedGamesW
, /* name */
2987 NULL
, /* description */
2988 &FOLDERID_Profile
, /* parent */
2989 Saved_GamesW
, /* relative path */
2990 SavedGamesParsingNameW
, /* parsing */
2992 NULL
, /* localized */
2994 NULL
, /* security */
2995 FILE_ATTRIBUTE_READONLY
, /* attributes */
2996 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2997 &GUID_NULL
/* typeid */
2999 { /* 0x63 - CSIDL_SEARCHES */
3000 &FOLDERID_SavedSearches
,
3005 KF_CATEGORY_PERUSER
, /* category */
3006 SearchesW
, /* name */
3007 NULL
, /* description */
3008 &FOLDERID_Profile
, /* parent */
3009 SearchesW
, /* relative path */
3010 SavedSearchesParsingNameW
, /* parsing */
3012 NULL
, /* localized */
3014 NULL
, /* security */
3015 FILE_ATTRIBUTE_READONLY
, /* attributes */
3016 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
3017 &GUID_NULL
/* typeid */
3020 &FOLDERID_SEARCH_CSC
,
3021 CSIDL_Type_Disallowed
,
3025 KF_CATEGORY_VIRTUAL
, /* category */
3026 CSCFolderW
, /* name */
3027 NULL
, /* description */
3028 &GUID_NULL
, /* parent */
3029 NULL
, /* relative path */
3030 SEARCH_CSCParsingNameW
, /* parsing */
3032 NULL
, /* localized */
3034 NULL
, /* security */
3037 &GUID_NULL
/* typeid */
3040 &FOLDERID_SEARCH_MAPI
,
3041 CSIDL_Type_Disallowed
,
3045 KF_CATEGORY_VIRTUAL
, /* category */
3046 MAPIFolderW
, /* name */
3047 NULL
, /* description */
3048 &GUID_NULL
, /* parent */
3049 NULL
, /* relative path */
3050 SEARCH_MAPIParsingNameW
, /* parsing */
3052 NULL
, /* localized */
3054 NULL
, /* security */
3057 &GUID_NULL
/* typeid */
3060 &FOLDERID_SearchHome
,
3061 CSIDL_Type_Disallowed
,
3065 KF_CATEGORY_VIRTUAL
, /* category */
3066 SearchHomeFolderW
, /* name */
3067 NULL
, /* description */
3068 &GUID_NULL
, /* parent */
3069 NULL
, /* relative path */
3070 SearchHomeParsingNameW
, /* parsing */
3072 NULL
, /* localized */
3074 NULL
, /* security */
3077 &GUID_NULL
/* typeid */
3080 &FOLDERID_SidebarDefaultParts
,
3081 CSIDL_Type_Disallowed
, /* FIXME */
3085 KF_CATEGORY_COMMON
, /* category */
3086 Default_GadgetsW
, /* name */
3087 NULL
, /* description */
3088 &FOLDERID_ProgramFiles
, /* parent */
3089 Windows_Sidebar_GadgetsW
, /* relative path */
3092 NULL
, /* localized */
3094 NULL
, /* security */
3097 &GUID_NULL
/* typeid */
3100 &FOLDERID_SidebarParts
,
3101 CSIDL_Type_Disallowed
, /* FIXME */
3105 KF_CATEGORY_PERUSER
, /* category */
3106 GadgetsW
, /* name */
3107 NULL
, /* description */
3108 &FOLDERID_LocalAppData
, /* parent */
3109 Microsoft_Windows_Sidebar_GadgetsW
, /* relative path */
3112 NULL
, /* localized */
3114 NULL
, /* security */
3117 &GUID_NULL
/* typeid */
3120 &FOLDERID_SyncManagerFolder
,
3121 CSIDL_Type_Disallowed
,
3125 KF_CATEGORY_VIRTUAL
, /* category */
3126 SyncCenterFolderW
, /* name */
3127 NULL
, /* description */
3128 &GUID_NULL
, /* parent */
3129 NULL
, /* relative path */
3130 SyncManagerFolderParsingNameW
, /* parsing */
3132 NULL
, /* localized */
3134 NULL
, /* security */
3137 &GUID_NULL
/* typeid */
3140 &FOLDERID_SyncResultsFolder
,
3141 CSIDL_Type_Disallowed
,
3145 KF_CATEGORY_VIRTUAL
, /* category */
3146 SyncResultsFolderW
, /* name */
3147 NULL
, /* description */
3148 &GUID_NULL
, /* parent */
3149 NULL
, /* relative path */
3150 SyncResultsFolderParsingNameW
, /* parsing */
3152 NULL
, /* localized */
3154 NULL
, /* security */
3157 &GUID_NULL
/* typeid */
3160 &FOLDERID_SyncSetupFolder
,
3161 CSIDL_Type_Disallowed
,
3165 KF_CATEGORY_VIRTUAL
, /* category */
3166 SyncSetupFolderW
, /* name */
3167 NULL
, /* description */
3168 &GUID_NULL
, /* parent */
3169 NULL
, /* relative path */
3170 SyncSetupFolderParsingNameW
, /* parsing */
3172 NULL
, /* localized */
3174 NULL
, /* security */
3177 &GUID_NULL
/* typeid */
3180 &FOLDERID_UserPinned
,
3181 CSIDL_Type_Disallowed
, /* FIXME */
3185 KF_CATEGORY_PERUSER
, /* category */
3186 User_PinnedW
, /* name */
3187 NULL
, /* description */
3188 &FOLDERID_QuickLaunch
, /* parent */
3189 User_PinnedW
, /* relative path */
3192 NULL
, /* localized */
3194 NULL
, /* security */
3195 FILE_ATTRIBUTE_HIDDEN
, /* attributes */
3196 KFDF_PRECREATE
, /* flags */
3197 &GUID_NULL
/* typeid */
3200 &FOLDERID_UserProfiles
,
3205 KF_CATEGORY_FIXED
, /* category */
3206 UserProfilesW
, /* name */
3207 NULL
, /* description */
3208 &GUID_NULL
, /* parent */
3209 NULL
, /* relative path */
3212 NULL
, /* localized */
3214 NULL
, /* security */
3215 FILE_ATTRIBUTE_READONLY
, /* attributes */
3216 KFDF_PRECREATE
, /* flags */
3217 &GUID_NULL
/* typeid */
3220 &FOLDERID_UserProgramFiles
,
3221 CSIDL_Type_Disallowed
, /* FIXME */
3225 KF_CATEGORY_PERUSER
, /* category */
3226 UserProgramFilesW
, /* name */
3227 NULL
, /* description */
3228 &FOLDERID_LocalAppData
, /* parent */
3229 ProgramsW
, /* relative path */
3232 NULL
, /* localized */
3234 NULL
, /* security */
3237 &GUID_NULL
/* typeid */
3240 &FOLDERID_UserProgramFilesCommon
,
3241 CSIDL_Type_Disallowed
, /* FIXME */
3245 KF_CATEGORY_PERUSER
, /* category */
3246 UserProgramFilesCommonW
, /* name */
3247 NULL
, /* description */
3248 &FOLDERID_UserProgramFiles
, /* parent */
3249 CommonW
, /* relative path */
3252 NULL
, /* localized */
3254 NULL
, /* security */
3257 &GUID_NULL
/* typeid */
3260 &FOLDERID_UsersFiles
,
3261 CSIDL_Type_Disallowed
,
3265 KF_CATEGORY_VIRTUAL
, /* category */
3266 UsersFilesFolderW
, /* name */
3267 NULL
, /* description */
3268 &GUID_NULL
, /* parent */
3269 NULL
, /* relative path */
3270 UsersFilesParsingNameW
, /* parsing */
3272 NULL
, /* localized */
3274 NULL
, /* security */
3277 &GUID_NULL
/* typeid */
3280 &FOLDERID_UsersLibraries
,
3281 CSIDL_Type_Disallowed
,
3285 KF_CATEGORY_VIRTUAL
, /* category */
3286 UsersLibrariesFolderW
, /* name */
3287 NULL
, /* description */
3288 &GUID_NULL
, /* parent */
3289 NULL
, /* relative path */
3290 UsersLibrariesParsingNameW
, /* parsing */
3292 NULL
, /* localized */
3294 NULL
, /* security */
3297 &GUID_NULL
/* typeid */
3300 &FOLDERID_VideosLibrary
,
3301 CSIDL_Type_Disallowed
, /* FIXME */
3305 KF_CATEGORY_PERUSER
, /* category */
3306 VideosLibraryW
, /* name */
3307 NULL
, /* description */
3308 &GUID_NULL
, /* parent */
3309 Videos_librarymsW
, /* relative path */
3310 VideosLibraryParsingNameW
, /* parsing */
3312 NULL
, /* localized */
3314 NULL
, /* security */
3317 &GUID_NULL
/* typeid */
3321 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
);
3323 /* Gets the value named value from the registry key
3324 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3325 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3326 * is assumed to be MAX_PATH WCHARs in length.
3327 * If it exists, expands the value and writes the expanded value to
3328 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3329 * Returns successful error code if the value was retrieved from the registry,
3330 * and a failure otherwise.
3332 static HRESULT
_SHGetUserShellFolderPath(HKEY rootKey
, LPCWSTR userPrefix
,
3333 LPCWSTR value
, LPWSTR path
)
3336 WCHAR shellFolderPath
[MAX_PATH
], userShellFolderPath
[MAX_PATH
];
3337 LPCWSTR pShellFolderPath
, pUserShellFolderPath
;
3338 HKEY userShellFolderKey
, shellFolderKey
;
3339 DWORD dwType
, dwPathLen
;
3341 TRACE("%p,%s,%s,%p\n",rootKey
, debugstr_w(userPrefix
), debugstr_w(value
),
3346 strcpyW(shellFolderPath
, userPrefix
);
3347 PathAddBackslashW(shellFolderPath
);
3348 strcatW(shellFolderPath
, szSHFolders
);
3349 pShellFolderPath
= shellFolderPath
;
3350 strcpyW(userShellFolderPath
, userPrefix
);
3351 PathAddBackslashW(userShellFolderPath
);
3352 strcatW(userShellFolderPath
, szSHUserFolders
);
3353 pUserShellFolderPath
= userShellFolderPath
;
3357 pUserShellFolderPath
= szSHUserFolders
;
3358 pShellFolderPath
= szSHFolders
;
3361 if (RegCreateKeyW(rootKey
, pShellFolderPath
, &shellFolderKey
))
3363 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath
));
3366 if (RegCreateKeyW(rootKey
, pUserShellFolderPath
, &userShellFolderKey
))
3368 TRACE("Failed to create %s\n",
3369 debugstr_w(pUserShellFolderPath
));
3370 RegCloseKey(shellFolderKey
);
3374 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3375 if (!RegQueryValueExW(userShellFolderKey
, value
, NULL
, &dwType
,
3376 (LPBYTE
)path
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3380 path
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3381 if (dwType
== REG_EXPAND_SZ
&& path
[0] == '%')
3383 WCHAR szTemp
[MAX_PATH
];
3385 _SHExpandEnvironmentStrings(path
, szTemp
);
3386 lstrcpynW(path
, szTemp
, MAX_PATH
);
3388 ret
= RegSetValueExW(shellFolderKey
, value
, 0, REG_SZ
, (LPBYTE
)path
,
3389 (strlenW(path
) + 1) * sizeof(WCHAR
));
3390 if (ret
!= ERROR_SUCCESS
)
3391 hr
= HRESULT_FROM_WIN32(ret
);
3397 RegCloseKey(shellFolderKey
);
3398 RegCloseKey(userShellFolderKey
);
3399 TRACE("returning 0x%08x\n", hr
);
3403 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3404 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3405 * - The entry's szDefaultPath may be either a string value or an integer
3406 * resource identifier. In the latter case, the string value of the resource
3408 * - Depending on the entry's type, the path may begin with an (unexpanded)
3409 * environment variable name. The caller is responsible for expanding
3410 * environment strings if so desired.
3411 * The types that are prepended with environment variables are:
3412 * CSIDL_Type_User: %USERPROFILE%
3413 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3414 * CSIDL_Type_CurrVer: %SystemDrive%
3415 * (Others might make sense too, but as yet are unneeded.)
3417 static HRESULT
_SHGetDefaultValue(BYTE folder
, LPWSTR pszPath
)
3420 WCHAR resourcePath
[MAX_PATH
];
3421 LPCWSTR pDefaultPath
= NULL
;
3423 TRACE("0x%02x,%p\n", folder
, pszPath
);
3425 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3426 return E_INVALIDARG
;
3429 return E_INVALIDARG
;
3437 case CSIDL_PROGRAM_FILES
:
3438 case CSIDL_PROGRAM_FILESX86
:
3439 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3440 folder
= is_wow64
? CSIDL_PROGRAM_FILESX86
: CSIDL_PROGRAM_FILES
;
3442 case CSIDL_PROGRAM_FILES_COMMON
:
3443 case CSIDL_PROGRAM_FILES_COMMONX86
:
3444 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3445 folder
= is_wow64
? CSIDL_PROGRAM_FILES_COMMONX86
: CSIDL_PROGRAM_FILES_COMMON
;
3450 if (CSIDL_Data
[folder
].szDefaultPath
&&
3451 IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
))
3453 if (LoadStringW(shell32_hInstance
,
3454 LOWORD(CSIDL_Data
[folder
].szDefaultPath
), resourcePath
, MAX_PATH
))
3457 pDefaultPath
= resourcePath
;
3461 FIXME("(%d,%s), LoadString failed, missing translation?\n", folder
,
3462 debugstr_w(pszPath
));
3469 pDefaultPath
= CSIDL_Data
[folder
].szDefaultPath
;
3473 switch (CSIDL_Data
[folder
].type
)
3475 case CSIDL_Type_User
:
3476 strcpyW(pszPath
, UserProfileW
);
3478 case CSIDL_Type_AllUsers
:
3479 strcpyW(pszPath
, AllUsersProfileW
);
3481 case CSIDL_Type_ProgramData
:
3482 strcpyW(pszPath
, ProgramDataVarW
);
3484 case CSIDL_Type_CurrVer
:
3485 strcpyW(pszPath
, SystemDriveW
);
3488 ; /* no corresponding env. var, do nothing */
3492 PathAddBackslashW(pszPath
);
3493 strcatW(pszPath
, pDefaultPath
);
3496 TRACE("returning 0x%08x\n", hr
);
3500 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3501 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3502 * can be overridden in the HKLM\\szCurrentVersion key.
3503 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3504 * the registry, uses _SHGetDefaultValue to get the value.
3506 static HRESULT
_SHGetCurrentVersionPath(DWORD dwFlags
, BYTE folder
,
3511 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3513 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3514 return E_INVALIDARG
;
3515 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_CurrVer
)
3516 return E_INVALIDARG
;
3518 return E_INVALIDARG
;
3520 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3521 hr
= _SHGetDefaultValue(folder
, pszPath
);
3526 if (RegCreateKeyW(HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hKey
))
3530 DWORD dwType
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3532 if (RegQueryValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, NULL
,
3533 &dwType
, (LPBYTE
)pszPath
, &dwPathLen
) ||
3534 (dwType
!= REG_SZ
&& dwType
!= REG_EXPAND_SZ
))
3536 hr
= _SHGetDefaultValue(folder
, pszPath
);
3537 dwType
= REG_EXPAND_SZ
;
3540 case CSIDL_PROGRAM_FILESX86
:
3541 case CSIDL_PROGRAM_FILES_COMMONX86
:
3542 /* these two should never be set on 32-bit setups */
3546 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3547 if (!is_wow64
) break;
3551 RegSetValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, 0, dwType
,
3552 (LPBYTE
)pszPath
, (strlenW(pszPath
)+1)*sizeof(WCHAR
));
3557 pszPath
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3563 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3567 static LPWSTR
_GetUserSidStringFromToken(HANDLE Token
)
3569 char InfoBuffer
[64];
3570 PTOKEN_USER UserInfo
;
3574 UserInfo
= (PTOKEN_USER
) InfoBuffer
;
3575 if (! GetTokenInformation(Token
, TokenUser
, InfoBuffer
, sizeof(InfoBuffer
),
3578 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
3580 UserInfo
= heap_alloc(InfoSize
);
3581 if (UserInfo
== NULL
)
3583 if (! GetTokenInformation(Token
, TokenUser
, UserInfo
, InfoSize
,
3586 heap_free(UserInfo
);
3591 if (! ConvertSidToStringSidW(UserInfo
->User
.Sid
, &SidStr
))
3594 if (UserInfo
!= (PTOKEN_USER
) InfoBuffer
)
3595 heap_free(UserInfo
);
3600 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3601 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3602 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3603 * - if hToken is -1, looks in HKEY_USERS\.Default
3604 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3605 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3606 * calls _SHGetDefaultValue for it.
3608 static HRESULT
_SHGetUserProfilePath(HANDLE hToken
, DWORD dwFlags
, BYTE folder
,
3611 const WCHAR
*szValueName
;
3615 TRACE("%p,0x%08x,0x%02x,%p\n", hToken
, dwFlags
, folder
, pszPath
);
3617 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3618 return E_INVALIDARG
;
3619 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_User
)
3620 return E_INVALIDARG
;
3622 return E_INVALIDARG
;
3624 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3626 if (hToken
!= NULL
&& hToken
!= (HANDLE
)-1)
3628 FIXME("unsupported for user other than current or default\n");
3631 hr
= _SHGetDefaultValue(folder
, pszPath
);
3635 LPCWSTR userPrefix
= NULL
;
3638 if (hToken
== (HANDLE
)-1)
3640 hRootKey
= HKEY_USERS
;
3641 userPrefix
= DefaultW
;
3643 else if (hToken
== NULL
)
3644 hRootKey
= HKEY_CURRENT_USER
;
3647 hRootKey
= HKEY_USERS
;
3648 userPrefix
= _GetUserSidStringFromToken(hToken
);
3649 if (userPrefix
== NULL
)
3656 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3657 szValueName
= CSIDL_Data
[folder
].szValueName
;
3660 StringFromGUID2( CSIDL_Data
[folder
].id
, buffer
, 39 );
3661 szValueName
= &buffer
[0];
3664 hr
= _SHGetUserShellFolderPath(hRootKey
, userPrefix
, szValueName
, pszPath
);
3665 if (FAILED(hr
) && hRootKey
!= HKEY_LOCAL_MACHINE
)
3666 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
, szValueName
, pszPath
);
3668 hr
= _SHGetDefaultValue(folder
, pszPath
);
3669 if (userPrefix
!= NULL
&& userPrefix
!= DefaultW
)
3670 LocalFree((HLOCAL
) userPrefix
);
3673 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3677 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3678 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3679 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3680 * If this fails, falls back to _SHGetDefaultValue.
3682 static HRESULT
_SHGetAllUsersProfilePath(DWORD dwFlags
, BYTE folder
,
3687 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3689 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3690 return E_INVALIDARG
;
3691 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_AllUsers
&& CSIDL_Data
[folder
].type
!= CSIDL_Type_ProgramData
)
3692 return E_INVALIDARG
;
3694 return E_INVALIDARG
;
3696 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3697 hr
= _SHGetDefaultValue(folder
, pszPath
);
3700 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
,
3701 CSIDL_Data
[folder
].szValueName
, pszPath
);
3703 hr
= _SHGetDefaultValue(folder
, pszPath
);
3705 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3709 static HRESULT
_SHOpenProfilesKey(PHKEY pKey
)
3714 lRet
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, ProfileListW
, 0, NULL
, 0,
3715 KEY_ALL_ACCESS
, NULL
, pKey
, &disp
);
3716 return HRESULT_FROM_WIN32(lRet
);
3719 /* Reads the value named szValueName from the key profilesKey (assumed to be
3720 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3721 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3722 * szDefault to the registry).
3724 static HRESULT
_SHGetProfilesValue(HKEY profilesKey
, LPCWSTR szValueName
,
3725 LPWSTR szValue
, LPCWSTR szDefault
)
3728 DWORD type
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3731 TRACE("%p,%s,%p,%s\n", profilesKey
, debugstr_w(szValueName
), szValue
,
3732 debugstr_w(szDefault
));
3733 lRet
= RegQueryValueExW(profilesKey
, szValueName
, NULL
, &type
,
3734 (LPBYTE
)szValue
, &dwPathLen
);
3735 if (!lRet
&& (type
== REG_SZ
|| type
== REG_EXPAND_SZ
) && dwPathLen
3738 dwPathLen
/= sizeof(WCHAR
);
3739 szValue
[dwPathLen
] = '\0';
3744 /* Missing or invalid value, set a default */
3745 lstrcpynW(szValue
, szDefault
, MAX_PATH
);
3746 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName
),
3747 debugstr_w(szValue
));
3748 lRet
= RegSetValueExW(profilesKey
, szValueName
, 0, REG_EXPAND_SZ
,
3750 (strlenW(szValue
) + 1) * sizeof(WCHAR
));
3752 hr
= HRESULT_FROM_WIN32(lRet
);
3756 TRACE("returning 0x%08x (output value is %s)\n", hr
, debugstr_w(szValue
));
3760 /* Attempts to expand environment variables from szSrc into szDest, which is
3761 * assumed to be MAX_PATH characters in length. Before referring to the
3762 * environment, handles a few variables directly, because the environment
3763 * variables may not be set when this is called (as during Wine's installation
3764 * when default values are being written to the registry).
3765 * The directly handled environment variables, and their source, are:
3766 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3767 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3769 * If one of the directly handled environment variables is expanded, only
3770 * expands a single variable, and only in the beginning of szSrc.
3772 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
)
3775 WCHAR szTemp
[MAX_PATH
], szProfilesPrefix
[MAX_PATH
] = { 0 };
3778 TRACE("%s, %p\n", debugstr_w(szSrc
), szDest
);
3780 if (!szSrc
|| !szDest
) return E_INVALIDARG
;
3782 /* short-circuit if there's nothing to expand */
3783 if (szSrc
[0] != '%')
3785 strcpyW(szDest
, szSrc
);
3789 /* Get the profile prefix, we'll probably be needing it */
3790 hr
= _SHOpenProfilesKey(&key
);
3793 WCHAR def_val
[MAX_PATH
];
3795 /* get the system drive */
3796 GetSystemDirectoryW(def_val
, MAX_PATH
);
3797 if (def_val
[1] == ':') strcpyW( def_val
+ 3, szDefaultProfileDirW
);
3798 else FIXME("non-drive system paths unsupported\n");
3800 hr
= _SHGetProfilesValue(key
, ProfilesDirectoryW
, szProfilesPrefix
, def_val
);
3804 strcpyW(szTemp
, szSrc
);
3805 while (SUCCEEDED(hr
) && szTemp
[0] == '%')
3807 if (!strncmpiW(szTemp
, AllUsersProfileW
, strlenW(AllUsersProfileW
)))
3809 WCHAR szAllUsers
[MAX_PATH
];
3811 strcpyW(szDest
, szProfilesPrefix
);
3812 hr
= _SHGetProfilesValue(key
, AllUsersProfileValueW
,
3813 szAllUsers
, AllUsersW
);
3814 PathAppendW(szDest
, szAllUsers
);
3815 PathAppendW(szDest
, szTemp
+ strlenW(AllUsersProfileW
));
3817 else if (!strncmpiW(szTemp
, ProgramDataVarW
, strlenW(ProgramDataVarW
)))
3819 WCHAR szProgramData
[MAX_PATH
], def_val
[MAX_PATH
];
3820 HKEY shellFolderKey
;
3821 DWORD dwType
, dwPathLen
= sizeof(def_val
);
3822 BOOL in_registry
= FALSE
;
3824 if (!RegCreateKeyW(HKEY_LOCAL_MACHINE
, szSHFolders
, &shellFolderKey
))
3826 if (!RegQueryValueExW(shellFolderKey
, Common_AppDataW
, NULL
, &dwType
,
3827 (LPBYTE
)def_val
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3830 RegCloseKey(shellFolderKey
);
3835 GetSystemDirectoryW(def_val
, MAX_PATH
);
3836 if (def_val
[1] == ':') strcpyW( def_val
+ 3, ProgramDataW
);
3837 else FIXME("non-drive system paths unsupported\n");
3840 hr
= _SHGetProfilesValue(key
, ProgramDataW
, szProgramData
, def_val
);
3841 PathAppendW(szDest
, szProgramData
);
3842 PathAppendW(szDest
, szTemp
+ strlenW(ProgramDataVarW
));
3844 else if (!strncmpiW(szTemp
, UserProfileW
, strlenW(UserProfileW
)))
3846 WCHAR userName
[MAX_PATH
];
3847 DWORD userLen
= MAX_PATH
;
3849 strcpyW(szDest
, szProfilesPrefix
);
3850 GetUserNameW(userName
, &userLen
);
3851 PathAppendW(szDest
, userName
);
3852 PathAppendW(szDest
, szTemp
+ strlenW(UserProfileW
));
3854 else if (!strncmpiW(szTemp
, SystemDriveW
, strlenW(SystemDriveW
)))
3856 GetSystemDirectoryW(szDest
, MAX_PATH
);
3857 if (szDest
[1] != ':')
3859 FIXME("non-drive system paths unsupported\n");
3864 strcpyW(szDest
+ 3, szTemp
+ strlenW(SystemDriveW
) + 1);
3870 DWORD ret
= ExpandEnvironmentStringsW(szSrc
, szDest
, MAX_PATH
);
3873 hr
= E_NOT_SUFFICIENT_BUFFER
;
3875 hr
= HRESULT_FROM_WIN32(GetLastError());
3879 if (SUCCEEDED(hr
) && szDest
[0] == '%')
3880 strcpyW(szTemp
, szDest
);
3883 /* terminate loop */
3890 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr
,
3891 debugstr_w(szSrc
), debugstr_w(szDest
));
3895 /*************************************************************************
3896 * SHGetFolderPathW [SHELL32.@]
3898 * Convert nFolder to path.
3902 * Failure: standard HRESULT error codes.
3905 * Most values can be overridden in either
3906 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3907 * or in the same location in HKLM.
3908 * The "Shell Folders" registry key was used in NT4 and earlier systems.
3909 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
3910 * changes made to it are made to the former key too. This synchronization is
3911 * done on-demand: not until someone requests the value of one of these paths
3912 * (by calling one of the SHGet functions) is the value synchronized.
3913 * Furthermore, the HKCU paths take precedence over the HKLM paths.
3915 HRESULT WINAPI
SHGetFolderPathW(
3916 HWND hwndOwner
, /* [I] owner window */
3917 int nFolder
, /* [I] CSIDL identifying the folder */
3918 HANDLE hToken
, /* [I] access token */
3919 DWORD dwFlags
, /* [I] which path to return */
3920 LPWSTR pszPath
) /* [O] converted path */
3922 HRESULT hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, NULL
, pszPath
);
3923 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) == hr
)
3924 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
3928 HRESULT WINAPI
SHGetFolderPathAndSubDirA(
3929 HWND hwndOwner
, /* [I] owner window */
3930 int nFolder
, /* [I] CSIDL identifying the folder */
3931 HANDLE hToken
, /* [I] access token */
3932 DWORD dwFlags
, /* [I] which path to return */
3933 LPCSTR pszSubPath
, /* [I] sub directory of the specified folder */
3934 LPSTR pszPath
) /* [O] converted path */
3938 LPWSTR pszSubPathW
= NULL
;
3939 LPWSTR pszPathW
= NULL
;
3941 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, debugstr_a(pszSubPath
), pszPath
);
3944 pszPathW
= heap_alloc(MAX_PATH
* sizeof(WCHAR
));
3946 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
3950 TRACE("%08x,%08x,%s\n",nFolder
, dwFlags
, debugstr_w(pszSubPathW
));
3952 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
3953 * set (null), or an empty string.therefore call it without the parameter set
3954 * if pszSubPath is an empty string
3956 if (pszSubPath
&& pszSubPath
[0]) {
3957 length
= MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, NULL
, 0);
3958 pszSubPathW
= heap_alloc(length
* sizeof(WCHAR
));
3960 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
3963 MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, pszSubPathW
, length
);
3966 hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, pszSubPathW
, pszPathW
);
3968 if (SUCCEEDED(hr
) && pszPath
)
3969 WideCharToMultiByte(CP_ACP
, 0, pszPathW
, -1, pszPath
, MAX_PATH
, NULL
, NULL
);
3972 heap_free(pszPathW
);
3973 heap_free(pszSubPathW
);
3977 /*************************************************************************
3978 * SHGetFolderPathAndSubDirW [SHELL32.@]
3980 HRESULT WINAPI
SHGetFolderPathAndSubDirW(
3981 HWND hwndOwner
, /* [I] owner window */
3982 int nFolder
, /* [I] CSIDL identifying the folder */
3983 HANDLE hToken
, /* [I] access token */
3984 DWORD dwFlags
, /* [I] which path to return */
3985 LPCWSTR pszSubPath
,/* [I] sub directory of the specified folder */
3986 LPWSTR pszPath
) /* [O] converted path */
3989 WCHAR szBuildPath
[MAX_PATH
], szTemp
[MAX_PATH
];
3990 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
3994 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, debugstr_w(pszSubPath
), pszPath
);
3996 /* Windows always NULL-terminates the resulting path regardless of success
3997 * or failure, so do so first
4002 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
4003 return E_INVALIDARG
;
4004 if ((SHGFP_TYPE_CURRENT
!= dwFlags
) && (SHGFP_TYPE_DEFAULT
!= dwFlags
))
4005 return E_INVALIDARG
;
4007 type
= CSIDL_Data
[folder
].type
;
4010 case CSIDL_Type_Disallowed
:
4013 case CSIDL_Type_NonExistent
:
4016 case CSIDL_Type_WindowsPath
:
4017 GetWindowsDirectoryW(szTemp
, MAX_PATH
);
4018 if (CSIDL_Data
[folder
].szDefaultPath
&&
4019 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4020 *CSIDL_Data
[folder
].szDefaultPath
)
4022 PathAddBackslashW(szTemp
);
4023 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4027 case CSIDL_Type_SystemPath
:
4028 GetSystemDirectoryW(szTemp
, MAX_PATH
);
4029 if (CSIDL_Data
[folder
].szDefaultPath
&&
4030 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4031 *CSIDL_Data
[folder
].szDefaultPath
)
4033 PathAddBackslashW(szTemp
);
4034 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4038 case CSIDL_Type_SystemX86Path
:
4039 if (!GetSystemWow64DirectoryW(szTemp
, MAX_PATH
)) GetSystemDirectoryW(szTemp
, MAX_PATH
);
4040 if (CSIDL_Data
[folder
].szDefaultPath
&&
4041 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4042 *CSIDL_Data
[folder
].szDefaultPath
)
4044 PathAddBackslashW(szTemp
);
4045 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4049 case CSIDL_Type_CurrVer
:
4050 hr
= _SHGetCurrentVersionPath(dwFlags
, folder
, szTemp
);
4052 case CSIDL_Type_User
:
4053 hr
= _SHGetUserProfilePath(hToken
, dwFlags
, folder
, szTemp
);
4055 case CSIDL_Type_AllUsers
:
4056 case CSIDL_Type_ProgramData
:
4057 hr
= _SHGetAllUsersProfilePath(dwFlags
, folder
, szTemp
);
4060 FIXME("bogus type %d, please fix\n", type
);
4065 /* Expand environment strings if necessary */
4067 hr
= _SHExpandEnvironmentStrings(szTemp
, szBuildPath
);
4069 strcpyW(szBuildPath
, szTemp
);
4071 if (FAILED(hr
)) goto end
;
4074 /* make sure the new path does not exceed the buffer length
4075 * and remember to backslash and terminate it */
4076 if(MAX_PATH
< (lstrlenW(szBuildPath
) + lstrlenW(pszSubPath
) + 2)) {
4077 hr
= HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE
);
4080 PathAppendW(szBuildPath
, pszSubPath
);
4081 PathRemoveBackslashW(szBuildPath
);
4083 /* Copy the path if it's available before we might return */
4084 if (SUCCEEDED(hr
) && pszPath
)
4085 strcpyW(pszPath
, szBuildPath
);
4087 /* if we don't care about existing directories we are ready */
4088 if(nFolder
& CSIDL_FLAG_DONT_VERIFY
) goto end
;
4090 if (PathFileExistsW(szBuildPath
)) goto end
;
4092 /* not existing but we are not allowed to create it. The return value
4093 * is verified against shell32 version 6.0.
4095 if (!(nFolder
& CSIDL_FLAG_CREATE
))
4097 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4101 /* create directory/directories */
4102 ret
= SHCreateDirectoryExW(hwndOwner
, szBuildPath
, NULL
);
4103 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4105 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath
));
4110 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath
));
4112 TRACE("returning 0x%08x (final path is %s)\n", hr
, debugstr_w(szBuildPath
));
4116 /*************************************************************************
4117 * SHGetFolderPathA [SHELL32.@]
4119 * See SHGetFolderPathW.
4121 HRESULT WINAPI
SHGetFolderPathA(
4128 WCHAR szTemp
[MAX_PATH
];
4131 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, pszPath
);
4135 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
, dwFlags
, szTemp
);
4136 if (SUCCEEDED(hr
) && pszPath
)
4137 WideCharToMultiByte(CP_ACP
, 0, szTemp
, -1, pszPath
, MAX_PATH
, NULL
,
4143 /* For each folder in folders, if its value has not been set in the registry,
4144 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4145 * folder's type) to get the unexpanded value first.
4146 * Writes the unexpanded value to User Shell Folders, and queries it with
4147 * SHGetFolderPathW to force the creation of the directory if it doesn't
4148 * already exist. SHGetFolderPathW also returns the expanded value, which
4149 * this then writes to Shell Folders.
4151 static HRESULT
_SHRegisterFolders(HKEY hRootKey
, HANDLE hToken
,
4152 LPCWSTR szUserShellFolderPath
, LPCWSTR szShellFolderPath
, const UINT folders
[],
4155 const WCHAR
*szValueName
;
4158 WCHAR path
[MAX_PATH
];
4160 HKEY hUserKey
= NULL
, hKey
= NULL
;
4161 DWORD dwType
, dwPathLen
;
4164 TRACE("%p,%p,%s,%p,%u\n", hRootKey
, hToken
,
4165 debugstr_w(szUserShellFolderPath
), folders
, foldersLen
);
4167 ret
= RegCreateKeyW(hRootKey
, szUserShellFolderPath
, &hUserKey
);
4169 hr
= HRESULT_FROM_WIN32(ret
);
4172 ret
= RegCreateKeyW(hRootKey
, szShellFolderPath
, &hKey
);
4174 hr
= HRESULT_FROM_WIN32(ret
);
4176 for (i
= 0; SUCCEEDED(hr
) && i
< foldersLen
; i
++)
4178 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
4180 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4181 szValueName
= CSIDL_Data
[folders
[i
]].szValueName
;
4182 if (!szValueName
&& CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4184 StringFromGUID2( CSIDL_Data
[folders
[i
]].id
, buffer
, 39 );
4185 szValueName
= &buffer
[0];
4188 if (RegQueryValueExW(hUserKey
, szValueName
, NULL
,
4189 &dwType
, (LPBYTE
)path
, &dwPathLen
) || (dwType
!= REG_SZ
&&
4190 dwType
!= REG_EXPAND_SZ
))
4193 if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4194 _SHGetUserProfilePath(hToken
, SHGFP_TYPE_DEFAULT
, folders
[i
],
4196 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_AllUsers
||
4197 CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_ProgramData
)
4198 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT
, folders
[i
], path
);
4199 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_WindowsPath
)
4201 GetWindowsDirectoryW(path
, MAX_PATH
);
4202 if (CSIDL_Data
[folders
[i
]].szDefaultPath
&&
4203 !IS_INTRESOURCE(CSIDL_Data
[folders
[i
]].szDefaultPath
))
4205 PathAddBackslashW(path
);
4206 strcatW(path
, CSIDL_Data
[folders
[i
]].szDefaultPath
);
4213 ret
= RegSetValueExW(hUserKey
, szValueName
, 0, REG_EXPAND_SZ
,
4214 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4216 hr
= HRESULT_FROM_WIN32(ret
);
4219 hr
= SHGetFolderPathW(NULL
, folders
[i
] | CSIDL_FLAG_CREATE
,
4220 hToken
, SHGFP_TYPE_DEFAULT
, path
);
4221 ret
= RegSetValueExW(hKey
, szValueName
, 0, REG_SZ
,
4222 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4224 hr
= HRESULT_FROM_WIN32(ret
);
4230 RegCloseKey(hUserKey
);
4234 TRACE("returning 0x%08x\n", hr
);
4238 static HRESULT
_SHRegisterUserShellFolders(BOOL bDefault
)
4240 static const UINT folders
[] = {
4251 CSIDL_DESKTOPDIRECTORY
,
4255 CSIDL_LOCAL_APPDATA
,
4256 CSIDL_INTERNET_CACHE
,
4265 CSIDL_APPDATA_LOCALLOW
,
4269 WCHAR userShellFolderPath
[MAX_PATH
], shellFolderPath
[MAX_PATH
];
4270 LPCWSTR pUserShellFolderPath
, pShellFolderPath
;
4275 TRACE("%s\n", bDefault
? "TRUE" : "FALSE");
4278 hToken
= (HANDLE
)-1;
4279 hRootKey
= HKEY_USERS
;
4280 strcpyW(userShellFolderPath
, DefaultW
);
4281 PathAddBackslashW(userShellFolderPath
);
4282 strcatW(userShellFolderPath
, szSHUserFolders
);
4283 pUserShellFolderPath
= userShellFolderPath
;
4284 strcpyW(shellFolderPath
, DefaultW
);
4285 PathAddBackslashW(shellFolderPath
);
4286 strcatW(shellFolderPath
, szSHFolders
);
4287 pShellFolderPath
= shellFolderPath
;
4292 hRootKey
= HKEY_CURRENT_USER
;
4293 pUserShellFolderPath
= szSHUserFolders
;
4294 pShellFolderPath
= szSHFolders
;
4297 hr
= _SHRegisterFolders(hRootKey
, hToken
, pUserShellFolderPath
,
4298 pShellFolderPath
, folders
, ARRAY_SIZE(folders
));
4299 TRACE("returning 0x%08x\n", hr
);
4303 static HRESULT
_SHRegisterCommonShellFolders(void)
4305 static const UINT folders
[] = {
4306 CSIDL_COMMON_STARTMENU
,
4307 CSIDL_COMMON_PROGRAMS
,
4308 CSIDL_COMMON_STARTUP
,
4309 CSIDL_COMMON_DESKTOPDIRECTORY
,
4310 CSIDL_COMMON_FAVORITES
,
4311 CSIDL_COMMON_APPDATA
,
4312 CSIDL_COMMON_TEMPLATES
,
4313 CSIDL_COMMON_DOCUMENTS
,
4314 CSIDL_COMMON_ADMINTOOLS
,
4316 CSIDL_COMMON_PICTURES
,
4322 hr
= _SHRegisterFolders(HKEY_LOCAL_MACHINE
, NULL
, szSHUserFolders
,
4323 szSHFolders
, folders
, ARRAY_SIZE(folders
));
4324 TRACE("returning 0x%08x\n", hr
);
4328 /******************************************************************************
4329 * _SHAppendToUnixPath [Internal]
4331 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
4332 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
4333 * and replaces backslashes with slashes.
4336 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
4337 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
4343 static inline BOOL
_SHAppendToUnixPath(char *szBasePath
, LPCWSTR pwszSubPath
) {
4344 WCHAR wszSubPath
[MAX_PATH
];
4345 int cLen
= strlen(szBasePath
);
4348 if (IS_INTRESOURCE(pwszSubPath
)) {
4349 if (!LoadStringW(shell32_hInstance
, LOWORD(pwszSubPath
), wszSubPath
, MAX_PATH
)) {
4350 /* Fall back to hard coded defaults. */
4351 switch (LOWORD(pwszSubPath
)) {
4353 lstrcpyW(wszSubPath
, DocumentsW
);
4356 lstrcpyW(wszSubPath
, My_MusicW
);
4358 case IDS_MYPICTURES
:
4359 lstrcpyW(wszSubPath
, My_PicturesW
);
4362 lstrcpyW(wszSubPath
, My_VideosW
);
4365 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath
));
4370 lstrcpyW(wszSubPath
, pwszSubPath
);
4373 if (szBasePath
[cLen
-1] != '/') szBasePath
[cLen
++] = '/';
4375 if (!WideCharToMultiByte(CP_UNIXCP
, 0, wszSubPath
, -1, szBasePath
+ cLen
,
4376 FILENAME_MAX
- cLen
, NULL
, NULL
))
4381 pBackslash
= szBasePath
+ cLen
;
4382 while ((pBackslash
= strchr(pBackslash
, '\\'))) *pBackslash
= '/';
4387 /******************************************************************************
4388 * _SHCreateSymbolicLinks [Internal]
4390 * Sets up symbol links for various shell folders to point into the users home
4391 * directory. We do an educated guess about what the user would probably want:
4392 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4393 * wine's 'My Documents' to point there. Furthermore, we imply that the user
4394 * is a Windows lover and has no problem with wine creating 'My Pictures',
4395 * 'My Music' and 'My Videos' subfolders under '$HOME/My Documents', if those
4396 * do not already exits. We put appropriate symbolic links in place for those,
4398 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4399 * point directly to $HOME. We assume the user to be a unix hacker who does not
4400 * want wine to create anything anywhere besides the .wine directory. So, if
4401 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4402 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4403 * directory, and try to link to that. If that fails, then we symlink to
4404 * $HOME directly. The same holds fo 'My Pictures' and 'My Videos'.
4405 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4406 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4408 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4410 static void _SHCreateSymbolicLinks(void)
4412 UINT aidsMyStuff
[] = { IDS_MYPICTURES
, IDS_MYVIDEOS
, IDS_MYMUSIC
}, i
;
4413 const WCHAR
* MyOSXStuffW
[] = { PicturesW
, MoviesW
, MusicW
};
4414 int acsidlMyStuff
[] = { CSIDL_MYPICTURES
, CSIDL_MYVIDEO
, CSIDL_MYMUSIC
};
4415 static const char * const xdg_dirs
[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" };
4416 static const unsigned int num
= ARRAY_SIZE(xdg_dirs
);
4417 WCHAR wszTempPath
[MAX_PATH
];
4418 char szPersonalTarget
[FILENAME_MAX
], *pszPersonal
;
4419 char szMyStuffTarget
[FILENAME_MAX
], *pszMyStuff
;
4420 char szDesktopTarget
[FILENAME_MAX
], *pszDesktop
;
4421 struct stat statFolder
;
4422 const char *pszHome
;
4424 char ** xdg_results
;
4425 char * xdg_desktop_dir
;
4427 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4428 hr
= SHGetFolderPathW(NULL
, CSIDL_PERSONAL
|CSIDL_FLAG_CREATE
, NULL
,
4429 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4430 if (FAILED(hr
)) return;
4431 pszPersonal
= wine_get_unix_file_name(wszTempPath
);
4432 if (!pszPersonal
) return;
4434 hr
= XDG_UserDirLookup(xdg_dirs
, num
, &xdg_results
);
4435 if (FAILED(hr
)) xdg_results
= NULL
;
4437 pszHome
= getenv("HOME");
4438 if (pszHome
&& !stat(pszHome
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4442 /* Check if there's already a Wine-specific 'My Documents' folder */
4443 strcpy(szPersonalTarget
, pszHome
);
4444 if (_SHAppendToUnixPath(szPersonalTarget
, MAKEINTRESOURCEW(IDS_PERSONAL
)) &&
4445 !stat(szPersonalTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4447 /* '$HOME/My Documents' exists. Create 'My Pictures',
4448 * 'My Videos' and 'My Music' subfolders or fail silently if
4449 * they already exist.
4451 for (i
= 0; i
< ARRAY_SIZE(aidsMyStuff
); i
++)
4453 strcpy(szMyStuffTarget
, szPersonalTarget
);
4454 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4455 mkdir(szMyStuffTarget
, 0777);
4460 /* Try to point to the XDG Documents folder */
4461 if (xdg_results
&& xdg_results
[num
-2] &&
4462 !stat(xdg_results
[num
-2], &statFolder
) &&
4463 S_ISDIR(statFolder
.st_mode
))
4465 strcpy(szPersonalTarget
, xdg_results
[num
-2]);
4469 /* Or the hardcoded / OS X Documents folder */
4470 strcpy(szPersonalTarget
, pszHome
);
4471 if (_SHAppendToUnixPath(szPersonalTarget
, DocumentsW
) &&
4472 !stat(szPersonalTarget
, &statFolder
) &&
4473 S_ISDIR(statFolder
.st_mode
))
4476 /* As a last resort point to $HOME. */
4477 strcpy(szPersonalTarget
, pszHome
);
4481 /* Replace 'My Documents' directory with a symlink or fail silently if not empty. */
4482 remove(pszPersonal
);
4483 symlink(szPersonalTarget
, pszPersonal
);
4487 /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs
4488 * in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */
4490 strcpy(szPersonalTarget
, pszPersonal
);
4491 for (i
= 0; i
< ARRAY_SIZE(aidsMyStuff
); i
++) {
4492 strcpy(szMyStuffTarget
, szPersonalTarget
);
4493 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4494 mkdir(szMyStuffTarget
, 0777);
4498 /* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
4499 for (i
=0; i
< ARRAY_SIZE(aidsMyStuff
); i
++)
4501 /* Create the current 'My Whatever' folder and get its unix path. */
4502 hr
= SHGetFolderPathW(NULL
, acsidlMyStuff
[i
]|CSIDL_FLAG_CREATE
, NULL
,
4503 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4504 if (FAILED(hr
)) continue;
4506 pszMyStuff
= wine_get_unix_file_name(wszTempPath
);
4507 if (!pszMyStuff
) continue;
4511 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4512 strcpy(szMyStuffTarget
, szPersonalTarget
);
4513 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])) &&
4514 !stat(szMyStuffTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4517 /* Try the XDG_XXX_DIR folder */
4518 if (xdg_results
&& xdg_results
[i
])
4520 strcpy(szMyStuffTarget
, xdg_results
[i
]);
4524 /* Or the OS X folder (these are never localized) */
4527 strcpy(szMyStuffTarget
, pszHome
);
4528 if (_SHAppendToUnixPath(szMyStuffTarget
, MyOSXStuffW
[i
]) &&
4529 !stat(szMyStuffTarget
, &statFolder
) &&
4530 S_ISDIR(statFolder
.st_mode
))
4534 /* As a last resort point to the same location as 'My Documents' */
4535 strcpy(szMyStuffTarget
, szPersonalTarget
);
4539 symlink(szMyStuffTarget
, pszMyStuff
);
4540 heap_free(pszMyStuff
);
4543 /* Last but not least, the Desktop folder */
4545 strcpy(szDesktopTarget
, pszHome
);
4547 strcpy(szDesktopTarget
, pszPersonal
);
4548 heap_free(pszPersonal
);
4550 xdg_desktop_dir
= xdg_results
? xdg_results
[num
- 1] : NULL
;
4551 if (xdg_desktop_dir
||
4552 (_SHAppendToUnixPath(szDesktopTarget
, DesktopW
) &&
4553 !stat(szDesktopTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
)))
4555 hr
= SHGetFolderPathW(NULL
, CSIDL_DESKTOPDIRECTORY
|CSIDL_FLAG_CREATE
, NULL
,
4556 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4557 if (SUCCEEDED(hr
) && (pszDesktop
= wine_get_unix_file_name(wszTempPath
)))
4560 if (xdg_desktop_dir
)
4561 symlink(xdg_desktop_dir
, pszDesktop
);
4563 symlink(szDesktopTarget
, pszDesktop
);
4564 heap_free(pszDesktop
);
4568 /* Free resources allocated by XDG_UserDirLookup() */
4571 for (i
= 0; i
< num
; i
++)
4572 heap_free(xdg_results
[i
]);
4573 heap_free(xdg_results
);
4577 /******************************************************************************
4578 * create_extra_folders [Internal]
4580 * Create some extra folders that don't have a standard CSIDL definition.
4582 static HRESULT
create_extra_folders(void)
4584 static const WCHAR environW
[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4585 static const WCHAR microsoftW
[] = {'M','i','c','r','o','s','o','f','t',0};
4586 static const WCHAR TempW
[] = {'T','e','m','p',0};
4587 static const WCHAR TEMPW
[] = {'T','E','M','P',0};
4588 static const WCHAR TMPW
[] = {'T','M','P',0};
4589 WCHAR path
[MAX_PATH
+5];
4592 DWORD type
, size
, ret
;
4594 ret
= RegCreateKeyW( HKEY_CURRENT_USER
, environW
, &hkey
);
4595 if (ret
) return HRESULT_FROM_WIN32( ret
);
4597 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4598 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE
| CSIDL_FLAG_CREATE
, NULL
,
4599 SHGFP_TYPE_DEFAULT
, TempW
, path
);
4602 size
= sizeof(path
);
4603 if (RegQueryValueExW( hkey
, TEMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4604 RegSetValueExW( hkey
, TEMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4605 size
= sizeof(path
);
4606 if (RegQueryValueExW( hkey
, TMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4607 RegSetValueExW( hkey
, TMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4609 RegCloseKey( hkey
);
4613 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4614 SHGFP_TYPE_DEFAULT
, microsoftW
, path
);
4618 hr
= SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4619 SHGFP_TYPE_DEFAULT
, Microsoft_Windows_ThemesW
, path
);
4625 /******************************************************************************
4626 * set_folder_attributes
4628 * Set the various folder attributes registry keys.
4630 static HRESULT
set_folder_attributes(void)
4632 static const WCHAR clsidW
[] = {'C','L','S','I','D','\\',0 };
4633 static const WCHAR shellfolderW
[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4634 static const WCHAR wfparsingW
[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4635 static const WCHAR wfdisplayW
[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4636 static const WCHAR hideasdeleteW
[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4637 static const WCHAR cfattributesW
[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4638 static const WCHAR emptyW
[] = {0};
4647 DWORD call_for_attr
;
4650 { &CLSID_UnixFolder
, TRUE
, FALSE
, FALSE
},
4651 { &CLSID_UnixDosFolder
, TRUE
, FALSE
, FALSE
,
4652 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4653 { &CLSID_FolderShortcut
, FALSE
, FALSE
, FALSE
,
4654 SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_LINK
,
4655 SFGAO_HASSUBFOLDER
|SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_FILESYSANCESTOR
},
4656 { &CLSID_MyDocuments
, TRUE
, FALSE
, FALSE
,
4657 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4658 { &CLSID_RecycleBin
, FALSE
, FALSE
, FALSE
,
4659 SFGAO_FOLDER
|SFGAO_DROPTARGET
|SFGAO_HASPROPSHEET
},
4660 { &CLSID_ControlPanel
, FALSE
, TRUE
, TRUE
,
4661 SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
}
4665 WCHAR buffer
[39 + ARRAY_SIZE(clsidW
) + ARRAY_SIZE(shellfolderW
)];
4669 for (i
= 0; i
< ARRAY_SIZE(folders
); i
++)
4671 strcpyW( buffer
, clsidW
);
4672 StringFromGUID2( folders
[i
].clsid
, buffer
+ strlenW(buffer
), 39 );
4673 strcatW( buffer
, shellfolderW
);
4674 res
= RegCreateKeyExW( HKEY_CLASSES_ROOT
, buffer
, 0, NULL
, 0,
4675 KEY_READ
| KEY_WRITE
, NULL
, &hkey
, NULL
);
4676 if (res
) return HRESULT_FROM_WIN32( res
);
4677 if (folders
[i
].wfparsing
)
4678 res
= RegSetValueExW( hkey
, wfparsingW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4679 if (folders
[i
].wfdisplay
)
4680 res
= RegSetValueExW( hkey
, wfdisplayW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4681 if (folders
[i
].hideasdel
)
4682 res
= RegSetValueExW( hkey
, hideasdeleteW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4683 if (folders
[i
].attr
)
4684 res
= RegSetValueExW( hkey
, szAttributes
, 0, REG_DWORD
,
4685 (const BYTE
*)&folders
[i
].attr
, sizeof(DWORD
));
4686 if (folders
[i
].call_for_attr
)
4687 res
= RegSetValueExW( hkey
, cfattributesW
, 0, REG_DWORD
,
4688 (const BYTE
*)&folders
[i
].call_for_attr
, sizeof(DWORD
));
4689 RegCloseKey( hkey
);
4694 /*************************************************************************
4695 * SHGetSpecialFolderPathA [SHELL32.@]
4697 BOOL WINAPI
SHGetSpecialFolderPathA (
4703 return SHGetFolderPathA(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4707 /*************************************************************************
4708 * SHGetSpecialFolderPathW
4710 BOOL WINAPI
SHGetSpecialFolderPathW (
4716 return SHGetFolderPathW(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4720 /*************************************************************************
4721 * SHGetSpecialFolderPath (SHELL32.175)
4723 BOOL WINAPI
SHGetSpecialFolderPathAW (
4730 if (SHELL_OsIsUnicode())
4731 return SHGetSpecialFolderPathW (hwndOwner
, szPath
, nFolder
, bCreate
);
4732 return SHGetSpecialFolderPathA (hwndOwner
, szPath
, nFolder
, bCreate
);
4735 /*************************************************************************
4736 * SHGetFolderLocation [SHELL32.@]
4738 * Gets the folder locations from the registry and creates a pidl.
4742 * nFolder [I] CSIDL_xxxxx
4743 * hToken [I] token representing user, or NULL for current user, or -1 for
4745 * dwReserved [I] must be zero
4746 * ppidl [O] PIDL of a special folder
4750 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
4753 * Creates missing reg keys and directories.
4754 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
4755 * virtual folders that are handled here.
4757 HRESULT WINAPI
SHGetFolderLocation(
4762 LPITEMIDLIST
*ppidl
)
4764 HRESULT hr
= E_INVALIDARG
;
4766 TRACE("%p 0x%08x %p 0x%08x %p\n",
4767 hwndOwner
, nFolder
, hToken
, dwReserved
, ppidl
);
4770 return E_INVALIDARG
;
4772 return E_INVALIDARG
;
4774 /* The virtual folders' locations are not user-dependent */
4776 switch (nFolder
& CSIDL_FOLDER_MASK
)
4779 *ppidl
= _ILCreateDesktop();
4782 case CSIDL_PERSONAL
:
4783 *ppidl
= _ILCreateMyDocuments();
4786 case CSIDL_INTERNET
:
4787 *ppidl
= _ILCreateIExplore();
4790 case CSIDL_CONTROLS
:
4791 *ppidl
= _ILCreateControlPanel();
4794 case CSIDL_PRINTERS
:
4795 *ppidl
= _ILCreatePrinters();
4798 case CSIDL_BITBUCKET
:
4799 *ppidl
= _ILCreateBitBucket();
4803 *ppidl
= _ILCreateMyComputer();
4807 *ppidl
= _ILCreateNetwork();
4812 WCHAR szPath
[MAX_PATH
];
4814 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
,
4815 SHGFP_TYPE_CURRENT
, szPath
);
4820 TRACE("Value=%s\n", debugstr_w(szPath
));
4821 hr
= SHILCreateFromPathW(szPath
, ppidl
, &attributes
);
4823 else if (hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
))
4825 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
4826 * version 6.0 returns E_FAIL for nonexistent paths
4835 TRACE("-- (new pidl %p)\n",*ppidl
);
4839 /*************************************************************************
4840 * SHGetSpecialFolderLocation [SHELL32.@]
4843 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
4846 HRESULT WINAPI
SHGetSpecialFolderLocation(
4849 LPITEMIDLIST
* ppidl
)
4851 HRESULT hr
= E_INVALIDARG
;
4853 TRACE("(%p,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
4856 return E_INVALIDARG
;
4858 hr
= SHGetFolderLocation(hwndOwner
, nFolder
, NULL
, 0, ppidl
);
4862 static int csidl_from_id( const KNOWNFOLDERID
*id
)
4865 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
4866 if (IsEqualGUID( CSIDL_Data
[i
].id
, id
)) return i
;
4870 /*************************************************************************
4871 * SHGetKnownFolderPath [SHELL32.@]
4873 HRESULT WINAPI
SHGetKnownFolderPath(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, WCHAR
**ret_path
)
4875 WCHAR pathW
[MAX_PATH
], tempW
[MAX_PATH
];
4879 int folder
= csidl_from_id(rfid
), shgfp_flags
;
4881 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, ret_path
);
4886 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
4888 if (flags
& ~(KF_FLAG_CREATE
|KF_FLAG_SIMPLE_IDLIST
|KF_FLAG_DONT_UNEXPAND
|
4889 KF_FLAG_DONT_VERIFY
|KF_FLAG_NO_ALIAS
|KF_FLAG_INIT
|KF_FLAG_DEFAULT_PATH
))
4891 FIXME("flags 0x%08x not supported\n", flags
);
4892 return E_INVALIDARG
;
4895 shgfp_flags
= flags
& KF_FLAG_DEFAULT_PATH
? SHGFP_TYPE_DEFAULT
: SHGFP_TYPE_CURRENT
;
4897 type
= CSIDL_Data
[folder
].type
;
4900 case CSIDL_Type_Disallowed
:
4903 case CSIDL_Type_NonExistent
:
4907 case CSIDL_Type_WindowsPath
:
4908 GetWindowsDirectoryW(tempW
, MAX_PATH
);
4909 if (CSIDL_Data
[folder
].szDefaultPath
&&
4910 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4911 *CSIDL_Data
[folder
].szDefaultPath
)
4913 PathAddBackslashW(tempW
);
4914 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4918 case CSIDL_Type_SystemPath
:
4919 GetSystemDirectoryW(tempW
, MAX_PATH
);
4920 if (CSIDL_Data
[folder
].szDefaultPath
&&
4921 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4922 *CSIDL_Data
[folder
].szDefaultPath
)
4924 PathAddBackslashW(tempW
);
4925 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4929 case CSIDL_Type_SystemX86Path
:
4930 if (!GetSystemWow64DirectoryW(tempW
, MAX_PATH
)) GetSystemDirectoryW(tempW
, MAX_PATH
);
4931 if (CSIDL_Data
[folder
].szDefaultPath
&&
4932 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4933 *CSIDL_Data
[folder
].szDefaultPath
)
4935 PathAddBackslashW(tempW
);
4936 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4940 case CSIDL_Type_CurrVer
:
4941 hr
= _SHGetCurrentVersionPath(shgfp_flags
, folder
, tempW
);
4943 case CSIDL_Type_User
:
4944 hr
= _SHGetUserProfilePath(token
, shgfp_flags
, folder
, tempW
);
4946 case CSIDL_Type_AllUsers
:
4947 case CSIDL_Type_ProgramData
:
4948 hr
= _SHGetAllUsersProfilePath(shgfp_flags
, folder
, tempW
);
4951 FIXME("bogus type %d, please fix\n", type
);
4959 /* Expand environment strings if necessary */
4962 hr
= _SHExpandEnvironmentStrings(tempW
, pathW
);
4967 strcpyW(pathW
, tempW
);
4969 /* if we don't care about existing directories we are ready */
4970 if (flags
& KF_FLAG_DONT_VERIFY
) goto done
;
4972 if (PathFileExistsW(pathW
)) goto done
;
4974 /* Does not exist but we are not allowed to create it. The return value
4975 * is verified against shell32 version 6.0.
4977 if (!(flags
& KF_FLAG_CREATE
))
4979 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4983 /* create directory/directories */
4984 ret
= SHCreateDirectoryExW(NULL
, pathW
, NULL
);
4985 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4987 ERR("Failed to create directory %s.\n", debugstr_w(pathW
));
4992 TRACE("Created missing system directory %s\n", debugstr_w(pathW
));
4995 TRACE("Final path is %s, %#x\n", debugstr_w(pathW
), hr
);
4997 *ret_path
= CoTaskMemAlloc((strlenW(pathW
) + 1) * sizeof(WCHAR
));
4999 return E_OUTOFMEMORY
;
5000 strcpyW(*ret_path
, pathW
);
5005 TRACE("Failed to get folder path, %#x.\n", hr
);
5010 /*************************************************************************
5011 * SHGetFolderPathEx [SHELL32.@]
5013 HRESULT WINAPI
SHGetFolderPathEx(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, LPWSTR path
, DWORD len
)
5018 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid
), flags
, token
, path
, len
);
5020 if (!path
|| !len
) return E_INVALIDARG
;
5022 hr
= SHGetKnownFolderPath( rfid
, flags
, token
, &buffer
);
5023 if (SUCCEEDED( hr
))
5025 if (strlenW( buffer
) + 1 > len
)
5027 CoTaskMemFree( buffer
);
5028 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER
);
5030 strcpyW( path
, buffer
);
5031 CoTaskMemFree( buffer
);
5037 * Internal function to convert known folder identifier to path of registry key
5038 * associated with known folder.
5041 * rfid [I] pointer to known folder identifier (may be NULL)
5042 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
5043 * lpPath [O] place to store string address. String should be
5044 * later freed using HeapFree(GetProcessHeap(),0, ... )
5046 static HRESULT
get_known_folder_registry_path(
5047 REFKNOWNFOLDERID rfid
,
5048 LPWSTR lpStringGuid
,
5051 static const WCHAR sBackslash
[] = {'\\',0};
5056 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid
), debugstr_w(lpStringGuid
), lpPath
);
5059 StringFromGUID2(rfid
, sGuid
, ARRAY_SIZE(sGuid
));
5061 lstrcpyW(sGuid
, lpStringGuid
);
5063 length
= lstrlenW(szKnownFolderDescriptions
)+51;
5064 *lpPath
= heap_alloc(length
*sizeof(WCHAR
));
5070 lstrcpyW(*lpPath
, szKnownFolderDescriptions
);
5071 lstrcatW(*lpPath
, sBackslash
);
5072 lstrcatW(*lpPath
, sGuid
);
5078 static HRESULT
get_known_folder_wstr(const WCHAR
*regpath
, const WCHAR
*value
, WCHAR
**out
)
5084 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
));
5088 *out
= CoTaskMemAlloc(size
);
5090 return E_OUTOFMEMORY
;
5092 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, *out
, &size
));
5094 CoTaskMemFree(*out
);
5101 static HRESULT
get_known_folder_dword(const WCHAR
*registryPath
, const WCHAR
*value
, DWORD
*out
)
5103 DWORD dwSize
= sizeof(DWORD
);
5105 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, value
, RRF_RT_DWORD
, &dwType
, out
, &dwSize
));
5109 * Internal function to get place where folder redirection information are stored.
5112 * rfid [I] pointer to known folder identifier (may be NULL)
5113 * rootKey [O] root key where the redirection information are stored
5114 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5115 * However, besides root key, path is always that same, and is stored
5116 * as "szKnownFolderRedirections" constant
5118 static HRESULT
get_known_folder_redirection_place(
5119 REFKNOWNFOLDERID rfid
,
5123 LPWSTR lpRegistryPath
= NULL
;
5124 KF_CATEGORY category
;
5126 /* first, get known folder's category */
5127 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5130 hr
= get_known_folder_dword(lpRegistryPath
, szCategory
, &category
);
5134 if(category
== KF_CATEGORY_COMMON
)
5136 *rootKey
= HKEY_LOCAL_MACHINE
;
5139 else if(category
== KF_CATEGORY_PERUSER
)
5141 *rootKey
= HKEY_CURRENT_USER
;
5148 heap_free(lpRegistryPath
);
5152 static HRESULT
get_known_folder_path_by_id(REFKNOWNFOLDERID folderId
, LPWSTR lpRegistryPath
, DWORD dwFlags
, LPWSTR
*ppszPath
);
5154 static HRESULT
redirect_known_folder(
5155 REFKNOWNFOLDERID rfid
,
5157 KF_REDIRECT_FLAGS flags
,
5158 LPCWSTR pszTargetPath
,
5160 KNOWNFOLDERID
const *pExclusion
,
5164 HKEY rootKey
= HKEY_LOCAL_MACHINE
, hKey
;
5166 LPWSTR lpRegistryPath
= NULL
, lpSrcPath
= NULL
;
5167 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid
), hwnd
, flags
, debugstr_w(pszTargetPath
), cFolders
, pExclusion
, ppszError
);
5169 if (ppszError
) *ppszError
= NULL
;
5171 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5174 hr
= get_known_folder_path_by_id(rfid
, lpRegistryPath
, 0, &lpSrcPath
);
5176 heap_free(lpRegistryPath
);
5178 /* get path to redirection storage */
5180 hr
= get_known_folder_redirection_place(rfid
, &rootKey
);
5182 /* write redirection information */
5184 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey
, szKnownFolderRedirections
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
));
5188 StringFromGUID2(rfid
, sGuid
, ARRAY_SIZE(sGuid
));
5190 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, sGuid
, 0, REG_SZ
, (LPBYTE
)pszTargetPath
, (lstrlenW(pszTargetPath
)+1)*sizeof(WCHAR
)));
5195 /* make sure destination path exists */
5196 SHCreateDirectory(NULL
, pszTargetPath
);
5198 /* copy content if required */
5199 if(SUCCEEDED(hr
) && (flags
& KF_REDIRECT_COPY_CONTENTS
) )
5201 static const WCHAR sWildcard
[] = {'\\','*',0};
5202 WCHAR srcPath
[MAX_PATH
+1], dstPath
[MAX_PATH
+1];
5203 SHFILEOPSTRUCTW fileOp
;
5205 ZeroMemory(srcPath
, sizeof(srcPath
));
5206 lstrcpyW(srcPath
, lpSrcPath
);
5207 lstrcatW(srcPath
, sWildcard
);
5209 ZeroMemory(dstPath
, sizeof(dstPath
));
5210 lstrcpyW(dstPath
, pszTargetPath
);
5212 ZeroMemory(&fileOp
, sizeof(fileOp
));
5214 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5215 fileOp
.wFunc
= FO_MOVE
;
5217 fileOp
.wFunc
= FO_COPY
;
5219 fileOp
.pFrom
= srcPath
;
5220 fileOp
.pTo
= dstPath
;
5221 fileOp
.fFlags
= FOF_NO_UI
;
5223 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5225 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5227 ZeroMemory(srcPath
, sizeof(srcPath
));
5228 lstrcpyW(srcPath
, lpSrcPath
);
5230 ZeroMemory(&fileOp
, sizeof(fileOp
));
5231 fileOp
.wFunc
= FO_DELETE
;
5232 fileOp
.pFrom
= srcPath
;
5233 fileOp
.fFlags
= FOF_NO_UI
;
5235 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5239 CoTaskMemFree(lpSrcPath
);
5247 IKnownFolder IKnownFolder_iface
;
5250 LPWSTR registryPath
;
5253 static inline struct knownfolder
*impl_from_IKnownFolder( IKnownFolder
*iface
)
5255 return CONTAINING_RECORD( iface
, struct knownfolder
, IKnownFolder_iface
);
5258 static ULONG WINAPI
knownfolder_AddRef(
5259 IKnownFolder
*iface
)
5261 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5262 return InterlockedIncrement( &knownfolder
->refs
);
5265 static ULONG WINAPI
knownfolder_Release(
5266 IKnownFolder
*iface
)
5268 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5269 LONG refs
= InterlockedDecrement( &knownfolder
->refs
);
5272 TRACE("destroying %p\n", knownfolder
);
5273 heap_free( knownfolder
->registryPath
);
5274 heap_free( knownfolder
);
5279 static HRESULT WINAPI
knownfolder_QueryInterface(
5280 IKnownFolder
*iface
,
5284 struct knownfolder
*This
= impl_from_IKnownFolder( iface
);
5286 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5289 if ( IsEqualGUID( riid
, &IID_IKnownFolder
) ||
5290 IsEqualGUID( riid
, &IID_IUnknown
) )
5294 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5296 TRACE("IID_IMarshal returning NULL.\n");
5297 return E_NOINTERFACE
;
5301 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5302 return E_NOINTERFACE
;
5304 IKnownFolder_AddRef( iface
);
5308 static HRESULT
knownfolder_set_id(
5309 struct knownfolder
*knownfolder
,
5310 const KNOWNFOLDERID
*kfid
)
5315 TRACE("%s\n", debugstr_guid(kfid
));
5317 knownfolder
->id
= *kfid
;
5319 /* check is it registry-registered folder */
5320 hr
= get_known_folder_registry_path(kfid
, NULL
, &knownfolder
->registryPath
);
5322 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, 0, 0, &hKey
));
5331 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5332 heap_free(knownfolder
->registryPath
);
5333 knownfolder
->registryPath
= NULL
;
5340 static HRESULT WINAPI
knownfolder_GetId(
5341 IKnownFolder
*iface
,
5342 KNOWNFOLDERID
*pkfid
)
5344 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5346 TRACE("%p\n", pkfid
);
5348 *pkfid
= knownfolder
->id
;
5352 static HRESULT WINAPI
knownfolder_GetCategory(
5353 IKnownFolder
*iface
,
5354 KF_CATEGORY
*pCategory
)
5356 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5359 TRACE("%p, %p\n", knownfolder
, pCategory
);
5361 /* we cannot get a category for a folder which is not registered */
5362 if(!knownfolder
->registryPath
)
5366 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, pCategory
);
5371 static HRESULT WINAPI
knownfolder_GetShellItem(
5372 IKnownFolder
*iface
,
5377 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5378 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder
, flags
, debugstr_guid(riid
), ppv
);
5379 return SHGetKnownFolderItem(&knownfolder
->id
, flags
, NULL
, riid
, ppv
);
5382 static HRESULT
get_known_folder_path(
5384 LPWSTR registryPath
,
5387 static const WCHAR sBackslash
[] = {'\\',0};
5389 DWORD dwSize
, dwType
;
5390 WCHAR path
[MAX_PATH
] = {0};
5391 WCHAR parentGuid
[39];
5392 KF_CATEGORY category
;
5393 LPWSTR parentRegistryPath
, parentPath
;
5394 HKEY hRedirectionRootKey
= NULL
;
5396 TRACE("(%s, %p)\n", debugstr_w(registryPath
), ppszPath
);
5399 /* check if folder has parent */
5400 dwSize
= sizeof(parentGuid
);
5401 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szParentFolder
, RRF_RT_REG_SZ
, &dwType
, parentGuid
, &dwSize
));
5402 if(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)) hr
= S_FALSE
;
5406 /* get parent's known folder path (recursive) */
5407 hr
= get_known_folder_registry_path(NULL
, parentGuid
, &parentRegistryPath
);
5408 if(FAILED(hr
)) return hr
;
5410 hr
= get_known_folder_path(parentGuid
, parentRegistryPath
, &parentPath
);
5412 heap_free(parentRegistryPath
);
5416 lstrcatW(path
, parentPath
);
5417 lstrcatW(path
, sBackslash
);
5419 heap_free(parentRegistryPath
);
5420 heap_free(parentPath
);
5423 /* check, if folder was redirected */
5425 hr
= get_known_folder_dword(registryPath
, szCategory
, &category
);
5429 if(category
== KF_CATEGORY_COMMON
)
5430 hRedirectionRootKey
= HKEY_LOCAL_MACHINE
;
5431 else if(category
== KF_CATEGORY_PERUSER
)
5432 hRedirectionRootKey
= HKEY_CURRENT_USER
;
5434 if(hRedirectionRootKey
)
5436 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, NULL
, &dwSize
));
5440 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5441 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5446 lstrcpyW(*ppszPath
, path
);
5447 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5453 /* no redirection, use previous way - read the relative path from folder definition */
5454 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, NULL
, &dwSize
));
5458 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5459 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5464 lstrcpyW(*ppszPath
, path
);
5465 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5470 TRACE("returning path: %s\n", debugstr_w(*ppszPath
));
5474 static HRESULT
get_known_folder_path_by_id(
5475 REFKNOWNFOLDERID folderId
,
5476 LPWSTR lpRegistryPath
,
5480 HRESULT hr
= E_FAIL
;
5484 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId
), debugstr_w(lpRegistryPath
), dwFlags
, ppszPath
);
5486 /* if this is registry-registered known folder, get path from registry */
5489 StringFromGUID2(folderId
, sGuid
, ARRAY_SIZE(sGuid
));
5491 hr
= get_known_folder_path(sGuid
, lpRegistryPath
, ppszPath
);
5493 /* in other case, use older way */
5496 hr
= SHGetKnownFolderPath( folderId
, dwFlags
, NULL
, ppszPath
);
5498 if (FAILED(hr
)) return hr
;
5500 /* check if known folder really exists */
5501 dwAttributes
= GetFileAttributesW(*ppszPath
);
5502 if(dwAttributes
== INVALID_FILE_ATTRIBUTES
|| !(dwAttributes
& FILE_ATTRIBUTE_DIRECTORY
) )
5504 TRACE("directory %s not found\n", debugstr_w(*ppszPath
));
5505 CoTaskMemFree(*ppszPath
);
5507 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
5513 static HRESULT WINAPI
knownfolder_GetPath(
5514 IKnownFolder
*iface
,
5518 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5519 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, dwFlags
, ppszPath
);
5521 return get_known_folder_path_by_id(&knownfolder
->id
, knownfolder
->registryPath
, dwFlags
, ppszPath
);
5524 static HRESULT WINAPI
knownfolder_SetPath(
5525 IKnownFolder
*iface
,
5529 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5532 TRACE("(%p, 0x%08x, %s)\n", knownfolder
, dwFlags
, debugstr_w(pszPath
));
5534 /* check if the known folder is registered */
5535 if(!knownfolder
->registryPath
)
5539 hr
= redirect_known_folder(&knownfolder
->id
, NULL
, 0, pszPath
, 0, NULL
, NULL
);
5544 static HRESULT WINAPI
knownfolder_GetIDList(
5545 IKnownFolder
*iface
,
5547 PIDLIST_ABSOLUTE
*ppidl
)
5549 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5550 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, flags
, ppidl
);
5551 return SHGetKnownFolderIDList(&knownfolder
->id
, flags
, NULL
, ppidl
);
5554 static HRESULT WINAPI
knownfolder_GetFolderType(
5555 IKnownFolder
*iface
,
5556 FOLDERTYPEID
*pftid
)
5558 FIXME("%p\n", pftid
);
5562 static HRESULT WINAPI
knownfolder_GetRedirectionCapabilities(
5563 IKnownFolder
*iface
,
5564 KF_REDIRECTION_CAPABILITIES
*pCapabilities
)
5566 FIXME("%p stub\n", pCapabilities
);
5567 if(!pCapabilities
) return E_INVALIDARG
;
5568 *pCapabilities
= KF_REDIRECTION_CAPABILITIES_DENY_ALL
;
5572 static HRESULT WINAPI
knownfolder_GetFolderDefinition(
5573 IKnownFolder
*iface
,
5574 KNOWNFOLDER_DEFINITION
*pKFD
)
5576 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5579 WCHAR parentGuid
[39];
5580 TRACE("(%p, %p)\n", knownfolder
, pKFD
);
5582 if(!pKFD
) return E_INVALIDARG
;
5584 ZeroMemory(pKFD
, sizeof(*pKFD
));
5586 /* required fields */
5587 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, &pKFD
->category
);
5591 hr
= get_known_folder_wstr(knownfolder
->registryPath
, szName
, &pKFD
->pszName
);
5595 /* optional fields */
5596 dwSize
= sizeof(parentGuid
);
5597 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, szParentFolder
,
5598 RRF_RT_REG_SZ
, NULL
, parentGuid
, &dwSize
));
5601 hr
= IIDFromString(parentGuid
, &pKFD
->fidParent
);
5606 get_known_folder_dword(knownfolder
->registryPath
, szAttributes
, &pKFD
->dwAttributes
);
5608 get_known_folder_wstr(knownfolder
->registryPath
, szRelativePath
, &pKFD
->pszRelativePath
);
5610 get_known_folder_wstr(knownfolder
->registryPath
, szParsingName
, &pKFD
->pszParsingName
);
5615 static const struct IKnownFolderVtbl knownfolder_vtbl
=
5617 knownfolder_QueryInterface
,
5619 knownfolder_Release
,
5621 knownfolder_GetCategory
,
5622 knownfolder_GetShellItem
,
5623 knownfolder_GetPath
,
5624 knownfolder_SetPath
,
5625 knownfolder_GetIDList
,
5626 knownfolder_GetFolderType
,
5627 knownfolder_GetRedirectionCapabilities
,
5628 knownfolder_GetFolderDefinition
5631 static HRESULT
knownfolder_create( struct knownfolder
**knownfolder
)
5633 struct knownfolder
*kf
;
5635 kf
= heap_alloc( sizeof(*kf
) );
5636 if (!kf
) return E_OUTOFMEMORY
;
5638 kf
->IKnownFolder_iface
.lpVtbl
= &knownfolder_vtbl
;
5640 memset( &kf
->id
, 0, sizeof(kf
->id
) );
5641 kf
->registryPath
= NULL
;
5645 TRACE("returning iface %p\n", &kf
->IKnownFolder_iface
);
5649 struct foldermanager
5651 IKnownFolderManager IKnownFolderManager_iface
;
5657 static inline struct foldermanager
*impl_from_IKnownFolderManager( IKnownFolderManager
*iface
)
5659 return CONTAINING_RECORD( iface
, struct foldermanager
, IKnownFolderManager_iface
);
5662 static ULONG WINAPI
foldermanager_AddRef(
5663 IKnownFolderManager
*iface
)
5665 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5666 return InterlockedIncrement( &foldermanager
->refs
);
5669 static ULONG WINAPI
foldermanager_Release(
5670 IKnownFolderManager
*iface
)
5672 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5673 LONG refs
= InterlockedDecrement( &foldermanager
->refs
);
5676 TRACE("destroying %p\n", foldermanager
);
5677 heap_free( foldermanager
->ids
);
5678 heap_free( foldermanager
);
5683 static HRESULT WINAPI
foldermanager_QueryInterface(
5684 IKnownFolderManager
*iface
,
5688 struct foldermanager
*This
= impl_from_IKnownFolderManager( iface
);
5690 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5693 if ( IsEqualGUID( riid
, &IID_IKnownFolderManager
) ||
5694 IsEqualGUID( riid
, &IID_IUnknown
) )
5698 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5700 TRACE("IID_IMarshal returning NULL.\n");
5701 return E_NOINTERFACE
;
5705 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5706 return E_NOINTERFACE
;
5708 IKnownFolderManager_AddRef( iface
);
5712 static HRESULT WINAPI
foldermanager_FolderIdFromCsidl(
5713 IKnownFolderManager
*iface
,
5715 KNOWNFOLDERID
*pfid
)
5717 TRACE("%d, %p\n", nCsidl
, pfid
);
5719 if (nCsidl
>= ARRAY_SIZE(CSIDL_Data
))
5720 return E_INVALIDARG
;
5721 *pfid
= *CSIDL_Data
[nCsidl
].id
;
5725 static HRESULT WINAPI
foldermanager_FolderIdToCsidl(
5726 IKnownFolderManager
*iface
,
5727 REFKNOWNFOLDERID rfid
,
5732 TRACE("%s, %p\n", debugstr_guid(rfid
), pnCsidl
);
5734 csidl
= csidl_from_id( rfid
);
5735 if (csidl
== -1) return E_INVALIDARG
;
5740 static HRESULT WINAPI
foldermanager_GetFolderIds(
5741 IKnownFolderManager
*iface
,
5742 KNOWNFOLDERID
**ppKFId
,
5745 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5747 TRACE("%p, %p\n", ppKFId
, pCount
);
5749 *ppKFId
= CoTaskMemAlloc(fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5750 memcpy(*ppKFId
, fm
->ids
, fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5751 *pCount
= fm
->num_ids
;
5755 static BOOL
is_knownfolder( struct foldermanager
*fm
, const KNOWNFOLDERID
*id
)
5759 LPWSTR registryPath
= NULL
;
5762 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
5763 for (i
= 0; i
< fm
->num_ids
; i
++)
5764 if (IsEqualGUID( &fm
->ids
[i
], id
)) return TRUE
;
5766 hr
= get_known_folder_registry_path(id
, NULL
, ®istryPath
);
5769 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, 0, &hKey
));
5770 heap_free(registryPath
);
5782 static HRESULT WINAPI
foldermanager_GetFolder(
5783 IKnownFolderManager
*iface
,
5784 REFKNOWNFOLDERID rfid
,
5785 IKnownFolder
**ppkf
)
5787 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5788 struct knownfolder
*kf
;
5791 TRACE("%s, %p\n", debugstr_guid(rfid
), ppkf
);
5793 if (!is_knownfolder( fm
, rfid
))
5795 WARN("unknown folder\n");
5796 return E_INVALIDARG
;
5798 hr
= knownfolder_create( &kf
);
5799 if (SUCCEEDED( hr
))
5801 hr
= knownfolder_set_id( kf
, rfid
);
5802 *ppkf
= &kf
->IKnownFolder_iface
;
5810 static HRESULT WINAPI
foldermanager_GetFolderByName(
5811 IKnownFolderManager
*iface
,
5812 LPCWSTR pszCanonicalName
,
5813 IKnownFolder
**ppkf
)
5815 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5816 struct knownfolder
*kf
;
5821 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName
), ppkf
);
5823 for (i
= 0; i
< fm
->num_ids
; i
++)
5826 hr
= get_known_folder_registry_path( &fm
->ids
[i
], NULL
, &path
);
5827 if (FAILED( hr
)) return hr
;
5829 hr
= get_known_folder_wstr( path
, szName
, &name
);
5831 if (FAILED( hr
)) return hr
;
5833 found
= !strcmpiW( pszCanonicalName
, name
);
5834 CoTaskMemFree( name
);
5840 hr
= knownfolder_create( &kf
);
5841 if (FAILED( hr
)) return hr
;
5843 hr
= knownfolder_set_id( kf
, &fm
->ids
[i
] );
5846 IKnownFolder_Release( &kf
->IKnownFolder_iface
);
5849 *ppkf
= &kf
->IKnownFolder_iface
;
5853 hr
= HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
5860 static HRESULT
register_folder(const KNOWNFOLDERID
*rfid
, const KNOWNFOLDER_DEFINITION
*pKFD
)
5865 LPWSTR registryPath
= NULL
;
5867 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
5868 TRACE("registry path: %s\n", debugstr_w(registryPath
));
5871 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, NULL
, 0, KEY_WRITE
, 0, &hKey
, &dwDisp
));
5875 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szCategory
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->category
, sizeof(pKFD
->category
)));
5877 if(SUCCEEDED(hr
) && pKFD
->dwAttributes
!= 0)
5878 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szAttributes
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->dwAttributes
, sizeof(pKFD
->dwAttributes
)));
5881 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszName
, (lstrlenW(pKFD
->pszName
)+1)*sizeof(WCHAR
) ));
5883 if(SUCCEEDED(hr
) && pKFD
->pszParsingName
)
5884 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParsingName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszParsingName
, (lstrlenW(pKFD
->pszParsingName
)+1)*sizeof(WCHAR
) ));
5886 if(SUCCEEDED(hr
) && !IsEqualGUID(&pKFD
->fidParent
, &GUID_NULL
))
5888 WCHAR sParentGuid
[39];
5889 StringFromGUID2(&pKFD
->fidParent
, sParentGuid
, ARRAY_SIZE(sParentGuid
));
5891 /* this known folder has parent folder */
5892 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParentFolder
, 0, REG_SZ
, (LPBYTE
)sParentGuid
, sizeof(sParentGuid
)));
5895 if(SUCCEEDED(hr
) && pKFD
->category
!= KF_CATEGORY_VIRTUAL
&& pKFD
->pszRelativePath
)
5896 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szRelativePath
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszRelativePath
, (lstrlenW(pKFD
->pszRelativePath
)+1)*sizeof(WCHAR
) ));
5901 SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
);
5904 heap_free(registryPath
);
5908 static HRESULT WINAPI
foldermanager_RegisterFolder(
5909 IKnownFolderManager
*iface
,
5910 REFKNOWNFOLDERID rfid
,
5911 KNOWNFOLDER_DEFINITION
const *pKFD
)
5913 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(rfid
), pKFD
);
5914 return register_folder(rfid
, pKFD
);
5917 static HRESULT WINAPI
foldermanager_UnregisterFolder(
5918 IKnownFolderManager
*iface
,
5919 REFKNOWNFOLDERID rfid
)
5922 LPWSTR registryPath
= NULL
;
5923 TRACE("(%p, %s)\n", iface
, debugstr_guid(rfid
));
5925 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
5928 hr
= HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
));
5930 heap_free(registryPath
);
5934 static HRESULT WINAPI
foldermanager_FindFolderFromPath(
5935 IKnownFolderManager
*iface
,
5938 IKnownFolder
**ppkf
)
5940 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath
), mode
, ppkf
);
5944 static HRESULT WINAPI
foldermanager_FindFolderFromIDList(
5945 IKnownFolderManager
*iface
,
5946 PCIDLIST_ABSOLUTE pidl
,
5947 IKnownFolder
**ppkf
)
5949 FIXME("%p, %p\n", pidl
, ppkf
);
5953 static HRESULT WINAPI
foldermanager_Redirect(
5954 IKnownFolderManager
*iface
,
5955 REFKNOWNFOLDERID rfid
,
5957 KF_REDIRECT_FLAGS flags
,
5958 LPCWSTR pszTargetPath
,
5960 KNOWNFOLDERID
const *pExclusion
,
5963 return redirect_known_folder(rfid
, hwnd
, flags
, pszTargetPath
, cFolders
, pExclusion
, ppszError
);
5966 static const struct IKnownFolderManagerVtbl foldermanager_vtbl
=
5968 foldermanager_QueryInterface
,
5969 foldermanager_AddRef
,
5970 foldermanager_Release
,
5971 foldermanager_FolderIdFromCsidl
,
5972 foldermanager_FolderIdToCsidl
,
5973 foldermanager_GetFolderIds
,
5974 foldermanager_GetFolder
,
5975 foldermanager_GetFolderByName
,
5976 foldermanager_RegisterFolder
,
5977 foldermanager_UnregisterFolder
,
5978 foldermanager_FindFolderFromPath
,
5979 foldermanager_FindFolderFromIDList
,
5980 foldermanager_Redirect
5983 static HRESULT
foldermanager_create( void **ppv
)
5986 struct foldermanager
*fm
;
5988 fm
= heap_alloc( sizeof(*fm
) );
5989 if (!fm
) return E_OUTOFMEMORY
;
5991 fm
->IKnownFolderManager_iface
.lpVtbl
= &foldermanager_vtbl
;
5995 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
5997 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
)) fm
->num_ids
++;
5999 fm
->ids
= heap_alloc( fm
->num_ids
* sizeof(KNOWNFOLDERID
) );
6003 return E_OUTOFMEMORY
;
6005 for (i
= j
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
6007 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
))
6009 fm
->ids
[j
] = *CSIDL_Data
[i
].id
;
6013 TRACE("found %u known folders\n", fm
->num_ids
);
6014 *ppv
= &fm
->IKnownFolderManager_iface
;
6016 TRACE("returning iface %p\n", *ppv
);
6020 HRESULT WINAPI
KnownFolderManager_Constructor( IUnknown
*punk
, REFIID riid
, void **ppv
)
6022 TRACE("%p, %s, %p\n", punk
, debugstr_guid(riid
), ppv
);
6027 return CLASS_E_NOAGGREGATION
;
6029 return foldermanager_create( ppv
);
6032 HRESULT WINAPI
SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, PIDLIST_ABSOLUTE
*pidl
)
6034 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, pidl
);
6037 return E_INVALIDARG
;
6040 FIXME("unsupported flags: 0x%08x\n", flags
);
6043 FIXME("user token is not used.\n");
6046 if (IsEqualIID(rfid
, &FOLDERID_Desktop
))
6047 *pidl
= _ILCreateDesktop();
6048 else if (IsEqualIID(rfid
, &FOLDERID_RecycleBinFolder
))
6049 *pidl
= _ILCreateBitBucket();
6050 else if (IsEqualIID(rfid
, &FOLDERID_ComputerFolder
))
6051 *pidl
= _ILCreateMyComputer();
6052 else if (IsEqualIID(rfid
, &FOLDERID_PrintersFolder
))
6053 *pidl
= _ILCreatePrinters();
6054 else if (IsEqualIID(rfid
, &FOLDERID_ControlPanelFolder
))
6055 *pidl
= _ILCreateControlPanel();
6056 else if (IsEqualIID(rfid
, &FOLDERID_NetworkFolder
))
6057 *pidl
= _ILCreateNetwork();
6058 else if (IsEqualIID(rfid
, &FOLDERID_Documents
))
6059 *pidl
= _ILCreateMyDocuments();
6062 DWORD attributes
= 0;
6066 hr
= SHGetKnownFolderPath(rfid
, flags
, token
, &pathW
);
6070 hr
= SHILCreateFromPathW(pathW
, pidl
, &attributes
);
6071 CoTaskMemFree(pathW
);
6075 return *pidl
? S_OK
: E_FAIL
;
6078 HRESULT WINAPI
SHGetKnownFolderItem(REFKNOWNFOLDERID rfid
, KNOWN_FOLDER_FLAG flags
, HANDLE hToken
,
6079 REFIID riid
, void **ppv
)
6081 PIDLIST_ABSOLUTE pidl
;
6084 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid
), flags
, hToken
, debugstr_guid(riid
), ppv
);
6086 hr
= SHGetKnownFolderIDList(rfid
, flags
, hToken
, &pidl
);
6093 hr
= SHCreateItemFromIDList(pidl
, riid
, ppv
);
6094 CoTaskMemFree(pidl
);
6098 static void register_system_knownfolders(void)
6102 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); ++i
)
6104 const CSIDL_DATA
*folder
= &CSIDL_Data
[i
];
6105 if(folder
->pszName
){
6106 KNOWNFOLDER_DEFINITION kfd
;
6108 /* register_folder won't modify kfd, so cast away const instead of
6110 kfd
.category
= folder
->category
;
6111 kfd
.pszName
= (WCHAR
*)folder
->pszName
;
6112 kfd
.pszDescription
= (WCHAR
*)folder
->pszDescription
;
6113 memcpy(&kfd
.fidParent
, folder
->fidParent
, sizeof(KNOWNFOLDERID
));
6114 kfd
.pszRelativePath
= (WCHAR
*)folder
->pszRelativePath
;
6115 kfd
.pszParsingName
= (WCHAR
*)folder
->pszParsingName
;
6116 kfd
.pszTooltip
= (WCHAR
*)folder
->pszTooltip
;
6117 kfd
.pszLocalizedName
= (WCHAR
*)folder
->pszLocalizedName
;
6118 kfd
.pszIcon
= (WCHAR
*)folder
->pszIcon
;
6119 kfd
.pszSecurity
= (WCHAR
*)folder
->pszSecurity
;
6120 kfd
.dwAttributes
= folder
->dwAttributes
;
6121 kfd
.kfdFlags
= folder
->kfdFlags
;
6122 memcpy(&kfd
.ftidType
, folder
->ftidType
, sizeof(FOLDERTYPEID
));
6124 register_folder(folder
->id
, &kfd
);
6129 HRESULT
SHELL_RegisterShellFolders(void)
6133 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6134 * 'My Videos', 'My Music' and 'Desktop' in advance, so that the
6135 * _SHRegister*ShellFolders() functions will find everything nice and clean
6136 * and thus will not attempt to create them in the profile directory. */
6137 _SHCreateSymbolicLinks();
6139 hr
= _SHRegisterUserShellFolders(TRUE
);
6141 hr
= _SHRegisterUserShellFolders(FALSE
);
6143 hr
= _SHRegisterCommonShellFolders();
6145 hr
= create_extra_folders();
6147 hr
= set_folder_attributes();
6149 register_system_knownfolders();