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 BOOL WINAPI
PathFindOnPathExA(LPSTR
,LPCSTR
*,DWORD
);
688 BOOL WINAPI
PathFindOnPathExW(LPWSTR
,LPCWSTR
*,DWORD
);
689 BOOL WINAPI
PathFileExistsDefExtA(LPSTR
,DWORD
);
690 BOOL WINAPI
PathFileExistsDefExtW(LPWSTR
,DWORD
);
692 static BOOL
PathResolveA(char *path
, const char **dirs
, DWORD flags
)
694 BOOL is_file_spec
= PathIsFileSpecA(path
);
695 DWORD dwWhich
= flags
& PRF_DONTFINDLNK
? 0xf : 0xff;
697 TRACE("(%s,%p,0x%08x)\n", debugstr_a(path
), dirs
, flags
);
699 if (flags
& PRF_VERIFYEXISTS
&& !PathFileExistsA(path
))
701 if (PathFindOnPathExA(path
, dirs
, dwWhich
))
703 if (PathFileExistsDefExtA(path
, dwWhich
))
705 if (!is_file_spec
) GetFullPathNameA(path
, MAX_PATH
, path
, NULL
);
706 SetLastError(ERROR_FILE_NOT_FOUND
);
712 SetLastError(ERROR_FILE_NOT_FOUND
);
716 GetFullPathNameA(path
, MAX_PATH
, path
, NULL
);
721 static BOOL
PathResolveW(WCHAR
*path
, const WCHAR
**dirs
, DWORD flags
)
723 BOOL is_file_spec
= PathIsFileSpecW(path
);
724 DWORD dwWhich
= flags
& PRF_DONTFINDLNK
? 0xf : 0xff;
726 TRACE("(%s,%p,0x%08x)\n", debugstr_w(path
), dirs
, flags
);
728 if (flags
& PRF_VERIFYEXISTS
&& !PathFileExistsW(path
))
730 if (PathFindOnPathExW(path
, dirs
, dwWhich
))
732 if (PathFileExistsDefExtW(path
, dwWhich
))
734 if (!is_file_spec
) GetFullPathNameW(path
, MAX_PATH
, path
, NULL
);
735 SetLastError(ERROR_FILE_NOT_FOUND
);
741 SetLastError(ERROR_FILE_NOT_FOUND
);
745 GetFullPathNameW(path
, MAX_PATH
, path
, NULL
);
750 /*************************************************************************
751 * PathResolve [SHELL32.51]
753 BOOL WINAPI
PathResolveAW(void *path
, const void **paths
, DWORD flags
)
755 if (SHELL_OsIsUnicode())
756 return PathResolveW(path
, (const WCHAR
**)paths
, flags
);
758 return PathResolveA(path
, (const char **)paths
, flags
);
761 /*************************************************************************
762 * PathProcessCommandA
764 static LONG
PathProcessCommandA (
770 FIXME("%s %p 0x%04x 0x%04x stub\n",
771 lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
772 if(!lpszPath
) return -1;
773 if(lpszBuff
) strcpy(lpszBuff
, lpszPath
);
774 return strlen(lpszPath
);
777 /*************************************************************************
778 * PathProcessCommandW
780 static LONG
PathProcessCommandW (
786 FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
787 debugstr_w(lpszPath
), lpszBuff
, dwBuffSize
, dwFlags
);
788 if(!lpszPath
) return -1;
789 if(lpszBuff
) strcpyW(lpszBuff
, lpszPath
);
790 return strlenW(lpszPath
);
793 /*************************************************************************
794 * PathProcessCommand (SHELL32.653)
796 LONG WINAPI
PathProcessCommandAW (
802 if (SHELL_OsIsUnicode())
803 return PathProcessCommandW(lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
804 return PathProcessCommandA(lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
808 ########## special ##########
811 /*************************************************************************
812 * PathSetDlgItemPath (SHELL32.48)
814 VOID WINAPI
PathSetDlgItemPathAW(HWND hDlg
, int id
, LPCVOID pszPath
)
816 if (SHELL_OsIsUnicode())
817 PathSetDlgItemPathW(hDlg
, id
, pszPath
);
819 PathSetDlgItemPathA(hDlg
, id
, pszPath
);
822 static const WCHAR szCategory
[] = {'C','a','t','e','g','o','r','y',0};
823 static const WCHAR szAttributes
[] = {'A','t','t','r','i','b','u','t','e','s',0};
824 static const WCHAR szName
[] = {'N','a','m','e',0};
825 static const WCHAR szParsingName
[] = {'P','a','r','s','i','n','g','N','a','m','e',0};
826 static const WCHAR szRelativePath
[] = {'R','e','l','a','t','i','v','e','P','a','t','h',0};
827 static const WCHAR szParentFolder
[] = {'P','a','r','e','n','t','F','o','l','d','e','r',0};
829 static const WCHAR szCurrentVersion
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\0'};
830 static const WCHAR AddNewProgramsFolderW
[] = {'A','d','d','N','e','w','P','r','o','g','r','a','m','s','F','o','l','d','e','r',0};
831 static const WCHAR AppUpdatesFolderW
[] = {'A','p','p','U','p','d','a','t','e','s','F','o','l','d','e','r',0};
832 static const WCHAR Administrative_ToolsW
[] = {'A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
833 static const WCHAR AppDataW
[] = {'A','p','p','D','a','t','a','\0'};
834 static const WCHAR AppData_RoamingW
[] = {'A','p','p','D','a','t','a','\\','R','o','a','m','i','n','g','\0'};
835 static const WCHAR AppData_LocalLowW
[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','L','o','w','\0'};
836 static const WCHAR AppData_LocalW
[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','\0'};
837 static const WCHAR Application_DataW
[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
838 static const WCHAR CacheW
[] = {'C','a','c','h','e','\0'};
839 static const WCHAR CD_BurningW
[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
840 static const WCHAR ChangeRemoveProgramsFolderW
[] = {'C','h','a','n','g','e','R','e','m','o','v','e','P','r','o','g','r','a','m','s','F','o','l','d','e','r',0};
841 static const WCHAR CommonW
[] = {'C','o','m','m','o','n',0};
842 static const WCHAR Common_Administrative_ToolsW
[] = {'C','o','m','m','o','n',' ','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
843 static const WCHAR Common_AppDataW
[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'};
844 static const WCHAR Common_DesktopW
[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'};
845 static const WCHAR Common_DocumentsW
[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'};
846 static const WCHAR CommonDownloadsW
[] = {'C','o','m','m','o','n','D','o','w','n','l','o','a','d','s',0};
847 static const WCHAR Common_FavoritesW
[] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'};
848 static const WCHAR CommonFilesDirW
[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'};
849 static const WCHAR CommonFilesDirX86W
[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
850 static const WCHAR CommonMusicW
[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'};
851 static const WCHAR CommonPicturesW
[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'};
852 static const WCHAR Common_ProgramsW
[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'};
853 static const WCHAR CommonRingtonesW
[] = {'C','o','m','m','o','n','R','i','n','g','t','o','n','e','s',0};
854 static const WCHAR Common_StartUpW
[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'};
855 static const WCHAR Common_StartupW
[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','u','p','\0'};
856 static const WCHAR Common_Start_MenuW
[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'};
857 static const WCHAR Common_TemplatesW
[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'};
858 static const WCHAR CommonVideoW
[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
859 static const WCHAR ConflictFolderW
[] = {'C','o','n','f','l','i','c','t','F','o','l','d','e','r',0};
860 static const WCHAR ConnectionsFolderW
[] = {'C','o','n','n','e','c','t','i','o','n','s','F','o','l','d','e','r',0};
861 static const WCHAR ContactsW
[] = {'C','o','n','t','a','c','t','s','\0'};
862 static const WCHAR ControlPanelFolderW
[] = {'C','o','n','t','r','o','l','P','a','n','e','l','F','o','l','d','e','r',0};
863 static const WCHAR CookiesW
[] = {'C','o','o','k','i','e','s','\0'};
864 static const WCHAR CSCFolderW
[] = {'C','S','C','F','o','l','d','e','r',0};
865 static const WCHAR Default_GadgetsW
[] = {'D','e','f','a','u','l','t',' ','G','a','d','g','e','t','s',0};
866 static const WCHAR DesktopW
[] = {'D','e','s','k','t','o','p','\0'};
867 static const WCHAR Device_Metadata_StoreW
[] = {'D','e','v','i','c','e',' ','M','e','t','a','d','a','t','a',' ','S','t','o','r','e',0};
868 static const WCHAR DocumentsW
[] = {'D','o','c','u','m','e','n','t','s','\0'};
869 static const WCHAR DocumentsLibraryW
[] = {'D','o','c','u','m','e','n','t','s','L','i','b','r','a','r','y','\0'};
870 static const WCHAR Documents_librarymsW
[] = {'D','o','c','u','m','e','n','t','s','.','l','i','b','r','a','r','y','-','m','s',0};
871 static const WCHAR DownloadsW
[] = {'D','o','w','n','l','o','a','d','s','\0'};
872 static const WCHAR FavoritesW
[] = {'F','a','v','o','r','i','t','e','s','\0'};
873 static const WCHAR FontsW
[] = {'F','o','n','t','s','\0'};
874 static const WCHAR GadgetsW
[] = {'G','a','d','g','e','t','s',0};
875 static const WCHAR GamesW
[] = {'G','a','m','e','s',0};
876 static const WCHAR GameTasksW
[] = {'G','a','m','e','T','a','s','k','s',0};
877 static const WCHAR HistoryW
[] = {'H','i','s','t','o','r','y','\0'};
878 static const WCHAR HomeGroupFolderW
[] = {'H','o','m','e','G','r','o','u','p','F','o','l','d','e','r',0};
879 static const WCHAR ImplicitAppShortcutsW
[] = {'I','m','p','l','i','c','i','t','A','p','p','S','h','o','r','t','c','u','t','s',0};
880 static const WCHAR InternetFolderW
[] = {'I','n','t','e','r','n','e','t','F','o','l','d','e','r',0};
881 static const WCHAR LibrariesW
[] = {'L','i','b','r','a','r','i','e','s',0};
882 static const WCHAR LinksW
[] = {'L','i','n','k','s','\0'};
883 static const WCHAR Local_AppDataW
[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
884 static const WCHAR Local_Settings_Application_DataW
[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
885 static const WCHAR Local_Settings_CD_BurningW
[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\\','M','i','c','r','o','s','o','f','t','\\','C','D',' ','B','u','r','n','i','n','g','\0'};
886 static const WCHAR Local_Settings_HistoryW
[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','H','i','s','t','o','r','y','\0'};
887 static const WCHAR Local_Settings_Temporary_Internet_FilesW
[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s','\0'};
888 static const WCHAR LocalAppDataLowW
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','L','o','w',0};
889 static const WCHAR LocalizedResourcesDirW
[] = {'L','o','c','a','l','i','z','e','d','R','e','s','o','u','r','c','e','s','D','i','r',0};
890 static const WCHAR MAPIFolderW
[] = {'M','A','P','I','F','o','l','d','e','r',0};
891 static const WCHAR Microsoft_Internet_Explorer_Quick_LaunchW
[] = {'M','i','c','r','o','s','o','f','t','\\','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\','Q','u','i','c','k',' ','L','a','u','n','c','h',0};
892 static const WCHAR Microsoft_Windows_Burn_BurnW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','B','u','r','n','\\','B','u','r','n',0};
893 static const WCHAR Microsoft_Windows_CookiesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','o','o','k','i','e','s',0};
894 static const WCHAR Microsoft_Windows_GameExplorerW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','G','a','m','e','E','x','p','l','o','r','e','r','\0'};
895 static const WCHAR Microsoft_Windows_DeviceMetadataStoreW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','D','e','v','i','c','e','M','e','t','a','d','a','t','a','S','t','o','r','e',0};
896 static const WCHAR Microsoft_Windows_HistoryW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','H','i','s','t','o','r','y',0};
897 static const WCHAR Microsoft_Windows_LibrariesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','L','i','b','r','a','r','i','e','s','\0'};
898 static const WCHAR Microsoft_Windows_Network_ShortcutsW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','N','e','t','w','o','r','k',' ','S','h','o','r','t','c','u','t','s',0};
899 static const WCHAR Microsoft_Windows_Photo_Gallery_Original_ImagesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','P','h','o','t','o',' ','G','a','l','l','e','r','y','\\','O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
900 static const WCHAR Microsoft_Windows_Printer_ShortcutsW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','P','r','i','n','t','e','r',' ','S','h','o','r','t','c','u','t','s',0};
901 static const WCHAR Microsoft_Windows_RecentW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','R','e','c','e','n','t','\0'};
902 static const WCHAR Microsoft_Windows_RingtonesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','R','i','n','g','t','o','n','e','s','\0'};
903 static const WCHAR Microsoft_Windows_SendToW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','e','n','d','T','o',0};
904 static const WCHAR Microsoft_Windows_Sidebar_GadgetsW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','S','i','d','e','b','a','r','\\','G','a','d','g','e','t','s',0};
905 static const WCHAR Microsoft_Windows_Start_MenuW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u',0};
906 static const WCHAR Microsoft_Windows_Start_Menu_ProgramsW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
907 static const WCHAR Microsoft_Windows_Start_Menu_Admin_ToolsW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
908 static const WCHAR Microsoft_Windows_Start_Menu_StartupW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
909 static const WCHAR Microsoft_Windows_TemplatesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','l','a','t','e','s',0};
910 static const WCHAR Microsoft_Windows_Temporary_Internet_FilesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s',0};
911 static const WCHAR Microsoft_Windows_ThemesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','T','h','e','m','e','s',0};
912 static const WCHAR MoviesW
[] = {'M','o','v','i','e','s','\0'};
913 static const WCHAR MusicW
[] = {'M','u','s','i','c','\0'};
914 static const WCHAR MusicLibraryW
[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
915 static const WCHAR Music_librarymsW
[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
916 static const WCHAR Music_PlaylistsW
[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
917 static const WCHAR Music_Sample_MusicW
[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
918 static const WCHAR Music_Sample_PlaylistsW
[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s','\0'};
919 static const WCHAR My_MusicW
[] = {'M','y',' ','M','u','s','i','c','\0'};
920 static const WCHAR My_PicturesW
[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
921 static const WCHAR My_VideosW
[] = {'M','y',' ','V','i','d','e','o','s','\0'};
922 static const WCHAR My_VideoW
[] = {'M','y',' ','V','i','d','e','o','\0'};
923 static const WCHAR MyComputerFolderW
[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
924 static const WCHAR NetHoodW
[] = {'N','e','t','H','o','o','d','\0'};
925 static const WCHAR NetworkPlacesFolderW
[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
926 static const WCHAR OEM_LinksW
[] = {'O','E','M',' ','L','i','n','k','s','\0'};
927 static const WCHAR Original_ImagesW
[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
928 static const WCHAR PersonalW
[] = {'P','e','r','s','o','n','a','l','\0'};
929 static const WCHAR PhotoAlbumsW
[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
930 static const WCHAR PicturesW
[] = {'P','i','c','t','u','r','e','s','\0'};
931 static const WCHAR PicturesLibraryW
[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
932 static const WCHAR Pictures_librarymsW
[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
933 static const WCHAR Pictures_Sample_PicturesW
[] = {'P','i','c','t','u','r','e','s','\\','S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s','\0'};
934 static const WCHAR Pictures_Slide_ShowsW
[] = {'P','i','c','t','u','r','e','s','\\','S','l','i','d','e',' ','S','h','o','w','s','\0'};
935 static const WCHAR PlaylistsW
[] = {'P','l','a','y','l','i','s','t','s',0};
936 static const WCHAR PrintersFolderW
[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
937 static const WCHAR PrintHoodW
[] = {'P','r','i','n','t','H','o','o','d','\0'};
938 static const WCHAR ProfileW
[] = {'P','r','o','f','i','l','e',0};
939 static const WCHAR ProgramDataW
[] = {'P','r','o','g','r','a','m','D','a','t','a','\0'};
940 static const WCHAR Program_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
941 static const WCHAR ProgramFilesW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
942 static const WCHAR ProgramFilesX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
943 static const WCHAR ProgramFilesX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
944 static const WCHAR Program_Files_Common_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
945 static const WCHAR Program_Files_x86W
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
946 static const WCHAR Program_Files_x86_Common_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\\','C','o','m','m','o','n',' ','F','i','l','e','s','\0'};
947 static const WCHAR ProgramFilesCommonW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
948 static const WCHAR ProgramFilesCommonX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','8','6',0};
949 static const WCHAR ProgramFilesCommonX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n','X','6','4',0};
950 static const WCHAR ProgramFilesDirW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
951 static const WCHAR ProgramFilesDirX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
952 static const WCHAR ProgramsW
[] = {'P','r','o','g','r','a','m','s','\0'};
953 static const WCHAR PublicW
[] = {'P','u','b','l','i','c',0};
954 static const WCHAR PublicGameTasksW
[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
955 static const WCHAR PublicLibrariesW
[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
956 static const WCHAR Quick_LaunchW
[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
957 static const WCHAR RecentW
[] = {'R','e','c','e','n','t','\0'};
958 static const WCHAR RecordedTVLibraryW
[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
959 static const WCHAR RecordedTV_librarymsW
[] = {'R','e','c','o','r','d','e','d','T','V','.','l','i','b','r','a','r','y','-','m','s',0};
960 static const WCHAR RecycleBinFolderW
[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
961 static const WCHAR ResourceDirW
[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
962 static const WCHAR ResourcesW
[] = {'R','e','s','o','u','r','c','e','s','\0'};
963 static const WCHAR RingtonesW
[] = {'R','i','n','g','t','o','n','e','s',0};
964 static const WCHAR SampleMusicW
[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
965 static const WCHAR Sample_MusicW
[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
966 static const WCHAR SamplePicturesW
[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
967 static const WCHAR Sample_PicturesW
[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
968 static const WCHAR SamplePlaylistsW
[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
969 static const WCHAR Sample_PlaylistsW
[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
970 static const WCHAR Sample_VideosW
[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
971 static const WCHAR SampleVideosW
[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
972 static const WCHAR Saved_GamesW
[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
973 static const WCHAR SavedGamesW
[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
974 static const WCHAR SearchesW
[] = {'S','e','a','r','c','h','e','s','\0'};
975 static const WCHAR SearchHomeFolderW
[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
976 static const WCHAR SendToW
[] = {'S','e','n','d','T','o','\0'};
977 static const WCHAR Slide_ShowsW
[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
978 static const WCHAR StartUpW
[] = {'S','t','a','r','t','U','p','\0'};
979 static const WCHAR StartupW
[] = {'S','t','a','r','t','u','p','\0'};
980 static const WCHAR Start_MenuW
[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
981 static const WCHAR Start_Menu_ProgramsW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
982 static const WCHAR Start_Menu_Admin_ToolsW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
983 static const WCHAR Start_Menu_StartupW
[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
984 static const WCHAR SyncCenterFolderW
[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
985 static const WCHAR SyncResultsFolderW
[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
986 static const WCHAR SyncSetupFolderW
[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
987 static const WCHAR SystemW
[] = {'S','y','s','t','e','m',0};
988 static const WCHAR SystemX86W
[] = {'S','y','s','t','e','m','X','8','6',0};
989 static const WCHAR TemplatesW
[] = {'T','e','m','p','l','a','t','e','s','\0'};
990 static const WCHAR User_PinnedW
[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
991 static const WCHAR UsersW
[] = {'U','s','e','r','s','\0'};
992 static const WCHAR UsersFilesFolderW
[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
993 static const WCHAR UsersLibrariesFolderW
[] = {'U','s','e','r','s','L','i','b','r','a','r','i','e','s','F','o','l','d','e','r',0};
994 static const WCHAR UserProfilesW
[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
995 static const WCHAR UserProgramFilesW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
996 static const WCHAR UserProgramFilesCommonW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
997 static const WCHAR UsersPublicW
[] = {'u','s','e','r','s','\\','P','u','b','l','i','c','\0'};
998 static const WCHAR VideosW
[] = {'V','i','d','e','o','s','\0'};
999 static const WCHAR VideosLibraryW
[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
1000 static const WCHAR Videos_librarymsW
[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
1001 static const WCHAR Videos_Sample_VideosW
[] = {'V','i','d','e','o','s','\\','S','a','m','p','l','e',' ','V','i','d','e','o','s','\0'};
1002 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
1003 static const WCHAR Windows_Sidebar_GadgetsW
[] = {'W','i','n','d','o','w','s',' ','S','i','d','e','b','a','r','\\','G','a','d','g','e','t','s',0};
1004 static const WCHAR DefaultW
[] = {'.','D','e','f','a','u','l','t','\0'};
1005 static const WCHAR AllUsersProfileW
[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
1006 static const WCHAR PublicProfileW
[] = {'%','P','U','B','L','I','C','%',0};
1007 static const WCHAR UserProfileW
[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
1008 static const WCHAR ProgramDataVarW
[] = {'%','P','r','o','g','r','a','m','D','a','t','a','%','\0'};
1009 static const WCHAR SystemDriveW
[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
1010 static const WCHAR ProfileListW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','P','r','o','f','i','l','e','L','i','s','t',0};
1011 static const WCHAR ProfilesDirectoryW
[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
1012 static const WCHAR szSHFolders
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
1013 static const WCHAR szSHUserFolders
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s','\0'};
1014 static const WCHAR szDefaultProfileDirW
[] = {'u','s','e','r','s',0};
1015 static const WCHAR szKnownFolderDescriptions
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','F','o','l','d','e','r','D','e','s','c','r','i','p','t','i','o','n','s','\0'};
1016 static const WCHAR szKnownFolderRedirections
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l','o','r','e','r','\\','U','s','e','r',' ','S','h','e','l','l',' ','F','o','l','d','e','r','s',0};
1018 #define CHANGEREMOVEPROGRAMS_PARSING_GUID '{','7','b','8','1','b','e','6','a','-','c','e','2','b','-','4','6','7','6','-','a','2','9','e','-','e','b','9','0','7','a','5','1','2','6','c','5','}'
1019 #define SYNCMANAGER_PARSING_GUID '{','9','C','7','3','F','5','E','5','-','7','A','E','7','-','4','E','3','2','-','A','8','E','8','-','8','D','2','3','B','8','5','2','5','5','B','F','}'
1020 #define SYSTEMFOLDERS_PARSING_GUID '{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}'
1021 #define USERFOLDERS_PARSING_GUID '{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}'
1022 #define USERSLIBRARIES_PARSING_GUID '{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}'
1024 static const WCHAR ComputerFolderParsingNameW
[] = {':',':','{','2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
1025 static const WCHAR ControlPanelFolderParsingNameW
[] = {':',':','{','2','6','E','E','0','6','6','8','-','A','0','0','A','-','4','4','D','7','-','9','3','7','1','-','B','E','B','0','6','4','C','9','8','6','8','3','}','\\','0',0};
1026 static const WCHAR ControlPanelFolderRelativePathW
[] = {':',':','{','2','1','E','C','2','0','2','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','D','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
1027 static const WCHAR GamesParsingNameW
[] = {':',':','{','E','D','2','2','8','F','D','F','-','9','E','A','8','-','4','8','7','0','-','8','3','b','1','-','9','6','b','0','2','C','F','E','0','D','5','2','}',0};
1028 static const WCHAR HomeGroupParsingNameW
[] = {':',':','{','B','4','F','B','3','F','9','8','-','C','1','E','A','-','4','2','8','d','-','A','7','8','A','-','D','1','F','5','6','5','9','C','B','A','9','3','}',0};
1029 static const WCHAR InternetFolderParsingNameW
[] = {':',':','{','8','7','1','C','5','3','8','0','-','4','2','A','0','-','1','0','6','9','-','A','2','E','A','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
1030 static const WCHAR NetworkFolderParsingNameW
[] = {':',':','{','F','0','2','C','1','A','0','D','-','B','E','2','1','-','4','3','5','0','-','8','8','B','0','-','7','3','6','7','F','C','9','6','E','F','3','C','}',0};
1031 static const WCHAR PublicParsingNameW
[] = {':',':','{','4','3','3','6','a','5','4','d','-','0','3','8','b','-','4','6','8','5','-','a','b','0','2','-','9','9','b','b','5','2','d','3','f','b','8','b','}',0};
1032 static const WCHAR RecycleBinFolderParsingNameW
[] = {':',':','{','6','4','5','F','F','0','4','0','-','5','0','8','1','-','1','0','1','B','-','9','F','0','8','-','0','0','A','A','0','0','2','F','9','5','4','E','}',0};
1033 static const WCHAR SearchHomeParsingNameW
[] = {':',':','{','9','3','4','3','8','1','2','e','-','1','c','3','7','-','4','a','4','9','-','a','1','2','e','-','4','b','2','d','8','1','0','d','9','5','6','b','}',0};
1034 static const WCHAR SEARCH_CSCParsingNameW
[] = {'s','h','e','l','l',':',':',':','{','B','D','7','A','2','E','7','B','-','2','1','C','B','-','4','1','b','2','-','A','0','8','6','-','B','3','0','9','6','8','0','C','6','B','7','E','}','\\','*',0};
1035 static const WCHAR SEARCH_MAPIParsingNameW
[] = {'s','h','e','l','l',':',':',':','{','8','9','D','8','3','5','7','6','-','6','B','D','1','-','4','C','8','6','-','9','4','5','4','-','B','E','B','0','4','E','9','4','C','8','1','9','}','\\','*',0};
1036 static const WCHAR UsersFilesParsingNameW
[] = {':',':','{','5','9','0','3','1','a','4','7','-','3','f','7','2','-','4','4','a','7','-','8','9','c','5','-','5','5','9','5','f','e','6','b','3','0','e','e','}',0};
1037 static const WCHAR UsersLibrariesParsingNameW
[] = {':',':','{','0','3','1','E','4','8','2','5','-','7','B','9','4','-','4','d','c','3','-','B','1','3','1','-','E','9','4','6','B','4','4','C','8','D','D','5','}',0};
1038 static const WCHAR AddNewProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','1','5','e','a','e','9','2','e','-','f','1','7','a','-','4','4','3','1','-','9','f','2','8','-','8','0','5','e','4','8','2','d','a','f','d','4','}',0};
1039 static const WCHAR ConnectionsFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','7','0','0','7','A','C','C','7','-','3','2','0','2','-','1','1','D','1','-','A','A','D','2','-','0','0','8','0','5','F','C','1','2','7','0','E','}',0};
1040 static const WCHAR PrintersFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':','{','2','2','2','7','A','2','8','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','E','-','0','8','0','0','2','B','3','0','3','0','9','D','}',0};
1041 static const WCHAR ChangeRemoveProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, 0};
1042 static const WCHAR AppUpdatesParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, '\\',':',':','{','d','4','5','0','a','8','a','1','-','9','5','6','8','-','4','5','c','7','-','9','c','0','e','-','b','4','f','9','f','b','4','5','3','7','b','d','}',0};
1043 static const WCHAR SyncManagerFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, 0};
1044 static const WCHAR ConflictFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','E','4','1','3','D','0','4','0','-','6','7','8','8','-','4','C','2','2','-','9','5','7','E','-','1','7','5','D','1','C','5','1','3','A','3','4','}',',',0};
1045 static const WCHAR SyncResultsFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','B','C','4','8','B','3','2','F','-','5','9','1','0','-','4','7','F','5','-','8','5','7','0','-','5','0','7','4','A','8','A','5','6','3','6','A','}',',',0};
1046 static const WCHAR SyncSetupFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, '\\',':',':','{','F','1','3','9','0','A','9','A','-','A','3','F','4','-','4','E','5','D','-','9','C','5','F','-','9','8','F','3','B','D','8','D','9','3','5','C','}',',',0};
1047 static const WCHAR ContactsParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','5','6','7','8','4','8','5','4','-','C','6','C','B','-','4','6','2','B','-','8','1','6','9','-','8','8','E','3','5','0','A','C','B','8','8','2','}',0};
1048 static const WCHAR DocumentsParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','F','D','D','3','9','A','D','0','-','2','3','8','F','-','4','6','A','F','-','A','D','B','4','-','6','C','8','5','4','8','0','3','6','9','C','7','}',0};
1049 static const WCHAR LinksParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','b','f','b','9','d','5','e','0','-','c','6','a','9','-','4','0','4','c','-','b','2','b','2','-','a','e','6','d','b','6','a','f','4','9','6','8','}',0};
1050 static const WCHAR MusicParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','4','B','D','8','D','5','7','1','-','6','D','1','9','-','4','8','D','3','-','B','E','9','7','-','4','2','2','2','2','0','0','8','0','E','4','3','}',0};
1051 static const WCHAR PicturesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','3','3','E','2','8','1','3','0','-','4','E','1','E','-','4','6','7','6','-','8','3','5','A','-','9','8','3','9','5','C','3','B','C','3','B','B','}',0};
1052 static const WCHAR SavedGamesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','4','C','5','C','3','2','F','F','-','B','B','9','D','-','4','3','b','0','-','B','5','B','4','-','2','D','7','2','E','5','4','E','A','A','A','4','}',0};
1053 static const WCHAR SavedSearchesParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','7','d','1','d','3','a','0','4','-','d','e','b','b','-','4','1','1','5','-','9','5','c','f','-','2','f','2','9','d','a','2','9','2','0','d','a','}',0};
1054 static const WCHAR VideosParsingNameW
[] = {':',':', USERFOLDERS_PARSING_GUID
, '\\','{','1','8','9','8','9','B','1','D','-','9','9','B','5','-','4','5','5','B','-','8','4','1','C','-','A','B','7','C','7','4','E','4','D','D','F','C','}',0};
1055 static const WCHAR DocumentsLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','7','b','0','d','b','1','7','d','-','9','c','d','2','-','4','a','9','3','-','9','7','3','3','-','4','6','c','c','8','9','0','2','2','e','7','c','}',0};
1056 static const WCHAR MusicLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','2','1','1','2','A','B','0','A','-','C','8','6','A','-','4','f','f','e','-','A','3','6','8','-','0','D','E','9','6','E','4','7','0','1','2','E','}',0};
1057 static const WCHAR PicturesLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','A','9','9','0','A','E','9','F','-','A','0','3','B','-','4','e','8','0','-','9','4','B','C','-','9','9','1','2','D','7','5','0','4','1','0','4','}',0};
1058 static const WCHAR VideosLibraryParsingNameW
[] = {':',':', USERSLIBRARIES_PARSING_GUID
, '\\','{','4','9','1','E','9','2','2','F','-','5','6','4','3','-','4','a','f','4','-','A','7','E','B','-','4','E','7','A','1','3','8','D','8','1','7','4','}',0};
1060 typedef enum _CSIDL_Type
{
1062 CSIDL_Type_AllUsers
,
1064 CSIDL_Type_Disallowed
,
1065 CSIDL_Type_NonExistent
,
1066 CSIDL_Type_WindowsPath
,
1067 CSIDL_Type_SystemPath
,
1068 CSIDL_Type_SystemX86Path
,
1069 CSIDL_Type_ProgramData
,
1072 #define CSIDL_CONTACTS 0x0043
1073 #define CSIDL_DOWNLOADS 0x0047
1074 #define CSIDL_LINKS 0x004d
1075 #define CSIDL_APPDATA_LOCALLOW 0x004e
1076 #define CSIDL_SAVED_GAMES 0x0062
1077 #define CSIDL_SEARCHES 0x0063
1081 IApplicationDestinations IApplicationDestinations_iface
;
1083 } IApplicationDestinationsImpl
;
1085 static inline IApplicationDestinationsImpl
*impl_from_IApplicationDestinations( IApplicationDestinations
*iface
)
1087 return CONTAINING_RECORD(iface
, IApplicationDestinationsImpl
, IApplicationDestinations_iface
);
1090 static HRESULT WINAPI
ApplicationDestinations_QueryInterface(IApplicationDestinations
*iface
, REFIID riid
,
1093 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1095 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1100 if (IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IApplicationDestinations
, riid
))
1102 *ppv
= &This
->IApplicationDestinations_iface
;
1103 IUnknown_AddRef((IUnknown
*)*ppv
);
1105 TRACE("Returning IApplicationDestinations: %p\n", *ppv
);
1110 FIXME("(%p)->(%s, %p) interface not supported.\n", This
, debugstr_guid(riid
), ppv
);
1112 return E_NOINTERFACE
;
1115 static ULONG WINAPI
ApplicationDestinations_AddRef(IApplicationDestinations
*iface
)
1117 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1118 ULONG ref
= InterlockedIncrement(&This
->ref
);
1120 TRACE("(%p), new refcount=%i\n", This
, ref
);
1125 static ULONG WINAPI
ApplicationDestinations_Release(IApplicationDestinations
*iface
)
1127 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1128 ULONG ref
= InterlockedDecrement(&This
->ref
);
1130 TRACE("(%p), new refcount=%i\n", This
, ref
);
1138 static HRESULT WINAPI
ApplicationDestinations_SetAppID(IApplicationDestinations
*iface
, const WCHAR
*appid
)
1140 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1142 FIXME("(%p, %s) stub!\n", This
, debugstr_w(appid
));
1147 static HRESULT WINAPI
ApplicationDestinations_RemoveDestination(IApplicationDestinations
*iface
, IUnknown
*punk
)
1149 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1151 FIXME("(%p, %p) stub!\n", This
, punk
);
1156 static HRESULT WINAPI
ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations
*iface
)
1158 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1160 FIXME("(%p) stub!\n", This
);
1165 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl
=
1167 ApplicationDestinations_QueryInterface
,
1168 ApplicationDestinations_AddRef
,
1169 ApplicationDestinations_Release
,
1170 ApplicationDestinations_SetAppID
,
1171 ApplicationDestinations_RemoveDestination
,
1172 ApplicationDestinations_RemoveAllDestinations
1175 HRESULT WINAPI
ApplicationDestinations_Constructor(IUnknown
*outer
, REFIID riid
, LPVOID
*ppv
)
1177 IApplicationDestinationsImpl
*This
;
1180 TRACE("(%p, %s, %p)\n", outer
, debugstr_guid(riid
), ppv
);
1183 return CLASS_E_NOAGGREGATION
;
1185 if (!(This
= SHAlloc(sizeof(*This
))))
1186 return E_OUTOFMEMORY
;
1188 This
->IApplicationDestinations_iface
.lpVtbl
= &ApplicationDestinationsVtbl
;
1191 hr
= IUnknown_QueryInterface(&This
->IApplicationDestinations_iface
, riid
, ppv
);
1200 const KNOWNFOLDERID
*id
;
1202 LPCWSTR szValueName
;
1203 LPCWSTR szDefaultPath
; /* fallback string or resource ID */
1205 /* KNOWNFOLDER_DEFINITION fields */
1206 KF_CATEGORY category
;
1207 const WCHAR
*pszName
;
1208 const WCHAR
*pszDescription
;
1209 const KNOWNFOLDERID
*fidParent
;
1210 const WCHAR
*pszRelativePath
;
1211 const WCHAR
*pszParsingName
;
1212 const WCHAR
*pszTooltip
;
1213 const WCHAR
*pszLocalizedName
;
1214 const WCHAR
*pszIcon
;
1215 const WCHAR
*pszSecurity
;
1217 KF_DEFINITION_FLAGS kfdFlags
;
1218 const FOLDERTYPEID
*ftidType
;
1221 static const CSIDL_DATA CSIDL_Data
[] =
1223 { /* 0x00 - CSIDL_DESKTOP */
1227 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1229 KF_CATEGORY_PERUSER
, /* category */
1230 DesktopW
, /* name */
1231 NULL
, /* description */
1232 &GUID_NULL
, /* parent */
1233 DesktopW
, /* relative path */
1236 NULL
, /* localized */
1238 NULL
, /* security */
1239 FILE_ATTRIBUTE_READONLY
, /* attributes */
1241 &GUID_NULL
/* typeid */
1243 { /* 0x01 - CSIDL_INTERNET */
1244 &FOLDERID_InternetFolder
,
1245 CSIDL_Type_Disallowed
,
1249 KF_CATEGORY_VIRTUAL
, /* category */
1250 InternetFolderW
, /* name */
1251 NULL
, /* description */
1252 &GUID_NULL
, /* parent */
1253 NULL
, /* relative path */
1254 InternetFolderParsingNameW
, /* parsing */
1256 NULL
, /* localized */
1258 NULL
, /* security */
1261 &GUID_NULL
/* typeid */
1263 { /* 0x02 - CSIDL_PROGRAMS */
1267 Start_Menu_ProgramsW
,
1269 KF_CATEGORY_PERUSER
, /* category */
1270 ProgramsW
, /* name */
1271 NULL
, /* description */
1272 &GUID_NULL
, /* parent */
1273 ProgramsW
, /* relative path */
1276 NULL
, /* localized */
1278 NULL
, /* security */
1279 FILE_ATTRIBUTE_READONLY
, /* attributes */
1281 &GUID_NULL
/* typeid */
1283 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1284 &FOLDERID_ControlPanelFolder
,
1285 CSIDL_Type_SystemPath
,
1289 KF_CATEGORY_VIRTUAL
, /* category */
1290 ControlPanelFolderW
, /* name */
1291 NULL
, /* description */
1292 &GUID_NULL
, /* parent */
1293 ControlPanelFolderRelativePathW
, /* relative path */
1294 ControlPanelFolderParsingNameW
, /* parsing */
1296 NULL
, /* localized */
1298 NULL
, /* security */
1301 &GUID_NULL
/* typeid */
1303 { /* 0x04 - CSIDL_PRINTERS */
1304 &FOLDERID_PrintersFolder
,
1305 CSIDL_Type_SystemPath
,
1309 KF_CATEGORY_VIRTUAL
, /* category */
1310 PrintersFolderW
, /* name */
1311 NULL
, /* description */
1312 &GUID_NULL
, /* parent */
1313 NULL
, /* relative path */
1314 PrintersFolderParsingNameW
, /* parsing */
1316 NULL
, /* localized */
1318 NULL
, /* security */
1321 &GUID_NULL
/* typeid */
1323 { /* 0x05 - CSIDL_PERSONAL */
1324 &FOLDERID_Documents
,
1327 MAKEINTRESOURCEW(IDS_PERSONAL
),
1329 KF_CATEGORY_PERUSER
, /* category */
1330 PersonalW
, /* name */
1331 NULL
, /* description */
1332 &GUID_NULL
, /* parent */
1333 DocumentsW
, /* relative path */
1334 DocumentsParsingNameW
, /* parsing */
1336 NULL
, /* localized */
1338 NULL
, /* security */
1339 FILE_ATTRIBUTE_READONLY
, /* attributes */
1340 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1341 &GUID_NULL
/* typeid */
1343 { /* 0x06 - CSIDL_FAVORITES */
1344 &FOLDERID_Favorites
,
1349 KF_CATEGORY_PERUSER
, /* category */
1350 FavoritesW
, /* name */
1351 NULL
, /* description */
1352 &GUID_NULL
, /* parent */
1353 FavoritesW
, /* relative path */
1356 NULL
, /* localized */
1358 NULL
, /* security */
1359 FILE_ATTRIBUTE_READONLY
, /* attributes */
1360 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1361 &GUID_NULL
/* typeid */
1363 { /* 0x07 - CSIDL_STARTUP */
1367 Start_Menu_StartupW
,
1369 KF_CATEGORY_PERUSER
, /* category */
1370 StartupW
, /* name */
1371 NULL
, /* description */
1372 &GUID_NULL
, /* parent */
1373 StartUpW
, /* relative path */
1376 NULL
, /* localized */
1378 NULL
, /* security */
1379 FILE_ATTRIBUTE_READONLY
, /* attributes */
1380 KFDF_PRECREATE
, /* flags */
1381 &GUID_NULL
/* typeid */
1383 { /* 0x08 - CSIDL_RECENT */
1389 KF_CATEGORY_PERUSER
, /* category */
1391 NULL
, /* description */
1392 &FOLDERID_RoamingAppData
, /* parent */
1393 Microsoft_Windows_RecentW
, /* relative path */
1396 NULL
, /* localized */
1398 NULL
, /* security */
1399 FILE_ATTRIBUTE_READONLY
, /* attributes */
1400 KFDF_PRECREATE
, /* flags */
1401 &GUID_NULL
/* typeid */
1403 { /* 0x09 - CSIDL_SENDTO */
1409 KF_CATEGORY_PERUSER
, /* category */
1411 NULL
, /* description */
1412 &FOLDERID_RoamingAppData
, /* parent */
1413 Microsoft_Windows_SendToW
, /* relative path */
1416 NULL
, /* localized */
1418 NULL
, /* security */
1420 KFDF_PRECREATE
, /* flags */
1421 &GUID_NULL
/* typeid */
1423 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1424 &FOLDERID_RecycleBinFolder
,
1425 CSIDL_Type_Disallowed
,
1429 KF_CATEGORY_VIRTUAL
, /* category */
1430 RecycleBinFolderW
, /* name */
1431 NULL
, /* description */
1432 &GUID_NULL
, /* parent */
1433 NULL
, /* relative path */
1434 RecycleBinFolderParsingNameW
, /* parsing */
1436 NULL
, /* localized */
1438 NULL
, /* security */
1441 &GUID_NULL
/* typeid */
1443 { /* 0x0b - CSIDL_STARTMENU */
1444 &FOLDERID_StartMenu
,
1449 KF_CATEGORY_PERUSER
, /* category */
1450 Start_MenuW
, /* name */
1451 NULL
, /* description */
1452 &FOLDERID_RoamingAppData
, /* parent */
1453 Microsoft_Windows_Start_MenuW
, /* relative path */
1456 NULL
, /* localized */
1458 NULL
, /* security */
1459 FILE_ATTRIBUTE_READONLY
, /* attributes */
1460 KFDF_PRECREATE
, /* flags */
1461 &GUID_NULL
/* typeid */
1463 { /* 0x0c - CSIDL_MYDOCUMENTS */
1465 CSIDL_Type_Disallowed
, /* matches WinXP--can't get its path */
1469 { /* 0x0d - CSIDL_MYMUSIC */
1473 MAKEINTRESOURCEW(IDS_MYMUSIC
),
1475 KF_CATEGORY_PERUSER
, /* category */
1476 My_MusicW
, /* name */
1477 NULL
, /* description */
1478 &FOLDERID_Profile
, /* parent */
1479 MusicW
, /* relative path */
1480 MusicParsingNameW
, /* parsing */
1482 NULL
, /* localized */
1484 NULL
, /* security */
1485 FILE_ATTRIBUTE_READONLY
, /* attributes */
1486 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1487 &GUID_NULL
/* typeid */
1489 { /* 0x0e - CSIDL_MYVIDEO */
1493 MAKEINTRESOURCEW(IDS_MYVIDEOS
),
1495 KF_CATEGORY_PERUSER
, /* category */
1496 My_VideoW
, /* name */
1497 NULL
, /* description */
1498 &FOLDERID_Profile
, /* parent */
1499 VideosW
, /* relative path */
1500 VideosParsingNameW
, /* parsing */
1502 NULL
, /* localized */
1504 NULL
, /* security */
1505 FILE_ATTRIBUTE_READONLY
, /* attributes */
1506 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1507 &GUID_NULL
/* typeid */
1509 { /* 0x0f - unassigned */
1511 CSIDL_Type_Disallowed
,
1515 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1519 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1521 KF_CATEGORY_PERUSER
, /* category */
1522 DesktopW
, /* name */
1523 NULL
, /* description */
1524 &FOLDERID_Profile
, /* parent */
1525 DesktopW
, /* relative path */
1528 NULL
, /* localized */
1530 NULL
, /* security */
1531 FILE_ATTRIBUTE_READONLY
, /* attributes */
1532 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1533 &GUID_NULL
/* typeid */
1535 { /* 0x11 - CSIDL_DRIVES */
1536 &FOLDERID_ComputerFolder
,
1537 CSIDL_Type_Disallowed
,
1541 KF_CATEGORY_VIRTUAL
, /* category */
1542 MyComputerFolderW
, /* name */
1543 NULL
, /* description */
1544 &GUID_NULL
, /* parent */
1545 NULL
, /* relative path */
1546 ComputerFolderParsingNameW
, /* parsing */
1548 NULL
, /* localized */
1550 NULL
, /* security */
1553 &GUID_NULL
/* typeid */
1555 { /* 0x12 - CSIDL_NETWORK */
1556 &FOLDERID_NetworkFolder
,
1557 CSIDL_Type_Disallowed
,
1561 KF_CATEGORY_VIRTUAL
, /* category */
1562 NetworkPlacesFolderW
, /* name */
1563 NULL
, /* description */
1564 &GUID_NULL
, /* parent */
1565 NULL
, /* relative path */
1566 NetworkFolderParsingNameW
, /* parsing */
1568 NULL
, /* localized */
1570 NULL
, /* security */
1573 &GUID_NULL
/* typeid */
1575 { /* 0x13 - CSIDL_NETHOOD */
1581 KF_CATEGORY_PERUSER
, /* category */
1582 NetHoodW
, /* name */
1583 NULL
, /* description */
1584 &FOLDERID_RoamingAppData
, /* parent */
1585 Microsoft_Windows_Network_ShortcutsW
, /* relative path */
1588 NULL
, /* localized */
1590 NULL
, /* security */
1593 &GUID_NULL
/* typeid */
1595 { /* 0x14 - CSIDL_FONTS */
1597 CSIDL_Type_WindowsPath
,
1601 KF_CATEGORY_FIXED
, /* category */
1603 NULL
, /* description */
1604 &GUID_NULL
, /* parent */
1605 NULL
, /* relative path */
1608 NULL
, /* localized */
1610 NULL
, /* security */
1613 &FOLDERID_Windows
/* typeid */
1615 { /* 0x15 - CSIDL_TEMPLATES */
1616 &FOLDERID_Templates
,
1621 KF_CATEGORY_PERUSER
, /* category */
1622 TemplatesW
, /* name */
1623 NULL
, /* description */
1624 &FOLDERID_RoamingAppData
, /* parent */
1625 Microsoft_Windows_TemplatesW
, /* relative path */
1628 NULL
, /* localized */
1630 NULL
, /* security */
1633 &GUID_NULL
/* typeid */
1635 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1636 &FOLDERID_CommonStartMenu
,
1637 CSIDL_Type_ProgramData
,
1639 Microsoft_Windows_Start_MenuW
,
1641 KF_CATEGORY_COMMON
, /* category */
1642 Common_Start_MenuW
, /* name */
1643 NULL
, /* description */
1644 &FOLDERID_ProgramData
, /* parent */
1645 Microsoft_Windows_Start_MenuW
, /* relative path */
1648 NULL
, /* localized */
1650 NULL
, /* security */
1651 FILE_ATTRIBUTE_READONLY
, /* attributes */
1653 &GUID_NULL
/* typeid */
1655 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1656 &FOLDERID_CommonPrograms
,
1657 CSIDL_Type_ProgramData
,
1659 Microsoft_Windows_Start_Menu_ProgramsW
,
1661 KF_CATEGORY_COMMON
, /* category */
1662 Common_ProgramsW
, /* name */
1663 NULL
, /* description */
1664 &FOLDERID_CommonStartMenu
, /* parent */
1665 ProgramsW
, /* relative path */
1668 NULL
, /* localized */
1670 NULL
, /* security */
1671 FILE_ATTRIBUTE_READONLY
, /* attributes */
1673 &GUID_NULL
/* typeid */
1675 { /* 0x18 - CSIDL_COMMON_STARTUP */
1676 &FOLDERID_CommonStartup
,
1677 CSIDL_Type_ProgramData
,
1679 Microsoft_Windows_Start_Menu_StartupW
,
1681 KF_CATEGORY_COMMON
, /* category */
1682 Common_StartupW
, /* name */
1683 NULL
, /* description */
1684 &FOLDERID_CommonPrograms
, /* parent */
1685 StartUpW
, /* relative path */
1688 NULL
, /* localized */
1690 NULL
, /* security */
1691 FILE_ATTRIBUTE_READONLY
, /* attributes */
1692 KFDF_PRECREATE
, /* flags */
1693 &GUID_NULL
/* typeid */
1695 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1696 &FOLDERID_PublicDesktop
,
1697 CSIDL_Type_AllUsers
,
1699 MAKEINTRESOURCEW(IDS_DESKTOPDIRECTORY
),
1701 KF_CATEGORY_COMMON
, /* category */
1702 Common_DesktopW
, /* name */
1703 NULL
, /* description */
1704 &FOLDERID_Public
, /* parent */
1705 DesktopW
, /* relative path */
1708 NULL
, /* localized */
1710 NULL
, /* security */
1711 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
1712 KFDF_PRECREATE
, /* flags */
1713 &GUID_NULL
/* typeid */
1715 { /* 0x1a - CSIDL_APPDATA */
1716 &FOLDERID_RoamingAppData
,
1721 KF_CATEGORY_PERUSER
, /* category */
1722 AppDataW
, /* name */
1723 NULL
, /* description */
1724 &FOLDERID_Profile
, /* parent */
1725 AppData_RoamingW
, /* relative path */
1728 NULL
, /* localized */
1730 NULL
, /* security */
1733 &GUID_NULL
/* typeid */
1735 { /* 0x1b - CSIDL_PRINTHOOD */
1736 &FOLDERID_PrintHood
,
1741 KF_CATEGORY_PERUSER
, /* category */
1742 PrintHoodW
, /* name */
1743 NULL
, /* description */
1744 &FOLDERID_RoamingAppData
, /* parent */
1745 Microsoft_Windows_Printer_ShortcutsW
, /* relative path */
1748 NULL
, /* localized */
1750 NULL
, /* security */
1753 &GUID_NULL
/* typeid */
1755 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1756 &FOLDERID_LocalAppData
,
1759 Local_Settings_Application_DataW
,
1761 KF_CATEGORY_PERUSER
, /* category */
1762 Local_AppDataW
, /* name */
1763 NULL
, /* description */
1764 &FOLDERID_Profile
, /* parent */
1765 AppData_LocalW
, /* relative path */
1768 NULL
, /* localized */
1770 NULL
, /* security */
1772 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1773 &GUID_NULL
/* typeid */
1775 { /* 0x1d - CSIDL_ALTSTARTUP */
1777 CSIDL_Type_NonExistent
,
1781 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1783 CSIDL_Type_NonExistent
,
1787 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1788 &FOLDERID_Favorites
,
1789 CSIDL_Type_AllUsers
,
1793 KF_CATEGORY_PERUSER
, /* category */
1794 FavoritesW
, /* name */
1795 NULL
, /* description */
1796 &FOLDERID_Profile
, /* parent */
1797 FavoritesW
, /* relative path */
1800 NULL
, /* localized */
1802 NULL
, /* security */
1803 FILE_ATTRIBUTE_READONLY
, /* attributes */
1804 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1805 &GUID_NULL
/* typeid */
1807 { /* 0x20 - CSIDL_INTERNET_CACHE */
1808 &FOLDERID_InternetCache
,
1811 Local_Settings_Temporary_Internet_FilesW
,
1813 KF_CATEGORY_PERUSER
, /* category */
1815 NULL
, /* description */
1816 &FOLDERID_LocalAppData
, /* parent */
1817 Microsoft_Windows_Temporary_Internet_FilesW
, /* relative path */
1820 NULL
, /* localized */
1822 NULL
, /* security */
1824 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1825 &GUID_NULL
/* typeid */
1827 { /* 0x21 - CSIDL_COOKIES */
1833 KF_CATEGORY_PERUSER
, /* category */
1834 CookiesW
, /* name */
1835 NULL
, /* description */
1836 &FOLDERID_RoamingAppData
, /* parent */
1837 Microsoft_Windows_CookiesW
, /* relative path */
1840 NULL
, /* localized */
1842 NULL
, /* security */
1845 &GUID_NULL
/* typeid */
1847 { /* 0x22 - CSIDL_HISTORY */
1851 Local_Settings_HistoryW
,
1853 KF_CATEGORY_PERUSER
, /* category */
1854 HistoryW
, /* name */
1855 NULL
, /* description */
1856 &FOLDERID_LocalAppData
, /* parent */
1857 Microsoft_Windows_HistoryW
, /* relative path */
1860 NULL
, /* localized */
1862 NULL
, /* security */
1864 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1865 &GUID_NULL
/* typeid */
1867 { /* 0x23 - CSIDL_COMMON_APPDATA */
1868 &FOLDERID_ProgramData
,
1869 CSIDL_Type_ProgramData
,
1873 KF_CATEGORY_FIXED
, /* category */
1874 Common_AppDataW
, /* name */
1875 NULL
, /* description */
1876 &GUID_NULL
, /* parent */
1877 NULL
, /* relative path */
1880 NULL
, /* localized */
1882 NULL
, /* security */
1885 &GUID_NULL
/* typeid */
1887 { /* 0x24 - CSIDL_WINDOWS */
1889 CSIDL_Type_WindowsPath
,
1893 KF_CATEGORY_FIXED
, /* category */
1894 WindowsW
, /* name */
1895 NULL
, /* description */
1896 &GUID_NULL
, /* parent */
1897 NULL
, /* relative path */
1900 NULL
, /* localized */
1902 NULL
, /* security */
1905 &GUID_NULL
/* typeid */
1907 { /* 0x25 - CSIDL_SYSTEM */
1909 CSIDL_Type_SystemPath
,
1913 KF_CATEGORY_FIXED
, /* category */
1915 NULL
, /* description */
1916 &GUID_NULL
, /* parent */
1917 NULL
, /* relative path */
1920 NULL
, /* localized */
1922 NULL
, /* security */
1925 &GUID_NULL
/* typeid */
1927 { /* 0x26 - CSIDL_PROGRAM_FILES */
1928 &FOLDERID_ProgramFiles
,
1933 KF_CATEGORY_FIXED
, /* category */
1934 ProgramFilesW
, /* name */
1935 NULL
, /* description */
1936 &GUID_NULL
, /* parent */
1937 NULL
, /* relative path */
1940 NULL
, /* localized */
1942 NULL
, /* security */
1943 FILE_ATTRIBUTE_READONLY
, /* attributes */
1945 &GUID_NULL
/* typeid */
1947 { /* 0x27 - CSIDL_MYPICTURES */
1951 MAKEINTRESOURCEW(IDS_MYPICTURES
),
1953 KF_CATEGORY_PERUSER
, /* category */
1954 My_PicturesW
, /* name */
1955 NULL
, /* description */
1956 &FOLDERID_Profile
, /* parent */
1957 PicturesW
, /* relative path */
1958 PicturesParsingNameW
, /* parsing */
1960 NULL
, /* localized */
1962 NULL
, /* security */
1963 FILE_ATTRIBUTE_READONLY
, /* attributes */
1964 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1965 &GUID_NULL
/* typeid */
1967 { /* 0x28 - CSIDL_PROFILE */
1973 KF_CATEGORY_FIXED
, /* category */
1974 ProfileW
, /* name */
1975 NULL
, /* description */
1976 &GUID_NULL
, /* parent */
1977 NULL
, /* relative path */
1980 NULL
, /* localized */
1982 NULL
, /* security */
1985 &GUID_NULL
/* typeid */
1987 { /* 0x29 - CSIDL_SYSTEMX86 */
1988 &FOLDERID_SystemX86
,
1989 CSIDL_Type_SystemX86Path
,
1993 KF_CATEGORY_FIXED
, /* category */
1994 SystemX86W
, /* name */
1995 NULL
, /* description */
1996 &GUID_NULL
, /* parent */
1997 NULL
, /* relative path */
2000 NULL
, /* localized */
2002 NULL
, /* security */
2005 &GUID_NULL
/* typeid */
2007 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
2008 &FOLDERID_ProgramFilesX86
,
2010 ProgramFilesDirX86W
,
2013 KF_CATEGORY_FIXED
, /* category */
2014 ProgramFilesX86W
, /* name */
2015 NULL
, /* description */
2016 &GUID_NULL
, /* parent */
2017 NULL
, /* relative path */
2020 NULL
, /* localized */
2022 NULL
, /* security */
2023 FILE_ATTRIBUTE_READONLY
, /* attributes */
2025 &GUID_NULL
/* typeid */
2027 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
2028 &FOLDERID_ProgramFilesCommon
,
2031 Program_Files_Common_FilesW
,
2033 KF_CATEGORY_FIXED
, /* category */
2034 ProgramFilesCommonW
, /* name */
2035 NULL
, /* description */
2036 &GUID_NULL
, /* parent */
2037 NULL
, /* relative path */
2040 NULL
, /* localized */
2042 NULL
, /* security */
2045 &GUID_NULL
/* typeid */
2047 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
2048 &FOLDERID_ProgramFilesCommonX86
,
2051 Program_Files_x86_Common_FilesW
,
2053 KF_CATEGORY_FIXED
, /* category */
2054 ProgramFilesCommonX86W
, /* name */
2055 NULL
, /* description */
2056 &GUID_NULL
, /* parent */
2057 NULL
, /* relative path */
2060 NULL
, /* localized */
2062 NULL
, /* security */
2065 &GUID_NULL
/* typeid */
2067 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2068 &FOLDERID_CommonTemplates
,
2069 CSIDL_Type_ProgramData
,
2071 Microsoft_Windows_TemplatesW
,
2073 KF_CATEGORY_COMMON
, /* category */
2074 Common_TemplatesW
, /* name */
2075 NULL
, /* description */
2076 &FOLDERID_ProgramData
, /* parent */
2077 Microsoft_Windows_TemplatesW
, /* relative path */
2080 NULL
, /* localized */
2082 NULL
, /* security */
2085 &GUID_NULL
/* typeid */
2087 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2088 &FOLDERID_PublicDocuments
,
2089 CSIDL_Type_AllUsers
,
2093 KF_CATEGORY_COMMON
, /* category */
2094 Common_DocumentsW
, /* name */
2095 NULL
, /* description */
2096 &FOLDERID_Public
, /* parent */
2097 DocumentsW
, /* relative path */
2100 NULL
, /* localized */
2102 NULL
, /* security */
2103 FILE_ATTRIBUTE_READONLY
, /* attributes */
2104 KFDF_PRECREATE
, /* flags */
2105 &GUID_NULL
/* typeid */
2107 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2108 &FOLDERID_CommonAdminTools
,
2109 CSIDL_Type_ProgramData
,
2110 Common_Administrative_ToolsW
,
2111 Microsoft_Windows_Start_Menu_Admin_ToolsW
,
2113 KF_CATEGORY_COMMON
, /* category */
2114 Common_Administrative_ToolsW
, /* name */
2115 NULL
, /* description */
2116 &FOLDERID_CommonPrograms
, /* parent */
2117 Administrative_ToolsW
, /* relative path */
2120 NULL
, /* localized */
2122 NULL
, /* security */
2123 FILE_ATTRIBUTE_READONLY
, /* attributes */
2124 KFDF_PRECREATE
, /* flags */
2125 &GUID_NULL
/* typeid */
2127 { /* 0x30 - CSIDL_ADMINTOOLS */
2128 &FOLDERID_AdminTools
,
2130 Administrative_ToolsW
,
2131 Start_Menu_Admin_ToolsW
,
2133 KF_CATEGORY_PERUSER
, /* category */
2134 Administrative_ToolsW
, /* name */
2135 NULL
, /* description */
2136 &FOLDERID_Programs
, /* parent */
2137 Administrative_ToolsW
, /* relative path */
2140 NULL
, /* localized */
2142 NULL
, /* security */
2143 FILE_ATTRIBUTE_READONLY
, /* attributes */
2144 KFDF_PRECREATE
, /* flags */
2145 &GUID_NULL
/* typeid */
2147 { /* 0x31 - CSIDL_CONNECTIONS */
2148 &FOLDERID_ConnectionsFolder
,
2149 CSIDL_Type_Disallowed
,
2153 KF_CATEGORY_VIRTUAL
, /* category */
2154 ConnectionsFolderW
, /* name */
2155 NULL
, /* description */
2156 &GUID_NULL
, /* parent */
2157 Administrative_ToolsW
, /* relative path */
2158 ConnectionsFolderParsingNameW
, /* parsing */
2160 NULL
, /* localized */
2162 NULL
, /* security */
2165 &GUID_NULL
/* typeid */
2167 { /* 0x32 - unassigned */
2169 CSIDL_Type_Disallowed
,
2173 { /* 0x33 - unassigned */
2175 CSIDL_Type_Disallowed
,
2179 { /* 0x34 - unassigned */
2181 CSIDL_Type_Disallowed
,
2185 { /* 0x35 - CSIDL_COMMON_MUSIC */
2186 &FOLDERID_PublicMusic
,
2187 CSIDL_Type_AllUsers
,
2191 KF_CATEGORY_COMMON
, /* category */
2192 CommonMusicW
, /* name */
2193 NULL
, /* description */
2194 &FOLDERID_Public
, /* parent */
2195 MusicW
, /* relative path */
2198 NULL
, /* localized */
2200 NULL
, /* security */
2201 FILE_ATTRIBUTE_READONLY
, /* attributes */
2202 KFDF_PRECREATE
, /* flags */
2203 &GUID_NULL
/* typeid */
2205 { /* 0x36 - CSIDL_COMMON_PICTURES */
2206 &FOLDERID_PublicPictures
,
2207 CSIDL_Type_AllUsers
,
2211 KF_CATEGORY_COMMON
, /* category */
2212 CommonPicturesW
, /* name */
2213 NULL
, /* description */
2214 &FOLDERID_Public
, /* parent */
2215 PicturesW
, /* relative path */
2218 NULL
, /* localized */
2220 NULL
, /* security */
2221 FILE_ATTRIBUTE_READONLY
, /* attributes */
2222 KFDF_PRECREATE
, /* flags */
2223 &GUID_NULL
/* typeid */
2225 { /* 0x37 - CSIDL_COMMON_VIDEO */
2226 &FOLDERID_PublicVideos
,
2227 CSIDL_Type_AllUsers
,
2231 KF_CATEGORY_COMMON
, /* category */
2232 CommonVideoW
, /* name */
2233 NULL
, /* description */
2234 &FOLDERID_Public
, /* parent */
2235 VideosW
, /* relative path */
2238 NULL
, /* localized */
2240 NULL
, /* security */
2241 FILE_ATTRIBUTE_READONLY
, /* attributes */
2242 KFDF_PRECREATE
, /* flags */
2243 &GUID_NULL
/* typeid */
2245 { /* 0x38 - CSIDL_RESOURCES */
2246 &FOLDERID_ResourceDir
,
2247 CSIDL_Type_WindowsPath
,
2251 KF_CATEGORY_FIXED
, /* category */
2252 ResourceDirW
, /* name */
2253 NULL
, /* description */
2254 &GUID_NULL
, /* parent */
2255 NULL
, /* relative path */
2258 NULL
, /* localized */
2260 NULL
, /* security */
2263 &GUID_NULL
/* typeid */
2265 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2266 &FOLDERID_LocalizedResourcesDir
,
2267 CSIDL_Type_NonExistent
,
2271 KF_CATEGORY_FIXED
, /* category */
2272 LocalizedResourcesDirW
, /* name */
2273 NULL
, /* description */
2274 &GUID_NULL
, /* parent */
2275 NULL
, /* relative path */
2278 NULL
, /* localized */
2280 NULL
, /* security */
2283 &GUID_NULL
/* typeid */
2285 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2286 &FOLDERID_CommonOEMLinks
,
2287 CSIDL_Type_ProgramData
,
2291 KF_CATEGORY_COMMON
, /* category */
2292 OEM_LinksW
, /* name */
2293 NULL
, /* description */
2294 &FOLDERID_ProgramData
, /* parent */
2295 OEM_LinksW
, /* relative path */
2298 NULL
, /* localized */
2300 NULL
, /* security */
2303 &GUID_NULL
/* typeid */
2305 { /* 0x3b - CSIDL_CDBURN_AREA */
2306 &FOLDERID_CDBurning
,
2309 Local_Settings_CD_BurningW
,
2311 KF_CATEGORY_PERUSER
, /* category */
2312 CD_BurningW
, /* name */
2313 NULL
, /* description */
2314 &FOLDERID_LocalAppData
, /* parent */
2315 Microsoft_Windows_Burn_BurnW
, /* relative path */
2318 NULL
, /* localized */
2320 NULL
, /* security */
2321 FILE_ATTRIBUTE_READONLY
, /* attributes */
2322 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2323 &GUID_NULL
/* typeid */
2325 { /* 0x3c unassigned */
2327 CSIDL_Type_Disallowed
,
2331 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2333 CSIDL_Type_Disallowed
, /* FIXME */
2337 { /* 0x3e - CSIDL_PROFILES */
2339 CSIDL_Type_Disallowed
, /* oddly, this matches WinXP */
2344 &FOLDERID_AddNewPrograms
,
2345 CSIDL_Type_Disallowed
,
2349 KF_CATEGORY_VIRTUAL
, /* category */
2350 AddNewProgramsFolderW
, /* name */
2351 NULL
, /* description */
2352 &GUID_NULL
, /* parent */
2353 NULL
, /* relative path */
2354 AddNewProgramsParsingNameW
, /* parsing */
2356 NULL
, /* localized */
2358 NULL
, /* security */
2361 &GUID_NULL
/* typeid */
2364 &FOLDERID_AppUpdates
,
2365 CSIDL_Type_Disallowed
,
2369 KF_CATEGORY_VIRTUAL
, /* category */
2370 AppUpdatesFolderW
, /* name */
2371 NULL
, /* description */
2372 &GUID_NULL
, /* parent */
2373 NULL
, /* relative path */
2374 AppUpdatesParsingNameW
, /* parsing */
2376 NULL
, /* localized */
2378 NULL
, /* security */
2381 &GUID_NULL
/* typeid */
2384 &FOLDERID_ChangeRemovePrograms
,
2385 CSIDL_Type_Disallowed
,
2389 KF_CATEGORY_VIRTUAL
, /* category */
2390 ChangeRemoveProgramsFolderW
, /* name */
2391 NULL
, /* description */
2392 &GUID_NULL
, /* parent */
2393 NULL
, /* relative path */
2394 ChangeRemoveProgramsParsingNameW
, /* parsing */
2396 NULL
, /* localized */
2398 NULL
, /* security */
2401 &GUID_NULL
/* typeid */
2404 &FOLDERID_ConflictFolder
,
2405 CSIDL_Type_Disallowed
,
2409 KF_CATEGORY_VIRTUAL
, /* category */
2410 ConflictFolderW
, /* name */
2411 NULL
, /* description */
2412 &GUID_NULL
, /* parent */
2413 NULL
, /* relative path */
2414 ConflictFolderParsingNameW
, /* parsing */
2416 NULL
, /* localized */
2418 NULL
, /* security */
2421 &GUID_NULL
/* typeid */
2423 { /* 0x43 - CSIDL_CONTACTS */
2429 KF_CATEGORY_PERUSER
, /* category */
2430 ContactsW
, /* name */
2431 NULL
, /* description */
2432 &FOLDERID_Profile
, /* parent */
2433 ContactsW
, /* relative path */
2434 ContactsParsingNameW
, /* parsing */
2436 NULL
, /* localized */
2438 NULL
, /* security */
2439 FILE_ATTRIBUTE_READONLY
, /* attributes */
2440 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2441 &GUID_NULL
/* typeid */
2444 &FOLDERID_DeviceMetadataStore
,
2445 CSIDL_Type_Disallowed
, /* FIXME */
2449 KF_CATEGORY_COMMON
, /* category */
2450 Device_Metadata_StoreW
, /* name */
2451 NULL
, /* description */
2452 &FOLDERID_ProgramData
, /* parent */
2453 Microsoft_Windows_DeviceMetadataStoreW
, /* relative path */
2456 NULL
, /* localized */
2458 NULL
, /* security */
2461 &GUID_NULL
/* typeid */
2470 &FOLDERID_DocumentsLibrary
,
2471 CSIDL_Type_Disallowed
, /* FIXME */
2475 KF_CATEGORY_PERUSER
, /* category */
2476 DocumentsLibraryW
, /* name */
2477 NULL
, /* description */
2478 &FOLDERID_Libraries
, /* parent */
2479 Documents_librarymsW
, /* relative path */
2480 DocumentsLibraryParsingNameW
, /* parsing */
2482 NULL
, /* localized */
2484 NULL
, /* security */
2486 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2487 &GUID_NULL
/* typeid */
2489 { /* 0x47 - CSIDL_DOWNLOADS */
2490 &FOLDERID_Downloads
,
2495 KF_CATEGORY_PERUSER
, /* category */
2496 DownloadsW
, /* name */
2497 NULL
, /* description */
2498 &FOLDERID_Profile
, /* parent */
2499 DownloadsW
, /* relative path */
2502 NULL
, /* localized */
2504 NULL
, /* security */
2505 FILE_ATTRIBUTE_READONLY
, /* attributes */
2506 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2507 &GUID_NULL
/* typeid */
2511 CSIDL_Type_Disallowed
,
2515 KF_CATEGORY_VIRTUAL
, /* category */
2517 NULL
, /* description */
2518 &GUID_NULL
, /* parent */
2519 NULL
, /* relative path */
2520 GamesParsingNameW
, /* parsing */
2522 NULL
, /* localized */
2524 NULL
, /* security */
2527 &GUID_NULL
/* typeid */
2530 &FOLDERID_GameTasks
,
2531 CSIDL_Type_Disallowed
, /* FIXME */
2535 KF_CATEGORY_PERUSER
, /* category */
2536 GameTasksW
, /* name */
2537 NULL
, /* description */
2538 &FOLDERID_LocalAppData
, /* parent */
2539 Microsoft_Windows_GameExplorerW
, /* relative path */
2542 NULL
, /* localized */
2544 NULL
, /* security */
2546 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2547 &GUID_NULL
/* typeid */
2550 &FOLDERID_HomeGroup
,
2551 CSIDL_Type_Disallowed
,
2555 KF_CATEGORY_VIRTUAL
, /* category */
2556 HomeGroupFolderW
, /* name */
2557 NULL
, /* description */
2558 &GUID_NULL
, /* parent */
2559 NULL
, /* relative path */
2560 HomeGroupParsingNameW
, /* parsing */
2562 NULL
, /* localized */
2564 NULL
, /* security */
2567 &GUID_NULL
/* typeid */
2570 &FOLDERID_ImplicitAppShortcuts
,
2571 CSIDL_Type_Disallowed
, /* FIXME */
2575 KF_CATEGORY_PERUSER
, /* category */
2576 ImplicitAppShortcutsW
, /* name */
2577 NULL
, /* description */
2578 &FOLDERID_UserPinned
, /* parent */
2579 ImplicitAppShortcutsW
, /* relative path */
2582 NULL
, /* localized */
2584 NULL
, /* security */
2586 KFDF_PRECREATE
, /* flags */
2587 &GUID_NULL
/* typeid */
2590 &FOLDERID_Libraries
,
2591 CSIDL_Type_Disallowed
, /* FIXME */
2595 KF_CATEGORY_PERUSER
, /* category */
2596 LibrariesW
, /* name */
2597 NULL
, /* description */
2598 &FOLDERID_RoamingAppData
, /* parent */
2599 Microsoft_Windows_LibrariesW
, /* relative path */
2602 NULL
, /* localized */
2604 NULL
, /* security */
2606 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2607 &GUID_NULL
/* typeid */
2609 { /* 0x4d - CSIDL_LINKS */
2615 KF_CATEGORY_PERUSER
, /* category */
2617 NULL
, /* description */
2618 &FOLDERID_Profile
, /* parent */
2619 LinksW
, /* relative path */
2620 LinksParsingNameW
, /* parsing */
2622 NULL
, /* localized */
2624 NULL
, /* security */
2625 FILE_ATTRIBUTE_READONLY
, /* attributes */
2626 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2627 &GUID_NULL
/* typeid */
2629 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2630 &FOLDERID_LocalAppDataLow
,
2635 KF_CATEGORY_PERUSER
, /* category */
2636 LocalAppDataLowW
, /* name */
2637 NULL
, /* description */
2638 &FOLDERID_Profile
, /* parent */
2639 AppData_LocalLowW
, /* relative path */
2642 NULL
, /* localized */
2644 NULL
, /* security */
2645 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
, /* attributes */
2646 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2647 &GUID_NULL
/* typeid */
2650 &FOLDERID_MusicLibrary
,
2651 CSIDL_Type_Disallowed
, /* FIXME */
2655 KF_CATEGORY_PERUSER
, /* category */
2656 MusicLibraryW
, /* name */
2657 NULL
, /* description */
2658 &FOLDERID_Libraries
, /* parent */
2659 Music_librarymsW
, /* relative path */
2660 MusicLibraryParsingNameW
, /* parsing */
2662 NULL
, /* localized */
2664 NULL
, /* security */
2666 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2667 &GUID_NULL
/* typeid */
2670 &FOLDERID_OriginalImages
,
2671 CSIDL_Type_Disallowed
, /* FIXME */
2675 KF_CATEGORY_PERUSER
, /* category */
2676 Original_ImagesW
, /* name */
2677 NULL
, /* description */
2678 &FOLDERID_LocalAppData
, /* parent */
2679 Microsoft_Windows_Photo_Gallery_Original_ImagesW
, /* relative path */
2682 NULL
, /* localized */
2684 NULL
, /* security */
2687 &GUID_NULL
/* typeid */
2690 &FOLDERID_PhotoAlbums
,
2693 Pictures_Slide_ShowsW
,
2695 KF_CATEGORY_PERUSER
, /* category */
2696 PhotoAlbumsW
, /* name */
2697 NULL
, /* description */
2698 &FOLDERID_Pictures
, /* parent */
2699 Slide_ShowsW
, /* relative path */
2702 NULL
, /* localized */
2704 NULL
, /* security */
2705 FILE_ATTRIBUTE_READONLY
, /* attributes */
2707 &GUID_NULL
/* typeid */
2710 &FOLDERID_PicturesLibrary
,
2711 CSIDL_Type_Disallowed
, /* FIXME */
2715 KF_CATEGORY_PERUSER
, /* category */
2716 PicturesLibraryW
, /* name */
2717 NULL
, /* description */
2718 &FOLDERID_Libraries
, /* parent */
2719 Pictures_librarymsW
, /* relative path */
2720 PicturesLibraryParsingNameW
, /* parsing */
2722 NULL
, /* localized */
2724 NULL
, /* security */
2726 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2727 &GUID_NULL
/* typeid */
2730 &FOLDERID_Playlists
,
2735 KF_CATEGORY_PERUSER
, /* category */
2736 PlaylistsW
, /* name */
2737 NULL
, /* description */
2738 &FOLDERID_Music
, /* parent */
2739 PlaylistsW
, /* relative path */
2742 NULL
, /* localized */
2744 NULL
, /* security */
2745 FILE_ATTRIBUTE_READONLY
, /* attributes */
2747 &GUID_NULL
/* typeid */
2750 &FOLDERID_ProgramFilesX64
,
2756 CSIDL_Type_NonExistent
,
2761 KF_CATEGORY_FIXED
, /* category */
2762 ProgramFilesX64W
, /* name */
2763 NULL
, /* description */
2764 &GUID_NULL
, /* parent */
2765 NULL
, /* relative path */
2768 NULL
, /* localized */
2770 NULL
, /* security */
2773 &GUID_NULL
/* typeid */
2776 &FOLDERID_ProgramFilesCommonX64
,
2779 ProgramFilesCommonX64W
,
2780 Program_Files_Common_FilesW
,
2782 CSIDL_Type_NonExistent
,
2787 KF_CATEGORY_FIXED
, /* category */
2788 ProgramFilesCommonX64W
, /* name */
2789 NULL
, /* description */
2790 &GUID_NULL
, /* parent */
2791 NULL
, /* relative path */
2794 NULL
, /* localized */
2796 NULL
, /* security */
2799 &GUID_NULL
/* typeid */
2803 CSIDL_Type_CurrVer
, /* FIXME */
2807 KF_CATEGORY_FIXED
, /* category */
2809 NULL
, /* description */
2810 &GUID_NULL
, /* parent */
2811 NULL
, /* relative path */
2812 PublicParsingNameW
, /* parsing */
2814 NULL
, /* localized */
2816 NULL
, /* security */
2817 FILE_ATTRIBUTE_READONLY
, /* attributes */
2818 KFDF_PRECREATE
, /* flags */
2819 &GUID_NULL
/* typeid */
2822 &FOLDERID_PublicDownloads
,
2823 CSIDL_Type_AllUsers
,
2827 KF_CATEGORY_COMMON
, /* category */
2828 CommonDownloadsW
, /* name */
2829 NULL
, /* description */
2830 &FOLDERID_Public
, /* parent */
2831 DownloadsW
, /* relative path */
2834 NULL
, /* localized */
2836 NULL
, /* security */
2837 FILE_ATTRIBUTE_READONLY
, /* attributes */
2838 KFDF_PRECREATE
, /* flags */
2839 &GUID_NULL
/* typeid */
2842 &FOLDERID_PublicGameTasks
,
2843 CSIDL_Type_ProgramData
,
2845 Microsoft_Windows_GameExplorerW
,
2847 KF_CATEGORY_COMMON
, /* category */
2848 PublicGameTasksW
, /* name */
2849 NULL
, /* description */
2850 &FOLDERID_ProgramData
, /* parent */
2851 Microsoft_Windows_GameExplorerW
, /* relative path */
2854 NULL
, /* localized */
2856 NULL
, /* security */
2858 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2859 &GUID_NULL
/* typeid */
2862 &FOLDERID_PublicLibraries
,
2863 CSIDL_Type_AllUsers
,
2865 Microsoft_Windows_LibrariesW
,
2867 KF_CATEGORY_COMMON
, /* category */
2868 PublicLibrariesW
, /* name */
2869 NULL
, /* description */
2870 &FOLDERID_Public
, /* parent */
2871 LibrariesW
, /* relative path */
2874 NULL
, /* localized */
2876 NULL
, /* security */
2877 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
2878 KFDF_PRECREATE
, /* flags */
2879 &GUID_NULL
/* typeid */
2882 &FOLDERID_PublicRingtones
,
2883 CSIDL_Type_ProgramData
,
2885 Microsoft_Windows_RingtonesW
,
2887 KF_CATEGORY_COMMON
, /* category */
2888 CommonRingtonesW
, /* name */
2889 NULL
, /* description */
2890 &FOLDERID_ProgramData
, /* parent */
2891 Microsoft_Windows_RingtonesW
, /* relative path */
2894 NULL
, /* localized */
2896 NULL
, /* security */
2898 KFDF_PRECREATE
, /* flags */
2899 &GUID_NULL
/* typeid */
2902 &FOLDERID_QuickLaunch
,
2903 CSIDL_Type_Disallowed
, /* FIXME */
2907 KF_CATEGORY_PERUSER
, /* category */
2908 Quick_LaunchW
, /* name */
2909 NULL
, /* description */
2910 &FOLDERID_RoamingAppData
, /* parent */
2911 Microsoft_Internet_Explorer_Quick_LaunchW
, /* relative path */
2914 NULL
, /* localized */
2916 NULL
, /* security */
2919 &GUID_NULL
/* typeid */
2922 &FOLDERID_RecordedTVLibrary
,
2923 CSIDL_Type_Disallowed
, /* FIXME */
2927 KF_CATEGORY_COMMON
, /* category */
2928 RecordedTVLibraryW
, /* name */
2929 NULL
, /* description */
2930 &FOLDERID_PublicLibraries
, /* parent */
2931 RecordedTV_librarymsW
, /* relative path */
2934 NULL
, /* localized */
2936 NULL
, /* security */
2938 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2939 &GUID_NULL
/* typeid */
2942 &FOLDERID_Ringtones
,
2943 CSIDL_Type_Disallowed
, /* FIXME */
2947 KF_CATEGORY_PERUSER
, /* category */
2948 RingtonesW
, /* name */
2949 NULL
, /* description */
2950 &FOLDERID_LocalAppData
, /* parent */
2951 Microsoft_Windows_RingtonesW
, /* relative path */
2954 NULL
, /* localized */
2956 NULL
, /* security */
2958 KFDF_PRECREATE
, /* flags */
2959 &GUID_NULL
/* typeid */
2962 &FOLDERID_SampleMusic
,
2963 CSIDL_Type_AllUsers
,
2965 Music_Sample_MusicW
,
2967 KF_CATEGORY_COMMON
, /* category */
2968 SampleMusicW
, /* name */
2969 NULL
, /* description */
2970 &FOLDERID_PublicMusic
, /* parent */
2971 Sample_MusicW
, /* relative path */
2974 NULL
, /* localized */
2976 NULL
, /* security */
2977 FILE_ATTRIBUTE_READONLY
, /* attributes */
2978 KFDF_PRECREATE
, /* flags */
2979 &GUID_NULL
/* typeid */
2982 &FOLDERID_SamplePictures
,
2983 CSIDL_Type_AllUsers
,
2985 Pictures_Sample_PicturesW
,
2987 KF_CATEGORY_COMMON
, /* category */
2988 SamplePicturesW
, /* name */
2989 NULL
, /* description */
2990 &FOLDERID_PublicPictures
, /* parent */
2991 Sample_PicturesW
, /* relative path */
2994 NULL
, /* localized */
2996 NULL
, /* security */
2997 FILE_ATTRIBUTE_READONLY
, /* attributes */
2998 KFDF_PRECREATE
, /* flags */
2999 &GUID_NULL
/* typeid */
3002 &FOLDERID_SamplePlaylists
,
3003 CSIDL_Type_AllUsers
,
3005 Music_Sample_PlaylistsW
,
3007 KF_CATEGORY_COMMON
, /* category */
3008 SamplePlaylistsW
, /* name */
3009 NULL
, /* description */
3010 &FOLDERID_PublicMusic
, /* parent */
3011 Sample_PlaylistsW
, /* relative path */
3014 NULL
, /* localized */
3016 NULL
, /* security */
3017 FILE_ATTRIBUTE_READONLY
, /* attributes */
3018 KFDF_PRECREATE
, /* flags */
3019 &GUID_NULL
/* typeid */
3022 &FOLDERID_SampleVideos
,
3023 CSIDL_Type_AllUsers
,
3025 Videos_Sample_VideosW
,
3027 KF_CATEGORY_COMMON
, /* category */
3028 SampleVideosW
, /* name */
3029 NULL
, /* description */
3030 &FOLDERID_PublicVideos
, /* parent */
3031 Sample_VideosW
, /* relative path */
3034 NULL
, /* localized */
3036 NULL
, /* security */
3037 FILE_ATTRIBUTE_READONLY
, /* attributes */
3038 KFDF_PRECREATE
, /* flags */
3039 &GUID_NULL
/* typeid */
3041 { /* 0x62 - CSIDL_SAVED_GAMES */
3042 &FOLDERID_SavedGames
,
3047 KF_CATEGORY_PERUSER
, /* category */
3048 SavedGamesW
, /* name */
3049 NULL
, /* description */
3050 &FOLDERID_Profile
, /* parent */
3051 Saved_GamesW
, /* relative path */
3052 SavedGamesParsingNameW
, /* parsing */
3054 NULL
, /* localized */
3056 NULL
, /* security */
3057 FILE_ATTRIBUTE_READONLY
, /* attributes */
3058 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
3059 &GUID_NULL
/* typeid */
3061 { /* 0x63 - CSIDL_SEARCHES */
3062 &FOLDERID_SavedSearches
,
3067 KF_CATEGORY_PERUSER
, /* category */
3068 SearchesW
, /* name */
3069 NULL
, /* description */
3070 &FOLDERID_Profile
, /* parent */
3071 SearchesW
, /* relative path */
3072 SavedSearchesParsingNameW
, /* parsing */
3074 NULL
, /* localized */
3076 NULL
, /* security */
3077 FILE_ATTRIBUTE_READONLY
, /* attributes */
3078 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
3079 &GUID_NULL
/* typeid */
3082 &FOLDERID_SEARCH_CSC
,
3083 CSIDL_Type_Disallowed
,
3087 KF_CATEGORY_VIRTUAL
, /* category */
3088 CSCFolderW
, /* name */
3089 NULL
, /* description */
3090 &GUID_NULL
, /* parent */
3091 NULL
, /* relative path */
3092 SEARCH_CSCParsingNameW
, /* parsing */
3094 NULL
, /* localized */
3096 NULL
, /* security */
3099 &GUID_NULL
/* typeid */
3102 &FOLDERID_SEARCH_MAPI
,
3103 CSIDL_Type_Disallowed
,
3107 KF_CATEGORY_VIRTUAL
, /* category */
3108 MAPIFolderW
, /* name */
3109 NULL
, /* description */
3110 &GUID_NULL
, /* parent */
3111 NULL
, /* relative path */
3112 SEARCH_MAPIParsingNameW
, /* parsing */
3114 NULL
, /* localized */
3116 NULL
, /* security */
3119 &GUID_NULL
/* typeid */
3122 &FOLDERID_SearchHome
,
3123 CSIDL_Type_Disallowed
,
3127 KF_CATEGORY_VIRTUAL
, /* category */
3128 SearchHomeFolderW
, /* name */
3129 NULL
, /* description */
3130 &GUID_NULL
, /* parent */
3131 NULL
, /* relative path */
3132 SearchHomeParsingNameW
, /* parsing */
3134 NULL
, /* localized */
3136 NULL
, /* security */
3139 &GUID_NULL
/* typeid */
3142 &FOLDERID_SidebarDefaultParts
,
3143 CSIDL_Type_Disallowed
, /* FIXME */
3147 KF_CATEGORY_COMMON
, /* category */
3148 Default_GadgetsW
, /* name */
3149 NULL
, /* description */
3150 &FOLDERID_ProgramFiles
, /* parent */
3151 Windows_Sidebar_GadgetsW
, /* relative path */
3154 NULL
, /* localized */
3156 NULL
, /* security */
3159 &GUID_NULL
/* typeid */
3162 &FOLDERID_SidebarParts
,
3163 CSIDL_Type_Disallowed
, /* FIXME */
3167 KF_CATEGORY_PERUSER
, /* category */
3168 GadgetsW
, /* name */
3169 NULL
, /* description */
3170 &FOLDERID_LocalAppData
, /* parent */
3171 Microsoft_Windows_Sidebar_GadgetsW
, /* relative path */
3174 NULL
, /* localized */
3176 NULL
, /* security */
3179 &GUID_NULL
/* typeid */
3182 &FOLDERID_SyncManagerFolder
,
3183 CSIDL_Type_Disallowed
,
3187 KF_CATEGORY_VIRTUAL
, /* category */
3188 SyncCenterFolderW
, /* name */
3189 NULL
, /* description */
3190 &GUID_NULL
, /* parent */
3191 NULL
, /* relative path */
3192 SyncManagerFolderParsingNameW
, /* parsing */
3194 NULL
, /* localized */
3196 NULL
, /* security */
3199 &GUID_NULL
/* typeid */
3202 &FOLDERID_SyncResultsFolder
,
3203 CSIDL_Type_Disallowed
,
3207 KF_CATEGORY_VIRTUAL
, /* category */
3208 SyncResultsFolderW
, /* name */
3209 NULL
, /* description */
3210 &GUID_NULL
, /* parent */
3211 NULL
, /* relative path */
3212 SyncResultsFolderParsingNameW
, /* parsing */
3214 NULL
, /* localized */
3216 NULL
, /* security */
3219 &GUID_NULL
/* typeid */
3222 &FOLDERID_SyncSetupFolder
,
3223 CSIDL_Type_Disallowed
,
3227 KF_CATEGORY_VIRTUAL
, /* category */
3228 SyncSetupFolderW
, /* name */
3229 NULL
, /* description */
3230 &GUID_NULL
, /* parent */
3231 NULL
, /* relative path */
3232 SyncSetupFolderParsingNameW
, /* parsing */
3234 NULL
, /* localized */
3236 NULL
, /* security */
3239 &GUID_NULL
/* typeid */
3242 &FOLDERID_UserPinned
,
3243 CSIDL_Type_Disallowed
, /* FIXME */
3247 KF_CATEGORY_PERUSER
, /* category */
3248 User_PinnedW
, /* name */
3249 NULL
, /* description */
3250 &FOLDERID_QuickLaunch
, /* parent */
3251 User_PinnedW
, /* relative path */
3254 NULL
, /* localized */
3256 NULL
, /* security */
3257 FILE_ATTRIBUTE_HIDDEN
, /* attributes */
3258 KFDF_PRECREATE
, /* flags */
3259 &GUID_NULL
/* typeid */
3262 &FOLDERID_UserProfiles
,
3267 KF_CATEGORY_FIXED
, /* category */
3268 UserProfilesW
, /* name */
3269 NULL
, /* description */
3270 &GUID_NULL
, /* parent */
3271 NULL
, /* relative path */
3274 NULL
, /* localized */
3276 NULL
, /* security */
3277 FILE_ATTRIBUTE_READONLY
, /* attributes */
3278 KFDF_PRECREATE
, /* flags */
3279 &GUID_NULL
/* typeid */
3282 &FOLDERID_UserProgramFiles
,
3283 CSIDL_Type_Disallowed
, /* FIXME */
3287 KF_CATEGORY_PERUSER
, /* category */
3288 UserProgramFilesW
, /* name */
3289 NULL
, /* description */
3290 &FOLDERID_LocalAppData
, /* parent */
3291 ProgramsW
, /* relative path */
3294 NULL
, /* localized */
3296 NULL
, /* security */
3299 &GUID_NULL
/* typeid */
3302 &FOLDERID_UserProgramFilesCommon
,
3303 CSIDL_Type_Disallowed
, /* FIXME */
3307 KF_CATEGORY_PERUSER
, /* category */
3308 UserProgramFilesCommonW
, /* name */
3309 NULL
, /* description */
3310 &FOLDERID_UserProgramFiles
, /* parent */
3311 CommonW
, /* relative path */
3314 NULL
, /* localized */
3316 NULL
, /* security */
3319 &GUID_NULL
/* typeid */
3322 &FOLDERID_UsersFiles
,
3323 CSIDL_Type_Disallowed
,
3327 KF_CATEGORY_VIRTUAL
, /* category */
3328 UsersFilesFolderW
, /* name */
3329 NULL
, /* description */
3330 &GUID_NULL
, /* parent */
3331 NULL
, /* relative path */
3332 UsersFilesParsingNameW
, /* parsing */
3334 NULL
, /* localized */
3336 NULL
, /* security */
3339 &GUID_NULL
/* typeid */
3342 &FOLDERID_UsersLibraries
,
3343 CSIDL_Type_Disallowed
,
3347 KF_CATEGORY_VIRTUAL
, /* category */
3348 UsersLibrariesFolderW
, /* name */
3349 NULL
, /* description */
3350 &GUID_NULL
, /* parent */
3351 NULL
, /* relative path */
3352 UsersLibrariesParsingNameW
, /* parsing */
3354 NULL
, /* localized */
3356 NULL
, /* security */
3359 &GUID_NULL
/* typeid */
3362 &FOLDERID_VideosLibrary
,
3363 CSIDL_Type_Disallowed
, /* FIXME */
3367 KF_CATEGORY_PERUSER
, /* category */
3368 VideosLibraryW
, /* name */
3369 NULL
, /* description */
3370 &GUID_NULL
, /* parent */
3371 Videos_librarymsW
, /* relative path */
3372 VideosLibraryParsingNameW
, /* parsing */
3374 NULL
, /* localized */
3376 NULL
, /* security */
3379 &GUID_NULL
/* typeid */
3383 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
);
3385 /* Gets the value named value from the registry key
3386 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3387 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3388 * is assumed to be MAX_PATH WCHARs in length.
3389 * If it exists, expands the value and writes the expanded value to
3390 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3391 * Returns successful error code if the value was retrieved from the registry,
3392 * and a failure otherwise.
3394 static HRESULT
_SHGetUserShellFolderPath(HKEY rootKey
, LPCWSTR userPrefix
,
3395 LPCWSTR value
, LPWSTR path
)
3398 WCHAR shellFolderPath
[MAX_PATH
], userShellFolderPath
[MAX_PATH
];
3399 LPCWSTR pShellFolderPath
, pUserShellFolderPath
;
3400 HKEY userShellFolderKey
, shellFolderKey
;
3401 DWORD dwType
, dwPathLen
;
3403 TRACE("%p,%s,%s,%p\n",rootKey
, debugstr_w(userPrefix
), debugstr_w(value
),
3408 strcpyW(shellFolderPath
, userPrefix
);
3409 PathAddBackslashW(shellFolderPath
);
3410 strcatW(shellFolderPath
, szSHFolders
);
3411 pShellFolderPath
= shellFolderPath
;
3412 strcpyW(userShellFolderPath
, userPrefix
);
3413 PathAddBackslashW(userShellFolderPath
);
3414 strcatW(userShellFolderPath
, szSHUserFolders
);
3415 pUserShellFolderPath
= userShellFolderPath
;
3419 pUserShellFolderPath
= szSHUserFolders
;
3420 pShellFolderPath
= szSHFolders
;
3423 if (RegCreateKeyW(rootKey
, pShellFolderPath
, &shellFolderKey
))
3425 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath
));
3428 if (RegCreateKeyW(rootKey
, pUserShellFolderPath
, &userShellFolderKey
))
3430 TRACE("Failed to create %s\n",
3431 debugstr_w(pUserShellFolderPath
));
3432 RegCloseKey(shellFolderKey
);
3436 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3437 if (!RegQueryValueExW(userShellFolderKey
, value
, NULL
, &dwType
,
3438 (LPBYTE
)path
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3442 path
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3443 if (dwType
== REG_EXPAND_SZ
&& path
[0] == '%')
3445 WCHAR szTemp
[MAX_PATH
];
3447 _SHExpandEnvironmentStrings(path
, szTemp
);
3448 lstrcpynW(path
, szTemp
, MAX_PATH
);
3450 ret
= RegSetValueExW(shellFolderKey
, value
, 0, REG_SZ
, (LPBYTE
)path
,
3451 (strlenW(path
) + 1) * sizeof(WCHAR
));
3452 if (ret
!= ERROR_SUCCESS
)
3453 hr
= HRESULT_FROM_WIN32(ret
);
3459 RegCloseKey(shellFolderKey
);
3460 RegCloseKey(userShellFolderKey
);
3461 TRACE("returning 0x%08x\n", hr
);
3465 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3466 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3467 * - The entry's szDefaultPath may be either a string value or an integer
3468 * resource identifier. In the latter case, the string value of the resource
3470 * - Depending on the entry's type, the path may begin with an (unexpanded)
3471 * environment variable name. The caller is responsible for expanding
3472 * environment strings if so desired.
3473 * The types that are prepended with environment variables are:
3474 * CSIDL_Type_User: %USERPROFILE%
3475 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3476 * CSIDL_Type_CurrVer: %SystemDrive%
3477 * (Others might make sense too, but as yet are unneeded.)
3479 static HRESULT
_SHGetDefaultValue(BYTE folder
, LPWSTR pszPath
)
3482 WCHAR resourcePath
[MAX_PATH
];
3483 LPCWSTR pDefaultPath
= NULL
;
3485 TRACE("0x%02x,%p\n", folder
, pszPath
);
3487 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3488 return E_INVALIDARG
;
3491 return E_INVALIDARG
;
3499 case CSIDL_PROGRAM_FILES
:
3500 case CSIDL_PROGRAM_FILESX86
:
3501 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3502 folder
= is_wow64
? CSIDL_PROGRAM_FILESX86
: CSIDL_PROGRAM_FILES
;
3504 case CSIDL_PROGRAM_FILES_COMMON
:
3505 case CSIDL_PROGRAM_FILES_COMMONX86
:
3506 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3507 folder
= is_wow64
? CSIDL_PROGRAM_FILES_COMMONX86
: CSIDL_PROGRAM_FILES_COMMON
;
3512 if (CSIDL_Data
[folder
].szDefaultPath
&&
3513 IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
))
3515 if (LoadStringW(shell32_hInstance
,
3516 LOWORD(CSIDL_Data
[folder
].szDefaultPath
), resourcePath
, MAX_PATH
))
3519 pDefaultPath
= resourcePath
;
3523 FIXME("(%d,%s), LoadString failed, missing translation?\n", folder
,
3524 debugstr_w(pszPath
));
3531 pDefaultPath
= CSIDL_Data
[folder
].szDefaultPath
;
3535 switch (CSIDL_Data
[folder
].type
)
3537 case CSIDL_Type_User
:
3538 strcpyW(pszPath
, UserProfileW
);
3540 case CSIDL_Type_AllUsers
:
3541 strcpyW(pszPath
, PublicProfileW
);
3543 case CSIDL_Type_ProgramData
:
3544 strcpyW(pszPath
, ProgramDataVarW
);
3546 case CSIDL_Type_CurrVer
:
3547 strcpyW(pszPath
, SystemDriveW
);
3550 ; /* no corresponding env. var, do nothing */
3554 PathAddBackslashW(pszPath
);
3555 strcatW(pszPath
, pDefaultPath
);
3558 TRACE("returning 0x%08x\n", hr
);
3562 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3563 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3564 * can be overridden in the HKLM\\szCurrentVersion key.
3565 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3566 * the registry, uses _SHGetDefaultValue to get the value.
3568 static HRESULT
_SHGetCurrentVersionPath(DWORD dwFlags
, BYTE folder
,
3573 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3575 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3576 return E_INVALIDARG
;
3577 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_CurrVer
)
3578 return E_INVALIDARG
;
3580 return E_INVALIDARG
;
3582 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3583 hr
= _SHGetDefaultValue(folder
, pszPath
);
3588 if (RegCreateKeyW(HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hKey
))
3592 DWORD dwType
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3594 if (RegQueryValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, NULL
,
3595 &dwType
, (LPBYTE
)pszPath
, &dwPathLen
) ||
3596 (dwType
!= REG_SZ
&& dwType
!= REG_EXPAND_SZ
))
3598 hr
= _SHGetDefaultValue(folder
, pszPath
);
3599 dwType
= REG_EXPAND_SZ
;
3602 case CSIDL_PROGRAM_FILESX86
:
3603 case CSIDL_PROGRAM_FILES_COMMONX86
:
3604 /* these two should never be set on 32-bit setups */
3608 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3609 if (!is_wow64
) break;
3613 RegSetValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, 0, dwType
,
3614 (LPBYTE
)pszPath
, (strlenW(pszPath
)+1)*sizeof(WCHAR
));
3619 pszPath
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3625 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3629 static LPWSTR
_GetUserSidStringFromToken(HANDLE Token
)
3631 char InfoBuffer
[64];
3632 PTOKEN_USER UserInfo
;
3636 UserInfo
= (PTOKEN_USER
) InfoBuffer
;
3637 if (! GetTokenInformation(Token
, TokenUser
, InfoBuffer
, sizeof(InfoBuffer
),
3640 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
3642 UserInfo
= heap_alloc(InfoSize
);
3643 if (UserInfo
== NULL
)
3645 if (! GetTokenInformation(Token
, TokenUser
, UserInfo
, InfoSize
,
3648 heap_free(UserInfo
);
3653 if (! ConvertSidToStringSidW(UserInfo
->User
.Sid
, &SidStr
))
3656 if (UserInfo
!= (PTOKEN_USER
) InfoBuffer
)
3657 heap_free(UserInfo
);
3662 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3663 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3664 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3665 * - if hToken is -1, looks in HKEY_USERS\.Default
3666 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3667 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3668 * calls _SHGetDefaultValue for it.
3670 static HRESULT
_SHGetUserProfilePath(HANDLE hToken
, DWORD dwFlags
, BYTE folder
,
3673 const WCHAR
*szValueName
;
3677 TRACE("%p,0x%08x,0x%02x,%p\n", hToken
, dwFlags
, folder
, pszPath
);
3679 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3680 return E_INVALIDARG
;
3681 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_User
)
3682 return E_INVALIDARG
;
3684 return E_INVALIDARG
;
3686 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3688 if (hToken
!= NULL
&& hToken
!= (HANDLE
)-1)
3690 FIXME("unsupported for user other than current or default\n");
3693 hr
= _SHGetDefaultValue(folder
, pszPath
);
3697 LPCWSTR userPrefix
= NULL
;
3700 if (hToken
== (HANDLE
)-1)
3702 hRootKey
= HKEY_USERS
;
3703 userPrefix
= DefaultW
;
3705 else if (hToken
== NULL
)
3706 hRootKey
= HKEY_CURRENT_USER
;
3709 hRootKey
= HKEY_USERS
;
3710 userPrefix
= _GetUserSidStringFromToken(hToken
);
3711 if (userPrefix
== NULL
)
3718 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3719 szValueName
= CSIDL_Data
[folder
].szValueName
;
3722 StringFromGUID2( CSIDL_Data
[folder
].id
, buffer
, 39 );
3723 szValueName
= &buffer
[0];
3726 hr
= _SHGetUserShellFolderPath(hRootKey
, userPrefix
, szValueName
, pszPath
);
3727 if (FAILED(hr
) && hRootKey
!= HKEY_LOCAL_MACHINE
)
3728 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
, szValueName
, pszPath
);
3730 hr
= _SHGetDefaultValue(folder
, pszPath
);
3731 if (userPrefix
!= NULL
&& userPrefix
!= DefaultW
)
3732 LocalFree((HLOCAL
) userPrefix
);
3735 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3739 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3740 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3741 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3742 * If this fails, falls back to _SHGetDefaultValue.
3744 static HRESULT
_SHGetAllUsersProfilePath(DWORD dwFlags
, BYTE folder
,
3749 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3751 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3752 return E_INVALIDARG
;
3753 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_AllUsers
&& CSIDL_Data
[folder
].type
!= CSIDL_Type_ProgramData
)
3754 return E_INVALIDARG
;
3756 return E_INVALIDARG
;
3758 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3759 hr
= _SHGetDefaultValue(folder
, pszPath
);
3762 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
,
3763 CSIDL_Data
[folder
].szValueName
, pszPath
);
3765 hr
= _SHGetDefaultValue(folder
, pszPath
);
3767 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3771 static HRESULT
_SHOpenProfilesKey(PHKEY pKey
)
3776 lRet
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, ProfileListW
, 0, NULL
, 0,
3777 KEY_ALL_ACCESS
, NULL
, pKey
, &disp
);
3778 return HRESULT_FROM_WIN32(lRet
);
3781 /* Reads the value named szValueName from the key profilesKey (assumed to be
3782 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3783 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3784 * szDefault to the registry).
3786 static HRESULT
_SHGetProfilesValue(HKEY profilesKey
, LPCWSTR szValueName
,
3787 LPWSTR szValue
, LPCWSTR szDefault
)
3790 DWORD type
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3793 TRACE("%p,%s,%p,%s\n", profilesKey
, debugstr_w(szValueName
), szValue
,
3794 debugstr_w(szDefault
));
3795 lRet
= RegQueryValueExW(profilesKey
, szValueName
, NULL
, &type
,
3796 (LPBYTE
)szValue
, &dwPathLen
);
3797 if (!lRet
&& (type
== REG_SZ
|| type
== REG_EXPAND_SZ
) && dwPathLen
3800 dwPathLen
/= sizeof(WCHAR
);
3801 szValue
[dwPathLen
] = '\0';
3806 /* Missing or invalid value, set a default */
3807 lstrcpynW(szValue
, szDefault
, MAX_PATH
);
3808 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName
),
3809 debugstr_w(szValue
));
3810 lRet
= RegSetValueExW(profilesKey
, szValueName
, 0, REG_EXPAND_SZ
,
3812 (strlenW(szValue
) + 1) * sizeof(WCHAR
));
3814 hr
= HRESULT_FROM_WIN32(lRet
);
3818 TRACE("returning 0x%08x (output value is %s)\n", hr
, debugstr_w(szValue
));
3822 /* Attempts to expand environment variables from szSrc into szDest, which is
3823 * assumed to be MAX_PATH characters in length. Before referring to the
3824 * environment, handles a few variables directly, because the environment
3825 * variables may not be set when this is called (as during Wine's installation
3826 * when default values are being written to the registry).
3827 * The directly handled environment variables, and their source, are:
3828 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3829 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3831 * If one of the directly handled environment variables is expanded, only
3832 * expands a single variable, and only in the beginning of szSrc.
3834 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
)
3837 WCHAR szTemp
[MAX_PATH
], szProfilesPrefix
[MAX_PATH
] = { 0 };
3840 TRACE("%s, %p\n", debugstr_w(szSrc
), szDest
);
3842 if (!szSrc
|| !szDest
) return E_INVALIDARG
;
3844 /* short-circuit if there's nothing to expand */
3845 if (szSrc
[0] != '%')
3847 strcpyW(szDest
, szSrc
);
3851 /* Get the profile prefix, we'll probably be needing it */
3852 hr
= _SHOpenProfilesKey(&key
);
3855 WCHAR def_val
[MAX_PATH
];
3857 /* get the system drive */
3858 GetSystemDirectoryW(def_val
, MAX_PATH
);
3859 strcpyW( def_val
+ 3, szDefaultProfileDirW
);
3861 hr
= _SHGetProfilesValue(key
, ProfilesDirectoryW
, szProfilesPrefix
, def_val
);
3865 strcpyW(szTemp
, szSrc
);
3866 while (SUCCEEDED(hr
) && szTemp
[0] == '%')
3868 if (!strncmpiW(szTemp
, AllUsersProfileW
, strlenW(AllUsersProfileW
)))
3870 WCHAR szAllUsers
[MAX_PATH
], def_val
[MAX_PATH
];
3872 GetSystemDirectoryW(def_val
, MAX_PATH
);
3873 strcpyW( def_val
+ 3, UsersPublicW
);
3875 hr
= _SHGetProfilesValue(key
, PublicW
, szAllUsers
, def_val
);
3876 PathAppendW(szDest
, szAllUsers
);
3877 PathAppendW(szDest
, szTemp
+ strlenW(AllUsersProfileW
));
3879 else if (!strncmpiW(szTemp
, PublicProfileW
, strlenW(PublicProfileW
)))
3881 WCHAR szAllUsers
[MAX_PATH
], def_val
[MAX_PATH
];
3883 GetSystemDirectoryW(def_val
, MAX_PATH
);
3884 strcpyW( def_val
+ 3, UsersPublicW
);
3886 hr
= _SHGetProfilesValue(key
, PublicW
, szAllUsers
, def_val
);
3887 PathAppendW(szDest
, szAllUsers
);
3888 PathAppendW(szDest
, szTemp
+ strlenW(PublicProfileW
));
3890 else if (!strncmpiW(szTemp
, ProgramDataVarW
, strlenW(ProgramDataVarW
)))
3892 WCHAR szProgramData
[MAX_PATH
], def_val
[MAX_PATH
];
3893 HKEY shellFolderKey
;
3894 DWORD dwType
, dwPathLen
= sizeof(def_val
);
3895 BOOL in_registry
= FALSE
;
3897 if (!RegCreateKeyW(HKEY_LOCAL_MACHINE
, szSHFolders
, &shellFolderKey
))
3899 if (!RegQueryValueExW(shellFolderKey
, Common_AppDataW
, NULL
, &dwType
,
3900 (LPBYTE
)def_val
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3903 RegCloseKey(shellFolderKey
);
3908 GetSystemDirectoryW(def_val
, MAX_PATH
);
3909 strcpyW( def_val
+ 3, ProgramDataW
);
3912 hr
= _SHGetProfilesValue(key
, ProgramDataW
, szProgramData
, def_val
);
3913 PathAppendW(szDest
, szProgramData
);
3914 PathAppendW(szDest
, szTemp
+ strlenW(ProgramDataVarW
));
3916 else if (!strncmpiW(szTemp
, UserProfileW
, strlenW(UserProfileW
)))
3918 WCHAR userName
[MAX_PATH
];
3919 DWORD userLen
= MAX_PATH
;
3921 strcpyW(szDest
, szProfilesPrefix
);
3922 GetUserNameW(userName
, &userLen
);
3923 PathAppendW(szDest
, userName
);
3924 PathAppendW(szDest
, szTemp
+ strlenW(UserProfileW
));
3926 else if (!strncmpiW(szTemp
, SystemDriveW
, strlenW(SystemDriveW
)))
3928 GetSystemDirectoryW(szDest
, MAX_PATH
);
3929 strcpyW(szDest
+ 3, szTemp
+ strlenW(SystemDriveW
) + 1);
3933 DWORD ret
= ExpandEnvironmentStringsW(szTemp
, szDest
, MAX_PATH
);
3936 hr
= E_NOT_SUFFICIENT_BUFFER
;
3938 hr
= HRESULT_FROM_WIN32(GetLastError());
3939 else if (!strcmpW( szTemp
, szDest
)) break; /* nothing expanded */
3941 if (SUCCEEDED(hr
)) strcpyW(szTemp
, szDest
);
3946 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr
,
3947 debugstr_w(szSrc
), debugstr_w(szDest
));
3951 /*************************************************************************
3952 * _SHGetXDGUserDirs [Internal]
3954 * Get XDG directories paths from XDG configuration.
3957 * xdg_dirs [I] Array of XDG directories to look for.
3958 * num_dirs [I] Number of elements in xdg_dirs.
3959 * xdg_results [O] An array of the XDG directories paths.
3961 static inline void _SHGetXDGUserDirs(const char * const *xdg_dirs
, const unsigned int num_dirs
, char *** xdg_results
) {
3964 hr
= XDG_UserDirLookup(xdg_dirs
, num_dirs
, xdg_results
);
3965 if (FAILED(hr
)) *xdg_results
= NULL
;
3968 /*************************************************************************
3969 * _SHFreeXDGUserDirs [Internal]
3971 * Free resources allocated by XDG_UserDirLookup().
3974 * num_dirs [I] Number of elements in xdg_results.
3975 * xdg_results [I] An array of the XDG directories paths.
3977 static inline void _SHFreeXDGUserDirs(const unsigned int num_dirs
, char ** xdg_results
) {
3982 for (i
= 0; i
< num_dirs
; i
++)
3983 heap_free(xdg_results
[i
]);
3984 heap_free(xdg_results
);
3988 /*************************************************************************
3989 * _SHAppendToUnixPath [Internal]
3991 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
3992 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
3993 * and replaces backslashes with slashes.
3996 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
3997 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
4003 static inline BOOL
_SHAppendToUnixPath(char *szBasePath
, LPCWSTR pwszSubPath
) {
4004 WCHAR wszSubPath
[MAX_PATH
];
4005 int cLen
= strlen(szBasePath
);
4008 if (IS_INTRESOURCE(pwszSubPath
)) {
4009 if (!LoadStringW(shell32_hInstance
, LOWORD(pwszSubPath
), wszSubPath
, MAX_PATH
)) {
4010 /* Fall back to hard coded defaults. */
4011 switch (LOWORD(pwszSubPath
)) {
4013 lstrcpyW(wszSubPath
, DocumentsW
);
4016 lstrcpyW(wszSubPath
, My_MusicW
);
4018 case IDS_MYPICTURES
:
4019 lstrcpyW(wszSubPath
, My_PicturesW
);
4022 lstrcpyW(wszSubPath
, My_VideosW
);
4025 lstrcpyW(wszSubPath
, DownloadsW
);
4028 lstrcpyW(wszSubPath
, TemplatesW
);
4031 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath
));
4036 lstrcpyW(wszSubPath
, pwszSubPath
);
4039 if (szBasePath
[cLen
-1] != '/') szBasePath
[cLen
++] = '/';
4041 if (!WideCharToMultiByte(CP_UNIXCP
, 0, wszSubPath
, -1, szBasePath
+ cLen
,
4042 FILENAME_MAX
- cLen
, NULL
, NULL
))
4047 pBackslash
= szBasePath
+ cLen
;
4048 while ((pBackslash
= strchr(pBackslash
, '\\'))) *pBackslash
= '/';
4053 /******************************************************************************
4054 * _SHGetFolderUnixPath [Internal]
4056 * Create a shell folder and get its unix path.
4059 * nFolder [I] CSIDL identifying the folder.
4061 static inline char * _SHGetFolderUnixPath(const int nFolder
)
4063 WCHAR wszTempPath
[MAX_PATH
];
4066 hr
= SHGetFolderPathW(NULL
, nFolder
, NULL
,
4067 SHGFP_TYPE_DEFAULT
, wszTempPath
);
4068 if (FAILED(hr
)) return NULL
;
4070 return wine_get_unix_file_name(wszTempPath
);
4073 /******************************************************************************
4074 * _SHCreateMyDocumentsSubDirs [Internal]
4076 * Create real directories for various shell folders under 'My Documents'. For
4077 * Windows and homeless styles. Fails silently for already existing sub dirs.
4080 * aidsMyStuff [I] Array of IDS_* resources to create sub dirs for.
4081 * num [I] Number of elements in aidsMyStuff.
4082 * szPersonalTarget [I] Unix path to 'My Documents' directory.
4084 static void _SHCreateMyDocumentsSubDirs(const UINT
* aidsMyStuff
, const UINT num
, const char * szPersonalTarget
)
4086 char szMyStuffTarget
[FILENAME_MAX
];
4089 if (aidsMyStuff
&& szPersonalTarget
)
4091 for (i
= 0; i
< num
; i
++)
4093 strcpy(szMyStuffTarget
, szPersonalTarget
);
4094 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4095 mkdir(szMyStuffTarget
, 0777);
4100 /******************************************************************************
4101 * _SHCreateMyDocumentsSymbolicLink [Internal]
4103 * Sets up a symbolic link for the 'My Documents' shell folder to point into
4104 * the users home directory.
4107 * aidsMyStuff [I] Array of IDS_* resources to create sub dirs for.
4108 * aids_num [I] Number of elements in aidsMyStuff.
4110 static void _SHCreateMyDocumentsSymbolicLink(const UINT
* aidsMyStuff
, const UINT aids_num
)
4112 static const char * const xdg_dirs
[] = { "DOCUMENTS" };
4113 static const unsigned int num
= ARRAY_SIZE(xdg_dirs
);
4114 char szPersonalTarget
[FILENAME_MAX
], *pszPersonal
;
4115 struct stat statFolder
;
4116 const char *pszHome
;
4117 char ** xdg_results
;
4119 /* Get the unix path of 'My Documents'. */
4120 pszPersonal
= _SHGetFolderUnixPath(CSIDL_PERSONAL
|CSIDL_FLAG_DONT_VERIFY
);
4121 if (!pszPersonal
) return;
4123 _SHGetXDGUserDirs(xdg_dirs
, num
, &xdg_results
);
4125 pszHome
= getenv("HOME");
4126 if (pszHome
&& !stat(pszHome
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4130 /* Check if there's already a Wine-specific 'My Documents' folder */
4131 strcpy(szPersonalTarget
, pszHome
);
4132 if (_SHAppendToUnixPath(szPersonalTarget
, MAKEINTRESOURCEW(IDS_PERSONAL
)) &&
4133 !stat(szPersonalTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4135 /* '$HOME/My Documents' exists. Create subfolders for
4136 * 'My Pictures', 'My Videos', 'My Music' etc. or fail silently
4137 * if they already exist.
4139 _SHCreateMyDocumentsSubDirs(aidsMyStuff
, aids_num
, szPersonalTarget
);
4143 /* Try to point to the XDG Documents folder */
4144 if (xdg_results
&& xdg_results
[0] &&
4145 !stat(xdg_results
[0], &statFolder
) &&
4146 S_ISDIR(statFolder
.st_mode
))
4148 strcpy(szPersonalTarget
, xdg_results
[0]);
4152 /* Or the hardcoded / OS X Documents folder */
4153 strcpy(szPersonalTarget
, pszHome
);
4154 if (_SHAppendToUnixPath(szPersonalTarget
, DocumentsW
) &&
4155 !stat(szPersonalTarget
, &statFolder
) &&
4156 S_ISDIR(statFolder
.st_mode
))
4159 /* As a last resort point to $HOME. */
4160 strcpy(szPersonalTarget
, pszHome
);
4164 /* Create symbolic link to 'My Documents' or fail silently if a directory
4165 * or symlink exists. */
4166 symlink(szPersonalTarget
, pszPersonal
);
4170 /* '$HOME' doesn't exist. Create subdirs for 'My Pictures', 'My Videos',
4171 * 'My Music' etc. in '%USERPROFILE%\My Documents' or fail silently if
4172 * they already exist. */
4174 strcpy(szPersonalTarget
, pszPersonal
);
4175 _SHCreateMyDocumentsSubDirs(aidsMyStuff
, aids_num
, szPersonalTarget
);
4178 heap_free(pszPersonal
);
4180 _SHFreeXDGUserDirs(num
, xdg_results
);
4183 /******************************************************************************
4184 * _SHCreateMyStuffSymbolicLink [Internal]
4186 * Sets up a symbolic link for one of the 'My Whatever' shell folders to point
4187 * into the users home directory.
4190 * nFolder [I] CSIDL identifying the folder.
4192 static void _SHCreateMyStuffSymbolicLink(int nFolder
)
4194 static const UINT aidsMyStuff
[] = {
4195 IDS_MYPICTURES
, IDS_MYVIDEOS
, IDS_MYMUSIC
, IDS_DOWNLOADS
, IDS_TEMPLATES
4197 static const WCHAR
* const MyOSXStuffW
[] = {
4198 PicturesW
, MoviesW
, MusicW
, DownloadsW
, TemplatesW
4200 static const int acsidlMyStuff
[] = {
4201 CSIDL_MYPICTURES
, CSIDL_MYVIDEO
, CSIDL_MYMUSIC
, CSIDL_DOWNLOADS
, CSIDL_TEMPLATES
4203 static const char * const xdg_dirs
[] = {
4204 "PICTURES", "VIDEOS", "MUSIC", "DOWNLOAD", "TEMPLATES"
4206 static const unsigned int num
= ARRAY_SIZE(xdg_dirs
);
4207 char szPersonalTarget
[FILENAME_MAX
], *pszPersonal
;
4208 char szMyStuffTarget
[FILENAME_MAX
], *pszMyStuff
;
4209 struct stat statFolder
;
4210 const char *pszHome
;
4211 char ** xdg_results
;
4212 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
4215 for (i
= 0; i
< ARRAY_SIZE(acsidlMyStuff
) && acsidlMyStuff
[i
] != folder
; i
++);
4216 if (i
>= ARRAY_SIZE(acsidlMyStuff
)) return;
4218 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4219 pszPersonal
= _SHGetFolderUnixPath(CSIDL_PERSONAL
|CSIDL_FLAG_CREATE
);
4220 if (!pszPersonal
) return;
4222 strcpy(szPersonalTarget
, pszPersonal
);
4223 if (!stat(pszPersonal
, &statFolder
) && S_ISLNK(statFolder
.st_mode
))
4225 int cLen
= readlink(pszPersonal
, szPersonalTarget
, FILENAME_MAX
-1);
4226 if (cLen
>= 0) szPersonalTarget
[cLen
] = '\0';
4228 heap_free(pszPersonal
);
4230 _SHGetXDGUserDirs(xdg_dirs
, num
, &xdg_results
);
4232 pszHome
= getenv("HOME");
4236 /* Get the current 'My Whatever' folder unix path. */
4237 pszMyStuff
= _SHGetFolderUnixPath(acsidlMyStuff
[i
]|CSIDL_FLAG_DONT_VERIFY
);
4238 if (!pszMyStuff
) break;
4242 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4243 strcpy(szMyStuffTarget
, szPersonalTarget
);
4244 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])) &&
4245 !stat(szMyStuffTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4248 /* Try the XDG_XXX_DIR folder */
4249 if (xdg_results
&& xdg_results
[i
])
4251 strcpy(szMyStuffTarget
, xdg_results
[i
]);
4255 /* Or the OS X folder (these are never localized) */
4258 strcpy(szMyStuffTarget
, pszHome
);
4259 if (_SHAppendToUnixPath(szMyStuffTarget
, MyOSXStuffW
[i
]) &&
4260 !stat(szMyStuffTarget
, &statFolder
) &&
4261 S_ISDIR(statFolder
.st_mode
))
4265 /* As a last resort point to the same location as 'My Documents' */
4266 strcpy(szMyStuffTarget
, szPersonalTarget
);
4269 symlink(szMyStuffTarget
, pszMyStuff
);
4270 heap_free(pszMyStuff
);
4274 _SHFreeXDGUserDirs(num
, xdg_results
);
4277 /******************************************************************************
4278 * _SHCreateDesktopSymbolicLink [Internal]
4280 * Sets up a symbolic link for the 'Desktop' shell folder to point into the
4281 * users home directory.
4283 static void _SHCreateDesktopSymbolicLink(void)
4285 static const char * const xdg_dirs
[] = { "DESKTOP" };
4286 static const unsigned int num
= ARRAY_SIZE(xdg_dirs
);
4288 char szDesktopTarget
[FILENAME_MAX
], *pszDesktop
;
4289 struct stat statFolder
;
4290 const char *pszHome
;
4291 char ** xdg_results
;
4292 char * xdg_desktop_dir
;
4294 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4295 pszPersonal
= _SHGetFolderUnixPath(CSIDL_PERSONAL
|CSIDL_FLAG_CREATE
);
4296 if (!pszPersonal
) return;
4298 _SHGetXDGUserDirs(xdg_dirs
, num
, &xdg_results
);
4300 pszHome
= getenv("HOME");
4303 strcpy(szDesktopTarget
, pszHome
);
4305 strcpy(szDesktopTarget
, pszPersonal
);
4306 heap_free(pszPersonal
);
4308 xdg_desktop_dir
= xdg_results
? xdg_results
[0] : NULL
;
4309 if (xdg_desktop_dir
||
4310 (_SHAppendToUnixPath(szDesktopTarget
, DesktopW
) &&
4311 !stat(szDesktopTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
)))
4313 pszDesktop
= _SHGetFolderUnixPath(CSIDL_DESKTOPDIRECTORY
|CSIDL_FLAG_DONT_VERIFY
);
4316 if (xdg_desktop_dir
)
4317 symlink(xdg_desktop_dir
, pszDesktop
);
4319 symlink(szDesktopTarget
, pszDesktop
);
4320 heap_free(pszDesktop
);
4324 _SHFreeXDGUserDirs(num
, xdg_results
);
4327 /******************************************************************************
4328 * _SHCreateSymbolicLink [Internal]
4330 * Sets up a symbolic link for one of the special shell folders to point into
4331 * the users home directory.
4334 * nFolder [I] CSIDL identifying the folder.
4336 static void _SHCreateSymbolicLink(int nFolder
)
4338 static const UINT aidsMyStuff
[] = {
4339 IDS_MYPICTURES
, IDS_MYVIDEOS
, IDS_MYMUSIC
, IDS_DOWNLOADS
, IDS_TEMPLATES
4341 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
4344 case CSIDL_PERSONAL
:
4345 _SHCreateMyDocumentsSymbolicLink(aidsMyStuff
, ARRAY_SIZE(aidsMyStuff
));
4347 case CSIDL_MYPICTURES
:
4350 case CSIDL_DOWNLOADS
:
4351 case CSIDL_TEMPLATES
:
4352 _SHCreateMyStuffSymbolicLink(folder
);
4354 case CSIDL_DESKTOPDIRECTORY
:
4355 _SHCreateDesktopSymbolicLink();
4360 /******************************************************************************
4361 * _SHCreateSymbolicLinks [Internal]
4363 * Sets up symbol links for various shell folders to point into the user's home
4364 * directory. We do an educated guess about what the user would probably want:
4365 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4366 * wine's 'My Documents' to point there. Furthermore, we infer that the user
4367 * is a Windows lover and has no problem with wine creating subfolders for
4368 * 'My Pictures', 'My Music', 'My Videos' etc. under '$HOME/My Documents', if
4369 * those do not already exist. We put appropriate symbolic links in place for
4371 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4372 * point directly to $HOME. We assume the user to be a unix hacker who does not
4373 * want wine to create anything anywhere besides the .wine directory. So, if
4374 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4375 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4376 * directory, and try to link to that. If that fails, then we symlink to
4377 * $HOME directly. The same holds for 'My Pictures', 'My Videos' etc.
4378 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4379 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4381 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4383 static void _SHCreateSymbolicLinks(void)
4385 static const int acsidlMyStuff
[] = {
4386 CSIDL_MYPICTURES
, CSIDL_MYVIDEO
, CSIDL_MYMUSIC
, CSIDL_DOWNLOADS
, CSIDL_TEMPLATES
, CSIDL_PERSONAL
, CSIDL_DESKTOPDIRECTORY
4390 for (i
=0; i
< ARRAY_SIZE(acsidlMyStuff
); i
++)
4391 _SHCreateSymbolicLink(acsidlMyStuff
[i
]);
4394 /******************************************************************************
4395 * SHGetFolderPathW [SHELL32.@]
4397 * Convert nFolder to path.
4401 * Failure: standard HRESULT error codes.
4404 * Most values can be overridden in either
4405 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
4406 * or in the same location in HKLM.
4407 * The "Shell Folders" registry key was used in NT4 and earlier systems.
4408 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
4409 * changes made to it are made to the former key too. This synchronization is
4410 * done on-demand: not until someone requests the value of one of these paths
4411 * (by calling one of the SHGet functions) is the value synchronized.
4412 * Furthermore, the HKCU paths take precedence over the HKLM paths.
4414 HRESULT WINAPI
SHGetFolderPathW(
4415 HWND hwndOwner
, /* [I] owner window */
4416 int nFolder
, /* [I] CSIDL identifying the folder */
4417 HANDLE hToken
, /* [I] access token */
4418 DWORD dwFlags
, /* [I] which path to return */
4419 LPWSTR pszPath
) /* [O] converted path */
4421 HRESULT hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, NULL
, pszPath
);
4422 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) == hr
)
4423 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4427 HRESULT WINAPI
SHGetFolderPathAndSubDirA(
4428 HWND hwndOwner
, /* [I] owner window */
4429 int nFolder
, /* [I] CSIDL identifying the folder */
4430 HANDLE hToken
, /* [I] access token */
4431 DWORD dwFlags
, /* [I] which path to return */
4432 LPCSTR pszSubPath
, /* [I] sub directory of the specified folder */
4433 LPSTR pszPath
) /* [O] converted path */
4437 LPWSTR pszSubPathW
= NULL
;
4438 LPWSTR pszPathW
= NULL
;
4440 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, debugstr_a(pszSubPath
), pszPath
);
4443 pszPathW
= heap_alloc(MAX_PATH
* sizeof(WCHAR
));
4445 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
4449 TRACE("%08x,%08x,%s\n",nFolder
, dwFlags
, debugstr_w(pszSubPathW
));
4451 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
4452 * set (null), or an empty string.therefore call it without the parameter set
4453 * if pszSubPath is an empty string
4455 if (pszSubPath
&& pszSubPath
[0]) {
4456 length
= MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, NULL
, 0);
4457 pszSubPathW
= heap_alloc(length
* sizeof(WCHAR
));
4459 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
4462 MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, pszSubPathW
, length
);
4465 hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, pszSubPathW
, pszPathW
);
4467 if (SUCCEEDED(hr
) && pszPath
)
4468 WideCharToMultiByte(CP_ACP
, 0, pszPathW
, -1, pszPath
, MAX_PATH
, NULL
, NULL
);
4471 heap_free(pszPathW
);
4472 heap_free(pszSubPathW
);
4476 /*************************************************************************
4477 * SHGetFolderPathAndSubDirW [SHELL32.@]
4479 HRESULT WINAPI
SHGetFolderPathAndSubDirW(
4480 HWND hwndOwner
, /* [I] owner window */
4481 int nFolder
, /* [I] CSIDL identifying the folder */
4482 HANDLE hToken
, /* [I] access token */
4483 DWORD dwFlags
, /* [I] which path to return */
4484 LPCWSTR pszSubPath
,/* [I] sub directory of the specified folder */
4485 LPWSTR pszPath
) /* [O] converted path */
4488 WCHAR szBuildPath
[MAX_PATH
], szTemp
[MAX_PATH
];
4489 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
4493 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, debugstr_w(pszSubPath
), pszPath
);
4495 /* Windows always NULL-terminates the resulting path regardless of success
4496 * or failure, so do so first
4501 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
4502 return E_INVALIDARG
;
4503 if ((SHGFP_TYPE_CURRENT
!= dwFlags
) && (SHGFP_TYPE_DEFAULT
!= dwFlags
))
4504 return E_INVALIDARG
;
4506 type
= CSIDL_Data
[folder
].type
;
4509 case CSIDL_Type_Disallowed
:
4512 case CSIDL_Type_NonExistent
:
4515 case CSIDL_Type_WindowsPath
:
4516 GetWindowsDirectoryW(szTemp
, MAX_PATH
);
4517 if (CSIDL_Data
[folder
].szDefaultPath
&&
4518 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4519 *CSIDL_Data
[folder
].szDefaultPath
)
4521 PathAddBackslashW(szTemp
);
4522 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4526 case CSIDL_Type_SystemPath
:
4527 GetSystemDirectoryW(szTemp
, MAX_PATH
);
4528 if (CSIDL_Data
[folder
].szDefaultPath
&&
4529 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4530 *CSIDL_Data
[folder
].szDefaultPath
)
4532 PathAddBackslashW(szTemp
);
4533 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4537 case CSIDL_Type_SystemX86Path
:
4538 if (!GetSystemWow64DirectoryW(szTemp
, MAX_PATH
)) GetSystemDirectoryW(szTemp
, MAX_PATH
);
4539 if (CSIDL_Data
[folder
].szDefaultPath
&&
4540 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
4541 *CSIDL_Data
[folder
].szDefaultPath
)
4543 PathAddBackslashW(szTemp
);
4544 strcatW(szTemp
, CSIDL_Data
[folder
].szDefaultPath
);
4548 case CSIDL_Type_CurrVer
:
4549 hr
= _SHGetCurrentVersionPath(dwFlags
, folder
, szTemp
);
4551 case CSIDL_Type_User
:
4552 hr
= _SHGetUserProfilePath(hToken
, dwFlags
, folder
, szTemp
);
4554 case CSIDL_Type_AllUsers
:
4555 case CSIDL_Type_ProgramData
:
4556 hr
= _SHGetAllUsersProfilePath(dwFlags
, folder
, szTemp
);
4559 FIXME("bogus type %d, please fix\n", type
);
4564 /* Expand environment strings if necessary */
4566 hr
= _SHExpandEnvironmentStrings(szTemp
, szBuildPath
);
4568 strcpyW(szBuildPath
, szTemp
);
4570 if (FAILED(hr
)) goto end
;
4573 /* make sure the new path does not exceed the buffer length
4574 * and remember to backslash and terminate it */
4575 if(MAX_PATH
< (lstrlenW(szBuildPath
) + lstrlenW(pszSubPath
) + 2)) {
4576 hr
= HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE
);
4579 PathAppendW(szBuildPath
, pszSubPath
);
4580 PathRemoveBackslashW(szBuildPath
);
4582 /* Copy the path if it's available before we might return */
4583 if (SUCCEEDED(hr
) && pszPath
)
4584 strcpyW(pszPath
, szBuildPath
);
4586 /* if we don't care about existing directories we are ready */
4587 if(nFolder
& CSIDL_FLAG_DONT_VERIFY
) goto end
;
4589 if (PathFileExistsW(szBuildPath
)) goto end
;
4591 /* not existing but we are not allowed to create it. The return value
4592 * is verified against shell32 version 6.0.
4594 if (!(nFolder
& CSIDL_FLAG_CREATE
))
4596 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4600 /* create symbolic links rather than directories for specific
4601 * user shell folders */
4602 _SHCreateSymbolicLink(folder
);
4604 /* create directory/directories */
4605 ret
= SHCreateDirectoryExW(hwndOwner
, szBuildPath
, NULL
);
4606 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4608 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath
));
4613 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath
));
4615 TRACE("returning 0x%08x (final path is %s)\n", hr
, debugstr_w(szBuildPath
));
4619 /*************************************************************************
4620 * SHGetFolderPathA [SHELL32.@]
4622 * See SHGetFolderPathW.
4624 HRESULT WINAPI
SHGetFolderPathA(
4631 WCHAR szTemp
[MAX_PATH
];
4634 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, pszPath
);
4638 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
, dwFlags
, szTemp
);
4639 if (SUCCEEDED(hr
) && pszPath
)
4640 WideCharToMultiByte(CP_ACP
, 0, szTemp
, -1, pszPath
, MAX_PATH
, NULL
,
4646 /* For each folder in folders, if its value has not been set in the registry,
4647 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4648 * folder's type) to get the unexpanded value first.
4649 * Writes the unexpanded value to User Shell Folders, and queries it with
4650 * SHGetFolderPathW to force the creation of the directory if it doesn't
4651 * already exist. SHGetFolderPathW also returns the expanded value, which
4652 * this then writes to Shell Folders.
4654 static HRESULT
_SHRegisterFolders(HKEY hRootKey
, HANDLE hToken
,
4655 LPCWSTR szUserShellFolderPath
, LPCWSTR szShellFolderPath
, const UINT folders
[],
4658 const WCHAR
*szValueName
;
4661 WCHAR path
[MAX_PATH
];
4663 HKEY hUserKey
= NULL
, hKey
= NULL
;
4664 DWORD dwType
, dwPathLen
;
4667 TRACE("%p,%p,%s,%p,%u\n", hRootKey
, hToken
,
4668 debugstr_w(szUserShellFolderPath
), folders
, foldersLen
);
4670 ret
= RegCreateKeyW(hRootKey
, szUserShellFolderPath
, &hUserKey
);
4672 hr
= HRESULT_FROM_WIN32(ret
);
4675 ret
= RegCreateKeyW(hRootKey
, szShellFolderPath
, &hKey
);
4677 hr
= HRESULT_FROM_WIN32(ret
);
4679 for (i
= 0; SUCCEEDED(hr
) && i
< foldersLen
; i
++)
4681 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
4683 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4684 szValueName
= CSIDL_Data
[folders
[i
]].szValueName
;
4685 if (!szValueName
&& CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4687 StringFromGUID2( CSIDL_Data
[folders
[i
]].id
, buffer
, 39 );
4688 szValueName
= &buffer
[0];
4691 if (RegQueryValueExW(hUserKey
, szValueName
, NULL
,
4692 &dwType
, (LPBYTE
)path
, &dwPathLen
) || (dwType
!= REG_SZ
&&
4693 dwType
!= REG_EXPAND_SZ
))
4696 if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4697 _SHGetUserProfilePath(hToken
, SHGFP_TYPE_DEFAULT
, folders
[i
],
4699 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_AllUsers
||
4700 CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_ProgramData
)
4701 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT
, folders
[i
], path
);
4702 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_WindowsPath
)
4704 GetWindowsDirectoryW(path
, MAX_PATH
);
4705 if (CSIDL_Data
[folders
[i
]].szDefaultPath
&&
4706 !IS_INTRESOURCE(CSIDL_Data
[folders
[i
]].szDefaultPath
))
4708 PathAddBackslashW(path
);
4709 strcatW(path
, CSIDL_Data
[folders
[i
]].szDefaultPath
);
4716 ret
= RegSetValueExW(hUserKey
, szValueName
, 0, REG_EXPAND_SZ
,
4717 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4719 hr
= HRESULT_FROM_WIN32(ret
);
4722 hr
= SHGetFolderPathW(NULL
, folders
[i
] | CSIDL_FLAG_CREATE
,
4723 hToken
, SHGFP_TYPE_DEFAULT
, path
);
4724 ret
= RegSetValueExW(hKey
, szValueName
, 0, REG_SZ
,
4725 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4727 hr
= HRESULT_FROM_WIN32(ret
);
4733 RegCloseKey(hUserKey
);
4737 TRACE("returning 0x%08x\n", hr
);
4741 static HRESULT
_SHRegisterUserShellFolders(BOOL bDefault
)
4743 static const UINT folders
[] = {
4754 CSIDL_DESKTOPDIRECTORY
,
4758 CSIDL_LOCAL_APPDATA
,
4759 CSIDL_INTERNET_CACHE
,
4768 CSIDL_APPDATA_LOCALLOW
,
4772 WCHAR userShellFolderPath
[MAX_PATH
], shellFolderPath
[MAX_PATH
];
4773 LPCWSTR pUserShellFolderPath
, pShellFolderPath
;
4778 TRACE("%s\n", bDefault
? "TRUE" : "FALSE");
4781 hToken
= (HANDLE
)-1;
4782 hRootKey
= HKEY_USERS
;
4783 strcpyW(userShellFolderPath
, DefaultW
);
4784 PathAddBackslashW(userShellFolderPath
);
4785 strcatW(userShellFolderPath
, szSHUserFolders
);
4786 pUserShellFolderPath
= userShellFolderPath
;
4787 strcpyW(shellFolderPath
, DefaultW
);
4788 PathAddBackslashW(shellFolderPath
);
4789 strcatW(shellFolderPath
, szSHFolders
);
4790 pShellFolderPath
= shellFolderPath
;
4795 hRootKey
= HKEY_CURRENT_USER
;
4796 pUserShellFolderPath
= szSHUserFolders
;
4797 pShellFolderPath
= szSHFolders
;
4800 hr
= _SHRegisterFolders(hRootKey
, hToken
, pUserShellFolderPath
,
4801 pShellFolderPath
, folders
, ARRAY_SIZE(folders
));
4802 TRACE("returning 0x%08x\n", hr
);
4806 static HRESULT
_SHRegisterCommonShellFolders(void)
4808 static const UINT folders
[] = {
4809 CSIDL_COMMON_STARTMENU
,
4810 CSIDL_COMMON_PROGRAMS
,
4811 CSIDL_COMMON_STARTUP
,
4812 CSIDL_COMMON_DESKTOPDIRECTORY
,
4813 CSIDL_COMMON_FAVORITES
,
4814 CSIDL_COMMON_APPDATA
,
4815 CSIDL_COMMON_TEMPLATES
,
4816 CSIDL_COMMON_DOCUMENTS
,
4817 CSIDL_COMMON_ADMINTOOLS
,
4819 CSIDL_COMMON_PICTURES
,
4825 hr
= _SHRegisterFolders(HKEY_LOCAL_MACHINE
, NULL
, szSHUserFolders
,
4826 szSHFolders
, folders
, ARRAY_SIZE(folders
));
4827 TRACE("returning 0x%08x\n", hr
);
4831 /******************************************************************************
4832 * create_extra_folders [Internal]
4834 * Create some extra folders that don't have a standard CSIDL definition.
4836 static HRESULT
create_extra_folders(void)
4838 static const WCHAR environW
[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4839 static const WCHAR microsoftW
[] = {'M','i','c','r','o','s','o','f','t',0};
4840 static const WCHAR TempW
[] = {'T','e','m','p',0};
4841 static const WCHAR TEMPW
[] = {'T','E','M','P',0};
4842 static const WCHAR TMPW
[] = {'T','M','P',0};
4843 WCHAR path
[MAX_PATH
+5];
4846 DWORD type
, size
, ret
;
4848 ret
= RegCreateKeyW( HKEY_CURRENT_USER
, environW
, &hkey
);
4849 if (ret
) return HRESULT_FROM_WIN32( ret
);
4851 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4852 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE
| CSIDL_FLAG_CREATE
, NULL
,
4853 SHGFP_TYPE_DEFAULT
, TempW
, path
);
4856 size
= sizeof(path
);
4857 if (RegQueryValueExW( hkey
, TEMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4858 RegSetValueExW( hkey
, TEMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4859 size
= sizeof(path
);
4860 if (RegQueryValueExW( hkey
, TMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4861 RegSetValueExW( hkey
, TMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4863 RegCloseKey( hkey
);
4867 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4868 SHGFP_TYPE_DEFAULT
, microsoftW
, path
);
4872 hr
= SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4873 SHGFP_TYPE_DEFAULT
, Microsoft_Windows_ThemesW
, path
);
4879 /******************************************************************************
4880 * set_folder_attributes
4882 * Set the various folder attributes registry keys.
4884 static HRESULT
set_folder_attributes(void)
4886 static const WCHAR clsidW
[] = {'C','L','S','I','D','\\',0 };
4887 static const WCHAR shellfolderW
[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4888 static const WCHAR wfparsingW
[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4889 static const WCHAR wfdisplayW
[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4890 static const WCHAR hideasdeleteW
[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4891 static const WCHAR cfattributesW
[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4892 static const WCHAR emptyW
[] = {0};
4901 DWORD call_for_attr
;
4904 { &CLSID_UnixFolder
, TRUE
, FALSE
, FALSE
},
4905 { &CLSID_UnixDosFolder
, TRUE
, FALSE
, FALSE
,
4906 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4907 { &CLSID_FolderShortcut
, FALSE
, FALSE
, FALSE
,
4908 SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_LINK
,
4909 SFGAO_HASSUBFOLDER
|SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_FILESYSANCESTOR
},
4910 { &CLSID_MyDocuments
, TRUE
, FALSE
, FALSE
,
4911 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4912 { &CLSID_RecycleBin
, FALSE
, FALSE
, FALSE
,
4913 SFGAO_FOLDER
|SFGAO_DROPTARGET
|SFGAO_HASPROPSHEET
},
4914 { &CLSID_ControlPanel
, FALSE
, TRUE
, TRUE
,
4915 SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
}
4919 WCHAR buffer
[39 + ARRAY_SIZE(clsidW
) + ARRAY_SIZE(shellfolderW
)];
4923 for (i
= 0; i
< ARRAY_SIZE(folders
); i
++)
4925 strcpyW( buffer
, clsidW
);
4926 StringFromGUID2( folders
[i
].clsid
, buffer
+ strlenW(buffer
), 39 );
4927 strcatW( buffer
, shellfolderW
);
4928 res
= RegCreateKeyExW( HKEY_CLASSES_ROOT
, buffer
, 0, NULL
, 0,
4929 KEY_READ
| KEY_WRITE
, NULL
, &hkey
, NULL
);
4930 if (res
) return HRESULT_FROM_WIN32( res
);
4931 if (folders
[i
].wfparsing
)
4932 res
= RegSetValueExW( hkey
, wfparsingW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4933 if (folders
[i
].wfdisplay
)
4934 res
= RegSetValueExW( hkey
, wfdisplayW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4935 if (folders
[i
].hideasdel
)
4936 res
= RegSetValueExW( hkey
, hideasdeleteW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4937 if (folders
[i
].attr
)
4938 res
= RegSetValueExW( hkey
, szAttributes
, 0, REG_DWORD
,
4939 (const BYTE
*)&folders
[i
].attr
, sizeof(DWORD
));
4940 if (folders
[i
].call_for_attr
)
4941 res
= RegSetValueExW( hkey
, cfattributesW
, 0, REG_DWORD
,
4942 (const BYTE
*)&folders
[i
].call_for_attr
, sizeof(DWORD
));
4943 RegCloseKey( hkey
);
4948 /*************************************************************************
4949 * SHGetSpecialFolderPathA [SHELL32.@]
4951 BOOL WINAPI
SHGetSpecialFolderPathA (
4957 return SHGetFolderPathA(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4961 /*************************************************************************
4962 * SHGetSpecialFolderPathW
4964 BOOL WINAPI
SHGetSpecialFolderPathW (
4970 return SHGetFolderPathW(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4974 /*************************************************************************
4975 * SHGetSpecialFolderPath (SHELL32.175)
4977 BOOL WINAPI
SHGetSpecialFolderPathAW (
4984 if (SHELL_OsIsUnicode())
4985 return SHGetSpecialFolderPathW (hwndOwner
, szPath
, nFolder
, bCreate
);
4986 return SHGetSpecialFolderPathA (hwndOwner
, szPath
, nFolder
, bCreate
);
4989 /*************************************************************************
4990 * SHGetFolderLocation [SHELL32.@]
4992 * Gets the folder locations from the registry and creates a pidl.
4996 * nFolder [I] CSIDL_xxxxx
4997 * hToken [I] token representing user, or NULL for current user, or -1 for
4999 * dwReserved [I] must be zero
5000 * ppidl [O] PIDL of a special folder
5004 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
5007 * Creates missing reg keys and directories.
5008 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
5009 * virtual folders that are handled here.
5011 HRESULT WINAPI
SHGetFolderLocation(
5016 LPITEMIDLIST
*ppidl
)
5018 HRESULT hr
= E_INVALIDARG
;
5020 TRACE("%p 0x%08x %p 0x%08x %p\n",
5021 hwndOwner
, nFolder
, hToken
, dwReserved
, ppidl
);
5024 return E_INVALIDARG
;
5026 return E_INVALIDARG
;
5028 /* The virtual folders' locations are not user-dependent */
5030 switch (nFolder
& CSIDL_FOLDER_MASK
)
5033 *ppidl
= _ILCreateDesktop();
5036 case CSIDL_PERSONAL
:
5037 *ppidl
= _ILCreateMyDocuments();
5040 case CSIDL_INTERNET
:
5041 *ppidl
= _ILCreateIExplore();
5044 case CSIDL_CONTROLS
:
5045 *ppidl
= _ILCreateControlPanel();
5048 case CSIDL_PRINTERS
:
5049 *ppidl
= _ILCreatePrinters();
5052 case CSIDL_BITBUCKET
:
5053 *ppidl
= _ILCreateBitBucket();
5057 *ppidl
= _ILCreateMyComputer();
5061 *ppidl
= _ILCreateNetwork();
5066 WCHAR szPath
[MAX_PATH
];
5068 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
,
5069 SHGFP_TYPE_CURRENT
, szPath
);
5074 TRACE("Value=%s\n", debugstr_w(szPath
));
5075 hr
= SHILCreateFromPathW(szPath
, ppidl
, &attributes
);
5077 else if (hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
))
5079 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
5080 * version 6.0 returns E_FAIL for nonexistent paths
5089 TRACE("-- (new pidl %p)\n",*ppidl
);
5093 /*************************************************************************
5094 * SHGetSpecialFolderLocation [SHELL32.@]
5097 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
5100 HRESULT WINAPI
SHGetSpecialFolderLocation(
5103 LPITEMIDLIST
* ppidl
)
5105 HRESULT hr
= E_INVALIDARG
;
5107 TRACE("(%p,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
5110 return E_INVALIDARG
;
5112 hr
= SHGetFolderLocation(hwndOwner
, nFolder
, NULL
, 0, ppidl
);
5116 static int csidl_from_id( const KNOWNFOLDERID
*id
)
5119 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
5120 if (IsEqualGUID( CSIDL_Data
[i
].id
, id
)) return i
;
5124 /*************************************************************************
5125 * SHGetKnownFolderPath [SHELL32.@]
5127 HRESULT WINAPI
SHGetKnownFolderPath(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, WCHAR
**ret_path
)
5129 WCHAR pathW
[MAX_PATH
], tempW
[MAX_PATH
];
5133 int folder
= csidl_from_id(rfid
), shgfp_flags
;
5135 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, ret_path
);
5140 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
5142 if (flags
& ~(KF_FLAG_CREATE
|KF_FLAG_SIMPLE_IDLIST
|KF_FLAG_DONT_UNEXPAND
|
5143 KF_FLAG_DONT_VERIFY
|KF_FLAG_NO_ALIAS
|KF_FLAG_INIT
|KF_FLAG_DEFAULT_PATH
))
5145 FIXME("flags 0x%08x not supported\n", flags
);
5146 return E_INVALIDARG
;
5149 shgfp_flags
= flags
& KF_FLAG_DEFAULT_PATH
? SHGFP_TYPE_DEFAULT
: SHGFP_TYPE_CURRENT
;
5151 type
= CSIDL_Data
[folder
].type
;
5154 case CSIDL_Type_Disallowed
:
5157 case CSIDL_Type_NonExistent
:
5161 case CSIDL_Type_WindowsPath
:
5162 GetWindowsDirectoryW(tempW
, MAX_PATH
);
5163 if (CSIDL_Data
[folder
].szDefaultPath
&&
5164 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
5165 *CSIDL_Data
[folder
].szDefaultPath
)
5167 PathAddBackslashW(tempW
);
5168 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
5172 case CSIDL_Type_SystemPath
:
5173 GetSystemDirectoryW(tempW
, MAX_PATH
);
5174 if (CSIDL_Data
[folder
].szDefaultPath
&&
5175 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
5176 *CSIDL_Data
[folder
].szDefaultPath
)
5178 PathAddBackslashW(tempW
);
5179 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
5183 case CSIDL_Type_SystemX86Path
:
5184 if (!GetSystemWow64DirectoryW(tempW
, MAX_PATH
)) GetSystemDirectoryW(tempW
, MAX_PATH
);
5185 if (CSIDL_Data
[folder
].szDefaultPath
&&
5186 !IS_INTRESOURCE(CSIDL_Data
[folder
].szDefaultPath
) &&
5187 *CSIDL_Data
[folder
].szDefaultPath
)
5189 PathAddBackslashW(tempW
);
5190 strcatW(tempW
, CSIDL_Data
[folder
].szDefaultPath
);
5194 case CSIDL_Type_CurrVer
:
5195 hr
= _SHGetCurrentVersionPath(shgfp_flags
, folder
, tempW
);
5197 case CSIDL_Type_User
:
5198 hr
= _SHGetUserProfilePath(token
, shgfp_flags
, folder
, tempW
);
5200 case CSIDL_Type_AllUsers
:
5201 case CSIDL_Type_ProgramData
:
5202 hr
= _SHGetAllUsersProfilePath(shgfp_flags
, folder
, tempW
);
5205 FIXME("bogus type %d, please fix\n", type
);
5213 /* Expand environment strings if necessary */
5216 hr
= _SHExpandEnvironmentStrings(tempW
, pathW
);
5221 strcpyW(pathW
, tempW
);
5223 /* if we don't care about existing directories we are ready */
5224 if (flags
& KF_FLAG_DONT_VERIFY
) goto done
;
5226 if (PathFileExistsW(pathW
)) goto done
;
5228 /* Does not exist but we are not allowed to create it. The return value
5229 * is verified against shell32 version 6.0.
5231 if (!(flags
& KF_FLAG_CREATE
))
5233 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
5237 /* create symbolic links rather than directories for specific
5238 * user shell folders */
5239 _SHCreateSymbolicLink(folder
);
5241 /* create directory/directories */
5242 ret
= SHCreateDirectoryExW(NULL
, pathW
, NULL
);
5243 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
5245 ERR("Failed to create directory %s.\n", debugstr_w(pathW
));
5250 TRACE("Created missing system directory %s\n", debugstr_w(pathW
));
5253 TRACE("Final path is %s, %#x\n", debugstr_w(pathW
), hr
);
5255 *ret_path
= CoTaskMemAlloc((strlenW(pathW
) + 1) * sizeof(WCHAR
));
5257 return E_OUTOFMEMORY
;
5258 strcpyW(*ret_path
, pathW
);
5263 TRACE("Failed to get folder path, %#x.\n", hr
);
5268 /*************************************************************************
5269 * SHGetFolderPathEx [SHELL32.@]
5271 HRESULT WINAPI
SHGetFolderPathEx(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, LPWSTR path
, DWORD len
)
5276 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid
), flags
, token
, path
, len
);
5278 if (!path
|| !len
) return E_INVALIDARG
;
5280 hr
= SHGetKnownFolderPath( rfid
, flags
, token
, &buffer
);
5281 if (SUCCEEDED( hr
))
5283 if (strlenW( buffer
) + 1 > len
)
5285 CoTaskMemFree( buffer
);
5286 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER
);
5288 strcpyW( path
, buffer
);
5289 CoTaskMemFree( buffer
);
5295 * Internal function to convert known folder identifier to path of registry key
5296 * associated with known folder.
5299 * rfid [I] pointer to known folder identifier (may be NULL)
5300 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
5301 * lpPath [O] place to store string address. String should be
5302 * later freed using HeapFree(GetProcessHeap(),0, ... )
5304 static HRESULT
get_known_folder_registry_path(
5305 REFKNOWNFOLDERID rfid
,
5306 LPWSTR lpStringGuid
,
5309 static const WCHAR sBackslash
[] = {'\\',0};
5314 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid
), debugstr_w(lpStringGuid
), lpPath
);
5317 StringFromGUID2(rfid
, sGuid
, ARRAY_SIZE(sGuid
));
5319 lstrcpyW(sGuid
, lpStringGuid
);
5321 length
= lstrlenW(szKnownFolderDescriptions
)+51;
5322 *lpPath
= heap_alloc(length
*sizeof(WCHAR
));
5328 lstrcpyW(*lpPath
, szKnownFolderDescriptions
);
5329 lstrcatW(*lpPath
, sBackslash
);
5330 lstrcatW(*lpPath
, sGuid
);
5336 static HRESULT
get_known_folder_wstr(const WCHAR
*regpath
, const WCHAR
*value
, WCHAR
**out
)
5342 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
));
5346 *out
= CoTaskMemAlloc(size
);
5348 return E_OUTOFMEMORY
;
5350 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, *out
, &size
));
5352 CoTaskMemFree(*out
);
5359 static HRESULT
get_known_folder_dword(const WCHAR
*registryPath
, const WCHAR
*value
, DWORD
*out
)
5361 DWORD dwSize
= sizeof(DWORD
);
5363 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, value
, RRF_RT_DWORD
, &dwType
, out
, &dwSize
));
5367 * Internal function to get place where folder redirection information are stored.
5370 * rfid [I] pointer to known folder identifier (may be NULL)
5371 * rootKey [O] root key where the redirection information are stored
5372 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5373 * However, besides root key, path is always that same, and is stored
5374 * as "szKnownFolderRedirections" constant
5376 static HRESULT
get_known_folder_redirection_place(
5377 REFKNOWNFOLDERID rfid
,
5381 LPWSTR lpRegistryPath
= NULL
;
5382 KF_CATEGORY category
;
5384 /* first, get known folder's category */
5385 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5388 hr
= get_known_folder_dword(lpRegistryPath
, szCategory
, &category
);
5392 if(category
== KF_CATEGORY_COMMON
)
5394 *rootKey
= HKEY_LOCAL_MACHINE
;
5397 else if(category
== KF_CATEGORY_PERUSER
)
5399 *rootKey
= HKEY_CURRENT_USER
;
5406 heap_free(lpRegistryPath
);
5410 static HRESULT
get_known_folder_path_by_id(REFKNOWNFOLDERID folderId
, LPWSTR lpRegistryPath
, DWORD dwFlags
, LPWSTR
*ppszPath
);
5412 static HRESULT
redirect_known_folder(
5413 REFKNOWNFOLDERID rfid
,
5415 KF_REDIRECT_FLAGS flags
,
5416 LPCWSTR pszTargetPath
,
5418 KNOWNFOLDERID
const *pExclusion
,
5422 HKEY rootKey
= HKEY_LOCAL_MACHINE
, hKey
;
5424 LPWSTR lpRegistryPath
= NULL
, lpSrcPath
= NULL
;
5425 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid
), hwnd
, flags
, debugstr_w(pszTargetPath
), cFolders
, pExclusion
, ppszError
);
5427 if (ppszError
) *ppszError
= NULL
;
5429 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5432 hr
= get_known_folder_path_by_id(rfid
, lpRegistryPath
, 0, &lpSrcPath
);
5434 heap_free(lpRegistryPath
);
5436 /* get path to redirection storage */
5438 hr
= get_known_folder_redirection_place(rfid
, &rootKey
);
5440 /* write redirection information */
5442 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey
, szKnownFolderRedirections
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
));
5446 StringFromGUID2(rfid
, sGuid
, ARRAY_SIZE(sGuid
));
5448 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, sGuid
, 0, REG_SZ
, (LPBYTE
)pszTargetPath
, (lstrlenW(pszTargetPath
)+1)*sizeof(WCHAR
)));
5453 /* make sure destination path exists */
5454 SHCreateDirectory(NULL
, pszTargetPath
);
5456 /* copy content if required */
5457 if(SUCCEEDED(hr
) && (flags
& KF_REDIRECT_COPY_CONTENTS
) )
5459 static const WCHAR sWildcard
[] = {'\\','*',0};
5460 WCHAR srcPath
[MAX_PATH
+1], dstPath
[MAX_PATH
+1];
5461 SHFILEOPSTRUCTW fileOp
;
5463 ZeroMemory(srcPath
, sizeof(srcPath
));
5464 lstrcpyW(srcPath
, lpSrcPath
);
5465 lstrcatW(srcPath
, sWildcard
);
5467 ZeroMemory(dstPath
, sizeof(dstPath
));
5468 lstrcpyW(dstPath
, pszTargetPath
);
5470 ZeroMemory(&fileOp
, sizeof(fileOp
));
5472 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5473 fileOp
.wFunc
= FO_MOVE
;
5475 fileOp
.wFunc
= FO_COPY
;
5477 fileOp
.pFrom
= srcPath
;
5478 fileOp
.pTo
= dstPath
;
5479 fileOp
.fFlags
= FOF_NO_UI
;
5481 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5483 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5485 ZeroMemory(srcPath
, sizeof(srcPath
));
5486 lstrcpyW(srcPath
, lpSrcPath
);
5488 ZeroMemory(&fileOp
, sizeof(fileOp
));
5489 fileOp
.wFunc
= FO_DELETE
;
5490 fileOp
.pFrom
= srcPath
;
5491 fileOp
.fFlags
= FOF_NO_UI
;
5493 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5497 CoTaskMemFree(lpSrcPath
);
5505 IKnownFolder IKnownFolder_iface
;
5508 LPWSTR registryPath
;
5511 static inline struct knownfolder
*impl_from_IKnownFolder( IKnownFolder
*iface
)
5513 return CONTAINING_RECORD( iface
, struct knownfolder
, IKnownFolder_iface
);
5516 static ULONG WINAPI
knownfolder_AddRef(
5517 IKnownFolder
*iface
)
5519 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5520 return InterlockedIncrement( &knownfolder
->refs
);
5523 static ULONG WINAPI
knownfolder_Release(
5524 IKnownFolder
*iface
)
5526 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5527 LONG refs
= InterlockedDecrement( &knownfolder
->refs
);
5530 TRACE("destroying %p\n", knownfolder
);
5531 heap_free( knownfolder
->registryPath
);
5532 heap_free( knownfolder
);
5537 static HRESULT WINAPI
knownfolder_QueryInterface(
5538 IKnownFolder
*iface
,
5542 struct knownfolder
*This
= impl_from_IKnownFolder( iface
);
5544 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5547 if ( IsEqualGUID( riid
, &IID_IKnownFolder
) ||
5548 IsEqualGUID( riid
, &IID_IUnknown
) )
5552 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5554 TRACE("IID_IMarshal returning NULL.\n");
5555 return E_NOINTERFACE
;
5559 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5560 return E_NOINTERFACE
;
5562 IKnownFolder_AddRef( iface
);
5566 static HRESULT
knownfolder_set_id(
5567 struct knownfolder
*knownfolder
,
5568 const KNOWNFOLDERID
*kfid
)
5573 TRACE("%s\n", debugstr_guid(kfid
));
5575 knownfolder
->id
= *kfid
;
5577 /* check is it registry-registered folder */
5578 hr
= get_known_folder_registry_path(kfid
, NULL
, &knownfolder
->registryPath
);
5580 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, 0, 0, &hKey
));
5589 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5590 heap_free(knownfolder
->registryPath
);
5591 knownfolder
->registryPath
= NULL
;
5598 static HRESULT WINAPI
knownfolder_GetId(
5599 IKnownFolder
*iface
,
5600 KNOWNFOLDERID
*pkfid
)
5602 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5604 TRACE("%p\n", pkfid
);
5606 *pkfid
= knownfolder
->id
;
5610 static HRESULT WINAPI
knownfolder_GetCategory(
5611 IKnownFolder
*iface
,
5612 KF_CATEGORY
*pCategory
)
5614 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5617 TRACE("%p, %p\n", knownfolder
, pCategory
);
5619 /* we cannot get a category for a folder which is not registered */
5620 if(!knownfolder
->registryPath
)
5624 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, pCategory
);
5629 static HRESULT WINAPI
knownfolder_GetShellItem(
5630 IKnownFolder
*iface
,
5635 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5636 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder
, flags
, debugstr_guid(riid
), ppv
);
5637 return SHGetKnownFolderItem(&knownfolder
->id
, flags
, NULL
, riid
, ppv
);
5640 static HRESULT
get_known_folder_path(
5642 LPWSTR registryPath
,
5645 static const WCHAR sBackslash
[] = {'\\',0};
5647 DWORD dwSize
, dwType
;
5648 WCHAR path
[MAX_PATH
] = {0};
5649 WCHAR parentGuid
[39];
5650 KF_CATEGORY category
;
5651 LPWSTR parentRegistryPath
, parentPath
;
5652 HKEY hRedirectionRootKey
= NULL
;
5654 TRACE("(%s, %p)\n", debugstr_w(registryPath
), ppszPath
);
5657 /* check if folder has parent */
5658 dwSize
= sizeof(parentGuid
);
5659 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szParentFolder
, RRF_RT_REG_SZ
, &dwType
, parentGuid
, &dwSize
));
5660 if(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)) hr
= S_FALSE
;
5664 /* get parent's known folder path (recursive) */
5665 hr
= get_known_folder_registry_path(NULL
, parentGuid
, &parentRegistryPath
);
5666 if(FAILED(hr
)) return hr
;
5668 hr
= get_known_folder_path(parentGuid
, parentRegistryPath
, &parentPath
);
5670 heap_free(parentRegistryPath
);
5674 lstrcatW(path
, parentPath
);
5675 lstrcatW(path
, sBackslash
);
5677 heap_free(parentRegistryPath
);
5678 heap_free(parentPath
);
5681 /* check, if folder was redirected */
5683 hr
= get_known_folder_dword(registryPath
, szCategory
, &category
);
5687 if(category
== KF_CATEGORY_COMMON
)
5688 hRedirectionRootKey
= HKEY_LOCAL_MACHINE
;
5689 else if(category
== KF_CATEGORY_PERUSER
)
5690 hRedirectionRootKey
= HKEY_CURRENT_USER
;
5692 if(hRedirectionRootKey
)
5694 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, NULL
, &dwSize
));
5698 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5699 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5704 lstrcpyW(*ppszPath
, path
);
5705 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5711 /* no redirection, use previous way - read the relative path from folder definition */
5712 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, NULL
, &dwSize
));
5716 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5717 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5722 lstrcpyW(*ppszPath
, path
);
5723 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5728 TRACE("returning path: %s\n", debugstr_w(*ppszPath
));
5732 static HRESULT
get_known_folder_path_by_id(
5733 REFKNOWNFOLDERID folderId
,
5734 LPWSTR lpRegistryPath
,
5738 HRESULT hr
= E_FAIL
;
5742 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId
), debugstr_w(lpRegistryPath
), dwFlags
, ppszPath
);
5744 /* if this is registry-registered known folder, get path from registry */
5747 StringFromGUID2(folderId
, sGuid
, ARRAY_SIZE(sGuid
));
5749 hr
= get_known_folder_path(sGuid
, lpRegistryPath
, ppszPath
);
5751 /* in other case, use older way */
5754 hr
= SHGetKnownFolderPath( folderId
, dwFlags
, NULL
, ppszPath
);
5756 if (FAILED(hr
)) return hr
;
5758 /* check if known folder really exists */
5759 dwAttributes
= GetFileAttributesW(*ppszPath
);
5760 if(dwAttributes
== INVALID_FILE_ATTRIBUTES
|| !(dwAttributes
& FILE_ATTRIBUTE_DIRECTORY
) )
5762 TRACE("directory %s not found\n", debugstr_w(*ppszPath
));
5763 CoTaskMemFree(*ppszPath
);
5765 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
5771 static HRESULT WINAPI
knownfolder_GetPath(
5772 IKnownFolder
*iface
,
5776 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5777 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, dwFlags
, ppszPath
);
5779 return get_known_folder_path_by_id(&knownfolder
->id
, knownfolder
->registryPath
, dwFlags
, ppszPath
);
5782 static HRESULT WINAPI
knownfolder_SetPath(
5783 IKnownFolder
*iface
,
5787 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5790 TRACE("(%p, 0x%08x, %s)\n", knownfolder
, dwFlags
, debugstr_w(pszPath
));
5792 /* check if the known folder is registered */
5793 if(!knownfolder
->registryPath
)
5797 hr
= redirect_known_folder(&knownfolder
->id
, NULL
, 0, pszPath
, 0, NULL
, NULL
);
5802 static HRESULT WINAPI
knownfolder_GetIDList(
5803 IKnownFolder
*iface
,
5805 PIDLIST_ABSOLUTE
*ppidl
)
5807 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5808 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, flags
, ppidl
);
5809 return SHGetKnownFolderIDList(&knownfolder
->id
, flags
, NULL
, ppidl
);
5812 static HRESULT WINAPI
knownfolder_GetFolderType(
5813 IKnownFolder
*iface
,
5814 FOLDERTYPEID
*pftid
)
5816 FIXME("%p\n", pftid
);
5820 static HRESULT WINAPI
knownfolder_GetRedirectionCapabilities(
5821 IKnownFolder
*iface
,
5822 KF_REDIRECTION_CAPABILITIES
*pCapabilities
)
5824 FIXME("%p stub\n", pCapabilities
);
5825 if(!pCapabilities
) return E_INVALIDARG
;
5826 *pCapabilities
= KF_REDIRECTION_CAPABILITIES_DENY_ALL
;
5830 static HRESULT WINAPI
knownfolder_GetFolderDefinition(
5831 IKnownFolder
*iface
,
5832 KNOWNFOLDER_DEFINITION
*pKFD
)
5834 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5837 WCHAR parentGuid
[39];
5838 TRACE("(%p, %p)\n", knownfolder
, pKFD
);
5840 if(!pKFD
) return E_INVALIDARG
;
5842 ZeroMemory(pKFD
, sizeof(*pKFD
));
5844 /* required fields */
5845 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, &pKFD
->category
);
5849 hr
= get_known_folder_wstr(knownfolder
->registryPath
, szName
, &pKFD
->pszName
);
5853 /* optional fields */
5854 dwSize
= sizeof(parentGuid
);
5855 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, szParentFolder
,
5856 RRF_RT_REG_SZ
, NULL
, parentGuid
, &dwSize
));
5859 hr
= IIDFromString(parentGuid
, &pKFD
->fidParent
);
5864 get_known_folder_dword(knownfolder
->registryPath
, szAttributes
, &pKFD
->dwAttributes
);
5866 get_known_folder_wstr(knownfolder
->registryPath
, szRelativePath
, &pKFD
->pszRelativePath
);
5868 get_known_folder_wstr(knownfolder
->registryPath
, szParsingName
, &pKFD
->pszParsingName
);
5873 static const struct IKnownFolderVtbl knownfolder_vtbl
=
5875 knownfolder_QueryInterface
,
5877 knownfolder_Release
,
5879 knownfolder_GetCategory
,
5880 knownfolder_GetShellItem
,
5881 knownfolder_GetPath
,
5882 knownfolder_SetPath
,
5883 knownfolder_GetIDList
,
5884 knownfolder_GetFolderType
,
5885 knownfolder_GetRedirectionCapabilities
,
5886 knownfolder_GetFolderDefinition
5889 static HRESULT
knownfolder_create( struct knownfolder
**knownfolder
)
5891 struct knownfolder
*kf
;
5893 kf
= heap_alloc( sizeof(*kf
) );
5894 if (!kf
) return E_OUTOFMEMORY
;
5896 kf
->IKnownFolder_iface
.lpVtbl
= &knownfolder_vtbl
;
5898 memset( &kf
->id
, 0, sizeof(kf
->id
) );
5899 kf
->registryPath
= NULL
;
5903 TRACE("returning iface %p\n", &kf
->IKnownFolder_iface
);
5907 struct foldermanager
5909 IKnownFolderManager IKnownFolderManager_iface
;
5915 static inline struct foldermanager
*impl_from_IKnownFolderManager( IKnownFolderManager
*iface
)
5917 return CONTAINING_RECORD( iface
, struct foldermanager
, IKnownFolderManager_iface
);
5920 static ULONG WINAPI
foldermanager_AddRef(
5921 IKnownFolderManager
*iface
)
5923 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5924 return InterlockedIncrement( &foldermanager
->refs
);
5927 static ULONG WINAPI
foldermanager_Release(
5928 IKnownFolderManager
*iface
)
5930 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5931 LONG refs
= InterlockedDecrement( &foldermanager
->refs
);
5934 TRACE("destroying %p\n", foldermanager
);
5935 heap_free( foldermanager
->ids
);
5936 heap_free( foldermanager
);
5941 static HRESULT WINAPI
foldermanager_QueryInterface(
5942 IKnownFolderManager
*iface
,
5946 struct foldermanager
*This
= impl_from_IKnownFolderManager( iface
);
5948 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5951 if ( IsEqualGUID( riid
, &IID_IKnownFolderManager
) ||
5952 IsEqualGUID( riid
, &IID_IUnknown
) )
5956 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5958 TRACE("IID_IMarshal returning NULL.\n");
5959 return E_NOINTERFACE
;
5963 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5964 return E_NOINTERFACE
;
5966 IKnownFolderManager_AddRef( iface
);
5970 static HRESULT WINAPI
foldermanager_FolderIdFromCsidl(
5971 IKnownFolderManager
*iface
,
5973 KNOWNFOLDERID
*pfid
)
5975 TRACE("%d, %p\n", nCsidl
, pfid
);
5977 if (nCsidl
>= ARRAY_SIZE(CSIDL_Data
))
5978 return E_INVALIDARG
;
5979 *pfid
= *CSIDL_Data
[nCsidl
].id
;
5983 static HRESULT WINAPI
foldermanager_FolderIdToCsidl(
5984 IKnownFolderManager
*iface
,
5985 REFKNOWNFOLDERID rfid
,
5990 TRACE("%s, %p\n", debugstr_guid(rfid
), pnCsidl
);
5992 csidl
= csidl_from_id( rfid
);
5993 if (csidl
== -1) return E_INVALIDARG
;
5998 static HRESULT WINAPI
foldermanager_GetFolderIds(
5999 IKnownFolderManager
*iface
,
6000 KNOWNFOLDERID
**ppKFId
,
6003 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
6005 TRACE("%p, %p\n", ppKFId
, pCount
);
6007 *ppKFId
= CoTaskMemAlloc(fm
->num_ids
* sizeof(KNOWNFOLDERID
));
6008 memcpy(*ppKFId
, fm
->ids
, fm
->num_ids
* sizeof(KNOWNFOLDERID
));
6009 *pCount
= fm
->num_ids
;
6013 static BOOL
is_knownfolder( struct foldermanager
*fm
, const KNOWNFOLDERID
*id
)
6017 LPWSTR registryPath
= NULL
;
6020 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
6021 for (i
= 0; i
< fm
->num_ids
; i
++)
6022 if (IsEqualGUID( &fm
->ids
[i
], id
)) return TRUE
;
6024 hr
= get_known_folder_registry_path(id
, NULL
, ®istryPath
);
6027 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, 0, &hKey
));
6028 heap_free(registryPath
);
6040 static HRESULT WINAPI
foldermanager_GetFolder(
6041 IKnownFolderManager
*iface
,
6042 REFKNOWNFOLDERID rfid
,
6043 IKnownFolder
**ppkf
)
6045 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
6046 struct knownfolder
*kf
;
6049 TRACE("%s, %p\n", debugstr_guid(rfid
), ppkf
);
6051 if (!is_knownfolder( fm
, rfid
))
6053 WARN("unknown folder\n");
6054 return E_INVALIDARG
;
6056 hr
= knownfolder_create( &kf
);
6057 if (SUCCEEDED( hr
))
6059 hr
= knownfolder_set_id( kf
, rfid
);
6060 *ppkf
= &kf
->IKnownFolder_iface
;
6068 static HRESULT WINAPI
foldermanager_GetFolderByName(
6069 IKnownFolderManager
*iface
,
6070 LPCWSTR pszCanonicalName
,
6071 IKnownFolder
**ppkf
)
6073 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
6074 struct knownfolder
*kf
;
6079 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName
), ppkf
);
6081 for (i
= 0; i
< fm
->num_ids
; i
++)
6084 hr
= get_known_folder_registry_path( &fm
->ids
[i
], NULL
, &path
);
6085 if (FAILED( hr
)) return hr
;
6087 hr
= get_known_folder_wstr( path
, szName
, &name
);
6089 if (FAILED( hr
)) return hr
;
6091 found
= !strcmpiW( pszCanonicalName
, name
);
6092 CoTaskMemFree( name
);
6098 hr
= knownfolder_create( &kf
);
6099 if (FAILED( hr
)) return hr
;
6101 hr
= knownfolder_set_id( kf
, &fm
->ids
[i
] );
6104 IKnownFolder_Release( &kf
->IKnownFolder_iface
);
6107 *ppkf
= &kf
->IKnownFolder_iface
;
6111 hr
= HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
6118 static HRESULT
register_folder(const KNOWNFOLDERID
*rfid
, const KNOWNFOLDER_DEFINITION
*pKFD
)
6123 LPWSTR registryPath
= NULL
;
6125 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
6126 TRACE("registry path: %s\n", debugstr_w(registryPath
));
6129 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, NULL
, 0, KEY_WRITE
, 0, &hKey
, &dwDisp
));
6133 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szCategory
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->category
, sizeof(pKFD
->category
)));
6135 if(SUCCEEDED(hr
) && pKFD
->dwAttributes
!= 0)
6136 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szAttributes
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->dwAttributes
, sizeof(pKFD
->dwAttributes
)));
6139 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszName
, (lstrlenW(pKFD
->pszName
)+1)*sizeof(WCHAR
) ));
6141 if(SUCCEEDED(hr
) && pKFD
->pszParsingName
)
6142 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParsingName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszParsingName
, (lstrlenW(pKFD
->pszParsingName
)+1)*sizeof(WCHAR
) ));
6144 if(SUCCEEDED(hr
) && !IsEqualGUID(&pKFD
->fidParent
, &GUID_NULL
))
6146 WCHAR sParentGuid
[39];
6147 StringFromGUID2(&pKFD
->fidParent
, sParentGuid
, ARRAY_SIZE(sParentGuid
));
6149 /* this known folder has parent folder */
6150 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParentFolder
, 0, REG_SZ
, (LPBYTE
)sParentGuid
, sizeof(sParentGuid
)));
6153 if(SUCCEEDED(hr
) && pKFD
->category
!= KF_CATEGORY_VIRTUAL
&& pKFD
->pszRelativePath
)
6154 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szRelativePath
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszRelativePath
, (lstrlenW(pKFD
->pszRelativePath
)+1)*sizeof(WCHAR
) ));
6159 SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
);
6162 heap_free(registryPath
);
6166 static HRESULT WINAPI
foldermanager_RegisterFolder(
6167 IKnownFolderManager
*iface
,
6168 REFKNOWNFOLDERID rfid
,
6169 KNOWNFOLDER_DEFINITION
const *pKFD
)
6171 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(rfid
), pKFD
);
6172 return register_folder(rfid
, pKFD
);
6175 static HRESULT WINAPI
foldermanager_UnregisterFolder(
6176 IKnownFolderManager
*iface
,
6177 REFKNOWNFOLDERID rfid
)
6180 LPWSTR registryPath
= NULL
;
6181 TRACE("(%p, %s)\n", iface
, debugstr_guid(rfid
));
6183 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
6186 hr
= HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
));
6188 heap_free(registryPath
);
6192 static HRESULT WINAPI
foldermanager_FindFolderFromPath(
6193 IKnownFolderManager
*iface
,
6196 IKnownFolder
**ppkf
)
6198 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath
), mode
, ppkf
);
6202 static HRESULT WINAPI
foldermanager_FindFolderFromIDList(
6203 IKnownFolderManager
*iface
,
6204 PCIDLIST_ABSOLUTE pidl
,
6205 IKnownFolder
**ppkf
)
6207 FIXME("%p, %p\n", pidl
, ppkf
);
6211 static HRESULT WINAPI
foldermanager_Redirect(
6212 IKnownFolderManager
*iface
,
6213 REFKNOWNFOLDERID rfid
,
6215 KF_REDIRECT_FLAGS flags
,
6216 LPCWSTR pszTargetPath
,
6218 KNOWNFOLDERID
const *pExclusion
,
6221 return redirect_known_folder(rfid
, hwnd
, flags
, pszTargetPath
, cFolders
, pExclusion
, ppszError
);
6224 static const struct IKnownFolderManagerVtbl foldermanager_vtbl
=
6226 foldermanager_QueryInterface
,
6227 foldermanager_AddRef
,
6228 foldermanager_Release
,
6229 foldermanager_FolderIdFromCsidl
,
6230 foldermanager_FolderIdToCsidl
,
6231 foldermanager_GetFolderIds
,
6232 foldermanager_GetFolder
,
6233 foldermanager_GetFolderByName
,
6234 foldermanager_RegisterFolder
,
6235 foldermanager_UnregisterFolder
,
6236 foldermanager_FindFolderFromPath
,
6237 foldermanager_FindFolderFromIDList
,
6238 foldermanager_Redirect
6241 static HRESULT
foldermanager_create( void **ppv
)
6244 struct foldermanager
*fm
;
6246 fm
= heap_alloc( sizeof(*fm
) );
6247 if (!fm
) return E_OUTOFMEMORY
;
6249 fm
->IKnownFolderManager_iface
.lpVtbl
= &foldermanager_vtbl
;
6253 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
6255 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
)) fm
->num_ids
++;
6257 fm
->ids
= heap_alloc( fm
->num_ids
* sizeof(KNOWNFOLDERID
) );
6261 return E_OUTOFMEMORY
;
6263 for (i
= j
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
6265 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
))
6267 fm
->ids
[j
] = *CSIDL_Data
[i
].id
;
6271 TRACE("found %u known folders\n", fm
->num_ids
);
6272 *ppv
= &fm
->IKnownFolderManager_iface
;
6274 TRACE("returning iface %p\n", *ppv
);
6278 HRESULT WINAPI
KnownFolderManager_Constructor( IUnknown
*punk
, REFIID riid
, void **ppv
)
6280 TRACE("%p, %s, %p\n", punk
, debugstr_guid(riid
), ppv
);
6285 return CLASS_E_NOAGGREGATION
;
6287 return foldermanager_create( ppv
);
6290 HRESULT WINAPI
SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, PIDLIST_ABSOLUTE
*pidl
)
6292 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, pidl
);
6295 return E_INVALIDARG
;
6298 FIXME("unsupported flags: 0x%08x\n", flags
);
6301 FIXME("user token is not used.\n");
6304 if (IsEqualIID(rfid
, &FOLDERID_Desktop
))
6305 *pidl
= _ILCreateDesktop();
6306 else if (IsEqualIID(rfid
, &FOLDERID_RecycleBinFolder
))
6307 *pidl
= _ILCreateBitBucket();
6308 else if (IsEqualIID(rfid
, &FOLDERID_ComputerFolder
))
6309 *pidl
= _ILCreateMyComputer();
6310 else if (IsEqualIID(rfid
, &FOLDERID_PrintersFolder
))
6311 *pidl
= _ILCreatePrinters();
6312 else if (IsEqualIID(rfid
, &FOLDERID_ControlPanelFolder
))
6313 *pidl
= _ILCreateControlPanel();
6314 else if (IsEqualIID(rfid
, &FOLDERID_NetworkFolder
))
6315 *pidl
= _ILCreateNetwork();
6316 else if (IsEqualIID(rfid
, &FOLDERID_Documents
))
6317 *pidl
= _ILCreateMyDocuments();
6320 DWORD attributes
= 0;
6324 hr
= SHGetKnownFolderPath(rfid
, flags
, token
, &pathW
);
6328 hr
= SHILCreateFromPathW(pathW
, pidl
, &attributes
);
6329 CoTaskMemFree(pathW
);
6333 return *pidl
? S_OK
: E_FAIL
;
6336 HRESULT WINAPI
SHGetKnownFolderItem(REFKNOWNFOLDERID rfid
, KNOWN_FOLDER_FLAG flags
, HANDLE hToken
,
6337 REFIID riid
, void **ppv
)
6339 PIDLIST_ABSOLUTE pidl
;
6342 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid
), flags
, hToken
, debugstr_guid(riid
), ppv
);
6344 hr
= SHGetKnownFolderIDList(rfid
, flags
, hToken
, &pidl
);
6351 hr
= SHCreateItemFromIDList(pidl
, riid
, ppv
);
6352 CoTaskMemFree(pidl
);
6356 static void register_system_knownfolders(void)
6360 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); ++i
)
6362 const CSIDL_DATA
*folder
= &CSIDL_Data
[i
];
6363 if(folder
->pszName
){
6364 KNOWNFOLDER_DEFINITION kfd
;
6366 /* register_folder won't modify kfd, so cast away const instead of
6368 kfd
.category
= folder
->category
;
6369 kfd
.pszName
= (WCHAR
*)folder
->pszName
;
6370 kfd
.pszDescription
= (WCHAR
*)folder
->pszDescription
;
6371 memcpy(&kfd
.fidParent
, folder
->fidParent
, sizeof(KNOWNFOLDERID
));
6372 kfd
.pszRelativePath
= (WCHAR
*)folder
->pszRelativePath
;
6373 kfd
.pszParsingName
= (WCHAR
*)folder
->pszParsingName
;
6374 kfd
.pszTooltip
= (WCHAR
*)folder
->pszTooltip
;
6375 kfd
.pszLocalizedName
= (WCHAR
*)folder
->pszLocalizedName
;
6376 kfd
.pszIcon
= (WCHAR
*)folder
->pszIcon
;
6377 kfd
.pszSecurity
= (WCHAR
*)folder
->pszSecurity
;
6378 kfd
.dwAttributes
= folder
->dwAttributes
;
6379 kfd
.kfdFlags
= folder
->kfdFlags
;
6380 memcpy(&kfd
.ftidType
, folder
->ftidType
, sizeof(FOLDERTYPEID
));
6382 register_folder(folder
->id
, &kfd
);
6387 HRESULT
SHELL_RegisterShellFolders(void)
6391 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6392 * 'My Videos', 'My Music', 'Desktop' etc. in advance, so that the
6393 * _SHRegister*ShellFolders() functions will find everything nice and clean
6394 * and thus will not attempt to create them in the profile directory. */
6395 _SHCreateSymbolicLinks();
6397 hr
= _SHRegisterUserShellFolders(TRUE
);
6399 hr
= _SHRegisterUserShellFolders(FALSE
);
6401 hr
= _SHRegisterCommonShellFolders();
6403 hr
= create_extra_folders();
6405 hr
= set_folder_attributes();
6407 register_system_knownfolders();