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 MoviesW
[] = {'M','o','v','i','e','s','\0'};
861 static const WCHAR MusicW
[] = {'M','u','s','i','c','\0'};
862 static const WCHAR MusicLibraryW
[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
863 static const WCHAR Music_librarymsW
[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
864 static const WCHAR Music_PlaylistsW
[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
865 static const WCHAR Music_Sample_MusicW
[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
866 static const WCHAR Music_Sample_PlaylistsW
[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s','\0'};
867 static const WCHAR My_MusicW
[] = {'M','y',' ','M','u','s','i','c','\0'};
868 static const WCHAR My_PicturesW
[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
869 static const WCHAR My_VideosW
[] = {'M','y',' ','V','i','d','e','o','s','\0'};
870 static const WCHAR My_VideoW
[] = {'M','y',' ','V','i','d','e','o','\0'};
871 static const WCHAR MyComputerFolderW
[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
872 static const WCHAR NetHoodW
[] = {'N','e','t','H','o','o','d','\0'};
873 static const WCHAR NetworkPlacesFolderW
[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
874 static const WCHAR OEM_LinksW
[] = {'O','E','M',' ','L','i','n','k','s','\0'};
875 static const WCHAR Original_ImagesW
[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
876 static const WCHAR PersonalW
[] = {'P','e','r','s','o','n','a','l','\0'};
877 static const WCHAR PhotoAlbumsW
[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
878 static const WCHAR PicturesW
[] = {'P','i','c','t','u','r','e','s','\0'};
879 static const WCHAR PicturesLibraryW
[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
880 static const WCHAR Pictures_librarymsW
[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
881 static const WCHAR Pictures_Sample_PicturesW
[] = {'P','i','c','t','u','r','e','s','\\','S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s','\0'};
882 static const WCHAR Pictures_Slide_ShowsW
[] = {'P','i','c','t','u','r','e','s','\\','S','l','i','d','e',' ','S','h','o','w','s','\0'};
883 static const WCHAR PlaylistsW
[] = {'P','l','a','y','l','i','s','t','s',0};
884 static const WCHAR PrintersFolderW
[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
885 static const WCHAR PrintHoodW
[] = {'P','r','i','n','t','H','o','o','d','\0'};
886 static const WCHAR ProfileW
[] = {'P','r','o','f','i','l','e',0};
887 static const WCHAR ProgramDataW
[] = {'P','r','o','g','r','a','m','D','a','t','a','\0'};
888 static const WCHAR Program_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
889 static const WCHAR ProgramFilesW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
890 static const WCHAR ProgramFilesX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
891 static const WCHAR ProgramFilesX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
892 static const WCHAR Program_Files_Common_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
893 static const WCHAR Program_Files_x86W
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
894 static const WCHAR Program_Files_x86_Common_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
895 static const WCHAR ProgramFilesCommonW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
896 static const WCHAR ProgramFilesCommonX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','8','6',0};
897 static const WCHAR ProgramFilesCommonX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','6','4',0};
898 static const WCHAR ProgramFilesDirW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
899 static const WCHAR ProgramFilesDirX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
900 static const WCHAR ProgramsW
[] = {'P','r','o','g','r','a','m','s','\0'};
901 static const WCHAR PublicW
[] = {'P','u','b','l','i','c',0};
902 static const WCHAR PublicGameTasksW
[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
903 static const WCHAR PublicLibrariesW
[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
904 static const WCHAR Quick_LaunchW
[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
905 static const WCHAR RecentW
[] = {'R','e','c','e','n','t','\0'};
906 static const WCHAR RecordedTVLibraryW
[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
907 static const WCHAR RecordedTV_librarymsW
[] = {'R','e','c','o','r','d','e','d','T','V','.','l','i','b','r','a','r','y','-','m','s',0};
908 static const WCHAR RecycleBinFolderW
[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
909 static const WCHAR ResourceDirW
[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
910 static const WCHAR ResourcesW
[] = {'R','e','s','o','u','r','c','e','s','\0'};
911 static const WCHAR RingtonesW
[] = {'R','i','n','g','t','o','n','e','s',0};
912 static const WCHAR SampleMusicW
[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
913 static const WCHAR Sample_MusicW
[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
914 static const WCHAR SamplePicturesW
[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
915 static const WCHAR Sample_PicturesW
[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
916 static const WCHAR SamplePlaylistsW
[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
917 static const WCHAR Sample_PlaylistsW
[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
918 static const WCHAR Sample_VideosW
[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
919 static const WCHAR SampleVideosW
[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
920 static const WCHAR Saved_GamesW
[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
921 static const WCHAR SavedGamesW
[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
922 static const WCHAR SearchesW
[] = {'S','e','a','r','c','h','e','s','\0'};
923 static const WCHAR SearchHomeFolderW
[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
924 static const WCHAR SendToW
[] = {'S','e','n','d','T','o','\0'};
925 static const WCHAR Slide_ShowsW
[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
926 static const WCHAR StartUpW
[] = {'S','t','a','r','t','U','p','\0'};
927 static const WCHAR StartupW
[] = {'S','t','a','r','t','u','p','\0'};
928 static const WCHAR Start_MenuW
[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
929 static const WCHAR Start_Menu_ProgramsW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
930 static const WCHAR Start_Menu_Admin_ToolsW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
931 static const WCHAR Start_Menu_StartupW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
932 static const WCHAR SyncCenterFolderW
[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
933 static const WCHAR SyncResultsFolderW
[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
934 static const WCHAR SyncSetupFolderW
[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
935 static const WCHAR SystemW
[] = {'S','y','s','t','e','m',0};
936 static const WCHAR SystemX86W
[] = {'S','y','s','t','e','m','X','8','6',0};
937 static const WCHAR TemplatesW
[] = {'T','e','m','p','l','a','t','e','s','\0'};
938 static const WCHAR User_PinnedW
[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
939 static const WCHAR UsersW
[] = {'U','s','e','r','s','\0'};
940 static const WCHAR UsersFilesFolderW
[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
941 static const WCHAR UsersLibrariesFolderW
[] = {'U','s','e','r','s','L','i','b','r','a','r','i','e','s','F','o','l','d','e','r',0};
942 static const WCHAR UserProfilesW
[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
943 static const WCHAR UserProgramFilesW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
944 static const WCHAR UserProgramFilesCommonW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
945 static const WCHAR UsersPublicW
[] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'};
946 static const WCHAR VideosW
[] = {'V','i','d','e','o','s','\0'};
947 static const WCHAR VideosLibraryW
[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
948 static const WCHAR Videos_librarymsW
[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
949 static const WCHAR Videos_Sample_VideosW
[] = {'V','i','d','e','o','s','\\','S','a','m','p','l','e',' ','V','i','d','e','o','s','\0'};
950 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
951 static const WCHAR Windows_Sidebar_GadgetsW
[] = {'W','i','n','d','o','w','s',' ','S','i','d','e','b','a','r','\\','G','a','d','g','e','t','s',0};
952 static const WCHAR DefaultW
[] = {'.','D','e','f','a','u','l','t','\0'};
953 static const WCHAR AllUsersProfileW
[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
954 static const WCHAR UserProfileW
[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
955 static const WCHAR ProgramDataVarW
[] = {'%','P','r','o','g','r','a','m','D','a','t','a','%','\0'};
956 static const WCHAR SystemDriveW
[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
957 static const WCHAR ProfileListW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0};
958 static const WCHAR ProfilesDirectoryW
[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
959 static const WCHAR AllUsersProfileValueW
[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
960 static const WCHAR szSHFolders
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
961 static const WCHAR szSHUserFolders
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
962 static const WCHAR szDefaultProfileDirW
[] = {'u','s','e','r','s',0};
963 static const WCHAR szKnownFolderDescriptions
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','F','o','l','d','e','r','D','e','s','c','r','i','p','t','i','o','n','s','\0'};
964 static const WCHAR szKnownFolderRedirections
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s',0};
965 static const WCHAR AllUsersW
[] = {'P','u','b','l','i','c',0};
967 #define CHANGEREMOVEPROGRAMS_PARSING_GUID '{','7','b','8','1','b','e','6','a','-','c','e','2','b','-','4','6','7','6','-','a','2','9','e','-','e','b','9','0','7','a','5','1','2','6','c','5','}'
968 #define SYNCMANAGER_PARSING_GUID '{','9','C','7','3','F','5','E','5','-','7','A','E','7','-','4','E','3','2','-','A','8','E','8','-','8','D','2','3','B','8','5','2','5','5','B','F','}'
969 #define SYSTEMFOLDERS_PARSING_GUID '{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}'
970 #define USERFOLDERS_PARSING_GUID '{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}'
971 #define USERSLIBRARIES_PARSING_GUID '{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}'
973 static const WCHAR ComputerFolderParsingNameW
[] = {':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
974 static const WCHAR ControlPanelFolderParsingNameW
[] = {':',':','{','2','6','E','E','0','6','6','8','-','A','0','0','A','-','4','4','D','7','-','9','3','7','1','-','B','E','B','0','6','4','C','9','8','6','8','3','}','\\','0',0};
975 static const WCHAR ControlPanelFolderRelativePathW
[] = {':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
976 static const WCHAR GamesParsingNameW
[] = {':',':','{','E','D','2','2','8','F','D','F','-','9','E','A','8','-','4','8','7','0','-','8','3','b','1','-','9','6','b','0','2','C','F','E','0','D','5','2','}',0};
977 static const WCHAR HomeGroupParsingNameW
[] = {':',':','{','B','4','F','B','3','F','9','8','-','C','1','E','A','-','4','2','8','d','-','A','7','8','A','-','D','1','F','5','6','5','9','C','B','A','9','3','}',0};
978 static const WCHAR InternetFolderParsingNameW
[] = {':',':','{','8','7','1','C','5','3','8','0','-','4','2','A','0','-','1','0','6','9','-','A','2','E','A','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
979 static const WCHAR NetworkFolderParsingNameW
[] = {':',':','{','F','0','2','C','1','A','0','D','-','B','E','2','1','-','4','3','5','0','-','8','8','B','0','-','7','3','6','7','F','C','9','6','E','F','3','C','}',0};
980 static const WCHAR PublicParsingNameW
[] = {':',':','{','4','3','3','6','a','5','4','d','-','0','3','8','b','-','4','6','8','5','-','a','b','0','2','-','9','9','b','b','5','2','d','3','f','b','8','b','}',0};
981 static const WCHAR RecycleBinFolderParsingNameW
[] = {':',':','{','6','4','5','F','F','0','4','0','-','5','0','8','1','-','1','0','1','B','-','9','F','0','8','-','0','0','A','A','0','0','2','F','9','5','4','E','}',0};
982 static const WCHAR SearchHomeParsingNameW
[] = {':',':','{','9','3','4','3','8','1','2','e','-','1','c','3','7','-','4','a','4','9','-','a','1','2','e','-','4','b','2','d','8','1','0','d','9','5','6','b','}',0};
983 static const WCHAR SEARCH_CSCParsingNameW
[] = {'s','h','e','l','l',':',':',':','{','B','D','7','A','2','E','7','B','-','2','1','C','B','-','4','1','b','2','-','A','0','8','6','-','B','3','0','9','6','8','0','C','6','B','7','E','}','\\','*',0};
984 static const WCHAR SEARCH_MAPIParsingNameW
[] = {'s','h','e','l','l',':',':',':','{','8','9','D','8','3','5','7','6','-','6','B','D','1','-','4','C','8','6','-','9','4','5','4','-','B','E','B','0','4','E','9','4','C','8','1','9','}','\\','*',0};
985 static const WCHAR UsersFilesParsingNameW
[] = {':',':','{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}',0};
986 static const WCHAR UsersLibrariesParsingNameW
[] = {':',':','{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}',0};
987 static const WCHAR AddNewProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','1','5','e','a','e','9','2','e','-','f','1','7','a','-','4','4','3','1','-','9','f','2','8','-','8','0','5','e','4','8','2','d','a','f','d','4','}',0};
988 static const WCHAR ConnectionsFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','7','0','0','7','A','C','C','7','-','3','2','0','2','-','1','1','D','1','-','A','A','D','2','-','0','0','8','0','5','F','C','1','2','7','0','E','}',0};
989 static const WCHAR PrintersFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','2','2','2','7','A','2','8','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','E','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
990 static const WCHAR ChangeRemoveProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, 0};
991 static const WCHAR AppUpdatesParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, '\\',':',':','{','d','4','5','0','a','8','a','1','-','9','5','6','8','-','4','5','c','7','-','9','c','0','e','-','b','4','f','9','f','b','4','5','3','7','b','d','}',0};
992 static const WCHAR SyncManagerFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, 0};
993 static const WCHAR ConflictFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','E','4','1','3','D','0','4','0','-','6','7','8','8','-','4','C','2','2','-','9','5','7','E','-','1','7','5','D','1','C','5','1','3','A','3','4','}',',',0};
994 static const WCHAR SyncResultsFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','B','C','4','8','B','3','2','F','-','5','9','1','0','-','4','7','F','5','-','8','5','7','0','-','5','0','7','4','A','8','A','5','6','3','6','A','}',',',0};
995 static const WCHAR SyncSetupFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','F','1','3','9','0','A','9','A','-','A','3','F','4','-','4','E','5','D','-','9','C','5','F','-','9','8','F','3','B','D','8','D','9','3','5','C','}',',',0};
996 static const WCHAR ContactsParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','5','6','7','8','4','8','5','4','-','C','6','C','B','-','4','6','2','B','-','8','1','6','9','-','8','8','E','3','5','0','A','C','B','8','8','2','}',0};
997 static const WCHAR DocumentsParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','F','D','D','3','9','A','D','0','-','2','3','8','F','-','4','6','A','F','-','A','D','B','4','-','6','C','8','5','4','8','0','3','6','9','C','7','}',0};
998 static const WCHAR LinksParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','b','f','b','9','d','5','e','0','-','c','6','a','9','-','4','0','4','c','-','b','2','b','2','-','a','e','6','d','b','6','a','f','4','9','6','8','}',0};
999 static const WCHAR MusicParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','4','B','D','8','D','5','7','1','-','6','D','1','9','-','4','8','D','3','-','B','E','9','7','-','4','2','2','2','2','0','0','8','0','E','4','3','}',0};
1000 static const WCHAR PicturesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','3','3','E','2','8','1','3','0','-','4','E','1','E','-','4','6','7','6','-','8','3','5','A','-','9','8','3','9','5','C','3','B','C','3','B','B','}',0};
1001 static const WCHAR SavedGamesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','4','C','5','C','3','2','F','F','-','B','B','9','D','-','4','3','b','0','-','B','5','B','4','-','2','D','7','2','E','5','4','E','A','A','A','4','}',0};
1002 static const WCHAR SavedSearchesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','7','d','1','d','3','a','0','4','-','d','e','b','b','-','4','1','1','5','-','9','5','c','f','-','2','f','2','9','d','a','2','9','2','0','d','a','}',0};
1003 static const WCHAR VideosParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','1','8','9','8','9','B','1','D','-','9','9','B','5','-','4','5','5','B','-','8','4','1','C','-','A','B','7','C','7','4','E','4','D','D','F','C','}',0};
1004 static const WCHAR DocumentsLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','7','b','0','d','b','1','7','d','-','9','c','d','2','-','4','a','9','3','-','9','7','3','3','-','4','6','c','c','8','9','0','2','2','e','7','c','}',0};
1005 static const WCHAR MusicLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','2','1','1','2','A','B','0','A','-','C','8','6','A','-','4','f','f','e','-','A','3','6','8','-','0','D','E','9','6','E','4','7','0','1','2','E','}',0};
1006 static const WCHAR PicturesLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','A','9','9','0','A','E','9','F','-','A','0','3','B','-','4','e','8','0','-','9','4','B','C','-','9','9','1','2','D','7','5','0','4','1','0','4','}',0};
1007 static const WCHAR VideosLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','4','9','1','E','9','2','2','F','-','5','6','4','3','-','4','a','f','4','-','A','7','E','B','-','4','E','7','A','1','3','8','D','8','1','7','4','}',0};
1009 typedef enum _CSIDL_Type
{
1011 CSIDL_Type_AllUsers
,
1013 CSIDL_Type_Disallowed
,
1014 CSIDL_Type_NonExistent
,
1015 CSIDL_Type_WindowsPath
,
1016 CSIDL_Type_SystemPath
,
1017 CSIDL_Type_SystemX86Path
,
1018 CSIDL_Type_ProgramData
,
1021 #define CSIDL_CONTACTS 0x0043
1022 #define CSIDL_DOWNLOADS 0x0047
1023 #define CSIDL_LINKS 0x004d
1024 #define CSIDL_APPDATA_LOCALLOW 0x004e
1025 #define CSIDL_SAVED_GAMES 0x0062
1026 #define CSIDL_SEARCHES 0x0063
1030 IApplicationDestinations IApplicationDestinations_iface
;
1032 } IApplicationDestinationsImpl
;
1034 static inline IApplicationDestinationsImpl
*impl_from_IApplicationDestinations( IApplicationDestinations
*iface
)
1036 return CONTAINING_RECORD(iface
, IApplicationDestinationsImpl
, IApplicationDestinations_iface
);
1039 static HRESULT WINAPI
ApplicationDestinations_QueryInterface(IApplicationDestinations
*iface
, REFIID riid
,
1042 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1044 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1049 if (IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IApplicationDestinations
, riid
))
1051 *ppv
= &This
->IApplicationDestinations_iface
;
1052 IUnknown_AddRef((IUnknown
*)*ppv
);
1054 TRACE("Returning IApplicationDestinations: %p\n", *ppv
);
1059 FIXME("(%p)->(%s, %p) interface not supported.\n", This
, debugstr_guid(riid
), ppv
);
1061 return E_NOINTERFACE
;
1064 static ULONG WINAPI
ApplicationDestinations_AddRef(IApplicationDestinations
*iface
)
1066 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1067 ULONG ref
= InterlockedIncrement(&This
->ref
);
1069 TRACE("(%p), new refcount=%i\n", This
, ref
);
1074 static ULONG WINAPI
ApplicationDestinations_Release(IApplicationDestinations
*iface
)
1076 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1077 ULONG ref
= InterlockedDecrement(&This
->ref
);
1079 TRACE("(%p), new refcount=%i\n", This
, ref
);
1082 HeapFree(GetProcessHeap(), 0, This
);
1087 static HRESULT WINAPI
ApplicationDestinations_SetAppID(IApplicationDestinations
*iface
, const WCHAR
*appid
)
1089 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1091 FIXME("(%p, %s) stub!\n", This
, debugstr_w(appid
));
1096 static HRESULT WINAPI
ApplicationDestinations_RemoveDestination(IApplicationDestinations
*iface
, IUnknown
*punk
)
1098 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1100 FIXME("(%p, %p) stub!\n", This
, punk
);
1105 static HRESULT WINAPI
ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations
*iface
)
1107 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1109 FIXME("(%p) stub!\n", This
);
1114 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl
=
1116 ApplicationDestinations_QueryInterface
,
1117 ApplicationDestinations_AddRef
,
1118 ApplicationDestinations_Release
,
1119 ApplicationDestinations_SetAppID
,
1120 ApplicationDestinations_RemoveDestination
,
1121 ApplicationDestinations_RemoveAllDestinations
1124 HRESULT WINAPI
ApplicationDestinations_Constructor(IUnknown
*outer
, REFIID riid
, LPVOID
*ppv
)
1126 IApplicationDestinationsImpl
*This
;
1129 TRACE("(%p, %s, %p)\n", outer
, debugstr_guid(riid
), ppv
);
1132 return CLASS_E_NOAGGREGATION
;
1134 if (!(This
= SHAlloc(sizeof(*This
))))
1135 return E_OUTOFMEMORY
;
1137 This
->IApplicationDestinations_iface
.lpVtbl
= &ApplicationDestinationsVtbl
;
1140 hr
= IUnknown_QueryInterface(&This
->IApplicationDestinations_iface
, riid
, ppv
);
1149 const KNOWNFOLDERID
*id
;
1151 LPCWSTR szValueName
;
1152 LPCWSTR szDefaultPath
; /* fallback string or resource ID */
1154 /* KNOWNFOLDER_DEFINITION fields */
1155 KF_CATEGORY category
;
1156 const WCHAR
*pszName
;
1157 const WCHAR
*pszDescription
;
1158 const KNOWNFOLDERID
*fidParent
;
1159 const WCHAR
*pszRelativePath
;
1160 const WCHAR
*pszParsingName
;
1161 const WCHAR
*pszTooltip
;
1162 const WCHAR
*pszLocalizedName
;
1163 const WCHAR
*pszIcon
;
1164 const WCHAR
*pszSecurity
;
1166 KF_DEFINITION_FLAGS kfdFlags
;
1167 const FOLDERTYPEID
*ftidType
;
1170 static const CSIDL_DATA CSIDL_Data
[] =
1172 { /* 0x00 - CSIDL_DESKTOP */
1176 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1178 KF_CATEGORY_PERUSER
, /* category */
1179 DesktopW
, /* name */
1180 NULL
, /* description */
1181 &GUID_NULL
, /* parent */
1182 DesktopW
, /* relative path */
1185 NULL
, /* localized */
1187 NULL
, /* security */
1188 FILE_ATTRIBUTE_READONLY
, /* attributes */
1190 &GUID_NULL
/* typeid */
1192 { /* 0x01 - CSIDL_INTERNET */
1193 &FOLDERID_InternetFolder
,
1194 CSIDL_Type_Disallowed
,
1198 KF_CATEGORY_VIRTUAL
, /* category */
1199 InternetFolderW
, /* name */
1200 NULL
, /* description */
1201 &GUID_NULL
, /* parent */
1202 NULL
, /* relative path */
1203 InternetFolderParsingNameW
, /* parsing */
1205 NULL
, /* localized */
1207 NULL
, /* security */
1210 &GUID_NULL
/* typeid */
1212 { /* 0x02 - CSIDL_PROGRAMS */
1216 Start_Menu_ProgramsW
,
1218 KF_CATEGORY_PERUSER
, /* category */
1219 ProgramsW
, /* name */
1220 NULL
, /* description */
1221 &GUID_NULL
, /* parent */
1222 ProgramsW
, /* relative path */
1225 NULL
, /* localized */
1227 NULL
, /* security */
1228 FILE_ATTRIBUTE_READONLY
, /* attributes */
1230 &GUID_NULL
/* typeid */
1232 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1233 &FOLDERID_ControlPanelFolder
,
1234 CSIDL_Type_SystemPath
,
1238 KF_CATEGORY_VIRTUAL
, /* category */
1239 ControlPanelFolderW
, /* name */
1240 NULL
, /* description */
1241 &GUID_NULL
, /* parent */
1242 ControlPanelFolderRelativePathW
, /* relative path */
1243 ControlPanelFolderParsingNameW
, /* parsing */
1245 NULL
, /* localized */
1247 NULL
, /* security */
1250 &GUID_NULL
/* typeid */
1252 { /* 0x04 - CSIDL_PRINTERS */
1253 &FOLDERID_PrintersFolder
,
1254 CSIDL_Type_SystemPath
,
1258 KF_CATEGORY_VIRTUAL
, /* category */
1259 PrintersFolderW
, /* name */
1260 NULL
, /* description */
1261 &GUID_NULL
, /* parent */
1262 NULL
, /* relative path */
1263 PrintersFolderParsingNameW
, /* parsing */
1265 NULL
, /* localized */
1267 NULL
, /* security */
1270 &GUID_NULL
/* typeid */
1272 { /* 0x05 - CSIDL_PERSONAL */
1273 &FOLDERID_Documents
,
1276 MAKEINTRESOURCEW(IDS_PERSONAL
),
1278 KF_CATEGORY_PERUSER
, /* category */
1279 PersonalW
, /* name */
1280 NULL
, /* description */
1281 &GUID_NULL
, /* parent */
1282 DocumentsW
, /* relative path */
1283 DocumentsParsingNameW
, /* parsing */
1285 NULL
, /* localized */
1287 NULL
, /* security */
1288 FILE_ATTRIBUTE_READONLY
, /* attributes */
1289 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1290 &GUID_NULL
/* typeid */
1292 { /* 0x06 - CSIDL_FAVORITES */
1293 &FOLDERID_Favorites
,
1298 KF_CATEGORY_PERUSER
, /* category */
1299 FavoritesW
, /* name */
1300 NULL
, /* description */
1301 &GUID_NULL
, /* parent */
1302 FavoritesW
, /* relative path */
1305 NULL
, /* localized */
1307 NULL
, /* security */
1308 FILE_ATTRIBUTE_READONLY
, /* attributes */
1309 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1310 &GUID_NULL
/* typeid */
1312 { /* 0x07 - CSIDL_STARTUP */
1316 Start_Menu_StartupW
,
1318 KF_CATEGORY_PERUSER
, /* category */
1319 StartupW
, /* name */
1320 NULL
, /* description */
1321 &GUID_NULL
, /* parent */
1322 StartUpW
, /* relative path */
1325 NULL
, /* localized */
1327 NULL
, /* security */
1328 FILE_ATTRIBUTE_READONLY
, /* attributes */
1329 KFDF_PRECREATE
, /* flags */
1330 &GUID_NULL
/* typeid */
1332 { /* 0x08 - CSIDL_RECENT */
1338 KF_CATEGORY_PERUSER
, /* category */
1340 NULL
, /* description */
1341 &FOLDERID_RoamingAppData
, /* parent */
1342 Microsoft_Windows_RecentW
, /* relative path */
1345 NULL
, /* localized */
1347 NULL
, /* security */
1348 FILE_ATTRIBUTE_READONLY
, /* attributes */
1349 KFDF_PRECREATE
, /* flags */
1350 &GUID_NULL
/* typeid */
1352 { /* 0x09 - CSIDL_SENDTO */
1358 KF_CATEGORY_PERUSER
, /* category */
1360 NULL
, /* description */
1361 &FOLDERID_RoamingAppData
, /* parent */
1362 Microsoft_Windows_SendToW
, /* relative path */
1365 NULL
, /* localized */
1367 NULL
, /* security */
1369 KFDF_PRECREATE
, /* flags */
1370 &GUID_NULL
/* typeid */
1372 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1373 &FOLDERID_RecycleBinFolder
,
1374 CSIDL_Type_Disallowed
,
1378 KF_CATEGORY_VIRTUAL
, /* category */
1379 RecycleBinFolderW
, /* name */
1380 NULL
, /* description */
1381 &GUID_NULL
, /* parent */
1382 NULL
, /* relative path */
1383 RecycleBinFolderParsingNameW
, /* parsing */
1385 NULL
, /* localized */
1387 NULL
, /* security */
1390 &GUID_NULL
/* typeid */
1392 { /* 0x0b - CSIDL_STARTMENU */
1393 &FOLDERID_StartMenu
,
1398 KF_CATEGORY_PERUSER
, /* category */
1399 Start_MenuW
, /* name */
1400 NULL
, /* description */
1401 &FOLDERID_RoamingAppData
, /* parent */
1402 Microsoft_Windows_Start_MenuW
, /* relative path */
1405 NULL
, /* localized */
1407 NULL
, /* security */
1408 FILE_ATTRIBUTE_READONLY
, /* attributes */
1409 KFDF_PRECREATE
, /* flags */
1410 &GUID_NULL
/* typeid */
1412 { /* 0x0c - CSIDL_MYDOCUMENTS */
1414 CSIDL_Type_Disallowed
, /* matches WinXP--can't get its path */
1418 { /* 0x0d - CSIDL_MYMUSIC */
1422 MAKEINTRESOURCEW(IDS_MYMUSIC
),
1424 KF_CATEGORY_PERUSER
, /* category */
1425 My_MusicW
, /* name */
1426 NULL
, /* description */
1427 &FOLDERID_Profile
, /* parent */
1428 MusicW
, /* relative path */
1429 MusicParsingNameW
, /* parsing */
1431 NULL
, /* localized */
1433 NULL
, /* security */
1434 FILE_ATTRIBUTE_READONLY
, /* attributes */
1435 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1436 &GUID_NULL
/* typeid */
1438 { /* 0x0e - CSIDL_MYVIDEO */
1442 MAKEINTRESOURCEW(IDS_MYVIDEOS
),
1444 KF_CATEGORY_PERUSER
, /* category */
1445 My_VideoW
, /* name */
1446 NULL
, /* description */
1447 &FOLDERID_Profile
, /* parent */
1448 VideosW
, /* relative path */
1449 VideosParsingNameW
, /* parsing */
1451 NULL
, /* localized */
1453 NULL
, /* security */
1454 FILE_ATTRIBUTE_READONLY
, /* attributes */
1455 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1456 &GUID_NULL
/* typeid */
1458 { /* 0x0f - unassigned */
1460 CSIDL_Type_Disallowed
,
1464 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1468 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1470 KF_CATEGORY_PERUSER
, /* category */
1471 DesktopW
, /* name */
1472 NULL
, /* description */
1473 &FOLDERID_Profile
, /* parent */
1474 DesktopW
, /* relative path */
1477 NULL
, /* localized */
1479 NULL
, /* security */
1480 FILE_ATTRIBUTE_READONLY
, /* attributes */
1481 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1482 &GUID_NULL
/* typeid */
1484 { /* 0x11 - CSIDL_DRIVES */
1485 &FOLDERID_ComputerFolder
,
1486 CSIDL_Type_Disallowed
,
1490 KF_CATEGORY_VIRTUAL
, /* category */
1491 MyComputerFolderW
, /* name */
1492 NULL
, /* description */
1493 &GUID_NULL
, /* parent */
1494 NULL
, /* relative path */
1495 ComputerFolderParsingNameW
, /* parsing */
1497 NULL
, /* localized */
1499 NULL
, /* security */
1502 &GUID_NULL
/* typeid */
1504 { /* 0x12 - CSIDL_NETWORK */
1505 &FOLDERID_NetworkFolder
,
1506 CSIDL_Type_Disallowed
,
1510 KF_CATEGORY_VIRTUAL
, /* category */
1511 NetworkPlacesFolderW
, /* name */
1512 NULL
, /* description */
1513 &GUID_NULL
, /* parent */
1514 NULL
, /* relative path */
1515 NetworkFolderParsingNameW
, /* parsing */
1517 NULL
, /* localized */
1519 NULL
, /* security */
1522 &GUID_NULL
/* typeid */
1524 { /* 0x13 - CSIDL_NETHOOD */
1530 KF_CATEGORY_PERUSER
, /* category */
1531 NetHoodW
, /* name */
1532 NULL
, /* description */
1533 &FOLDERID_RoamingAppData
, /* parent */
1534 Microsoft_Windows_Network_ShortcutsW
, /* relative path */
1537 NULL
, /* localized */
1539 NULL
, /* security */
1542 &GUID_NULL
/* typeid */
1544 { /* 0x14 - CSIDL_FONTS */
1546 CSIDL_Type_WindowsPath
,
1550 KF_CATEGORY_FIXED
, /* category */
1552 NULL
, /* description */
1553 &GUID_NULL
, /* parent */
1554 NULL
, /* relative path */
1557 NULL
, /* localized */
1559 NULL
, /* security */
1562 &FOLDERID_Windows
/* typeid */
1564 { /* 0x15 - CSIDL_TEMPLATES */
1565 &FOLDERID_Templates
,
1570 KF_CATEGORY_PERUSER
, /* category */
1571 TemplatesW
, /* name */
1572 NULL
, /* description */
1573 &FOLDERID_RoamingAppData
, /* parent */
1574 Microsoft_Windows_TemplatesW
, /* relative path */
1577 NULL
, /* localized */
1579 NULL
, /* security */
1582 &GUID_NULL
/* typeid */
1584 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1585 &FOLDERID_CommonStartMenu
,
1586 CSIDL_Type_ProgramData
,
1588 Microsoft_Windows_Start_MenuW
,
1590 KF_CATEGORY_COMMON
, /* category */
1591 Common_Start_MenuW
, /* name */
1592 NULL
, /* description */
1593 &FOLDERID_ProgramData
, /* parent */
1594 Microsoft_Windows_Start_MenuW
, /* relative path */
1597 NULL
, /* localized */
1599 NULL
, /* security */
1600 FILE_ATTRIBUTE_READONLY
, /* attributes */
1602 &GUID_NULL
/* typeid */
1604 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1605 &FOLDERID_CommonPrograms
,
1606 CSIDL_Type_ProgramData
,
1608 Microsoft_Windows_Start_Menu_ProgramsW
,
1610 KF_CATEGORY_COMMON
, /* category */
1611 Common_ProgramsW
, /* name */
1612 NULL
, /* description */
1613 &FOLDERID_CommonStartMenu
, /* parent */
1614 ProgramsW
, /* relative path */
1617 NULL
, /* localized */
1619 NULL
, /* security */
1620 FILE_ATTRIBUTE_READONLY
, /* attributes */
1622 &GUID_NULL
/* typeid */
1624 { /* 0x18 - CSIDL_COMMON_STARTUP */
1625 &FOLDERID_CommonStartup
,
1626 CSIDL_Type_ProgramData
,
1628 Microsoft_Windows_Start_Menu_StartupW
,
1630 KF_CATEGORY_COMMON
, /* category */
1631 Common_StartupW
, /* name */
1632 NULL
, /* description */
1633 &FOLDERID_CommonPrograms
, /* parent */
1634 StartUpW
, /* relative path */
1637 NULL
, /* localized */
1639 NULL
, /* security */
1640 FILE_ATTRIBUTE_READONLY
, /* attributes */
1641 KFDF_PRECREATE
, /* flags */
1642 &GUID_NULL
/* typeid */
1644 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1645 &FOLDERID_PublicDesktop
,
1646 CSIDL_Type_AllUsers
,
1648 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1650 KF_CATEGORY_COMMON
, /* category */
1651 Common_DesktopW
, /* name */
1652 NULL
, /* description */
1653 &FOLDERID_Public
, /* parent */
1654 DesktopW
, /* relative path */
1657 NULL
, /* localized */
1659 NULL
, /* security */
1660 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
1661 KFDF_PRECREATE
, /* flags */
1662 &GUID_NULL
/* typeid */
1664 { /* 0x1a - CSIDL_APPDATA */
1665 &FOLDERID_RoamingAppData
,
1670 KF_CATEGORY_PERUSER
, /* category */
1671 AppDataW
, /* name */
1672 NULL
, /* description */
1673 &FOLDERID_Profile
, /* parent */
1674 AppData_RoamingW
, /* relative path */
1677 NULL
, /* localized */
1679 NULL
, /* security */
1682 &GUID_NULL
/* typeid */
1684 { /* 0x1b - CSIDL_PRINTHOOD */
1685 &FOLDERID_PrintHood
,
1690 KF_CATEGORY_PERUSER
, /* category */
1691 PrintHoodW
, /* name */
1692 NULL
, /* description */
1693 &FOLDERID_RoamingAppData
, /* parent */
1694 Microsoft_Windows_Printer_ShortcutsW
, /* relative path */
1697 NULL
, /* localized */
1699 NULL
, /* security */
1702 &GUID_NULL
/* typeid */
1704 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1705 &FOLDERID_LocalAppData
,
1708 Local_Settings_Application_DataW
,
1710 KF_CATEGORY_PERUSER
, /* category */
1711 Local_AppDataW
, /* name */
1712 NULL
, /* description */
1713 &FOLDERID_Profile
, /* parent */
1714 AppData_LocalW
, /* relative path */
1717 NULL
, /* localized */
1719 NULL
, /* security */
1721 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1722 &GUID_NULL
/* typeid */
1724 { /* 0x1d - CSIDL_ALTSTARTUP */
1726 CSIDL_Type_NonExistent
,
1730 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1732 CSIDL_Type_NonExistent
,
1736 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1737 &FOLDERID_Favorites
,
1738 CSIDL_Type_AllUsers
,
1742 KF_CATEGORY_PERUSER
, /* category */
1743 FavoritesW
, /* name */
1744 NULL
, /* description */
1745 &FOLDERID_Profile
, /* parent */
1746 FavoritesW
, /* relative path */
1749 NULL
, /* localized */
1751 NULL
, /* security */
1752 FILE_ATTRIBUTE_READONLY
, /* attributes */
1753 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1754 &GUID_NULL
/* typeid */
1756 { /* 0x20 - CSIDL_INTERNET_CACHE */
1757 &FOLDERID_InternetCache
,
1760 Local_Settings_Temporary_Internet_FilesW
,
1762 KF_CATEGORY_PERUSER
, /* category */
1764 NULL
, /* description */
1765 &FOLDERID_LocalAppData
, /* parent */
1766 Microsoft_Windows_Temporary_Internet_FilesW
, /* relative path */
1769 NULL
, /* localized */
1771 NULL
, /* security */
1773 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1774 &GUID_NULL
/* typeid */
1776 { /* 0x21 - CSIDL_COOKIES */
1782 KF_CATEGORY_PERUSER
, /* category */
1783 CookiesW
, /* name */
1784 NULL
, /* description */
1785 &FOLDERID_RoamingAppData
, /* parent */
1786 Microsoft_Windows_CookiesW
, /* relative path */
1789 NULL
, /* localized */
1791 NULL
, /* security */
1794 &GUID_NULL
/* typeid */
1796 { /* 0x22 - CSIDL_HISTORY */
1800 Local_Settings_HistoryW
,
1802 KF_CATEGORY_PERUSER
, /* category */
1803 HistoryW
, /* name */
1804 NULL
, /* description */
1805 &FOLDERID_LocalAppData
, /* parent */
1806 Microsoft_Windows_HistoryW
, /* relative path */
1809 NULL
, /* localized */
1811 NULL
, /* security */
1813 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1814 &GUID_NULL
/* typeid */
1816 { /* 0x23 - CSIDL_COMMON_APPDATA */
1817 &FOLDERID_ProgramData
,
1818 CSIDL_Type_ProgramData
,
1822 KF_CATEGORY_FIXED
, /* category */
1823 Common_AppDataW
, /* name */
1824 NULL
, /* description */
1825 &GUID_NULL
, /* parent */
1826 NULL
, /* relative path */
1829 NULL
, /* localized */
1831 NULL
, /* security */
1834 &GUID_NULL
/* typeid */
1836 { /* 0x24 - CSIDL_WINDOWS */
1838 CSIDL_Type_WindowsPath
,
1842 KF_CATEGORY_FIXED
, /* category */
1843 WindowsW
, /* name */
1844 NULL
, /* description */
1845 &GUID_NULL
, /* parent */
1846 NULL
, /* relative path */
1849 NULL
, /* localized */
1851 NULL
, /* security */
1854 &GUID_NULL
/* typeid */
1856 { /* 0x25 - CSIDL_SYSTEM */
1858 CSIDL_Type_SystemPath
,
1862 KF_CATEGORY_FIXED
, /* category */
1864 NULL
, /* description */
1865 &GUID_NULL
, /* parent */
1866 NULL
, /* relative path */
1869 NULL
, /* localized */
1871 NULL
, /* security */
1874 &GUID_NULL
/* typeid */
1876 { /* 0x26 - CSIDL_PROGRAM_FILES */
1877 &FOLDERID_ProgramFiles
,
1882 KF_CATEGORY_FIXED
, /* category */
1883 ProgramFilesW
, /* name */
1884 NULL
, /* description */
1885 &GUID_NULL
, /* parent */
1886 NULL
, /* relative path */
1889 NULL
, /* localized */
1891 NULL
, /* security */
1892 FILE_ATTRIBUTE_READONLY
, /* attributes */
1894 &GUID_NULL
/* typeid */
1896 { /* 0x27 - CSIDL_MYPICTURES */
1900 MAKEINTRESOURCEW(IDS_MYPICTURES
),
1902 KF_CATEGORY_PERUSER
, /* category */
1903 My_PicturesW
, /* name */
1904 NULL
, /* description */
1905 &FOLDERID_Profile
, /* parent */
1906 PicturesW
, /* relative path */
1907 PicturesParsingNameW
, /* parsing */
1909 NULL
, /* localized */
1911 NULL
, /* security */
1912 FILE_ATTRIBUTE_READONLY
, /* attributes */
1913 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1914 &GUID_NULL
/* typeid */
1916 { /* 0x28 - CSIDL_PROFILE */
1922 KF_CATEGORY_FIXED
, /* category */
1923 ProfileW
, /* name */
1924 NULL
, /* description */
1925 &GUID_NULL
, /* parent */
1926 NULL
, /* relative path */
1929 NULL
, /* localized */
1931 NULL
, /* security */
1934 &GUID_NULL
/* typeid */
1936 { /* 0x29 - CSIDL_SYSTEMX86 */
1937 &FOLDERID_SystemX86
,
1938 CSIDL_Type_SystemX86Path
,
1942 KF_CATEGORY_FIXED
, /* category */
1943 SystemX86W
, /* name */
1944 NULL
, /* description */
1945 &GUID_NULL
, /* parent */
1946 NULL
, /* relative path */
1949 NULL
, /* localized */
1951 NULL
, /* security */
1954 &GUID_NULL
/* typeid */
1956 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
1957 &FOLDERID_ProgramFilesX86
,
1959 ProgramFilesDirX86W
,
1962 KF_CATEGORY_FIXED
, /* category */
1963 ProgramFilesX86W
, /* name */
1964 NULL
, /* description */
1965 &GUID_NULL
, /* parent */
1966 NULL
, /* relative path */
1969 NULL
, /* localized */
1971 NULL
, /* security */
1972 FILE_ATTRIBUTE_READONLY
, /* attributes */
1974 &GUID_NULL
/* typeid */
1976 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
1977 &FOLDERID_ProgramFilesCommon
,
1980 Program_Files_Common_FilesW
,
1982 KF_CATEGORY_FIXED
, /* category */
1983 ProgramFilesCommonW
, /* name */
1984 NULL
, /* description */
1985 &GUID_NULL
, /* parent */
1986 NULL
, /* relative path */
1989 NULL
, /* localized */
1991 NULL
, /* security */
1994 &GUID_NULL
/* typeid */
1996 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
1997 &FOLDERID_ProgramFilesCommonX86
,
2000 Program_Files_x86_Common_FilesW
,
2002 KF_CATEGORY_FIXED
, /* category */
2003 ProgramFilesCommonX86W
, /* name */
2004 NULL
, /* description */
2005 &GUID_NULL
, /* parent */
2006 NULL
, /* relative path */
2009 NULL
, /* localized */
2011 NULL
, /* security */
2014 &GUID_NULL
/* typeid */
2016 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2017 &FOLDERID_CommonTemplates
,
2018 CSIDL_Type_ProgramData
,
2020 Microsoft_Windows_TemplatesW
,
2022 KF_CATEGORY_COMMON
, /* category */
2023 Common_TemplatesW
, /* name */
2024 NULL
, /* description */
2025 &FOLDERID_ProgramData
, /* parent */
2026 Microsoft_Windows_TemplatesW
, /* relative path */
2029 NULL
, /* localized */
2031 NULL
, /* security */
2034 &GUID_NULL
/* typeid */
2036 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2037 &FOLDERID_PublicDocuments
,
2038 CSIDL_Type_AllUsers
,
2042 KF_CATEGORY_COMMON
, /* category */
2043 Common_DocumentsW
, /* name */
2044 NULL
, /* description */
2045 &FOLDERID_Public
, /* parent */
2046 DocumentsW
, /* relative path */
2049 NULL
, /* localized */
2051 NULL
, /* security */
2052 FILE_ATTRIBUTE_READONLY
, /* attributes */
2053 KFDF_PRECREATE
, /* flags */
2054 &GUID_NULL
/* typeid */
2056 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2057 &FOLDERID_CommonAdminTools
,
2058 CSIDL_Type_ProgramData
,
2059 Common_Administrative_ToolsW
,
2060 Microsoft_Windows_Start_Menu_Admin_ToolsW
,
2062 KF_CATEGORY_COMMON
, /* category */
2063 Common_Administrative_ToolsW
, /* name */
2064 NULL
, /* description */
2065 &FOLDERID_CommonPrograms
, /* parent */
2066 Administrative_ToolsW
, /* relative path */
2069 NULL
, /* localized */
2071 NULL
, /* security */
2072 FILE_ATTRIBUTE_READONLY
, /* attributes */
2073 KFDF_PRECREATE
, /* flags */
2074 &GUID_NULL
/* typeid */
2076 { /* 0x30 - CSIDL_ADMINTOOLS */
2077 &FOLDERID_AdminTools
,
2079 Administrative_ToolsW
,
2080 Start_Menu_Admin_ToolsW
,
2082 KF_CATEGORY_PERUSER
, /* category */
2083 Administrative_ToolsW
, /* name */
2084 NULL
, /* description */
2085 &FOLDERID_Programs
, /* parent */
2086 Administrative_ToolsW
, /* relative path */
2089 NULL
, /* localized */
2091 NULL
, /* security */
2092 FILE_ATTRIBUTE_READONLY
, /* attributes */
2093 KFDF_PRECREATE
, /* flags */
2094 &GUID_NULL
/* typeid */
2096 { /* 0x31 - CSIDL_CONNECTIONS */
2097 &FOLDERID_ConnectionsFolder
,
2098 CSIDL_Type_Disallowed
,
2102 KF_CATEGORY_VIRTUAL
, /* category */
2103 ConnectionsFolderW
, /* name */
2104 NULL
, /* description */
2105 &GUID_NULL
, /* parent */
2106 Administrative_ToolsW
, /* relative path */
2107 ConnectionsFolderParsingNameW
, /* parsing */
2109 NULL
, /* localized */
2111 NULL
, /* security */
2114 &GUID_NULL
/* typeid */
2116 { /* 0x32 - unassigned */
2118 CSIDL_Type_Disallowed
,
2122 { /* 0x33 - unassigned */
2124 CSIDL_Type_Disallowed
,
2128 { /* 0x34 - unassigned */
2130 CSIDL_Type_Disallowed
,
2134 { /* 0x35 - CSIDL_COMMON_MUSIC */
2135 &FOLDERID_PublicMusic
,
2136 CSIDL_Type_AllUsers
,
2140 KF_CATEGORY_COMMON
, /* category */
2141 CommonMusicW
, /* name */
2142 NULL
, /* description */
2143 &FOLDERID_Public
, /* parent */
2144 MusicW
, /* relative path */
2147 NULL
, /* localized */
2149 NULL
, /* security */
2150 FILE_ATTRIBUTE_READONLY
, /* attributes */
2151 KFDF_PRECREATE
, /* flags */
2152 &GUID_NULL
/* typeid */
2154 { /* 0x36 - CSIDL_COMMON_PICTURES */
2155 &FOLDERID_PublicPictures
,
2156 CSIDL_Type_AllUsers
,
2160 KF_CATEGORY_COMMON
, /* category */
2161 CommonPicturesW
, /* name */
2162 NULL
, /* description */
2163 &FOLDERID_Public
, /* parent */
2164 PicturesW
, /* relative path */
2167 NULL
, /* localized */
2169 NULL
, /* security */
2170 FILE_ATTRIBUTE_READONLY
, /* attributes */
2171 KFDF_PRECREATE
, /* flags */
2172 &GUID_NULL
/* typeid */
2174 { /* 0x37 - CSIDL_COMMON_VIDEO */
2175 &FOLDERID_PublicVideos
,
2176 CSIDL_Type_AllUsers
,
2180 KF_CATEGORY_COMMON
, /* category */
2181 CommonVideoW
, /* name */
2182 NULL
, /* description */
2183 &FOLDERID_Public
, /* parent */
2184 VideosW
, /* relative path */
2187 NULL
, /* localized */
2189 NULL
, /* security */
2190 FILE_ATTRIBUTE_READONLY
, /* attributes */
2191 KFDF_PRECREATE
, /* flags */
2192 &GUID_NULL
/* typeid */
2194 { /* 0x38 - CSIDL_RESOURCES */
2195 &FOLDERID_ResourceDir
,
2196 CSIDL_Type_WindowsPath
,
2200 KF_CATEGORY_FIXED
, /* category */
2201 ResourceDirW
, /* name */
2202 NULL
, /* description */
2203 &GUID_NULL
, /* parent */
2204 NULL
, /* relative path */
2207 NULL
, /* localized */
2209 NULL
, /* security */
2212 &GUID_NULL
/* typeid */
2214 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2215 &FOLDERID_LocalizedResourcesDir
,
2216 CSIDL_Type_NonExistent
,
2220 KF_CATEGORY_FIXED
, /* category */
2221 LocalizedResourcesDirW
, /* name */
2222 NULL
, /* description */
2223 &GUID_NULL
, /* parent */
2224 NULL
, /* relative path */
2227 NULL
, /* localized */
2229 NULL
, /* security */
2232 &GUID_NULL
/* typeid */
2234 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2235 &FOLDERID_CommonOEMLinks
,
2236 CSIDL_Type_ProgramData
,
2240 KF_CATEGORY_COMMON
, /* category */
2241 OEM_LinksW
, /* name */
2242 NULL
, /* description */
2243 &FOLDERID_ProgramData
, /* parent */
2244 OEM_LinksW
, /* relative path */
2247 NULL
, /* localized */
2249 NULL
, /* security */
2252 &GUID_NULL
/* typeid */
2254 { /* 0x3b - CSIDL_CDBURN_AREA */
2255 &FOLDERID_CDBurning
,
2258 Local_Settings_CD_BurningW
,
2260 KF_CATEGORY_PERUSER
, /* category */
2261 CD_BurningW
, /* name */
2262 NULL
, /* description */
2263 &FOLDERID_LocalAppData
, /* parent */
2264 Microsoft_Windows_Burn_BurnW
, /* relative path */
2267 NULL
, /* localized */
2269 NULL
, /* security */
2270 FILE_ATTRIBUTE_READONLY
, /* attributes */
2271 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2272 &GUID_NULL
/* typeid */
2274 { /* 0x3c unassigned */
2276 CSIDL_Type_Disallowed
,
2280 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2282 CSIDL_Type_Disallowed
, /* FIXME */
2286 { /* 0x3e - CSIDL_PROFILES */
2288 CSIDL_Type_Disallowed
, /* oddly, this matches WinXP */
2293 &FOLDERID_AddNewPrograms
,
2294 CSIDL_Type_Disallowed
,
2298 KF_CATEGORY_VIRTUAL
, /* category */
2299 AddNewProgramsFolderW
, /* name */
2300 NULL
, /* description */
2301 &GUID_NULL
, /* parent */
2302 NULL
, /* relative path */
2303 AddNewProgramsParsingNameW
, /* parsing */
2305 NULL
, /* localized */
2307 NULL
, /* security */
2310 &GUID_NULL
/* typeid */
2313 &FOLDERID_AppUpdates
,
2314 CSIDL_Type_Disallowed
,
2318 KF_CATEGORY_VIRTUAL
, /* category */
2319 AppUpdatesFolderW
, /* name */
2320 NULL
, /* description */
2321 &GUID_NULL
, /* parent */
2322 NULL
, /* relative path */
2323 AppUpdatesParsingNameW
, /* parsing */
2325 NULL
, /* localized */
2327 NULL
, /* security */
2330 &GUID_NULL
/* typeid */
2333 &FOLDERID_ChangeRemovePrograms
,
2334 CSIDL_Type_Disallowed
,
2338 KF_CATEGORY_VIRTUAL
, /* category */
2339 ChangeRemoveProgramsFolderW
, /* name */
2340 NULL
, /* description */
2341 &GUID_NULL
, /* parent */
2342 NULL
, /* relative path */
2343 ChangeRemoveProgramsParsingNameW
, /* parsing */
2345 NULL
, /* localized */
2347 NULL
, /* security */
2350 &GUID_NULL
/* typeid */
2353 &FOLDERID_ConflictFolder
,
2354 CSIDL_Type_Disallowed
,
2358 KF_CATEGORY_VIRTUAL
, /* category */
2359 ConflictFolderW
, /* name */
2360 NULL
, /* description */
2361 &GUID_NULL
, /* parent */
2362 NULL
, /* relative path */
2363 ConflictFolderParsingNameW
, /* parsing */
2365 NULL
, /* localized */
2367 NULL
, /* security */
2370 &GUID_NULL
/* typeid */
2372 { /* 0x43 - CSIDL_CONTACTS */
2378 KF_CATEGORY_PERUSER
, /* category */
2379 ContactsW
, /* name */
2380 NULL
, /* description */
2381 &FOLDERID_Profile
, /* parent */
2382 ContactsW
, /* relative path */
2383 ContactsParsingNameW
, /* parsing */
2385 NULL
, /* localized */
2387 NULL
, /* security */
2388 FILE_ATTRIBUTE_READONLY
, /* attributes */
2389 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2390 &GUID_NULL
/* typeid */
2393 &FOLDERID_DeviceMetadataStore
,
2394 CSIDL_Type_Disallowed
, /* FIXME */
2398 KF_CATEGORY_COMMON
, /* category */
2399 Device_Metadata_StoreW
, /* name */
2400 NULL
, /* description */
2401 &FOLDERID_ProgramData
, /* parent */
2402 Microsoft_Windows_DeviceMetadataStoreW
, /* relative path */
2405 NULL
, /* localized */
2407 NULL
, /* security */
2410 &GUID_NULL
/* typeid */
2419 &FOLDERID_DocumentsLibrary
,
2420 CSIDL_Type_Disallowed
, /* FIXME */
2424 KF_CATEGORY_PERUSER
, /* category */
2425 DocumentsLibraryW
, /* name */
2426 NULL
, /* description */
2427 &FOLDERID_Libraries
, /* parent */
2428 Documents_librarymsW
, /* relative path */
2429 DocumentsLibraryParsingNameW
, /* parsing */
2431 NULL
, /* localized */
2433 NULL
, /* security */
2435 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2436 &GUID_NULL
/* typeid */
2438 { /* 0x47 - CSIDL_DOWNLOADS */
2439 &FOLDERID_Downloads
,
2444 KF_CATEGORY_PERUSER
, /* category */
2445 DownloadsW
, /* name */
2446 NULL
, /* description */
2447 &FOLDERID_Profile
, /* parent */
2448 DownloadsW
, /* relative path */
2451 NULL
, /* localized */
2453 NULL
, /* security */
2454 FILE_ATTRIBUTE_READONLY
, /* attributes */
2455 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2456 &GUID_NULL
/* typeid */
2460 CSIDL_Type_Disallowed
,
2464 KF_CATEGORY_VIRTUAL
, /* category */
2466 NULL
, /* description */
2467 &GUID_NULL
, /* parent */
2468 NULL
, /* relative path */
2469 GamesParsingNameW
, /* parsing */
2471 NULL
, /* localized */
2473 NULL
, /* security */
2476 &GUID_NULL
/* typeid */
2479 &FOLDERID_GameTasks
,
2480 CSIDL_Type_Disallowed
, /* FIXME */
2484 KF_CATEGORY_PERUSER
, /* category */
2485 GameTasksW
, /* name */
2486 NULL
, /* description */
2487 &FOLDERID_LocalAppData
, /* parent */
2488 Microsoft_Windows_GameExplorerW
, /* relative path */
2491 NULL
, /* localized */
2493 NULL
, /* security */
2495 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2496 &GUID_NULL
/* typeid */
2499 &FOLDERID_HomeGroup
,
2500 CSIDL_Type_Disallowed
,
2504 KF_CATEGORY_VIRTUAL
, /* category */
2505 HomeGroupFolderW
, /* name */
2506 NULL
, /* description */
2507 &GUID_NULL
, /* parent */
2508 NULL
, /* relative path */
2509 HomeGroupParsingNameW
, /* parsing */
2511 NULL
, /* localized */
2513 NULL
, /* security */
2516 &GUID_NULL
/* typeid */
2519 &FOLDERID_ImplicitAppShortcuts
,
2520 CSIDL_Type_Disallowed
, /* FIXME */
2524 KF_CATEGORY_PERUSER
, /* category */
2525 ImplicitAppShortcutsW
, /* name */
2526 NULL
, /* description */
2527 &FOLDERID_UserPinned
, /* parent */
2528 ImplicitAppShortcutsW
, /* relative path */
2531 NULL
, /* localized */
2533 NULL
, /* security */
2535 KFDF_PRECREATE
, /* flags */
2536 &GUID_NULL
/* typeid */
2539 &FOLDERID_Libraries
,
2540 CSIDL_Type_Disallowed
, /* FIXME */
2544 KF_CATEGORY_PERUSER
, /* category */
2545 LibrariesW
, /* name */
2546 NULL
, /* description */
2547 &FOLDERID_RoamingAppData
, /* parent */
2548 Microsoft_Windows_LibrariesW
, /* relative path */
2551 NULL
, /* localized */
2553 NULL
, /* security */
2555 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2556 &GUID_NULL
/* typeid */
2558 { /* 0x4d - CSIDL_LINKS */
2564 KF_CATEGORY_PERUSER
, /* category */
2566 NULL
, /* description */
2567 &FOLDERID_Profile
, /* parent */
2568 LinksW
, /* relative path */
2569 LinksParsingNameW
, /* parsing */
2571 NULL
, /* localized */
2573 NULL
, /* security */
2574 FILE_ATTRIBUTE_READONLY
, /* attributes */
2575 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2576 &GUID_NULL
/* typeid */
2578 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2579 &FOLDERID_LocalAppDataLow
,
2584 KF_CATEGORY_PERUSER
, /* category */
2585 LocalAppDataLowW
, /* name */
2586 NULL
, /* description */
2587 &FOLDERID_Profile
, /* parent */
2588 AppData_LocalLowW
, /* relative path */
2591 NULL
, /* localized */
2593 NULL
, /* security */
2594 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
, /* attributes */
2595 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2596 &GUID_NULL
/* typeid */
2599 &FOLDERID_MusicLibrary
,
2600 CSIDL_Type_Disallowed
, /* FIXME */
2604 KF_CATEGORY_PERUSER
, /* category */
2605 MusicLibraryW
, /* name */
2606 NULL
, /* description */
2607 &FOLDERID_Libraries
, /* parent */
2608 Music_librarymsW
, /* relative path */
2609 MusicLibraryParsingNameW
, /* parsing */
2611 NULL
, /* localized */
2613 NULL
, /* security */
2615 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2616 &GUID_NULL
/* typeid */
2619 &FOLDERID_OriginalImages
,
2620 CSIDL_Type_Disallowed
, /* FIXME */
2624 KF_CATEGORY_PERUSER
, /* category */
2625 Original_ImagesW
, /* name */
2626 NULL
, /* description */
2627 &FOLDERID_LocalAppData
, /* parent */
2628 Microsoft_Windows_Photo_Gallery_Original_ImagesW
, /* relative path */
2631 NULL
, /* localized */
2633 NULL
, /* security */
2636 &GUID_NULL
/* typeid */
2639 &FOLDERID_PhotoAlbums
,
2642 Pictures_Slide_ShowsW
,
2644 KF_CATEGORY_PERUSER
, /* category */
2645 PhotoAlbumsW
, /* name */
2646 NULL
, /* description */
2647 &FOLDERID_Pictures
, /* parent */
2648 Slide_ShowsW
, /* relative path */
2651 NULL
, /* localized */
2653 NULL
, /* security */
2654 FILE_ATTRIBUTE_READONLY
, /* attributes */
2656 &GUID_NULL
/* typeid */
2659 &FOLDERID_PicturesLibrary
,
2660 CSIDL_Type_Disallowed
, /* FIXME */
2664 KF_CATEGORY_PERUSER
, /* category */
2665 PicturesLibraryW
, /* name */
2666 NULL
, /* description */
2667 &FOLDERID_Libraries
, /* parent */
2668 Pictures_librarymsW
, /* relative path */
2669 PicturesLibraryParsingNameW
, /* parsing */
2671 NULL
, /* localized */
2673 NULL
, /* security */
2675 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2676 &GUID_NULL
/* typeid */
2679 &FOLDERID_Playlists
,
2684 KF_CATEGORY_PERUSER
, /* category */
2685 PlaylistsW
, /* name */
2686 NULL
, /* description */
2687 &FOLDERID_Music
, /* parent */
2688 PlaylistsW
, /* relative path */
2691 NULL
, /* localized */
2693 NULL
, /* security */
2694 FILE_ATTRIBUTE_READONLY
, /* attributes */
2696 &GUID_NULL
/* typeid */
2699 &FOLDERID_ProgramFilesX64
,
2700 CSIDL_Type_NonExistent
,
2704 KF_CATEGORY_FIXED
, /* category */
2705 ProgramFilesX64W
, /* name */
2706 NULL
, /* description */
2707 &GUID_NULL
, /* parent */
2708 NULL
, /* relative path */
2711 NULL
, /* localized */
2713 NULL
, /* security */
2716 &GUID_NULL
/* typeid */
2719 &FOLDERID_ProgramFilesCommonX64
,
2720 CSIDL_Type_NonExistent
,
2724 KF_CATEGORY_FIXED
, /* category */
2725 ProgramFilesCommonX64W
, /* name */
2726 NULL
, /* description */
2727 &GUID_NULL
, /* parent */
2728 NULL
, /* relative path */
2731 NULL
, /* localized */
2733 NULL
, /* security */
2736 &GUID_NULL
/* typeid */
2740 CSIDL_Type_CurrVer
, /* FIXME */
2744 KF_CATEGORY_FIXED
, /* category */
2746 NULL
, /* description */
2747 &GUID_NULL
, /* parent */
2748 NULL
, /* relative path */
2749 PublicParsingNameW
, /* parsing */
2751 NULL
, /* localized */
2753 NULL
, /* security */
2754 FILE_ATTRIBUTE_READONLY
, /* attributes */
2755 KFDF_PRECREATE
, /* flags */
2756 &GUID_NULL
/* typeid */
2759 &FOLDERID_PublicDownloads
,
2760 CSIDL_Type_AllUsers
,
2764 KF_CATEGORY_COMMON
, /* category */
2765 CommonDownloadsW
, /* name */
2766 NULL
, /* description */
2767 &FOLDERID_Public
, /* parent */
2768 DownloadsW
, /* relative path */
2771 NULL
, /* localized */
2773 NULL
, /* security */
2774 FILE_ATTRIBUTE_READONLY
, /* attributes */
2775 KFDF_PRECREATE
, /* flags */
2776 &GUID_NULL
/* typeid */
2779 &FOLDERID_PublicGameTasks
,
2780 CSIDL_Type_ProgramData
,
2782 Microsoft_Windows_GameExplorerW
,
2784 KF_CATEGORY_COMMON
, /* category */
2785 PublicGameTasksW
, /* name */
2786 NULL
, /* description */
2787 &FOLDERID_ProgramData
, /* parent */
2788 Microsoft_Windows_GameExplorerW
, /* relative path */
2791 NULL
, /* localized */
2793 NULL
, /* security */
2795 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2796 &GUID_NULL
/* typeid */
2799 &FOLDERID_PublicLibraries
,
2800 CSIDL_Type_AllUsers
,
2802 Microsoft_Windows_LibrariesW
,
2804 KF_CATEGORY_COMMON
, /* category */
2805 PublicLibrariesW
, /* name */
2806 NULL
, /* description */
2807 &FOLDERID_Public
, /* parent */
2808 LibrariesW
, /* relative path */
2811 NULL
, /* localized */
2813 NULL
, /* security */
2814 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
2815 KFDF_PRECREATE
, /* flags */
2816 &GUID_NULL
/* typeid */
2819 &FOLDERID_PublicRingtones
,
2820 CSIDL_Type_ProgramData
,
2822 Microsoft_Windows_RingtonesW
,
2824 KF_CATEGORY_COMMON
, /* category */
2825 CommonRingtonesW
, /* name */
2826 NULL
, /* description */
2827 &FOLDERID_ProgramData
, /* parent */
2828 Microsoft_Windows_RingtonesW
, /* relative path */
2831 NULL
, /* localized */
2833 NULL
, /* security */
2835 KFDF_PRECREATE
, /* flags */
2836 &GUID_NULL
/* typeid */
2839 &FOLDERID_QuickLaunch
,
2840 CSIDL_Type_Disallowed
, /* FIXME */
2844 KF_CATEGORY_PERUSER
, /* category */
2845 Quick_LaunchW
, /* name */
2846 NULL
, /* description */
2847 &FOLDERID_RoamingAppData
, /* parent */
2848 Microsoft_Internet_Explorer_Quick_LaunchW
, /* relative path */
2851 NULL
, /* localized */
2853 NULL
, /* security */
2856 &GUID_NULL
/* typeid */
2859 &FOLDERID_RecordedTVLibrary
,
2860 CSIDL_Type_Disallowed
, /* FIXME */
2864 KF_CATEGORY_COMMON
, /* category */
2865 RecordedTVLibraryW
, /* name */
2866 NULL
, /* description */
2867 &FOLDERID_PublicLibraries
, /* parent */
2868 RecordedTV_librarymsW
, /* relative path */
2871 NULL
, /* localized */
2873 NULL
, /* security */
2875 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2876 &GUID_NULL
/* typeid */
2879 &FOLDERID_Ringtones
,
2880 CSIDL_Type_Disallowed
, /* FIXME */
2884 KF_CATEGORY_PERUSER
, /* category */
2885 RingtonesW
, /* name */
2886 NULL
, /* description */
2887 &FOLDERID_LocalAppData
, /* parent */
2888 Microsoft_Windows_RingtonesW
, /* relative path */
2891 NULL
, /* localized */
2893 NULL
, /* security */
2895 KFDF_PRECREATE
, /* flags */
2896 &GUID_NULL
/* typeid */
2899 &FOLDERID_SampleMusic
,
2900 CSIDL_Type_AllUsers
,
2902 Music_Sample_MusicW
,
2904 KF_CATEGORY_COMMON
, /* category */
2905 SampleMusicW
, /* name */
2906 NULL
, /* description */
2907 &FOLDERID_PublicMusic
, /* parent */
2908 Sample_MusicW
, /* relative path */
2911 NULL
, /* localized */
2913 NULL
, /* security */
2914 FILE_ATTRIBUTE_READONLY
, /* attributes */
2915 KFDF_PRECREATE
, /* flags */
2916 &GUID_NULL
/* typeid */
2919 &FOLDERID_SamplePictures
,
2920 CSIDL_Type_AllUsers
,
2922 Pictures_Sample_PicturesW
,
2924 KF_CATEGORY_COMMON
, /* category */
2925 SamplePicturesW
, /* name */
2926 NULL
, /* description */
2927 &FOLDERID_PublicPictures
, /* parent */
2928 Sample_PicturesW
, /* relative path */
2931 NULL
, /* localized */
2933 NULL
, /* security */
2934 FILE_ATTRIBUTE_READONLY
, /* attributes */
2935 KFDF_PRECREATE
, /* flags */
2936 &GUID_NULL
/* typeid */
2939 &FOLDERID_SamplePlaylists
,
2940 CSIDL_Type_AllUsers
,
2942 Music_Sample_PlaylistsW
,
2944 KF_CATEGORY_COMMON
, /* category */
2945 SamplePlaylistsW
, /* name */
2946 NULL
, /* description */
2947 &FOLDERID_PublicMusic
, /* parent */
2948 Sample_PlaylistsW
, /* relative path */
2951 NULL
, /* localized */
2953 NULL
, /* security */
2954 FILE_ATTRIBUTE_READONLY
, /* attributes */
2955 KFDF_PRECREATE
, /* flags */
2956 &GUID_NULL
/* typeid */
2959 &FOLDERID_SampleVideos
,
2960 CSIDL_Type_AllUsers
,
2962 Videos_Sample_VideosW
,
2964 KF_CATEGORY_COMMON
, /* category */
2965 SampleVideosW
, /* name */
2966 NULL
, /* description */
2967 &FOLDERID_PublicVideos
, /* parent */
2968 Sample_VideosW
, /* relative path */
2971 NULL
, /* localized */
2973 NULL
, /* security */
2974 FILE_ATTRIBUTE_READONLY
, /* attributes */
2975 KFDF_PRECREATE
, /* flags */
2976 &GUID_NULL
/* typeid */
2978 { /* 0x62 - CSIDL_SAVED_GAMES */
2979 &FOLDERID_SavedGames
,
2984 KF_CATEGORY_PERUSER
, /* category */
2985 SavedGamesW
, /* name */
2986 NULL
, /* description */
2987 &FOLDERID_Profile
, /* parent */
2988 Saved_GamesW
, /* relative path */
2989 SavedGamesParsingNameW
, /* parsing */
2991 NULL
, /* localized */
2993 NULL
, /* security */
2994 FILE_ATTRIBUTE_READONLY
, /* attributes */
2995 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2996 &GUID_NULL
/* typeid */
2998 { /* 0x63 - CSIDL_SEARCHES */
2999 &FOLDERID_SavedSearches
,
3004 KF_CATEGORY_PERUSER
, /* category */
3005 SearchesW
, /* name */
3006 NULL
, /* description */
3007 &FOLDERID_Profile
, /* parent */
3008 SearchesW
, /* relative path */
3009 SavedSearchesParsingNameW
, /* parsing */
3011 NULL
, /* localized */
3013 NULL
, /* security */
3014 FILE_ATTRIBUTE_READONLY
, /* attributes */
3015 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
3016 &GUID_NULL
/* typeid */
3019 &FOLDERID_SEARCH_CSC
,
3020 CSIDL_Type_Disallowed
,
3024 KF_CATEGORY_VIRTUAL
, /* category */
3025 CSCFolderW
, /* name */
3026 NULL
, /* description */
3027 &GUID_NULL
, /* parent */
3028 NULL
, /* relative path */
3029 SEARCH_CSCParsingNameW
, /* parsing */
3031 NULL
, /* localized */
3033 NULL
, /* security */
3036 &GUID_NULL
/* typeid */
3039 &FOLDERID_SEARCH_MAPI
,
3040 CSIDL_Type_Disallowed
,
3044 KF_CATEGORY_VIRTUAL
, /* category */
3045 MAPIFolderW
, /* name */
3046 NULL
, /* description */
3047 &GUID_NULL
, /* parent */
3048 NULL
, /* relative path */
3049 SEARCH_MAPIParsingNameW
, /* parsing */
3051 NULL
, /* localized */
3053 NULL
, /* security */
3056 &GUID_NULL
/* typeid */
3059 &FOLDERID_SearchHome
,
3060 CSIDL_Type_Disallowed
,
3064 KF_CATEGORY_VIRTUAL
, /* category */
3065 SearchHomeFolderW
, /* name */
3066 NULL
, /* description */
3067 &GUID_NULL
, /* parent */
3068 NULL
, /* relative path */
3069 SearchHomeParsingNameW
, /* parsing */
3071 NULL
, /* localized */
3073 NULL
, /* security */
3076 &GUID_NULL
/* typeid */
3079 &FOLDERID_SidebarDefaultParts
,
3080 CSIDL_Type_Disallowed
, /* FIXME */
3084 KF_CATEGORY_COMMON
, /* category */
3085 Default_GadgetsW
, /* name */
3086 NULL
, /* description */
3087 &FOLDERID_ProgramFiles
, /* parent */
3088 Windows_Sidebar_GadgetsW
, /* relative path */
3091 NULL
, /* localized */
3093 NULL
, /* security */
3096 &GUID_NULL
/* typeid */
3099 &FOLDERID_SidebarParts
,
3100 CSIDL_Type_Disallowed
, /* FIXME */
3104 KF_CATEGORY_PERUSER
, /* category */
3105 GadgetsW
, /* name */
3106 NULL
, /* description */
3107 &FOLDERID_LocalAppData
, /* parent */
3108 Microsoft_Windows_Sidebar_GadgetsW
, /* relative path */
3111 NULL
, /* localized */
3113 NULL
, /* security */
3116 &GUID_NULL
/* typeid */
3119 &FOLDERID_SyncManagerFolder
,
3120 CSIDL_Type_Disallowed
,
3124 KF_CATEGORY_VIRTUAL
, /* category */
3125 SyncCenterFolderW
, /* name */
3126 NULL
, /* description */
3127 &GUID_NULL
, /* parent */
3128 NULL
, /* relative path */
3129 SyncManagerFolderParsingNameW
, /* parsing */
3131 NULL
, /* localized */
3133 NULL
, /* security */
3136 &GUID_NULL
/* typeid */
3139 &FOLDERID_SyncResultsFolder
,
3140 CSIDL_Type_Disallowed
,
3144 KF_CATEGORY_VIRTUAL
, /* category */
3145 SyncResultsFolderW
, /* name */
3146 NULL
, /* description */
3147 &GUID_NULL
, /* parent */
3148 NULL
, /* relative path */
3149 SyncResultsFolderParsingNameW
, /* parsing */
3151 NULL
, /* localized */
3153 NULL
, /* security */
3156 &GUID_NULL
/* typeid */
3159 &FOLDERID_SyncSetupFolder
,
3160 CSIDL_Type_Disallowed
,
3164 KF_CATEGORY_VIRTUAL
, /* category */
3165 SyncSetupFolderW
, /* name */
3166 NULL
, /* description */
3167 &GUID_NULL
, /* parent */
3168 NULL
, /* relative path */
3169 SyncSetupFolderParsingNameW
, /* parsing */
3171 NULL
, /* localized */
3173 NULL
, /* security */
3176 &GUID_NULL
/* typeid */
3179 &FOLDERID_UserPinned
,
3180 CSIDL_Type_Disallowed
, /* FIXME */
3184 KF_CATEGORY_PERUSER
, /* category */
3185 User_PinnedW
, /* name */
3186 NULL
, /* description */
3187 &FOLDERID_QuickLaunch
, /* parent */
3188 User_PinnedW
, /* relative path */
3191 NULL
, /* localized */
3193 NULL
, /* security */
3194 FILE_ATTRIBUTE_HIDDEN
, /* attributes */
3195 KFDF_PRECREATE
, /* flags */
3196 &GUID_NULL
/* typeid */
3199 &FOLDERID_UserProfiles
,
3204 KF_CATEGORY_FIXED
, /* category */
3205 UserProfilesW
, /* name */
3206 NULL
, /* description */
3207 &GUID_NULL
, /* parent */
3208 NULL
, /* relative path */
3211 NULL
, /* localized */
3213 NULL
, /* security */
3214 FILE_ATTRIBUTE_READONLY
, /* attributes */
3215 KFDF_PRECREATE
, /* flags */
3216 &GUID_NULL
/* typeid */
3219 &FOLDERID_UserProgramFiles
,
3220 CSIDL_Type_Disallowed
, /* FIXME */
3224 KF_CATEGORY_PERUSER
, /* category */
3225 UserProgramFilesW
, /* name */
3226 NULL
, /* description */
3227 &FOLDERID_LocalAppData
, /* parent */
3228 ProgramsW
, /* relative path */
3231 NULL
, /* localized */
3233 NULL
, /* security */
3236 &GUID_NULL
/* typeid */
3239 &FOLDERID_UserProgramFilesCommon
,
3240 CSIDL_Type_Disallowed
, /* FIXME */
3244 KF_CATEGORY_PERUSER
, /* category */
3245 UserProgramFilesCommonW
, /* name */
3246 NULL
, /* description */
3247 &FOLDERID_UserProgramFiles
, /* parent */
3248 CommonW
, /* relative path */
3251 NULL
, /* localized */
3253 NULL
, /* security */
3256 &GUID_NULL
/* typeid */
3259 &FOLDERID_UsersFiles
,
3260 CSIDL_Type_Disallowed
,
3264 KF_CATEGORY_VIRTUAL
, /* category */
3265 UsersFilesFolderW
, /* name */
3266 NULL
, /* description */
3267 &GUID_NULL
, /* parent */
3268 NULL
, /* relative path */
3269 UsersFilesParsingNameW
, /* parsing */
3271 NULL
, /* localized */
3273 NULL
, /* security */
3276 &GUID_NULL
/* typeid */
3279 &FOLDERID_UsersLibraries
,
3280 CSIDL_Type_Disallowed
,
3284 KF_CATEGORY_VIRTUAL
, /* category */
3285 UsersLibrariesFolderW
, /* name */
3286 NULL
, /* description */
3287 &GUID_NULL
, /* parent */
3288 NULL
, /* relative path */
3289 UsersLibrariesParsingNameW
, /* parsing */
3291 NULL
, /* localized */
3293 NULL
, /* security */
3296 &GUID_NULL
/* typeid */
3299 &FOLDERID_VideosLibrary
,
3300 CSIDL_Type_Disallowed
, /* FIXME */
3304 KF_CATEGORY_PERUSER
, /* category */
3305 VideosLibraryW
, /* name */
3306 NULL
, /* description */
3307 &GUID_NULL
, /* parent */
3308 Videos_librarymsW
, /* relative path */
3309 VideosLibraryParsingNameW
, /* parsing */
3311 NULL
, /* localized */
3313 NULL
, /* security */
3316 &GUID_NULL
/* typeid */
3320 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
);
3322 /* Gets the value named value from the registry key
3323 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3324 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3325 * is assumed to be MAX_PATH WCHARs in length.
3326 * If it exists, expands the value and writes the expanded value to
3327 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3328 * Returns successful error code if the value was retrieved from the registry,
3329 * and a failure otherwise.
3331 static HRESULT
_SHGetUserShellFolderPath(HKEY rootKey
, LPCWSTR userPrefix
,
3332 LPCWSTR value
, LPWSTR path
)
3335 WCHAR shellFolderPath
[MAX_PATH
], userShellFolderPath
[MAX_PATH
];
3336 LPCWSTR pShellFolderPath
, pUserShellFolderPath
;
3337 HKEY userShellFolderKey
, shellFolderKey
;
3338 DWORD dwType
, dwPathLen
;
3340 TRACE("%p,%s,%s,%p\n",rootKey
, debugstr_w(userPrefix
), debugstr_w(value
),
3345 strcpyW(shellFolderPath
, userPrefix
);
3346 PathAddBackslashW(shellFolderPath
);
3347 strcatW(shellFolderPath
, szSHFolders
);
3348 pShellFolderPath
= shellFolderPath
;
3349 strcpyW(userShellFolderPath
, userPrefix
);
3350 PathAddBackslashW(userShellFolderPath
);
3351 strcatW(userShellFolderPath
, szSHUserFolders
);
3352 pUserShellFolderPath
= userShellFolderPath
;
3356 pUserShellFolderPath
= szSHUserFolders
;
3357 pShellFolderPath
= szSHFolders
;
3360 if (RegCreateKeyW(rootKey
, pShellFolderPath
, &shellFolderKey
))
3362 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath
));
3365 if (RegCreateKeyW(rootKey
, pUserShellFolderPath
, &userShellFolderKey
))
3367 TRACE("Failed to create %s\n",
3368 debugstr_w(pUserShellFolderPath
));
3369 RegCloseKey(shellFolderKey
);
3373 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3374 if (!RegQueryValueExW(userShellFolderKey
, value
, NULL
, &dwType
,
3375 (LPBYTE
)path
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3379 path
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3380 if (dwType
== REG_EXPAND_SZ
&& path
[0] == '%')
3382 WCHAR szTemp
[MAX_PATH
];
3384 _SHExpandEnvironmentStrings(path
, szTemp
);
3385 lstrcpynW(path
, szTemp
, MAX_PATH
);
3387 ret
= RegSetValueExW(shellFolderKey
, value
, 0, REG_SZ
, (LPBYTE
)path
,
3388 (strlenW(path
) + 1) * sizeof(WCHAR
));
3389 if (ret
!= ERROR_SUCCESS
)
3390 hr
= HRESULT_FROM_WIN32(ret
);
3396 RegCloseKey(shellFolderKey
);
3397 RegCloseKey(userShellFolderKey
);
3398 TRACE("returning 0x%08x\n", hr
);
3402 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3403 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3404 * - The entry's szDefaultPath may be either a string value or an integer
3405 * resource identifier. In the latter case, the string value of the resource
3407 * - Depending on the entry's type, the path may begin with an (unexpanded)
3408 * environment variable name. The caller is responsible for expanding
3409 * environment strings if so desired.
3410 * The types that are prepended with environment variables are:
3411 * CSIDL_Type_User: %USERPROFILE%
3412 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3413 * CSIDL_Type_CurrVer: %SystemDrive%
3414 * (Others might make sense too, but as yet are unneeded.)
3416 static HRESULT
_SHGetDefaultValue(BYTE folder
, LPWSTR pszPath
)
3419 WCHAR resourcePath
[MAX_PATH
];
3420 LPCWSTR pDefaultPath
= NULL
;
3422 TRACE("0x%02x,%p\n", folder
, pszPath
);
3424 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3425 return E_INVALIDARG
;
3427 return E_INVALIDARG
;
3435 case CSIDL_PROGRAM_FILES
:
3436 case CSIDL_PROGRAM_FILESX86
:
3437 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3438 folder
= is_wow64
? CSIDL_PROGRAM_FILESX86
: CSIDL_PROGRAM_FILES
;
3440 case CSIDL_PROGRAM_FILES_COMMON
:
3441 case CSIDL_PROGRAM_FILES_COMMONX86
:
3442 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3443 folder
= is_wow64
? CSIDL_PROGRAM_FILES_COMMONX86
: CSIDL_PROGRAM_FILES_COMMON
;
3448 if (CSIDL_Data
[folder
].szDefaultPath
&&
3449 IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
))
3451 if (LoadStringW(shell32_hInstance
,
3452 LOWORD(CSIDL_Data
[folder
].szDefaultPath
), resourcePath
, MAX_PATH
))
3455 pDefaultPath
= resourcePath
;
3459 FIXME("(%d,%s), LoadString failed, missing translation?\n", folder
,
3460 debugstr_w(pszPath
));
3467 pDefaultPath
= CSIDL_Data
[folder
].szDefaultPath
;
3471 switch (CSIDL_Data
[folder
].type
)
3473 case CSIDL_Type_User
:
3474 strcpyW(pszPath
, UserProfileW
);
3476 case CSIDL_Type_AllUsers
:
3477 strcpyW(pszPath
, AllUsersProfileW
);
3479 case CSIDL_Type_ProgramData
:
3480 strcpyW(pszPath
, ProgramDataVarW
);
3482 case CSIDL_Type_CurrVer
:
3483 strcpyW(pszPath
, SystemDriveW
);
3486 ; /* no corresponding env. var, do nothing */
3490 PathAddBackslashW(pszPath
);
3491 strcatW(pszPath
, pDefaultPath
);
3494 TRACE("returning 0x%08x\n", hr
);
3498 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3499 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3500 * can be overridden in the HKLM\\szCurrentVersion key.
3501 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3502 * the registry, uses _SHGetDefaultValue to get the value.
3504 static HRESULT
_SHGetCurrentVersionPath(DWORD dwFlags
, BYTE folder
,
3509 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3511 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3512 return E_INVALIDARG
;
3513 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_CurrVer
)
3514 return E_INVALIDARG
;
3516 return E_INVALIDARG
;
3518 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3519 hr
= _SHGetDefaultValue(folder
, pszPath
);
3524 if (RegCreateKeyW(HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hKey
))
3528 DWORD dwType
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3530 if (RegQueryValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, NULL
,
3531 &dwType
, (LPBYTE
)pszPath
, &dwPathLen
) ||
3532 (dwType
!= REG_SZ
&& dwType
!= REG_EXPAND_SZ
))
3534 hr
= _SHGetDefaultValue(folder
, pszPath
);
3535 dwType
= REG_EXPAND_SZ
;
3538 case CSIDL_PROGRAM_FILESX86
:
3539 case CSIDL_PROGRAM_FILES_COMMONX86
:
3540 /* these two should never be set on 32-bit setups */
3544 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3545 if (!is_wow64
) break;
3549 RegSetValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, 0, dwType
,
3550 (LPBYTE
)pszPath
, (strlenW(pszPath
)+1)*sizeof(WCHAR
));
3555 pszPath
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3561 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3565 static LPWSTR
_GetUserSidStringFromToken(HANDLE Token
)
3567 char InfoBuffer
[64];
3568 PTOKEN_USER UserInfo
;
3572 UserInfo
= (PTOKEN_USER
) InfoBuffer
;
3573 if (! GetTokenInformation(Token
, TokenUser
, InfoBuffer
, sizeof(InfoBuffer
),
3576 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
3578 UserInfo
= HeapAlloc(GetProcessHeap(), 0, InfoSize
);
3579 if (UserInfo
== NULL
)
3581 if (! GetTokenInformation(Token
, TokenUser
, UserInfo
, InfoSize
,
3584 HeapFree(GetProcessHeap(), 0, UserInfo
);
3589 if (! ConvertSidToStringSidW(UserInfo
->User
.Sid
, &SidStr
))
3592 if (UserInfo
!= (PTOKEN_USER
) InfoBuffer
)
3593 HeapFree(GetProcessHeap(), 0, UserInfo
);
3598 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3599 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3600 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3601 * - if hToken is -1, looks in HKEY_USERS\.Default
3602 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3603 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3604 * calls _SHGetDefaultValue for it.
3606 static HRESULT
_SHGetUserProfilePath(HANDLE hToken
, DWORD dwFlags
, BYTE folder
,
3609 const WCHAR
*szValueName
;
3613 TRACE("%p,0x%08x,0x%02x,%p\n", hToken
, dwFlags
, folder
, pszPath
);
3615 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3616 return E_INVALIDARG
;
3617 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_User
)
3618 return E_INVALIDARG
;
3620 return E_INVALIDARG
;
3622 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3624 if (hToken
!= NULL
&& hToken
!= (HANDLE
)-1)
3626 FIXME("unsupported for user other than current or default\n");
3629 hr
= _SHGetDefaultValue(folder
, pszPath
);
3633 LPCWSTR userPrefix
= NULL
;
3636 if (hToken
== (HANDLE
)-1)
3638 hRootKey
= HKEY_USERS
;
3639 userPrefix
= DefaultW
;
3641 else if (hToken
== NULL
)
3642 hRootKey
= HKEY_CURRENT_USER
;
3645 hRootKey
= HKEY_USERS
;
3646 userPrefix
= _GetUserSidStringFromToken(hToken
);
3647 if (userPrefix
== NULL
)
3654 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3655 szValueName
= CSIDL_Data
[folder
].szValueName
;
3658 StringFromGUID2( CSIDL_Data
[folder
].id
, buffer
, 39 );
3659 szValueName
= &buffer
[0];
3662 hr
= _SHGetUserShellFolderPath(hRootKey
, userPrefix
, szValueName
, pszPath
);
3663 if (FAILED(hr
) && hRootKey
!= HKEY_LOCAL_MACHINE
)
3664 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
, szValueName
, pszPath
);
3666 hr
= _SHGetDefaultValue(folder
, pszPath
);
3667 if (userPrefix
!= NULL
&& userPrefix
!= DefaultW
)
3668 LocalFree((HLOCAL
) userPrefix
);
3671 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3675 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3676 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3677 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3678 * If this fails, falls back to _SHGetDefaultValue.
3680 static HRESULT
_SHGetAllUsersProfilePath(DWORD dwFlags
, BYTE folder
,
3685 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3687 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
3688 return E_INVALIDARG
;
3689 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_AllUsers
&& CSIDL_Data
[folder
].type
!= CSIDL_Type_ProgramData
)
3690 return E_INVALIDARG
;
3692 return E_INVALIDARG
;
3694 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3695 hr
= _SHGetDefaultValue(folder
, pszPath
);
3698 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
,
3699 CSIDL_Data
[folder
].szValueName
, pszPath
);
3701 hr
= _SHGetDefaultValue(folder
, pszPath
);
3703 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3707 static HRESULT
_SHOpenProfilesKey(PHKEY pKey
)
3712 lRet
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, ProfileListW
, 0, NULL
, 0,
3713 KEY_ALL_ACCESS
, NULL
, pKey
, &disp
);
3714 return HRESULT_FROM_WIN32(lRet
);
3717 /* Reads the value named szValueName from the key profilesKey (assumed to be
3718 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3719 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3720 * szDefault to the registry).
3722 static HRESULT
_SHGetProfilesValue(HKEY profilesKey
, LPCWSTR szValueName
,
3723 LPWSTR szValue
, LPCWSTR szDefault
)
3726 DWORD type
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3729 TRACE("%p,%s,%p,%s\n", profilesKey
, debugstr_w(szValueName
), szValue
,
3730 debugstr_w(szDefault
));
3731 lRet
= RegQueryValueExW(profilesKey
, szValueName
, NULL
, &type
,
3732 (LPBYTE
)szValue
, &dwPathLen
);
3733 if (!lRet
&& (type
== REG_SZ
|| type
== REG_EXPAND_SZ
) && dwPathLen
3736 dwPathLen
/= sizeof(WCHAR
);
3737 szValue
[dwPathLen
] = '\0';
3742 /* Missing or invalid value, set a default */
3743 lstrcpynW(szValue
, szDefault
, MAX_PATH
);
3744 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName
),
3745 debugstr_w(szValue
));
3746 lRet
= RegSetValueExW(profilesKey
, szValueName
, 0, REG_EXPAND_SZ
,
3748 (strlenW(szValue
) + 1) * sizeof(WCHAR
));
3750 hr
= HRESULT_FROM_WIN32(lRet
);
3754 TRACE("returning 0x%08x (output value is %s)\n", hr
, debugstr_w(szValue
));
3758 /* Attempts to expand environment variables from szSrc into szDest, which is
3759 * assumed to be MAX_PATH characters in length. Before referring to the
3760 * environment, handles a few variables directly, because the environment
3761 * variables may not be set when this is called (as during Wine's installation
3762 * when default values are being written to the registry).
3763 * The directly handled environment variables, and their source, are:
3764 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3765 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3767 * If one of the directly handled environment variables is expanded, only
3768 * expands a single variable, and only in the beginning of szSrc.
3770 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
)
3773 WCHAR szTemp
[MAX_PATH
], szProfilesPrefix
[MAX_PATH
] = { 0 };
3776 TRACE("%s, %p\n", debugstr_w(szSrc
), szDest
);
3778 if (!szSrc
|| !szDest
) return E_INVALIDARG
;
3780 /* short-circuit if there's nothing to expand */
3781 if (szSrc
[0] != '%')
3783 strcpyW(szDest
, szSrc
);
3787 /* Get the profile prefix, we'll probably be needing it */
3788 hr
= _SHOpenProfilesKey(&key
);
3791 WCHAR def_val
[MAX_PATH
];
3793 /* get the system drive */
3794 GetSystemDirectoryW(def_val
, MAX_PATH
);
3795 if (def_val
[1] == ':') strcpyW( def_val
+ 3, szDefaultProfileDirW
);
3796 else FIXME("non-drive system paths unsupported\n");
3798 hr
= _SHGetProfilesValue(key
, ProfilesDirectoryW
, szProfilesPrefix
, def_val
);
3802 strcpyW(szTemp
, szSrc
);
3803 while (SUCCEEDED(hr
) && szTemp
[0] == '%')
3805 if (!strncmpiW(szTemp
, AllUsersProfileW
, strlenW(AllUsersProfileW
)))
3807 WCHAR szAllUsers
[MAX_PATH
];
3809 strcpyW(szDest
, szProfilesPrefix
);
3810 hr
= _SHGetProfilesValue(key
, AllUsersProfileValueW
,
3811 szAllUsers
, AllUsersW
);
3812 PathAppendW(szDest
, szAllUsers
);
3813 PathAppendW(szDest
, szTemp
+ strlenW(AllUsersProfileW
));
3815 else if (!strncmpiW(szTemp
, ProgramDataVarW
, strlenW(ProgramDataVarW
)))
3817 WCHAR szProgramData
[MAX_PATH
], def_val
[MAX_PATH
];
3818 HKEY shellFolderKey
;
3819 DWORD dwType
, dwPathLen
= sizeof(def_val
);
3820 BOOL in_registry
= FALSE
;
3822 if (!RegCreateKeyW(HKEY_LOCAL_MACHINE
, szSHFolders
, &shellFolderKey
))
3824 if (!RegQueryValueExW(shellFolderKey
, Common_AppDataW
, NULL
, &dwType
,
3825 (LPBYTE
)def_val
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3828 RegCloseKey(shellFolderKey
);
3833 GetSystemDirectoryW(def_val
, MAX_PATH
);
3834 if (def_val
[1] == ':') strcpyW( def_val
+ 3, ProgramDataW
);
3835 else FIXME("non-drive system paths unsupported\n");
3838 hr
= _SHGetProfilesValue(key
, ProgramDataW
, szProgramData
, def_val
);
3839 PathAppendW(szDest
, szProgramData
);
3840 PathAppendW(szDest
, szTemp
+ strlenW(ProgramDataVarW
));
3842 else if (!strncmpiW(szTemp
, UserProfileW
, strlenW(UserProfileW
)))
3844 WCHAR userName
[MAX_PATH
];
3845 DWORD userLen
= MAX_PATH
;
3847 strcpyW(szDest
, szProfilesPrefix
);
3848 GetUserNameW(userName
, &userLen
);
3849 PathAppendW(szDest
, userName
);
3850 PathAppendW(szDest
, szTemp
+ strlenW(UserProfileW
));
3852 else if (!strncmpiW(szTemp
, SystemDriveW
, strlenW(SystemDriveW
)))
3854 GetSystemDirectoryW(szDest
, MAX_PATH
);
3855 if (szDest
[1] != ':')
3857 FIXME("non-drive system paths unsupported\n");
3862 strcpyW(szDest
+ 3, szTemp
+ strlenW(SystemDriveW
) + 1);
3868 DWORD ret
= ExpandEnvironmentStringsW(szSrc
, szDest
, MAX_PATH
);
3871 hr
= E_NOT_SUFFICIENT_BUFFER
;
3873 hr
= HRESULT_FROM_WIN32(GetLastError());
3877 if (SUCCEEDED(hr
) && szDest
[0] == '%')
3878 strcpyW(szTemp
, szDest
);
3881 /* terminate loop */
3888 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr
,
3889 debugstr_w(szSrc
), debugstr_w(szDest
));
3893 /*************************************************************************
3894 * SHGetFolderPathW [SHELL32.@]
3896 * Convert nFolder to path.
3900 * Failure: standard HRESULT error codes.
3903 * Most values can be overridden in either
3904 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3905 * or in the same location in HKLM.
3906 * The "Shell Folders" registry key was used in NT4 and earlier systems.
3907 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
3908 * changes made to it are made to the former key too. This synchronization is
3909 * done on-demand: not until someone requests the value of one of these paths
3910 * (by calling one of the SHGet functions) is the value synchronized.
3911 * Furthermore, the HKCU paths take precedence over the HKLM paths.
3913 HRESULT WINAPI
SHGetFolderPathW(
3914 HWND hwndOwner
, /* [I] owner window */
3915 int nFolder
, /* [I] CSIDL identifying the folder */
3916 HANDLE hToken
, /* [I] access token */
3917 DWORD dwFlags
, /* [I] which path to return */
3918 LPWSTR pszPath
) /* [O] converted path */
3920 HRESULT hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, NULL
, pszPath
);
3921 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) == hr
)
3922 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
3926 HRESULT WINAPI
SHGetFolderPathAndSubDirA(
3927 HWND hwndOwner
, /* [I] owner window */
3928 int nFolder
, /* [I] CSIDL identifying the folder */
3929 HANDLE hToken
, /* [I] access token */
3930 DWORD dwFlags
, /* [I] which path to return */
3931 LPCSTR pszSubPath
, /* [I] sub directory of the specified folder */
3932 LPSTR pszPath
) /* [O] converted path */
3936 LPWSTR pszSubPathW
= NULL
;
3937 LPWSTR pszPathW
= NULL
;
3938 TRACE("%08x,%08x,%s\n",nFolder
, dwFlags
, debugstr_w(pszSubPathW
));
3941 pszPathW
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* sizeof(WCHAR
));
3943 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
3947 TRACE("%08x,%08x,%s\n",nFolder
, dwFlags
, debugstr_w(pszSubPathW
));
3949 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
3950 * set (null), or an empty string.therefore call it without the parameter set
3951 * if pszSubPath is an empty string
3953 if (pszSubPath
&& pszSubPath
[0]) {
3954 length
= MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, NULL
, 0);
3955 pszSubPathW
= HeapAlloc(GetProcessHeap(), 0, length
* sizeof(WCHAR
));
3957 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
3960 MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, pszSubPathW
, length
);
3963 hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, pszSubPathW
, pszPathW
);
3965 if (SUCCEEDED(hr
) && pszPath
)
3966 WideCharToMultiByte(CP_ACP
, 0, pszPathW
, -1, pszPath
, MAX_PATH
, NULL
, NULL
);
3969 HeapFree(GetProcessHeap(), 0, pszPathW
);
3970 HeapFree(GetProcessHeap(), 0, pszSubPathW
);
3974 /*************************************************************************
3975 * SHGetFolderPathAndSubDirW [SHELL32.@]
3977 HRESULT WINAPI
SHGetFolderPathAndSubDirW(
3978 HWND hwndOwner
, /* [I] owner window */
3979 int nFolder
, /* [I] CSIDL identifying the folder */
3980 HANDLE hToken
, /* [I] access token */
3981 DWORD dwFlags
, /* [I] which path to return */
3982 LPCWSTR pszSubPath
,/* [I] sub directory of the specified folder */
3983 LPWSTR pszPath
) /* [O] converted path */
3986 WCHAR szBuildPath
[MAX_PATH
], szTemp
[MAX_PATH
];
3987 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
3991 TRACE("%p,%p,nFolder=0x%04x,%s\n", hwndOwner
,pszPath
,nFolder
,debugstr_w(pszSubPath
));
3993 /* Windows always NULL-terminates the resulting path regardless of success
3994 * or failure, so do so first
3999 if (folder
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
4000 return E_INVALIDARG
;
4001 if ((SHGFP_TYPE_CURRENT
!= dwFlags
) && (SHGFP_TYPE_DEFAULT
!= dwFlags
))
4002 return E_INVALIDARG
;
4004 type
= CSIDL_Data
[folder
].type
;
4007 case CSIDL_Type_Disallowed
:
4010 case CSIDL_Type_NonExistent
:
4013 case CSIDL_Type_WindowsPath
:
4014 GetWindowsDirectoryW(szTemp
, MAX_PATH
);
4015 if (CSIDL_Data
[folder
].szDefaultPath
&&
4016 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4017 *CSIDL_Data
[folder
].szDefaultPath
)
4019 PathAddBackslashW(szTemp
);
4020 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4024 case CSIDL_Type_SystemPath
:
4025 GetSystemDirectoryW(szTemp
, MAX_PATH
);
4026 if (CSIDL_Data
[folder
].szDefaultPath
&&
4027 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4028 *CSIDL_Data
[folder
].szDefaultPath
)
4030 PathAddBackslashW(szTemp
);
4031 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4035 case CSIDL_Type_SystemX86Path
:
4036 if (!GetSystemWow64DirectoryW(szTemp
, MAX_PATH
)) GetSystemDirectoryW(szTemp
, MAX_PATH
);
4037 if (CSIDL_Data
[folder
].szDefaultPath
&&
4038 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4039 *CSIDL_Data
[folder
].szDefaultPath
)
4041 PathAddBackslashW(szTemp
);
4042 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4046 case CSIDL_Type_CurrVer
:
4047 hr
= _SHGetCurrentVersionPath(dwFlags
, folder
, szTemp
);
4049 case CSIDL_Type_User
:
4050 hr
= _SHGetUserProfilePath(hToken
, dwFlags
, folder
, szTemp
);
4052 case CSIDL_Type_AllUsers
:
4053 case CSIDL_Type_ProgramData
:
4054 hr
= _SHGetAllUsersProfilePath(dwFlags
, folder
, szTemp
);
4057 FIXME("bogus type %d, please fix\n", type
);
4062 /* Expand environment strings if necessary */
4064 hr
= _SHExpandEnvironmentStrings(szTemp
, szBuildPath
);
4066 strcpyW(szBuildPath
, szTemp
);
4068 if (FAILED(hr
)) goto end
;
4071 /* make sure the new path does not exceed the buffer length
4072 * and remember to backslash and terminate it */
4073 if(MAX_PATH
< (lstrlenW(szBuildPath
) + lstrlenW(pszSubPath
) + 2)) {
4074 hr
= HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE
);
4077 PathAppendW(szBuildPath
, pszSubPath
);
4078 PathRemoveBackslashW(szBuildPath
);
4080 /* Copy the path if it's available before we might return */
4081 if (SUCCEEDED(hr
) && pszPath
)
4082 strcpyW(pszPath
, szBuildPath
);
4084 /* if we don't care about existing directories we are ready */
4085 if(nFolder
& CSIDL_FLAG_DONT_VERIFY
) goto end
;
4087 if (PathFileExistsW(szBuildPath
)) goto end
;
4089 /* not existing but we are not allowed to create it. The return value
4090 * is verified against shell32 version 6.0.
4092 if (!(nFolder
& CSIDL_FLAG_CREATE
))
4094 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4098 /* create directory/directories */
4099 ret
= SHCreateDirectoryExW(hwndOwner
, szBuildPath
, NULL
);
4100 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4102 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath
));
4107 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath
));
4109 TRACE("returning 0x%08x (final path is %s)\n", hr
, debugstr_w(szBuildPath
));
4113 /*************************************************************************
4114 * SHGetFolderPathA [SHELL32.@]
4116 * See SHGetFolderPathW.
4118 HRESULT WINAPI
SHGetFolderPathA(
4125 WCHAR szTemp
[MAX_PATH
];
4128 TRACE("%p,%p,nFolder=0x%04x\n",hwndOwner
,pszPath
,nFolder
);
4132 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
, dwFlags
, szTemp
);
4133 if (SUCCEEDED(hr
) && pszPath
)
4134 WideCharToMultiByte(CP_ACP
, 0, szTemp
, -1, pszPath
, MAX_PATH
, NULL
,
4140 /* For each folder in folders, if its value has not been set in the registry,
4141 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4142 * folder's type) to get the unexpanded value first.
4143 * Writes the unexpanded value to User Shell Folders, and queries it with
4144 * SHGetFolderPathW to force the creation of the directory if it doesn't
4145 * already exist. SHGetFolderPathW also returns the expanded value, which
4146 * this then writes to Shell Folders.
4148 static HRESULT
_SHRegisterFolders(HKEY hRootKey
, HANDLE hToken
,
4149 LPCWSTR szUserShellFolderPath
, LPCWSTR szShellFolderPath
, const UINT folders
[],
4152 const WCHAR
*szValueName
;
4155 WCHAR path
[MAX_PATH
];
4157 HKEY hUserKey
= NULL
, hKey
= NULL
;
4158 DWORD dwType
, dwPathLen
;
4161 TRACE("%p,%p,%s,%p,%u\n", hRootKey
, hToken
,
4162 debugstr_w(szUserShellFolderPath
), folders
, foldersLen
);
4164 ret
= RegCreateKeyW(hRootKey
, szUserShellFolderPath
, &hUserKey
);
4166 hr
= HRESULT_FROM_WIN32(ret
);
4169 ret
= RegCreateKeyW(hRootKey
, szShellFolderPath
, &hKey
);
4171 hr
= HRESULT_FROM_WIN32(ret
);
4173 for (i
= 0; SUCCEEDED(hr
) && i
< foldersLen
; i
++)
4175 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
4177 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4178 szValueName
= CSIDL_Data
[folders
[i
]].szValueName
;
4179 if (!szValueName
&& CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4181 StringFromGUID2( CSIDL_Data
[folders
[i
]].id
, buffer
, 39 );
4182 szValueName
= &buffer
[0];
4185 if (RegQueryValueExW(hUserKey
, szValueName
, NULL
,
4186 &dwType
, (LPBYTE
)path
, &dwPathLen
) || (dwType
!= REG_SZ
&&
4187 dwType
!= REG_EXPAND_SZ
))
4190 if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4191 _SHGetUserProfilePath(hToken
, SHGFP_TYPE_DEFAULT
, folders
[i
],
4193 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_AllUsers
||
4194 CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_ProgramData
)
4195 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT
, folders
[i
], path
);
4196 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_WindowsPath
)
4198 GetWindowsDirectoryW(path
, MAX_PATH
);
4199 if (CSIDL_Data
[folders
[i
]].szDefaultPath
&&
4200 !IS_INTRESOURCE(CSIDL_Data
[folders
[i
]].szDefaultPath
))
4202 PathAddBackslashW(path
);
4203 strcatW(path
, CSIDL_Data
[folders
[i
]].szDefaultPath
);
4210 ret
= RegSetValueExW(hUserKey
, szValueName
, 0, REG_EXPAND_SZ
,
4211 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4213 hr
= HRESULT_FROM_WIN32(ret
);
4216 hr
= SHGetFolderPathW(NULL
, folders
[i
] | CSIDL_FLAG_CREATE
,
4217 hToken
, SHGFP_TYPE_DEFAULT
, path
);
4218 ret
= RegSetValueExW(hKey
, szValueName
, 0, REG_SZ
,
4219 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4221 hr
= HRESULT_FROM_WIN32(ret
);
4227 RegCloseKey(hUserKey
);
4231 TRACE("returning 0x%08x\n", hr
);
4235 static HRESULT
_SHRegisterUserShellFolders(BOOL bDefault
)
4237 static const UINT folders
[] = {
4248 CSIDL_DESKTOPDIRECTORY
,
4252 CSIDL_LOCAL_APPDATA
,
4253 CSIDL_INTERNET_CACHE
,
4262 CSIDL_APPDATA_LOCALLOW
,
4266 WCHAR userShellFolderPath
[MAX_PATH
], shellFolderPath
[MAX_PATH
];
4267 LPCWSTR pUserShellFolderPath
, pShellFolderPath
;
4272 TRACE("%s\n", bDefault
? "TRUE" : "FALSE");
4275 hToken
= (HANDLE
)-1;
4276 hRootKey
= HKEY_USERS
;
4277 strcpyW(userShellFolderPath
, DefaultW
);
4278 PathAddBackslashW(userShellFolderPath
);
4279 strcatW(userShellFolderPath
, szSHUserFolders
);
4280 pUserShellFolderPath
= userShellFolderPath
;
4281 strcpyW(shellFolderPath
, DefaultW
);
4282 PathAddBackslashW(shellFolderPath
);
4283 strcatW(shellFolderPath
, szSHFolders
);
4284 pShellFolderPath
= shellFolderPath
;
4289 hRootKey
= HKEY_CURRENT_USER
;
4290 pUserShellFolderPath
= szSHUserFolders
;
4291 pShellFolderPath
= szSHFolders
;
4294 hr
= _SHRegisterFolders(hRootKey
, hToken
, pUserShellFolderPath
,
4295 pShellFolderPath
, folders
, sizeof(folders
) / sizeof(folders
[0]));
4296 TRACE("returning 0x%08x\n", hr
);
4300 static HRESULT
_SHRegisterCommonShellFolders(void)
4302 static const UINT folders
[] = {
4303 CSIDL_COMMON_STARTMENU
,
4304 CSIDL_COMMON_PROGRAMS
,
4305 CSIDL_COMMON_STARTUP
,
4306 CSIDL_COMMON_DESKTOPDIRECTORY
,
4307 CSIDL_COMMON_FAVORITES
,
4308 CSIDL_COMMON_APPDATA
,
4309 CSIDL_COMMON_TEMPLATES
,
4310 CSIDL_COMMON_DOCUMENTS
,
4311 CSIDL_COMMON_ADMINTOOLS
,
4313 CSIDL_COMMON_PICTURES
,
4319 hr
= _SHRegisterFolders(HKEY_LOCAL_MACHINE
, NULL
, szSHUserFolders
,
4320 szSHFolders
, folders
, sizeof(folders
) / sizeof(folders
[0]));
4321 TRACE("returning 0x%08x\n", hr
);
4325 /******************************************************************************
4326 * _SHAppendToUnixPath [Internal]
4328 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
4329 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
4330 * and replaces backslashes with slashes.
4333 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
4334 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
4340 static inline BOOL
_SHAppendToUnixPath(char *szBasePath
, LPCWSTR pwszSubPath
) {
4341 WCHAR wszSubPath
[MAX_PATH
];
4342 int cLen
= strlen(szBasePath
);
4345 if (IS_INTRESOURCE(pwszSubPath
)) {
4346 if (!LoadStringW(shell32_hInstance
, LOWORD(pwszSubPath
), wszSubPath
, MAX_PATH
)) {
4347 /* Fall back to hard coded defaults. */
4348 switch (LOWORD(pwszSubPath
)) {
4350 lstrcpyW(wszSubPath
, DocumentsW
);
4353 lstrcpyW(wszSubPath
, My_MusicW
);
4355 case IDS_MYPICTURES
:
4356 lstrcpyW(wszSubPath
, My_PicturesW
);
4359 lstrcpyW(wszSubPath
, My_VideosW
);
4362 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath
));
4367 lstrcpyW(wszSubPath
, pwszSubPath
);
4370 if (szBasePath
[cLen
-1] != '/') szBasePath
[cLen
++] = '/';
4372 if (!WideCharToMultiByte(CP_UNIXCP
, 0, wszSubPath
, -1, szBasePath
+ cLen
,
4373 FILENAME_MAX
- cLen
, NULL
, NULL
))
4378 pBackslash
= szBasePath
+ cLen
;
4379 while ((pBackslash
= strchr(pBackslash
, '\\'))) *pBackslash
= '/';
4384 /******************************************************************************
4385 * _SHCreateSymbolicLinks [Internal]
4387 * Sets up symbol links for various shell folders to point into the users home
4388 * directory. We do an educated guess about what the user would probably want:
4389 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4390 * wine's 'My Documents' to point there. Furthermore, we imply that the user
4391 * is a Windows lover and has no problem with wine creating 'My Pictures',
4392 * 'My Music' and 'My Videos' subfolders under '$HOME/My Documents', if those
4393 * do not already exits. We put appropriate symbolic links in place for those,
4395 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4396 * point directly to $HOME. We assume the user to be a unix hacker who does not
4397 * want wine to create anything anywhere besides the .wine directory. So, if
4398 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4399 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4400 * directory, and try to link to that. If that fails, then we symlink to
4401 * $HOME directly. The same holds fo 'My Pictures' and 'My Videos'.
4402 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4403 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4405 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4407 static void _SHCreateSymbolicLinks(void)
4409 UINT aidsMyStuff
[] = { IDS_MYPICTURES
, IDS_MYVIDEOS
, IDS_MYMUSIC
}, i
;
4410 const WCHAR
* MyOSXStuffW
[] = { PicturesW
, MoviesW
, MusicW
};
4411 int acsidlMyStuff
[] = { CSIDL_MYPICTURES
, CSIDL_MYVIDEO
, CSIDL_MYMUSIC
};
4412 static const char * const xdg_dirs
[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" };
4413 static const unsigned int num
= sizeof(xdg_dirs
) / sizeof(xdg_dirs
[0]);
4414 WCHAR wszTempPath
[MAX_PATH
];
4415 char szPersonalTarget
[FILENAME_MAX
], *pszPersonal
;
4416 char szMyStuffTarget
[FILENAME_MAX
], *pszMyStuff
;
4417 char szDesktopTarget
[FILENAME_MAX
], *pszDesktop
;
4418 struct stat statFolder
;
4419 const char *pszHome
;
4421 char ** xdg_results
;
4422 char * xdg_desktop_dir
;
4424 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4425 hr
= SHGetFolderPathW(NULL
, CSIDL_PERSONAL
|CSIDL_FLAG_CREATE
, NULL
,
4426 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4427 if (FAILED(hr
)) return;
4428 pszPersonal
= wine_get_unix_file_name(wszTempPath
);
4429 if (!pszPersonal
) return;
4431 hr
= XDG_UserDirLookup(xdg_dirs
, num
, &xdg_results
);
4432 if (FAILED(hr
)) xdg_results
= NULL
;
4434 pszHome
= getenv("HOME");
4435 if (pszHome
&& !stat(pszHome
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4439 /* Check if there's already a Wine-specific 'My Documents' folder */
4440 strcpy(szPersonalTarget
, pszHome
);
4441 if (_SHAppendToUnixPath(szPersonalTarget
, MAKEINTRESOURCEW(IDS_PERSONAL
)) &&
4442 !stat(szPersonalTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4444 /* '$HOME/My Documents' exists. Create 'My Pictures',
4445 * 'My Videos' and 'My Music' subfolders or fail silently if
4446 * they already exist.
4448 for (i
= 0; i
< sizeof(aidsMyStuff
)/sizeof(*aidsMyStuff
); i
++)
4450 strcpy(szMyStuffTarget
, szPersonalTarget
);
4451 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4452 mkdir(szMyStuffTarget
, 0777);
4457 /* Try to point to the XDG Documents folder */
4458 if (xdg_results
&& xdg_results
[num
-2] &&
4459 !stat(xdg_results
[num
-2], &statFolder
) &&
4460 S_ISDIR(statFolder
.st_mode
))
4462 strcpy(szPersonalTarget
, xdg_results
[num
-2]);
4466 /* Or the hardcoded / OS X Documents folder */
4467 strcpy(szPersonalTarget
, pszHome
);
4468 if (_SHAppendToUnixPath(szPersonalTarget
, DocumentsW
) &&
4469 !stat(szPersonalTarget
, &statFolder
) &&
4470 S_ISDIR(statFolder
.st_mode
))
4473 /* As a last resort point to $HOME. */
4474 strcpy(szPersonalTarget
, pszHome
);
4478 /* Replace 'My Documents' directory with a symlink or fail silently if not empty. */
4479 remove(pszPersonal
);
4480 symlink(szPersonalTarget
, pszPersonal
);
4484 /* '$HOME' doesn't exist. Create 'My Pictures', 'My Videos' and 'My Music' subdirs
4485 * in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */
4487 strcpy(szPersonalTarget
, pszPersonal
);
4488 for (i
= 0; i
< sizeof(aidsMyStuff
)/sizeof(aidsMyStuff
[0]); i
++) {
4489 strcpy(szMyStuffTarget
, szPersonalTarget
);
4490 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4491 mkdir(szMyStuffTarget
, 0777);
4495 /* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
4496 for (i
=0; i
< sizeof(aidsMyStuff
)/sizeof(aidsMyStuff
[0]); i
++)
4498 /* Create the current 'My Whatever' folder and get its unix path. */
4499 hr
= SHGetFolderPathW(NULL
, acsidlMyStuff
[i
]|CSIDL_FLAG_CREATE
, NULL
,
4500 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4501 if (FAILED(hr
)) continue;
4503 pszMyStuff
= wine_get_unix_file_name(wszTempPath
);
4504 if (!pszMyStuff
) continue;
4508 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4509 strcpy(szMyStuffTarget
, szPersonalTarget
);
4510 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])) &&
4511 !stat(szMyStuffTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4514 /* Try the XDG_XXX_DIR folder */
4515 if (xdg_results
&& xdg_results
[i
])
4517 strcpy(szMyStuffTarget
, xdg_results
[i
]);
4521 /* Or the OS X folder (these are never localized) */
4524 strcpy(szMyStuffTarget
, pszHome
);
4525 if (_SHAppendToUnixPath(szMyStuffTarget
, MyOSXStuffW
[i
]) &&
4526 !stat(szMyStuffTarget
, &statFolder
) &&
4527 S_ISDIR(statFolder
.st_mode
))
4531 /* As a last resort point to the same location as 'My Documents' */
4532 strcpy(szMyStuffTarget
, szPersonalTarget
);
4536 symlink(szMyStuffTarget
, pszMyStuff
);
4537 HeapFree(GetProcessHeap(), 0, pszMyStuff
);
4540 /* Last but not least, the Desktop folder */
4542 strcpy(szDesktopTarget
, pszHome
);
4544 strcpy(szDesktopTarget
, pszPersonal
);
4545 HeapFree(GetProcessHeap(), 0, pszPersonal
);
4547 xdg_desktop_dir
= xdg_results
? xdg_results
[num
- 1] : NULL
;
4548 if (xdg_desktop_dir
||
4549 (_SHAppendToUnixPath(szDesktopTarget
, DesktopW
) &&
4550 !stat(szDesktopTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
)))
4552 hr
= SHGetFolderPathW(NULL
, CSIDL_DESKTOPDIRECTORY
|CSIDL_FLAG_CREATE
, NULL
,
4553 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4554 if (SUCCEEDED(hr
) && (pszDesktop
= wine_get_unix_file_name(wszTempPath
)))
4557 if (xdg_desktop_dir
)
4558 symlink(xdg_desktop_dir
, pszDesktop
);
4560 symlink(szDesktopTarget
, pszDesktop
);
4561 HeapFree(GetProcessHeap(), 0, pszDesktop
);
4565 /* Free resources allocated by XDG_UserDirLookup() */
4568 for (i
= 0; i
< num
; i
++)
4569 HeapFree(GetProcessHeap(), 0, xdg_results
[i
]);
4570 HeapFree(GetProcessHeap(), 0, xdg_results
);
4574 /******************************************************************************
4575 * create_extra_folders [Internal]
4577 * Create some extra folders that don't have a standard CSIDL definition.
4579 static HRESULT
create_extra_folders(void)
4581 static const WCHAR environW
[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4582 static const WCHAR microsoftW
[] = {'M','i','c','r','o','s','o','f','t',0};
4583 static const WCHAR TempW
[] = {'T','e','m','p',0};
4584 static const WCHAR TEMPW
[] = {'T','E','M','P',0};
4585 static const WCHAR TMPW
[] = {'T','M','P',0};
4586 WCHAR path
[MAX_PATH
+5];
4589 DWORD type
, size
, ret
;
4591 ret
= RegCreateKeyW( HKEY_CURRENT_USER
, environW
, &hkey
);
4592 if (ret
) return HRESULT_FROM_WIN32( ret
);
4594 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4595 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE
| CSIDL_FLAG_CREATE
, NULL
,
4596 SHGFP_TYPE_DEFAULT
, TempW
, path
);
4599 size
= sizeof(path
);
4600 if (RegQueryValueExW( hkey
, TEMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4601 RegSetValueExW( hkey
, TEMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4602 size
= sizeof(path
);
4603 if (RegQueryValueExW( hkey
, TMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4604 RegSetValueExW( hkey
, TMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4606 RegCloseKey( hkey
);
4610 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4611 SHGFP_TYPE_DEFAULT
, microsoftW
, path
);
4617 /******************************************************************************
4618 * set_folder_attributes
4620 * Set the various folder attributes registry keys.
4622 static HRESULT
set_folder_attributes(void)
4624 static const WCHAR clsidW
[] = {'C','L','S','I','D','\\',0 };
4625 static const WCHAR shellfolderW
[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4626 static const WCHAR wfparsingW
[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4627 static const WCHAR wfdisplayW
[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4628 static const WCHAR hideasdeleteW
[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4629 static const WCHAR cfattributesW
[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4630 static const WCHAR emptyW
[] = {0};
4639 DWORD call_for_attr
;
4642 { &CLSID_UnixFolder
, TRUE
, FALSE
, FALSE
},
4643 { &CLSID_UnixDosFolder
, TRUE
, FALSE
, FALSE
,
4644 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4645 { &CLSID_FolderShortcut
, FALSE
, FALSE
, FALSE
,
4646 SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_LINK
,
4647 SFGAO_HASSUBFOLDER
|SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_FILESYSANCESTOR
},
4648 { &CLSID_MyDocuments
, TRUE
, FALSE
, FALSE
,
4649 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4650 { &CLSID_RecycleBin
, FALSE
, FALSE
, FALSE
,
4651 SFGAO_FOLDER
|SFGAO_DROPTARGET
|SFGAO_HASPROPSHEET
},
4652 { &CLSID_ControlPanel
, FALSE
, TRUE
, TRUE
,
4653 SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
}
4657 WCHAR buffer
[39 + (sizeof(clsidW
) + sizeof(shellfolderW
)) / sizeof(WCHAR
)];
4661 for (i
= 0; i
< sizeof(folders
)/sizeof(folders
[0]); i
++)
4663 strcpyW( buffer
, clsidW
);
4664 StringFromGUID2( folders
[i
].clsid
, buffer
+ strlenW(buffer
), 39 );
4665 strcatW( buffer
, shellfolderW
);
4666 res
= RegCreateKeyExW( HKEY_CLASSES_ROOT
, buffer
, 0, NULL
, 0,
4667 KEY_READ
| KEY_WRITE
, NULL
, &hkey
, NULL
);
4668 if (res
) return HRESULT_FROM_WIN32( res
);
4669 if (folders
[i
].wfparsing
)
4670 res
= RegSetValueExW( hkey
, wfparsingW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4671 if (folders
[i
].wfdisplay
)
4672 res
= RegSetValueExW( hkey
, wfdisplayW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4673 if (folders
[i
].hideasdel
)
4674 res
= RegSetValueExW( hkey
, hideasdeleteW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4675 if (folders
[i
].attr
)
4676 res
= RegSetValueExW( hkey
, szAttributes
, 0, REG_DWORD
,
4677 (const BYTE
*)&folders
[i
].attr
, sizeof(DWORD
));
4678 if (folders
[i
].call_for_attr
)
4679 res
= RegSetValueExW( hkey
, cfattributesW
, 0, REG_DWORD
,
4680 (const BYTE
*)&folders
[i
].call_for_attr
, sizeof(DWORD
));
4681 RegCloseKey( hkey
);
4686 /*************************************************************************
4687 * SHGetSpecialFolderPathA [SHELL32.@]
4689 BOOL WINAPI
SHGetSpecialFolderPathA (
4695 return SHGetFolderPathA(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4699 /*************************************************************************
4700 * SHGetSpecialFolderPathW
4702 BOOL WINAPI
SHGetSpecialFolderPathW (
4708 return SHGetFolderPathW(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4712 /*************************************************************************
4713 * SHGetSpecialFolderPath (SHELL32.175)
4715 BOOL WINAPI
SHGetSpecialFolderPathAW (
4722 if (SHELL_OsIsUnicode())
4723 return SHGetSpecialFolderPathW (hwndOwner
, szPath
, nFolder
, bCreate
);
4724 return SHGetSpecialFolderPathA (hwndOwner
, szPath
, nFolder
, bCreate
);
4727 /*************************************************************************
4728 * SHGetFolderLocation [SHELL32.@]
4730 * Gets the folder locations from the registry and creates a pidl.
4734 * nFolder [I] CSIDL_xxxxx
4735 * hToken [I] token representing user, or NULL for current user, or -1 for
4737 * dwReserved [I] must be zero
4738 * ppidl [O] PIDL of a special folder
4742 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
4745 * Creates missing reg keys and directories.
4746 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
4747 * virtual folders that are handled here.
4749 HRESULT WINAPI
SHGetFolderLocation(
4754 LPITEMIDLIST
*ppidl
)
4756 HRESULT hr
= E_INVALIDARG
;
4758 TRACE("%p 0x%08x %p 0x%08x %p\n",
4759 hwndOwner
, nFolder
, hToken
, dwReserved
, ppidl
);
4762 return E_INVALIDARG
;
4764 return E_INVALIDARG
;
4766 /* The virtual folders' locations are not user-dependent */
4768 switch (nFolder
& CSIDL_FOLDER_MASK
)
4771 *ppidl
= _ILCreateDesktop();
4774 case CSIDL_PERSONAL
:
4775 *ppidl
= _ILCreateMyDocuments();
4778 case CSIDL_INTERNET
:
4779 *ppidl
= _ILCreateIExplore();
4782 case CSIDL_CONTROLS
:
4783 *ppidl
= _ILCreateControlPanel();
4786 case CSIDL_PRINTERS
:
4787 *ppidl
= _ILCreatePrinters();
4790 case CSIDL_BITBUCKET
:
4791 *ppidl
= _ILCreateBitBucket();
4795 *ppidl
= _ILCreateMyComputer();
4799 *ppidl
= _ILCreateNetwork();
4804 WCHAR szPath
[MAX_PATH
];
4806 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
,
4807 SHGFP_TYPE_CURRENT
, szPath
);
4812 TRACE("Value=%s\n", debugstr_w(szPath
));
4813 hr
= SHILCreateFromPathW(szPath
, ppidl
, &attributes
);
4815 else if (hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
))
4817 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
4818 * version 6.0 returns E_FAIL for nonexistent paths
4827 TRACE("-- (new pidl %p)\n",*ppidl
);
4831 /*************************************************************************
4832 * SHGetSpecialFolderLocation [SHELL32.@]
4835 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
4838 HRESULT WINAPI
SHGetSpecialFolderLocation(
4841 LPITEMIDLIST
* ppidl
)
4843 HRESULT hr
= E_INVALIDARG
;
4845 TRACE("(%p,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
4848 return E_INVALIDARG
;
4850 hr
= SHGetFolderLocation(hwndOwner
, nFolder
, NULL
, 0, ppidl
);
4854 static int csidl_from_id( const KNOWNFOLDERID
*id
)
4857 for (i
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); i
++)
4858 if (IsEqualGUID( CSIDL_Data
[i
].id
, id
)) return i
;
4862 /*************************************************************************
4863 * SHGetKnownFolderPath [SHELL32.@]
4865 HRESULT WINAPI
SHGetKnownFolderPath(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, WCHAR
**ret_path
)
4867 WCHAR pathW
[MAX_PATH
], tempW
[MAX_PATH
];
4871 int folder
= csidl_from_id(rfid
), shgfp_flags
;
4873 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, ret_path
);
4878 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
4880 if (flags
& ~(KF_FLAG_CREATE
|KF_FLAG_DONT_VERIFY
|KF_FLAG_NO_ALIAS
|
4881 KF_FLAG_INIT
|KF_FLAG_DEFAULT_PATH
))
4883 FIXME("flags 0x%08x not supported\n", flags
);
4884 return E_INVALIDARG
;
4887 shgfp_flags
= flags
& KF_FLAG_DEFAULT_PATH
? SHGFP_TYPE_DEFAULT
: SHGFP_TYPE_CURRENT
;
4889 type
= CSIDL_Data
[folder
].type
;
4892 case CSIDL_Type_Disallowed
:
4895 case CSIDL_Type_NonExistent
:
4899 case CSIDL_Type_WindowsPath
:
4900 GetWindowsDirectoryW(tempW
, MAX_PATH
);
4901 if (CSIDL_Data
[folder
].szDefaultPath
&&
4902 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4903 *CSIDL_Data
[folder
].szDefaultPath
)
4905 PathAddBackslashW(tempW
);
4906 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4910 case CSIDL_Type_SystemPath
:
4911 GetSystemDirectoryW(tempW
, MAX_PATH
);
4912 if (CSIDL_Data
[folder
].szDefaultPath
&&
4913 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4914 *CSIDL_Data
[folder
].szDefaultPath
)
4916 PathAddBackslashW(tempW
);
4917 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4921 case CSIDL_Type_SystemX86Path
:
4922 if (!GetSystemWow64DirectoryW(tempW
, MAX_PATH
)) GetSystemDirectoryW(tempW
, MAX_PATH
);
4923 if (CSIDL_Data
[folder
].szDefaultPath
&&
4924 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4925 *CSIDL_Data
[folder
].szDefaultPath
)
4927 PathAddBackslashW(tempW
);
4928 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
4932 case CSIDL_Type_CurrVer
:
4933 hr
= _SHGetCurrentVersionPath(shgfp_flags
, folder
, tempW
);
4935 case CSIDL_Type_User
:
4936 hr
= _SHGetUserProfilePath(token
, shgfp_flags
, folder
, tempW
);
4938 case CSIDL_Type_AllUsers
:
4939 case CSIDL_Type_ProgramData
:
4940 hr
= _SHGetAllUsersProfilePath(shgfp_flags
, folder
, tempW
);
4943 FIXME("bogus type %d, please fix\n", type
);
4951 /* Expand environment strings if necessary */
4954 hr
= _SHExpandEnvironmentStrings(tempW
, pathW
);
4959 strcpyW(pathW
, tempW
);
4961 /* if we don't care about existing directories we are ready */
4962 if (flags
& KF_FLAG_DONT_VERIFY
) goto done
;
4964 if (PathFileExistsW(pathW
)) goto done
;
4966 /* Does not exist but we are not allowed to create it. The return value
4967 * is verified against shell32 version 6.0.
4969 if (!(flags
& KF_FLAG_CREATE
))
4971 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4975 /* create directory/directories */
4976 ret
= SHCreateDirectoryExW(NULL
, pathW
, NULL
);
4977 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4979 ERR("Failed to create directory %s.\n", debugstr_w(pathW
));
4984 TRACE("Created missing system directory %s\n", debugstr_w(pathW
));
4987 TRACE("Final path is %s, %#x\n", debugstr_w(pathW
), hr
);
4989 *ret_path
= CoTaskMemAlloc((strlenW(pathW
) + 1) * sizeof(WCHAR
));
4991 return E_OUTOFMEMORY
;
4992 strcpyW(*ret_path
, pathW
);
4997 TRACE("Failed to get folder path, %#x.\n", hr
);
5002 /*************************************************************************
5003 * SHGetFolderPathEx [SHELL32.@]
5005 HRESULT WINAPI
SHGetFolderPathEx(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, LPWSTR path
, DWORD len
)
5010 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid
), flags
, token
, path
, len
);
5012 if (!path
|| !len
) return E_INVALIDARG
;
5014 hr
= SHGetKnownFolderPath( rfid
, flags
, token
, &buffer
);
5015 if (SUCCEEDED( hr
))
5017 if (strlenW( buffer
) + 1 > len
)
5019 CoTaskMemFree( buffer
);
5020 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER
);
5022 strcpyW( path
, buffer
);
5023 CoTaskMemFree( buffer
);
5029 * Internal function to convert known folder identifier to path of registry key
5030 * associated with known folder.
5033 * rfid [I] pointer to known folder identifier (may be NULL)
5034 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
5035 * lpPath [O] place to store string address. String should be
5036 * later freed using HeapFree(GetProcessHeap(),0, ... )
5038 static HRESULT
get_known_folder_registry_path(
5039 REFKNOWNFOLDERID rfid
,
5040 LPWSTR lpStringGuid
,
5043 static const WCHAR sBackslash
[] = {'\\',0};
5048 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid
), debugstr_w(lpStringGuid
), lpPath
);
5051 StringFromGUID2(rfid
, sGuid
, sizeof(sGuid
)/sizeof(sGuid
[0]));
5053 lstrcpyW(sGuid
, lpStringGuid
);
5055 length
= lstrlenW(szKnownFolderDescriptions
)+51;
5056 *lpPath
= HeapAlloc(GetProcessHeap(), 0, length
*sizeof(WCHAR
));
5062 lstrcpyW(*lpPath
, szKnownFolderDescriptions
);
5063 lstrcatW(*lpPath
, sBackslash
);
5064 lstrcatW(*lpPath
, sGuid
);
5070 static HRESULT
get_known_folder_wstr(const WCHAR
*regpath
, const WCHAR
*value
, WCHAR
**out
)
5076 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
));
5080 *out
= CoTaskMemAlloc(size
);
5082 return E_OUTOFMEMORY
;
5084 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, *out
, &size
));
5086 CoTaskMemFree(*out
);
5093 static HRESULT
get_known_folder_dword(const WCHAR
*registryPath
, const WCHAR
*value
, DWORD
*out
)
5095 DWORD dwSize
= sizeof(DWORD
);
5097 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, value
, RRF_RT_DWORD
, &dwType
, out
, &dwSize
));
5101 * Internal function to get place where folder redirection information are stored.
5104 * rfid [I] pointer to known folder identifier (may be NULL)
5105 * rootKey [O] root key where the redirection information are stored
5106 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5107 * However, besides root key, path is always that same, and is stored
5108 * as "szKnownFolderRedirections" constant
5110 static HRESULT
get_known_folder_redirection_place(
5111 REFKNOWNFOLDERID rfid
,
5115 LPWSTR lpRegistryPath
= NULL
;
5116 KF_CATEGORY category
;
5118 /* first, get known folder's category */
5119 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5122 hr
= get_known_folder_dword(lpRegistryPath
, szCategory
, &category
);
5126 if(category
== KF_CATEGORY_COMMON
)
5128 *rootKey
= HKEY_LOCAL_MACHINE
;
5131 else if(category
== KF_CATEGORY_PERUSER
)
5133 *rootKey
= HKEY_CURRENT_USER
;
5140 HeapFree(GetProcessHeap(), 0, lpRegistryPath
);
5144 static HRESULT
get_known_folder_path_by_id(REFKNOWNFOLDERID folderId
, LPWSTR lpRegistryPath
, DWORD dwFlags
, LPWSTR
*ppszPath
);
5146 static HRESULT
redirect_known_folder(
5147 REFKNOWNFOLDERID rfid
,
5149 KF_REDIRECT_FLAGS flags
,
5150 LPCWSTR pszTargetPath
,
5152 KNOWNFOLDERID
const *pExclusion
,
5156 HKEY rootKey
= HKEY_LOCAL_MACHINE
, hKey
;
5158 LPWSTR lpRegistryPath
= NULL
, lpSrcPath
= NULL
;
5159 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid
), hwnd
, flags
, debugstr_w(pszTargetPath
), cFolders
, pExclusion
, ppszError
);
5161 if (ppszError
) *ppszError
= NULL
;
5163 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5166 hr
= get_known_folder_path_by_id(rfid
, lpRegistryPath
, 0, &lpSrcPath
);
5168 HeapFree(GetProcessHeap(), 0, lpRegistryPath
);
5170 /* get path to redirection storage */
5172 hr
= get_known_folder_redirection_place(rfid
, &rootKey
);
5174 /* write redirection information */
5176 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey
, szKnownFolderRedirections
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
));
5180 StringFromGUID2(rfid
, sGuid
, sizeof(sGuid
)/sizeof(sGuid
[0]));
5182 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, sGuid
, 0, REG_SZ
, (LPBYTE
)pszTargetPath
, (lstrlenW(pszTargetPath
)+1)*sizeof(WCHAR
)));
5187 /* make sure destination path exists */
5188 SHCreateDirectory(NULL
, pszTargetPath
);
5190 /* copy content if required */
5191 if(SUCCEEDED(hr
) && (flags
& KF_REDIRECT_COPY_CONTENTS
) )
5193 static const WCHAR sWildcard
[] = {'\\','*',0};
5194 WCHAR srcPath
[MAX_PATH
+1], dstPath
[MAX_PATH
+1];
5195 SHFILEOPSTRUCTW fileOp
;
5197 ZeroMemory(srcPath
, sizeof(srcPath
));
5198 lstrcpyW(srcPath
, lpSrcPath
);
5199 lstrcatW(srcPath
, sWildcard
);
5201 ZeroMemory(dstPath
, sizeof(dstPath
));
5202 lstrcpyW(dstPath
, pszTargetPath
);
5204 ZeroMemory(&fileOp
, sizeof(fileOp
));
5206 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5207 fileOp
.wFunc
= FO_MOVE
;
5209 fileOp
.wFunc
= FO_COPY
;
5211 fileOp
.pFrom
= srcPath
;
5212 fileOp
.pTo
= dstPath
;
5213 fileOp
.fFlags
= FOF_NO_UI
;
5215 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5217 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5219 ZeroMemory(srcPath
, sizeof(srcPath
));
5220 lstrcpyW(srcPath
, lpSrcPath
);
5222 ZeroMemory(&fileOp
, sizeof(fileOp
));
5223 fileOp
.wFunc
= FO_DELETE
;
5224 fileOp
.pFrom
= srcPath
;
5225 fileOp
.fFlags
= FOF_NO_UI
;
5227 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5231 CoTaskMemFree(lpSrcPath
);
5239 IKnownFolder IKnownFolder_iface
;
5242 LPWSTR registryPath
;
5245 static inline struct knownfolder
*impl_from_IKnownFolder( IKnownFolder
*iface
)
5247 return CONTAINING_RECORD( iface
, struct knownfolder
, IKnownFolder_iface
);
5250 static ULONG WINAPI
knownfolder_AddRef(
5251 IKnownFolder
*iface
)
5253 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5254 return InterlockedIncrement( &knownfolder
->refs
);
5257 static ULONG WINAPI
knownfolder_Release(
5258 IKnownFolder
*iface
)
5260 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5261 LONG refs
= InterlockedDecrement( &knownfolder
->refs
);
5264 TRACE("destroying %p\n", knownfolder
);
5265 HeapFree( GetProcessHeap(), 0, knownfolder
->registryPath
);
5266 HeapFree( GetProcessHeap(), 0, knownfolder
);
5271 static HRESULT WINAPI
knownfolder_QueryInterface(
5272 IKnownFolder
*iface
,
5276 struct knownfolder
*This
= impl_from_IKnownFolder( iface
);
5278 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5281 if ( IsEqualGUID( riid
, &IID_IKnownFolder
) ||
5282 IsEqualGUID( riid
, &IID_IUnknown
) )
5286 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5288 TRACE("IID_IMarshal returning NULL.\n");
5289 return E_NOINTERFACE
;
5293 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5294 return E_NOINTERFACE
;
5296 IKnownFolder_AddRef( iface
);
5300 static HRESULT
knownfolder_set_id(
5301 struct knownfolder
*knownfolder
,
5302 const KNOWNFOLDERID
*kfid
)
5307 TRACE("%s\n", debugstr_guid(kfid
));
5309 knownfolder
->id
= *kfid
;
5311 /* check is it registry-registered folder */
5312 hr
= get_known_folder_registry_path(kfid
, NULL
, &knownfolder
->registryPath
);
5314 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, 0, 0, &hKey
));
5323 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5324 HeapFree(GetProcessHeap(), 0, knownfolder
->registryPath
);
5325 knownfolder
->registryPath
= NULL
;
5332 static HRESULT WINAPI
knownfolder_GetId(
5333 IKnownFolder
*iface
,
5334 KNOWNFOLDERID
*pkfid
)
5336 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5338 TRACE("%p\n", pkfid
);
5340 *pkfid
= knownfolder
->id
;
5344 static HRESULT WINAPI
knownfolder_GetCategory(
5345 IKnownFolder
*iface
,
5346 KF_CATEGORY
*pCategory
)
5348 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5351 TRACE("%p, %p\n", knownfolder
, pCategory
);
5353 /* we cannot get a category for a folder which is not registered */
5354 if(!knownfolder
->registryPath
)
5358 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, pCategory
);
5363 static HRESULT WINAPI
knownfolder_GetShellItem(
5364 IKnownFolder
*iface
,
5369 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5370 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder
, flags
, debugstr_guid(riid
), ppv
);
5371 return SHGetKnownFolderItem(&knownfolder
->id
, flags
, NULL
, riid
, ppv
);
5374 static HRESULT
get_known_folder_path(
5376 LPWSTR registryPath
,
5379 static const WCHAR sBackslash
[] = {'\\',0};
5381 DWORD dwSize
, dwType
;
5382 WCHAR path
[MAX_PATH
] = {0};
5383 WCHAR parentGuid
[39];
5384 KF_CATEGORY category
;
5385 LPWSTR parentRegistryPath
, parentPath
;
5386 HKEY hRedirectionRootKey
= NULL
;
5388 TRACE("(%s, %p)\n", debugstr_w(registryPath
), ppszPath
);
5391 /* check if folder has parent */
5392 dwSize
= sizeof(parentGuid
);
5393 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szParentFolder
, RRF_RT_REG_SZ
, &dwType
, parentGuid
, &dwSize
));
5394 if(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)) hr
= S_FALSE
;
5398 /* get parent's known folder path (recursive) */
5399 hr
= get_known_folder_registry_path(NULL
, parentGuid
, &parentRegistryPath
);
5400 if(FAILED(hr
)) return hr
;
5402 hr
= get_known_folder_path(parentGuid
, parentRegistryPath
, &parentPath
);
5404 HeapFree(GetProcessHeap(), 0, parentRegistryPath
);
5408 lstrcatW(path
, parentPath
);
5409 lstrcatW(path
, sBackslash
);
5411 HeapFree(GetProcessHeap(), 0, parentRegistryPath
);
5412 HeapFree(GetProcessHeap(), 0, parentPath
);
5415 /* check, if folder was redirected */
5417 hr
= get_known_folder_dword(registryPath
, szCategory
, &category
);
5421 if(category
== KF_CATEGORY_COMMON
)
5422 hRedirectionRootKey
= HKEY_LOCAL_MACHINE
;
5423 else if(category
== KF_CATEGORY_PERUSER
)
5424 hRedirectionRootKey
= HKEY_CURRENT_USER
;
5426 if(hRedirectionRootKey
)
5428 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, NULL
, &dwSize
));
5432 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5433 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5438 lstrcpyW(*ppszPath
, path
);
5439 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5445 /* no redirection, use previous way - read the relative path from folder definition */
5446 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, NULL
, &dwSize
));
5450 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5451 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5456 lstrcpyW(*ppszPath
, path
);
5457 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5462 TRACE("returning path: %s\n", debugstr_w(*ppszPath
));
5466 static HRESULT
get_known_folder_path_by_id(
5467 REFKNOWNFOLDERID folderId
,
5468 LPWSTR lpRegistryPath
,
5472 HRESULT hr
= E_FAIL
;
5476 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId
), debugstr_w(lpRegistryPath
), dwFlags
, ppszPath
);
5478 /* if this is registry-registered known folder, get path from registry */
5481 StringFromGUID2(folderId
, sGuid
, sizeof(sGuid
)/sizeof(sGuid
[0]));
5483 hr
= get_known_folder_path(sGuid
, lpRegistryPath
, ppszPath
);
5485 /* in other case, use older way */
5488 hr
= SHGetKnownFolderPath( folderId
, dwFlags
, NULL
, ppszPath
);
5490 if (FAILED(hr
)) return hr
;
5492 /* check if known folder really exists */
5493 dwAttributes
= GetFileAttributesW(*ppszPath
);
5494 if(dwAttributes
== INVALID_FILE_ATTRIBUTES
|| !(dwAttributes
& FILE_ATTRIBUTE_DIRECTORY
) )
5496 TRACE("directory %s not found\n", debugstr_w(*ppszPath
));
5497 CoTaskMemFree(*ppszPath
);
5499 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
5505 static HRESULT WINAPI
knownfolder_GetPath(
5506 IKnownFolder
*iface
,
5510 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5511 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, dwFlags
, ppszPath
);
5513 return get_known_folder_path_by_id(&knownfolder
->id
, knownfolder
->registryPath
, dwFlags
, ppszPath
);
5516 static HRESULT WINAPI
knownfolder_SetPath(
5517 IKnownFolder
*iface
,
5521 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5524 TRACE("(%p, 0x%08x, %s)\n", knownfolder
, dwFlags
, debugstr_w(pszPath
));
5526 /* check if the known folder is registered */
5527 if(!knownfolder
->registryPath
)
5531 hr
= redirect_known_folder(&knownfolder
->id
, NULL
, 0, pszPath
, 0, NULL
, NULL
);
5536 static HRESULT WINAPI
knownfolder_GetIDList(
5537 IKnownFolder
*iface
,
5539 PIDLIST_ABSOLUTE
*ppidl
)
5541 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5542 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, flags
, ppidl
);
5543 return SHGetKnownFolderIDList(&knownfolder
->id
, flags
, NULL
, ppidl
);
5546 static HRESULT WINAPI
knownfolder_GetFolderType(
5547 IKnownFolder
*iface
,
5548 FOLDERTYPEID
*pftid
)
5550 FIXME("%p\n", pftid
);
5554 static HRESULT WINAPI
knownfolder_GetRedirectionCapabilities(
5555 IKnownFolder
*iface
,
5556 KF_REDIRECTION_CAPABILITIES
*pCapabilities
)
5558 FIXME("%p\n", pCapabilities
);
5562 static HRESULT WINAPI
knownfolder_GetFolderDefinition(
5563 IKnownFolder
*iface
,
5564 KNOWNFOLDER_DEFINITION
*pKFD
)
5566 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5569 WCHAR parentGuid
[39];
5570 TRACE("(%p, %p)\n", knownfolder
, pKFD
);
5572 if(!pKFD
) return E_INVALIDARG
;
5574 ZeroMemory(pKFD
, sizeof(*pKFD
));
5576 /* required fields */
5577 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, &pKFD
->category
);
5581 hr
= get_known_folder_wstr(knownfolder
->registryPath
, szName
, &pKFD
->pszName
);
5585 /* optional fields */
5586 dwSize
= sizeof(parentGuid
);
5587 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, szParentFolder
,
5588 RRF_RT_REG_SZ
, NULL
, parentGuid
, &dwSize
));
5591 hr
= IIDFromString(parentGuid
, &pKFD
->fidParent
);
5596 get_known_folder_dword(knownfolder
->registryPath
, szAttributes
, &pKFD
->dwAttributes
);
5598 get_known_folder_wstr(knownfolder
->registryPath
, szRelativePath
, &pKFD
->pszRelativePath
);
5600 get_known_folder_wstr(knownfolder
->registryPath
, szParsingName
, &pKFD
->pszParsingName
);
5605 static const struct IKnownFolderVtbl knownfolder_vtbl
=
5607 knownfolder_QueryInterface
,
5609 knownfolder_Release
,
5611 knownfolder_GetCategory
,
5612 knownfolder_GetShellItem
,
5613 knownfolder_GetPath
,
5614 knownfolder_SetPath
,
5615 knownfolder_GetIDList
,
5616 knownfolder_GetFolderType
,
5617 knownfolder_GetRedirectionCapabilities
,
5618 knownfolder_GetFolderDefinition
5621 static HRESULT
knownfolder_create( struct knownfolder
**knownfolder
)
5623 struct knownfolder
*kf
;
5625 kf
= HeapAlloc( GetProcessHeap(), 0, sizeof(*kf
) );
5626 if (!kf
) return E_OUTOFMEMORY
;
5628 kf
->IKnownFolder_iface
.lpVtbl
= &knownfolder_vtbl
;
5630 memset( &kf
->id
, 0, sizeof(kf
->id
) );
5631 kf
->registryPath
= NULL
;
5635 TRACE("returning iface %p\n", &kf
->IKnownFolder_iface
);
5639 struct foldermanager
5641 IKnownFolderManager IKnownFolderManager_iface
;
5647 static inline struct foldermanager
*impl_from_IKnownFolderManager( IKnownFolderManager
*iface
)
5649 return CONTAINING_RECORD( iface
, struct foldermanager
, IKnownFolderManager_iface
);
5652 static ULONG WINAPI
foldermanager_AddRef(
5653 IKnownFolderManager
*iface
)
5655 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5656 return InterlockedIncrement( &foldermanager
->refs
);
5659 static ULONG WINAPI
foldermanager_Release(
5660 IKnownFolderManager
*iface
)
5662 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5663 LONG refs
= InterlockedDecrement( &foldermanager
->refs
);
5666 TRACE("destroying %p\n", foldermanager
);
5667 HeapFree( GetProcessHeap(), 0, foldermanager
->ids
);
5668 HeapFree( GetProcessHeap(), 0, foldermanager
);
5673 static HRESULT WINAPI
foldermanager_QueryInterface(
5674 IKnownFolderManager
*iface
,
5678 struct foldermanager
*This
= impl_from_IKnownFolderManager( iface
);
5680 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5683 if ( IsEqualGUID( riid
, &IID_IKnownFolderManager
) ||
5684 IsEqualGUID( riid
, &IID_IUnknown
) )
5688 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5690 TRACE("IID_IMarshal returning NULL.\n");
5691 return E_NOINTERFACE
;
5695 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5696 return E_NOINTERFACE
;
5698 IKnownFolderManager_AddRef( iface
);
5702 static HRESULT WINAPI
foldermanager_FolderIdFromCsidl(
5703 IKnownFolderManager
*iface
,
5705 KNOWNFOLDERID
*pfid
)
5707 TRACE("%d, %p\n", nCsidl
, pfid
);
5709 if (nCsidl
>= sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]))
5710 return E_INVALIDARG
;
5711 *pfid
= *CSIDL_Data
[nCsidl
].id
;
5715 static HRESULT WINAPI
foldermanager_FolderIdToCsidl(
5716 IKnownFolderManager
*iface
,
5717 REFKNOWNFOLDERID rfid
,
5722 TRACE("%s, %p\n", debugstr_guid(rfid
), pnCsidl
);
5724 csidl
= csidl_from_id( rfid
);
5725 if (csidl
== -1) return E_INVALIDARG
;
5730 static HRESULT WINAPI
foldermanager_GetFolderIds(
5731 IKnownFolderManager
*iface
,
5732 KNOWNFOLDERID
**ppKFId
,
5735 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5737 TRACE("%p, %p\n", ppKFId
, pCount
);
5739 *ppKFId
= CoTaskMemAlloc(fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5740 memcpy(*ppKFId
, fm
->ids
, fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5741 *pCount
= fm
->num_ids
;
5745 static BOOL
is_knownfolder( struct foldermanager
*fm
, const KNOWNFOLDERID
*id
)
5749 LPWSTR registryPath
= NULL
;
5752 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
5753 for (i
= 0; i
< fm
->num_ids
; i
++)
5754 if (IsEqualGUID( &fm
->ids
[i
], id
)) return TRUE
;
5756 hr
= get_known_folder_registry_path(id
, NULL
, ®istryPath
);
5759 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, 0, &hKey
));
5760 HeapFree(GetProcessHeap(), 0, registryPath
);
5772 static HRESULT WINAPI
foldermanager_GetFolder(
5773 IKnownFolderManager
*iface
,
5774 REFKNOWNFOLDERID rfid
,
5775 IKnownFolder
**ppkf
)
5777 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5778 struct knownfolder
*kf
;
5781 TRACE("%s, %p\n", debugstr_guid(rfid
), ppkf
);
5783 if (!is_knownfolder( fm
, rfid
))
5785 WARN("unknown folder\n");
5786 return E_INVALIDARG
;
5788 hr
= knownfolder_create( &kf
);
5789 if (SUCCEEDED( hr
))
5791 hr
= knownfolder_set_id( kf
, rfid
);
5792 *ppkf
= &kf
->IKnownFolder_iface
;
5800 static HRESULT WINAPI
foldermanager_GetFolderByName(
5801 IKnownFolderManager
*iface
,
5802 LPCWSTR pszCanonicalName
,
5803 IKnownFolder
**ppkf
)
5805 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5806 struct knownfolder
*kf
;
5811 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName
), ppkf
);
5813 for (i
= 0; i
< fm
->num_ids
; i
++)
5816 hr
= get_known_folder_registry_path( &fm
->ids
[i
], NULL
, &path
);
5817 if (FAILED( hr
)) return hr
;
5819 hr
= get_known_folder_wstr( path
, szName
, &name
);
5820 HeapFree( GetProcessHeap(), 0, path
);
5821 if (FAILED( hr
)) return hr
;
5823 found
= !strcmpiW( pszCanonicalName
, name
);
5824 CoTaskMemFree( name
);
5830 hr
= knownfolder_create( &kf
);
5831 if (FAILED( hr
)) return hr
;
5833 hr
= knownfolder_set_id( kf
, &fm
->ids
[i
] );
5836 IKnownFolder_Release( &kf
->IKnownFolder_iface
);
5839 *ppkf
= &kf
->IKnownFolder_iface
;
5843 hr
= HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
5850 static HRESULT
register_folder(const KNOWNFOLDERID
*rfid
, const KNOWNFOLDER_DEFINITION
*pKFD
)
5855 LPWSTR registryPath
= NULL
;
5857 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
5858 TRACE("registry path: %s\n", debugstr_w(registryPath
));
5861 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, NULL
, 0, KEY_WRITE
, 0, &hKey
, &dwDisp
));
5865 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szCategory
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->category
, sizeof(pKFD
->category
)));
5867 if(SUCCEEDED(hr
) && pKFD
->dwAttributes
!= 0)
5868 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szAttributes
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->dwAttributes
, sizeof(pKFD
->dwAttributes
)));
5871 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszName
, (lstrlenW(pKFD
->pszName
)+1)*sizeof(WCHAR
) ));
5873 if(SUCCEEDED(hr
) && pKFD
->pszParsingName
)
5874 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParsingName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszParsingName
, (lstrlenW(pKFD
->pszParsingName
)+1)*sizeof(WCHAR
) ));
5876 if(SUCCEEDED(hr
) && !IsEqualGUID(&pKFD
->fidParent
, &GUID_NULL
))
5878 WCHAR sParentGuid
[39];
5879 StringFromGUID2(&pKFD
->fidParent
, sParentGuid
, sizeof(sParentGuid
)/sizeof(sParentGuid
[0]));
5881 /* this known folder has parent folder */
5882 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParentFolder
, 0, REG_SZ
, (LPBYTE
)sParentGuid
, sizeof(sParentGuid
)));
5885 if(SUCCEEDED(hr
) && pKFD
->category
!= KF_CATEGORY_VIRTUAL
&& pKFD
->pszRelativePath
)
5886 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szRelativePath
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszRelativePath
, (lstrlenW(pKFD
->pszRelativePath
)+1)*sizeof(WCHAR
) ));
5891 SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
);
5894 HeapFree(GetProcessHeap(), 0, registryPath
);
5898 static HRESULT WINAPI
foldermanager_RegisterFolder(
5899 IKnownFolderManager
*iface
,
5900 REFKNOWNFOLDERID rfid
,
5901 KNOWNFOLDER_DEFINITION
const *pKFD
)
5903 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(rfid
), pKFD
);
5904 return register_folder(rfid
, pKFD
);
5907 static HRESULT WINAPI
foldermanager_UnregisterFolder(
5908 IKnownFolderManager
*iface
,
5909 REFKNOWNFOLDERID rfid
)
5912 LPWSTR registryPath
= NULL
;
5913 TRACE("(%p, %s)\n", iface
, debugstr_guid(rfid
));
5915 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
5918 hr
= HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
));
5920 HeapFree(GetProcessHeap(), 0, registryPath
);
5924 static HRESULT WINAPI
foldermanager_FindFolderFromPath(
5925 IKnownFolderManager
*iface
,
5928 IKnownFolder
**ppkf
)
5930 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath
), mode
, ppkf
);
5934 static HRESULT WINAPI
foldermanager_FindFolderFromIDList(
5935 IKnownFolderManager
*iface
,
5936 PCIDLIST_ABSOLUTE pidl
,
5937 IKnownFolder
**ppkf
)
5939 FIXME("%p, %p\n", pidl
, ppkf
);
5943 static HRESULT WINAPI
foldermanager_Redirect(
5944 IKnownFolderManager
*iface
,
5945 REFKNOWNFOLDERID rfid
,
5947 KF_REDIRECT_FLAGS flags
,
5948 LPCWSTR pszTargetPath
,
5950 KNOWNFOLDERID
const *pExclusion
,
5953 return redirect_known_folder(rfid
, hwnd
, flags
, pszTargetPath
, cFolders
, pExclusion
, ppszError
);
5956 static const struct IKnownFolderManagerVtbl foldermanager_vtbl
=
5958 foldermanager_QueryInterface
,
5959 foldermanager_AddRef
,
5960 foldermanager_Release
,
5961 foldermanager_FolderIdFromCsidl
,
5962 foldermanager_FolderIdToCsidl
,
5963 foldermanager_GetFolderIds
,
5964 foldermanager_GetFolder
,
5965 foldermanager_GetFolderByName
,
5966 foldermanager_RegisterFolder
,
5967 foldermanager_UnregisterFolder
,
5968 foldermanager_FindFolderFromPath
,
5969 foldermanager_FindFolderFromIDList
,
5970 foldermanager_Redirect
5973 static HRESULT
foldermanager_create( void **ppv
)
5976 struct foldermanager
*fm
;
5978 fm
= HeapAlloc( GetProcessHeap(), 0, sizeof(*fm
) );
5979 if (!fm
) return E_OUTOFMEMORY
;
5981 fm
->IKnownFolderManager_iface
.lpVtbl
= &foldermanager_vtbl
;
5985 for (i
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); i
++)
5987 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
)) fm
->num_ids
++;
5989 fm
->ids
= HeapAlloc( GetProcessHeap(), 0, fm
->num_ids
* sizeof(KNOWNFOLDERID
) );
5992 HeapFree( GetProcessHeap(), 0, fm
);
5993 return E_OUTOFMEMORY
;
5995 for (i
= j
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); i
++)
5997 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
))
5999 fm
->ids
[j
] = *CSIDL_Data
[i
].id
;
6003 TRACE("found %u known folders\n", fm
->num_ids
);
6004 *ppv
= &fm
->IKnownFolderManager_iface
;
6006 TRACE("returning iface %p\n", *ppv
);
6010 HRESULT WINAPI
KnownFolderManager_Constructor( IUnknown
*punk
, REFIID riid
, void **ppv
)
6012 TRACE("%p, %s, %p\n", punk
, debugstr_guid(riid
), ppv
);
6017 return CLASS_E_NOAGGREGATION
;
6019 return foldermanager_create( ppv
);
6022 HRESULT WINAPI
SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, PIDLIST_ABSOLUTE
*pidl
)
6024 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, pidl
);
6027 return E_INVALIDARG
;
6030 FIXME("unsupported flags: 0x%08x\n", flags
);
6033 FIXME("user token is not used.\n");
6036 if (IsEqualIID(rfid
, &FOLDERID_Desktop
))
6037 *pidl
= _ILCreateDesktop();
6038 else if (IsEqualIID(rfid
, &FOLDERID_RecycleBinFolder
))
6039 *pidl
= _ILCreateBitBucket();
6040 else if (IsEqualIID(rfid
, &FOLDERID_ComputerFolder
))
6041 *pidl
= _ILCreateMyComputer();
6042 else if (IsEqualIID(rfid
, &FOLDERID_PrintersFolder
))
6043 *pidl
= _ILCreatePrinters();
6044 else if (IsEqualIID(rfid
, &FOLDERID_ControlPanelFolder
))
6045 *pidl
= _ILCreateControlPanel();
6046 else if (IsEqualIID(rfid
, &FOLDERID_NetworkFolder
))
6047 *pidl
= _ILCreateNetwork();
6048 else if (IsEqualIID(rfid
, &FOLDERID_Documents
))
6049 *pidl
= _ILCreateMyDocuments();
6052 DWORD attributes
= 0;
6056 hr
= SHGetKnownFolderPath(rfid
, flags
, token
, &pathW
);
6060 hr
= SHILCreateFromPathW(pathW
, pidl
, &attributes
);
6061 CoTaskMemFree(pathW
);
6065 return *pidl
? S_OK
: E_FAIL
;
6068 HRESULT WINAPI
SHGetKnownFolderItem(REFKNOWNFOLDERID rfid
, KNOWN_FOLDER_FLAG flags
, HANDLE hToken
,
6069 REFIID riid
, void **ppv
)
6071 PIDLIST_ABSOLUTE pidl
;
6074 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid
), flags
, hToken
, debugstr_guid(riid
), ppv
);
6076 hr
= SHGetKnownFolderIDList(rfid
, flags
, hToken
, &pidl
);
6083 hr
= SHCreateItemFromIDList(pidl
, riid
, ppv
);
6084 CoTaskMemFree(pidl
);
6088 static void register_system_knownfolders(void)
6091 for(i
= 0; i
< sizeof(CSIDL_Data
) / sizeof(CSIDL_Data
[0]); ++i
){
6092 const CSIDL_DATA
*folder
= &CSIDL_Data
[i
];
6093 if(folder
->pszName
){
6094 KNOWNFOLDER_DEFINITION kfd
;
6096 /* register_folder won't modify kfd, so cast away const instead of
6098 kfd
.category
= folder
->category
;
6099 kfd
.pszName
= (WCHAR
*)folder
->pszName
;
6100 kfd
.pszDescription
= (WCHAR
*)folder
->pszDescription
;
6101 memcpy(&kfd
.fidParent
, folder
->fidParent
, sizeof(KNOWNFOLDERID
));
6102 kfd
.pszRelativePath
= (WCHAR
*)folder
->pszRelativePath
;
6103 kfd
.pszParsingName
= (WCHAR
*)folder
->pszParsingName
;
6104 kfd
.pszTooltip
= (WCHAR
*)folder
->pszTooltip
;
6105 kfd
.pszLocalizedName
= (WCHAR
*)folder
->pszLocalizedName
;
6106 kfd
.pszIcon
= (WCHAR
*)folder
->pszIcon
;
6107 kfd
.pszSecurity
= (WCHAR
*)folder
->pszSecurity
;
6108 kfd
.dwAttributes
= folder
->dwAttributes
;
6109 kfd
.kfdFlags
= folder
->kfdFlags
;
6110 memcpy(&kfd
.ftidType
, folder
->ftidType
, sizeof(FOLDERTYPEID
));
6112 register_folder(folder
->id
, &kfd
);
6117 HRESULT
SHELL_RegisterShellFolders(void)
6121 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6122 * 'My Videos', 'My Music' and 'Desktop' in advance, so that the
6123 * _SHRegister*ShellFolders() functions will find everything nice and clean
6124 * and thus will not attempt to create them in the profile directory. */
6125 _SHCreateSymbolicLinks();
6127 hr
= _SHRegisterUserShellFolders(TRUE
);
6129 hr
= _SHRegisterUserShellFolders(FALSE
);
6131 hr
= _SHRegisterCommonShellFolders();
6133 hr
= create_extra_folders();
6135 hr
= set_folder_attributes();
6137 register_system_knownfolders();