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 CacheW
[] = {'C','a','c','h','e','\0'};
838 static const WCHAR CD_BurningW
[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
839 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};
840 static const WCHAR CommonW
[] = {'C','o','m','m','o','n',0};
841 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'};
842 static const WCHAR Common_AppDataW
[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'};
843 static const WCHAR Common_DesktopW
[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'};
844 static const WCHAR Common_DocumentsW
[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'};
845 static const WCHAR CommonDownloadsW
[] = {'C','o','m','m','o','n','D','o','w','n','l','o','a','d','s',0};
846 static const WCHAR Common_FavoritesW
[] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'};
847 static const WCHAR CommonFilesDirW
[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'};
848 static const WCHAR CommonFilesDirX86W
[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
849 static const WCHAR CommonMusicW
[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'};
850 static const WCHAR CommonPicturesW
[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'};
851 static const WCHAR Common_ProgramsW
[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'};
852 static const WCHAR CommonRingtonesW
[] = {'C','o','m','m','o','n','R','i','n','g','t','o','n','e','s',0};
853 static const WCHAR Common_StartUpW
[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\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_Start_MenuW
[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'};
856 static const WCHAR Common_TemplatesW
[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'};
857 static const WCHAR CommonVideoW
[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
858 static const WCHAR ConflictFolderW
[] = {'C','o','n','f','l','i','c','t','F','o','l','d','e','r',0};
859 static const WCHAR ConnectionsFolderW
[] = {'C','o','n','n','e','c','t','i','o','n','s','F','o','l','d','e','r',0};
860 static const WCHAR ContactsW
[] = {'C','o','n','t','a','c','t','s','\0'};
861 static const WCHAR ControlPanelFolderW
[] = {'C','o','n','t','r','o','l','P','a','n','e','l','F','o','l','d','e','r',0};
862 static const WCHAR CookiesW
[] = {'C','o','o','k','i','e','s','\0'};
863 static const WCHAR CSCFolderW
[] = {'C','S','C','F','o','l','d','e','r',0};
864 static const WCHAR Default_GadgetsW
[] = {'D','e','f','a','u','l','t',' ','G','a','d','g','e','t','s',0};
865 static const WCHAR DesktopW
[] = {'D','e','s','k','t','o','p','\0'};
866 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};
867 static const WCHAR DocumentsW
[] = {'D','o','c','u','m','e','n','t','s','\0'};
868 static const WCHAR DocumentsLibraryW
[] = {'D','o','c','u','m','e','n','t','s','L','i','b','r','a','r','y','\0'};
869 static const WCHAR Documents_librarymsW
[] = {'D','o','c','u','m','e','n','t','s','.','l','i','b','r','a','r','y','-','m','s',0};
870 static const WCHAR DownloadsW
[] = {'D','o','w','n','l','o','a','d','s','\0'};
871 static const WCHAR FavoritesW
[] = {'F','a','v','o','r','i','t','e','s','\0'};
872 static const WCHAR FontsW
[] = {'F','o','n','t','s','\0'};
873 static const WCHAR GadgetsW
[] = {'G','a','d','g','e','t','s',0};
874 static const WCHAR GamesW
[] = {'G','a','m','e','s',0};
875 static const WCHAR GameTasksW
[] = {'G','a','m','e','T','a','s','k','s',0};
876 static const WCHAR HistoryW
[] = {'H','i','s','t','o','r','y','\0'};
877 static const WCHAR HomeGroupFolderW
[] = {'H','o','m','e','G','r','o','u','p','F','o','l','d','e','r',0};
878 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};
879 static const WCHAR InternetFolderW
[] = {'I','n','t','e','r','n','e','t','F','o','l','d','e','r',0};
880 static const WCHAR LibrariesW
[] = {'L','i','b','r','a','r','i','e','s',0};
881 static const WCHAR LinksW
[] = {'L','i','n','k','s','\0'};
882 static const WCHAR Local_AppDataW
[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
883 static const WCHAR LocalAppDataLowW
[] = {'L','o','c','a','l','A','p','p','D','a','t','a','L','o','w',0};
884 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};
885 static const WCHAR MAPIFolderW
[] = {'M','A','P','I','F','o','l','d','e','r',0};
886 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};
887 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};
888 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'};
889 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};
890 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};
891 static const WCHAR Microsoft_Windows_INetCacheW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','I','N','e','t','C','a','c','h','e',0};
892 static const WCHAR Microsoft_Windows_INetCookiesW
[] = {'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\','I','N','e','t','C','o','o','k','i','e','s',0};
893 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'};
894 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};
895 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};
896 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};
897 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'};
898 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'};
899 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};
900 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};
901 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};
902 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};
903 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};
904 static const WCHAR MoviesW
[] = {'M','o','v','i','e','s','\0'};
905 static const WCHAR MusicW
[] = {'M','u','s','i','c','\0'};
906 static const WCHAR MusicLibraryW
[] = {'M','u','s','i','c','L','i','b','r','a','r','y',0};
907 static const WCHAR Music_librarymsW
[] = {'M','u','s','i','c','.','l','i','b','r','a','r','y','-','m','s',0};
908 static const WCHAR My_MusicW
[] = {'M','y',' ','M','u','s','i','c','\0'};
909 static const WCHAR My_PicturesW
[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
910 static const WCHAR My_VideosW
[] = {'M','y',' ','V','i','d','e','o','s','\0'};
911 static const WCHAR My_VideoW
[] = {'M','y',' ','V','i','d','e','o','\0'};
912 static const WCHAR MyComputerFolderW
[] = {'M','y','C','o','m','p','u','t','e','r','F','o','l','d','e','r',0};
913 static const WCHAR NetHoodW
[] = {'N','e','t','H','o','o','d','\0'};
914 static const WCHAR NetworkPlacesFolderW
[] = {'N','e','t','w','o','r','k','P','l','a','c','e','s','F','o','l','d','e','r',0};
915 static const WCHAR OEM_LinksW
[] = {'O','E','M',' ','L','i','n','k','s','\0'};
916 static const WCHAR Original_ImagesW
[] = {'O','r','i','g','i','n','a','l',' ','I','m','a','g','e','s',0};
917 static const WCHAR PersonalW
[] = {'P','e','r','s','o','n','a','l','\0'};
918 static const WCHAR PhotoAlbumsW
[] = {'P','h','o','t','o','A','l','b','u','m','s',0};
919 static const WCHAR PicturesW
[] = {'P','i','c','t','u','r','e','s','\0'};
920 static const WCHAR PicturesLibraryW
[] = {'P','i','c','t','u','r','e','s','L','i','b','r','a','r','y',0};
921 static const WCHAR Pictures_librarymsW
[] = {'P','i','c','t','u','r','e','s','.','l','i','b','r','a','r','y','-','m','s',0};
922 static const WCHAR PlaylistsW
[] = {'P','l','a','y','l','i','s','t','s',0};
923 static const WCHAR PrintersFolderW
[] = {'P','r','i','n','t','e','r','s','F','o','l','d','e','r',0};
924 static const WCHAR PrintHoodW
[] = {'P','r','i','n','t','H','o','o','d','\0'};
925 static const WCHAR ProfileW
[] = {'P','r','o','f','i','l','e',0};
926 static const WCHAR ProgramDataW
[] = {'P','r','o','g','r','a','m','D','a','t','a','\0'};
927 static const WCHAR Program_FilesW
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
928 static const WCHAR ProgramFilesW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','\0'};
929 static const WCHAR ProgramFilesX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','8','6','\0'};
930 static const WCHAR ProgramFilesX64W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','X','6','4','\0'};
931 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'};
932 static const WCHAR Program_Files_x86W
[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
933 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'};
934 static const WCHAR ProgramFilesCommonW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','C','o','m','m','o','n',0};
935 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};
936 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};
937 static const WCHAR ProgramFilesDirW
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
938 static const WCHAR ProgramFilesDirX86W
[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
939 static const WCHAR ProgramsW
[] = {'P','r','o','g','r','a','m','s','\0'};
940 static const WCHAR PublicW
[] = {'P','u','b','l','i','c',0};
941 static const WCHAR PublicGameTasksW
[] = {'P','u','b','l','i','c','G','a','m','e','T','a','s','k','s',0};
942 static const WCHAR PublicLibrariesW
[] = {'P','u','b','l','i','c','L','i','b','r','a','r','i','e','s',0};
943 static const WCHAR Quick_LaunchW
[] = {'Q','u','i','c','k',' ','L','a','u','n','c','h',0};
944 static const WCHAR RecentW
[] = {'R','e','c','e','n','t','\0'};
945 static const WCHAR RecordedTVLibraryW
[] = {'R','e','c','o','r','d','e','d','T','V','L','i','b','r','a','r','y',0};
946 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};
947 static const WCHAR RecycleBinFolderW
[] = {'R','e','c','y','c','l','e','B','i','n','F','o','l','d','e','r',0};
948 static const WCHAR ResourceDirW
[] = {'R','e','s','o','u','r','c','e','D','i','r','\0'};
949 static const WCHAR ResourcesW
[] = {'R','e','s','o','u','r','c','e','s','\0'};
950 static const WCHAR RingtonesW
[] = {'R','i','n','g','t','o','n','e','s',0};
951 static const WCHAR SampleMusicW
[] = {'S','a','m','p','l','e','M','u','s','i','c',0};
952 static const WCHAR Sample_MusicW
[] = {'S','a','m','p','l','e',' ','M','u','s','i','c',0};
953 static const WCHAR SamplePicturesW
[] = {'S','a','m','p','l','e','P','i','c','t','u','r','e','s',0};
954 static const WCHAR Sample_PicturesW
[] = {'S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s',0};
955 static const WCHAR SamplePlaylistsW
[] = {'S','a','m','p','l','e','P','l','a','y','l','i','s','t','s',0};
956 static const WCHAR Sample_PlaylistsW
[] = {'S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s',0};
957 static const WCHAR Sample_VideosW
[] = {'S','a','m','p','l','e',' ','V','i','d','e','o','s',0};
958 static const WCHAR SampleVideosW
[] = {'S','a','m','p','l','e','V','i','d','e','o','s',0};
959 static const WCHAR Saved_GamesW
[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
960 static const WCHAR SavedGamesW
[] = {'S','a','v','e','d','G','a','m','e','s','\0'};
961 static const WCHAR SearchesW
[] = {'S','e','a','r','c','h','e','s','\0'};
962 static const WCHAR SearchHomeFolderW
[] = {'S','e','a','r','c','h','H','o','m','e','F','o','l','d','e','r',0};
963 static const WCHAR SendToW
[] = {'S','e','n','d','T','o','\0'};
964 static const WCHAR Slide_ShowsW
[] = {'S','l','i','d','e',' ','S','h','o','w','s',0};
965 static const WCHAR StartUpW
[] = {'S','t','a','r','t','U','p','\0'};
966 static const WCHAR StartupW
[] = {'S','t','a','r','t','u','p','\0'};
967 static const WCHAR Start_MenuW
[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
968 static const WCHAR SyncCenterFolderW
[] = {'S','y','n','c','C','e','n','t','e','r','F','o','l','d','e','r',0};
969 static const WCHAR SyncResultsFolderW
[] = {'S','y','n','c','R','e','s','u','l','t','s','F','o','l','d','e','r',0};
970 static const WCHAR SyncSetupFolderW
[] = {'S','y','n','c','S','e','t','u','p','F','o','l','d','e','r',0};
971 static const WCHAR SystemW
[] = {'S','y','s','t','e','m',0};
972 static const WCHAR SystemX86W
[] = {'S','y','s','t','e','m','X','8','6',0};
973 static const WCHAR TemplatesW
[] = {'T','e','m','p','l','a','t','e','s','\0'};
974 static const WCHAR User_PinnedW
[] = {'U','s','e','r',' ','P','i','n','n','e','d',0};
975 static const WCHAR UsersW
[] = {'U','s','e','r','s','\0'};
976 static const WCHAR UsersFilesFolderW
[] = {'U','s','e','r','s','F','i','l','e','s','F','o','l','d','e','r',0};
977 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};
978 static const WCHAR UserProfilesW
[] = {'U','s','e','r','P','r','o','f','i','l','e','s',0};
979 static const WCHAR UserProgramFilesW
[] = {'U','s','e','r','P','r','o','g','r','a','m','F','i','l','e','s',0};
980 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};
981 static const WCHAR UsersPublicW
[] = {'u','s','e','r','s','\\','P','u','b','l','i','c','\0'};
982 static const WCHAR VideosW
[] = {'V','i','d','e','o','s','\0'};
983 static const WCHAR VideosLibraryW
[] = {'V','i','d','e','o','s','L','i','b','r','a','r','y',0};
984 static const WCHAR Videos_librarymsW
[] = {'V','i','d','e','o','s','.','l','i','b','r','a','r','y','-','m','s',0};
985 static const WCHAR WindowsW
[] = {'W','i','n','d','o','w','s',0};
986 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};
987 static const WCHAR DefaultW
[] = {'.','D','e','f','a','u','l','t','\0'};
988 static const WCHAR AllUsersProfileW
[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
989 static const WCHAR PublicProfileW
[] = {'%','P','U','B','L','I','C','%',0};
990 static const WCHAR UserProfileW
[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
991 static const WCHAR ProgramDataVarW
[] = {'%','P','r','o','g','r','a','m','D','a','t','a','%','\0'};
992 static const WCHAR SystemDriveW
[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
993 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};
994 static const WCHAR ProfilesDirectoryW
[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
995 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'};
996 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'};
997 static const WCHAR szDefaultProfileDirW
[] = {'u','s','e','r','s',0};
998 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'};
999 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};
1001 #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','}'
1002 #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','}'
1003 #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','}'
1004 #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','}'
1005 #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','}'
1007 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};
1008 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};
1009 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};
1010 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};
1011 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};
1012 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};
1013 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};
1014 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};
1015 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};
1016 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};
1017 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};
1018 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};
1019 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};
1020 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};
1021 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};
1022 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};
1023 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};
1024 static const WCHAR ChangeRemoveProgramsParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', CHANGEREMOVEPROGRAMS_PARSING_GUID
, 0};
1025 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};
1026 static const WCHAR SyncManagerFolderParsingNameW
[] = {':',':', SYSTEMFOLDERS_PARSING_GUID
, '\\',':',':', SYNCMANAGER_PARSING_GUID
, 0};
1027 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};
1028 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};
1029 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};
1030 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};
1031 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};
1032 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};
1033 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};
1034 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};
1035 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};
1036 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};
1037 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};
1038 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};
1039 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};
1040 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};
1041 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};
1043 typedef enum _CSIDL_Type
{
1045 CSIDL_Type_AllUsers
,
1047 CSIDL_Type_Disallowed
,
1048 CSIDL_Type_NonExistent
,
1049 CSIDL_Type_WindowsPath
,
1050 CSIDL_Type_SystemPath
,
1051 CSIDL_Type_SystemX86Path
,
1052 CSIDL_Type_ProgramData
,
1055 #define CSIDL_CONTACTS 0x0043
1056 #define CSIDL_DOWNLOADS 0x0047
1057 #define CSIDL_LINKS 0x004d
1058 #define CSIDL_APPDATA_LOCALLOW 0x004e
1059 #define CSIDL_SAVED_GAMES 0x0062
1060 #define CSIDL_SEARCHES 0x0063
1064 IApplicationDestinations IApplicationDestinations_iface
;
1066 } IApplicationDestinationsImpl
;
1068 static inline IApplicationDestinationsImpl
*impl_from_IApplicationDestinations( IApplicationDestinations
*iface
)
1070 return CONTAINING_RECORD(iface
, IApplicationDestinationsImpl
, IApplicationDestinations_iface
);
1073 static HRESULT WINAPI
ApplicationDestinations_QueryInterface(IApplicationDestinations
*iface
, REFIID riid
,
1076 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1078 TRACE("(%p, %s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1083 if (IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IApplicationDestinations
, riid
))
1085 *ppv
= &This
->IApplicationDestinations_iface
;
1086 IUnknown_AddRef((IUnknown
*)*ppv
);
1088 TRACE("Returning IApplicationDestinations: %p\n", *ppv
);
1093 FIXME("(%p)->(%s, %p) interface not supported.\n", This
, debugstr_guid(riid
), ppv
);
1095 return E_NOINTERFACE
;
1098 static ULONG WINAPI
ApplicationDestinations_AddRef(IApplicationDestinations
*iface
)
1100 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1101 ULONG ref
= InterlockedIncrement(&This
->ref
);
1103 TRACE("(%p), new refcount=%i\n", This
, ref
);
1108 static ULONG WINAPI
ApplicationDestinations_Release(IApplicationDestinations
*iface
)
1110 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1111 ULONG ref
= InterlockedDecrement(&This
->ref
);
1113 TRACE("(%p), new refcount=%i\n", This
, ref
);
1121 static HRESULT WINAPI
ApplicationDestinations_SetAppID(IApplicationDestinations
*iface
, const WCHAR
*appid
)
1123 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1125 FIXME("(%p, %s) stub!\n", This
, debugstr_w(appid
));
1130 static HRESULT WINAPI
ApplicationDestinations_RemoveDestination(IApplicationDestinations
*iface
, IUnknown
*punk
)
1132 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1134 FIXME("(%p, %p) stub!\n", This
, punk
);
1139 static HRESULT WINAPI
ApplicationDestinations_RemoveAllDestinations(IApplicationDestinations
*iface
)
1141 IApplicationDestinationsImpl
*This
= impl_from_IApplicationDestinations(iface
);
1143 FIXME("(%p) stub!\n", This
);
1148 static const IApplicationDestinationsVtbl ApplicationDestinationsVtbl
=
1150 ApplicationDestinations_QueryInterface
,
1151 ApplicationDestinations_AddRef
,
1152 ApplicationDestinations_Release
,
1153 ApplicationDestinations_SetAppID
,
1154 ApplicationDestinations_RemoveDestination
,
1155 ApplicationDestinations_RemoveAllDestinations
1158 HRESULT WINAPI
ApplicationDestinations_Constructor(IUnknown
*outer
, REFIID riid
, LPVOID
*ppv
)
1160 IApplicationDestinationsImpl
*This
;
1163 TRACE("(%p, %s, %p)\n", outer
, debugstr_guid(riid
), ppv
);
1166 return CLASS_E_NOAGGREGATION
;
1168 if (!(This
= SHAlloc(sizeof(*This
))))
1169 return E_OUTOFMEMORY
;
1171 This
->IApplicationDestinations_iface
.lpVtbl
= &ApplicationDestinationsVtbl
;
1174 hr
= IUnknown_QueryInterface(&This
->IApplicationDestinations_iface
, riid
, ppv
);
1183 const KNOWNFOLDERID
*id
;
1185 LPCWSTR szValueName
;
1186 LPCWSTR szDefaultPath
; /* fallback string or resource ID */
1188 /* KNOWNFOLDER_DEFINITION fields */
1189 KF_CATEGORY category
;
1190 const WCHAR
*pszName
;
1191 const WCHAR
*pszDescription
;
1192 const KNOWNFOLDERID
*fidParent
;
1193 const WCHAR
*pszRelativePath
;
1194 const WCHAR
*pszParsingName
;
1195 const WCHAR
*pszTooltip
;
1196 const WCHAR
*pszLocalizedName
;
1197 const WCHAR
*pszIcon
;
1198 const WCHAR
*pszSecurity
;
1200 KF_DEFINITION_FLAGS kfdFlags
;
1201 const FOLDERTYPEID
*ftidType
;
1204 static const CSIDL_DATA CSIDL_Data
[] =
1206 { /* 0x00 - CSIDL_DESKTOP */
1212 KF_CATEGORY_PERUSER
, /* category */
1213 DesktopW
, /* name */
1214 NULL
, /* description */
1215 &GUID_NULL
, /* parent */
1216 DesktopW
, /* relative path */
1219 NULL
, /* localized */
1221 NULL
, /* security */
1222 FILE_ATTRIBUTE_READONLY
, /* attributes */
1224 &GUID_NULL
/* typeid */
1226 { /* 0x01 - CSIDL_INTERNET */
1227 &FOLDERID_InternetFolder
,
1228 CSIDL_Type_Disallowed
,
1232 KF_CATEGORY_VIRTUAL
, /* category */
1233 InternetFolderW
, /* name */
1234 NULL
, /* description */
1235 &GUID_NULL
, /* parent */
1236 NULL
, /* relative path */
1237 InternetFolderParsingNameW
, /* parsing */
1239 NULL
, /* localized */
1241 NULL
, /* security */
1244 &GUID_NULL
/* typeid */
1246 { /* 0x02 - CSIDL_PROGRAMS */
1252 KF_CATEGORY_PERUSER
, /* category */
1253 ProgramsW
, /* name */
1254 NULL
, /* description */
1255 &FOLDERID_StartMenu
, /* parent */
1256 ProgramsW
, /* relative path */
1259 NULL
, /* localized */
1261 NULL
, /* security */
1262 FILE_ATTRIBUTE_READONLY
, /* attributes */
1264 &GUID_NULL
/* typeid */
1266 { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1267 &FOLDERID_ControlPanelFolder
,
1268 CSIDL_Type_SystemPath
,
1272 KF_CATEGORY_VIRTUAL
, /* category */
1273 ControlPanelFolderW
, /* name */
1274 NULL
, /* description */
1275 &GUID_NULL
, /* parent */
1276 ControlPanelFolderRelativePathW
, /* relative path */
1277 ControlPanelFolderParsingNameW
, /* parsing */
1279 NULL
, /* localized */
1281 NULL
, /* security */
1284 &GUID_NULL
/* typeid */
1286 { /* 0x04 - CSIDL_PRINTERS */
1287 &FOLDERID_PrintersFolder
,
1288 CSIDL_Type_SystemPath
,
1292 KF_CATEGORY_VIRTUAL
, /* category */
1293 PrintersFolderW
, /* name */
1294 NULL
, /* description */
1295 &GUID_NULL
, /* parent */
1296 NULL
, /* relative path */
1297 PrintersFolderParsingNameW
, /* parsing */
1299 NULL
, /* localized */
1301 NULL
, /* security */
1304 &GUID_NULL
/* typeid */
1306 { /* 0x05 - CSIDL_PERSONAL */
1307 &FOLDERID_Documents
,
1312 KF_CATEGORY_PERUSER
, /* category */
1313 PersonalW
, /* name */
1314 NULL
, /* description */
1315 &FOLDERID_Profile
, /* parent */
1316 DocumentsW
, /* relative path */
1317 DocumentsParsingNameW
, /* parsing */
1319 NULL
, /* localized */
1321 NULL
, /* security */
1322 FILE_ATTRIBUTE_READONLY
, /* attributes */
1323 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1324 &GUID_NULL
/* typeid */
1326 { /* 0x06 - CSIDL_FAVORITES */
1327 &FOLDERID_Favorites
,
1332 KF_CATEGORY_PERUSER
, /* category */
1333 FavoritesW
, /* name */
1334 NULL
, /* description */
1335 &GUID_NULL
, /* parent */
1336 FavoritesW
, /* relative path */
1339 NULL
, /* localized */
1341 NULL
, /* security */
1342 FILE_ATTRIBUTE_READONLY
, /* attributes */
1343 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1344 &GUID_NULL
/* typeid */
1346 { /* 0x07 - CSIDL_STARTUP */
1352 KF_CATEGORY_PERUSER
, /* category */
1353 StartupW
, /* name */
1354 NULL
, /* description */
1355 &FOLDERID_Programs
, /* parent */
1356 StartUpW
, /* relative path */
1359 NULL
, /* localized */
1361 NULL
, /* security */
1362 FILE_ATTRIBUTE_READONLY
, /* attributes */
1363 KFDF_PRECREATE
, /* flags */
1364 &GUID_NULL
/* typeid */
1366 { /* 0x08 - CSIDL_RECENT */
1372 KF_CATEGORY_PERUSER
, /* category */
1374 NULL
, /* description */
1375 &FOLDERID_RoamingAppData
, /* parent */
1376 Microsoft_Windows_RecentW
, /* relative path */
1379 NULL
, /* localized */
1381 NULL
, /* security */
1382 FILE_ATTRIBUTE_READONLY
, /* attributes */
1383 KFDF_PRECREATE
, /* flags */
1384 &GUID_NULL
/* typeid */
1386 { /* 0x09 - CSIDL_SENDTO */
1392 KF_CATEGORY_PERUSER
, /* category */
1394 NULL
, /* description */
1395 &FOLDERID_RoamingAppData
, /* parent */
1396 Microsoft_Windows_SendToW
, /* relative path */
1399 NULL
, /* localized */
1401 NULL
, /* security */
1403 KFDF_PRECREATE
, /* flags */
1404 &GUID_NULL
/* typeid */
1406 { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1407 &FOLDERID_RecycleBinFolder
,
1408 CSIDL_Type_Disallowed
,
1412 KF_CATEGORY_VIRTUAL
, /* category */
1413 RecycleBinFolderW
, /* name */
1414 NULL
, /* description */
1415 &GUID_NULL
, /* parent */
1416 NULL
, /* relative path */
1417 RecycleBinFolderParsingNameW
, /* parsing */
1419 NULL
, /* localized */
1421 NULL
, /* security */
1424 &GUID_NULL
/* typeid */
1426 { /* 0x0b - CSIDL_STARTMENU */
1427 &FOLDERID_StartMenu
,
1432 KF_CATEGORY_PERUSER
, /* category */
1433 Start_MenuW
, /* name */
1434 NULL
, /* description */
1435 &FOLDERID_RoamingAppData
, /* parent */
1436 Microsoft_Windows_Start_MenuW
, /* relative path */
1439 NULL
, /* localized */
1441 NULL
, /* security */
1442 FILE_ATTRIBUTE_READONLY
, /* attributes */
1443 KFDF_PRECREATE
, /* flags */
1444 &GUID_NULL
/* typeid */
1446 { /* 0x0c - CSIDL_MYDOCUMENTS */
1448 CSIDL_Type_Disallowed
, /* matches WinXP--can't get its path */
1452 { /* 0x0d - CSIDL_MYMUSIC */
1458 KF_CATEGORY_PERUSER
, /* category */
1459 My_MusicW
, /* name */
1460 NULL
, /* description */
1461 &FOLDERID_Profile
, /* parent */
1462 MusicW
, /* relative path */
1463 MusicParsingNameW
, /* parsing */
1465 NULL
, /* localized */
1467 NULL
, /* security */
1468 FILE_ATTRIBUTE_READONLY
, /* attributes */
1469 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1470 &GUID_NULL
/* typeid */
1472 { /* 0x0e - CSIDL_MYVIDEO */
1478 KF_CATEGORY_PERUSER
, /* category */
1479 My_VideoW
, /* name */
1480 NULL
, /* description */
1481 &FOLDERID_Profile
, /* parent */
1482 VideosW
, /* relative path */
1483 VideosParsingNameW
, /* parsing */
1485 NULL
, /* localized */
1487 NULL
, /* security */
1488 FILE_ATTRIBUTE_READONLY
, /* attributes */
1489 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1490 &GUID_NULL
/* typeid */
1492 { /* 0x0f - unassigned */
1494 CSIDL_Type_Disallowed
,
1498 { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1504 KF_CATEGORY_PERUSER
, /* category */
1505 DesktopW
, /* name */
1506 NULL
, /* description */
1507 &FOLDERID_Profile
, /* parent */
1508 DesktopW
, /* relative path */
1511 NULL
, /* localized */
1513 NULL
, /* security */
1514 FILE_ATTRIBUTE_READONLY
, /* attributes */
1515 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1516 &GUID_NULL
/* typeid */
1518 { /* 0x11 - CSIDL_DRIVES */
1519 &FOLDERID_ComputerFolder
,
1520 CSIDL_Type_Disallowed
,
1524 KF_CATEGORY_VIRTUAL
, /* category */
1525 MyComputerFolderW
, /* name */
1526 NULL
, /* description */
1527 &GUID_NULL
, /* parent */
1528 NULL
, /* relative path */
1529 ComputerFolderParsingNameW
, /* parsing */
1531 NULL
, /* localized */
1533 NULL
, /* security */
1536 &GUID_NULL
/* typeid */
1538 { /* 0x12 - CSIDL_NETWORK */
1539 &FOLDERID_NetworkFolder
,
1540 CSIDL_Type_Disallowed
,
1544 KF_CATEGORY_VIRTUAL
, /* category */
1545 NetworkPlacesFolderW
, /* name */
1546 NULL
, /* description */
1547 &GUID_NULL
, /* parent */
1548 NULL
, /* relative path */
1549 NetworkFolderParsingNameW
, /* parsing */
1551 NULL
, /* localized */
1553 NULL
, /* security */
1556 &GUID_NULL
/* typeid */
1558 { /* 0x13 - CSIDL_NETHOOD */
1564 KF_CATEGORY_PERUSER
, /* category */
1565 NetHoodW
, /* name */
1566 NULL
, /* description */
1567 &FOLDERID_RoamingAppData
, /* parent */
1568 Microsoft_Windows_Network_ShortcutsW
, /* relative path */
1571 NULL
, /* localized */
1573 NULL
, /* security */
1576 &GUID_NULL
/* typeid */
1578 { /* 0x14 - CSIDL_FONTS */
1580 CSIDL_Type_WindowsPath
,
1584 KF_CATEGORY_FIXED
, /* category */
1586 NULL
, /* description */
1587 &FOLDERID_Windows
, /* parent */
1588 NULL
, /* relative path */
1591 NULL
, /* localized */
1593 NULL
, /* security */
1596 &FOLDERID_Windows
/* typeid */
1598 { /* 0x15 - CSIDL_TEMPLATES */
1599 &FOLDERID_Templates
,
1604 KF_CATEGORY_PERUSER
, /* category */
1605 TemplatesW
, /* name */
1606 NULL
, /* description */
1607 &FOLDERID_RoamingAppData
, /* parent */
1608 Microsoft_Windows_TemplatesW
, /* relative path */
1611 NULL
, /* localized */
1613 NULL
, /* security */
1616 &GUID_NULL
/* typeid */
1618 { /* 0x16 - CSIDL_COMMON_STARTMENU */
1619 &FOLDERID_CommonStartMenu
,
1620 CSIDL_Type_ProgramData
,
1624 KF_CATEGORY_COMMON
, /* category */
1625 Common_Start_MenuW
, /* name */
1626 NULL
, /* description */
1627 &FOLDERID_ProgramData
, /* parent */
1628 Microsoft_Windows_Start_MenuW
, /* relative path */
1631 NULL
, /* localized */
1633 NULL
, /* security */
1634 FILE_ATTRIBUTE_READONLY
, /* attributes */
1636 &GUID_NULL
/* typeid */
1638 { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1639 &FOLDERID_CommonPrograms
,
1640 CSIDL_Type_ProgramData
,
1644 KF_CATEGORY_COMMON
, /* category */
1645 Common_ProgramsW
, /* name */
1646 NULL
, /* description */
1647 &FOLDERID_CommonStartMenu
, /* parent */
1648 ProgramsW
, /* relative path */
1651 NULL
, /* localized */
1653 NULL
, /* security */
1654 FILE_ATTRIBUTE_READONLY
, /* attributes */
1656 &GUID_NULL
/* typeid */
1658 { /* 0x18 - CSIDL_COMMON_STARTUP */
1659 &FOLDERID_CommonStartup
,
1660 CSIDL_Type_ProgramData
,
1664 KF_CATEGORY_COMMON
, /* category */
1665 Common_StartupW
, /* name */
1666 NULL
, /* description */
1667 &FOLDERID_CommonPrograms
, /* parent */
1668 StartUpW
, /* relative path */
1671 NULL
, /* localized */
1673 NULL
, /* security */
1674 FILE_ATTRIBUTE_READONLY
, /* attributes */
1675 KFDF_PRECREATE
, /* flags */
1676 &GUID_NULL
/* typeid */
1678 { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1679 &FOLDERID_PublicDesktop
,
1680 CSIDL_Type_AllUsers
,
1684 KF_CATEGORY_COMMON
, /* category */
1685 Common_DesktopW
, /* name */
1686 NULL
, /* description */
1687 &FOLDERID_Public
, /* parent */
1688 DesktopW
, /* relative path */
1691 NULL
, /* localized */
1693 NULL
, /* security */
1694 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
1695 KFDF_PRECREATE
, /* flags */
1696 &GUID_NULL
/* typeid */
1698 { /* 0x1a - CSIDL_APPDATA */
1699 &FOLDERID_RoamingAppData
,
1704 KF_CATEGORY_PERUSER
, /* category */
1705 AppDataW
, /* name */
1706 NULL
, /* description */
1707 &FOLDERID_Profile
, /* parent */
1708 AppData_RoamingW
, /* relative path */
1711 NULL
, /* localized */
1713 NULL
, /* security */
1716 &GUID_NULL
/* typeid */
1718 { /* 0x1b - CSIDL_PRINTHOOD */
1719 &FOLDERID_PrintHood
,
1724 KF_CATEGORY_PERUSER
, /* category */
1725 PrintHoodW
, /* name */
1726 NULL
, /* description */
1727 &FOLDERID_RoamingAppData
, /* parent */
1728 Microsoft_Windows_Printer_ShortcutsW
, /* relative path */
1731 NULL
, /* localized */
1733 NULL
, /* security */
1736 &GUID_NULL
/* typeid */
1738 { /* 0x1c - CSIDL_LOCAL_APPDATA */
1739 &FOLDERID_LocalAppData
,
1744 KF_CATEGORY_PERUSER
, /* category */
1745 Local_AppDataW
, /* name */
1746 NULL
, /* description */
1747 &FOLDERID_Profile
, /* parent */
1748 AppData_LocalW
, /* relative path */
1751 NULL
, /* localized */
1753 NULL
, /* security */
1755 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1756 &GUID_NULL
/* typeid */
1758 { /* 0x1d - CSIDL_ALTSTARTUP */
1760 CSIDL_Type_NonExistent
,
1764 { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1766 CSIDL_Type_NonExistent
,
1770 { /* 0x1f - CSIDL_COMMON_FAVORITES */
1771 &FOLDERID_Favorites
,
1772 CSIDL_Type_AllUsers
,
1776 KF_CATEGORY_PERUSER
, /* category */
1777 FavoritesW
, /* name */
1778 NULL
, /* description */
1779 &FOLDERID_Profile
, /* parent */
1780 FavoritesW
, /* relative path */
1783 NULL
, /* localized */
1785 NULL
, /* security */
1786 FILE_ATTRIBUTE_READONLY
, /* attributes */
1787 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
1788 &GUID_NULL
/* typeid */
1790 { /* 0x20 - CSIDL_INTERNET_CACHE */
1791 &FOLDERID_InternetCache
,
1796 KF_CATEGORY_PERUSER
, /* category */
1798 NULL
, /* description */
1799 &FOLDERID_LocalAppData
, /* parent */
1800 Microsoft_Windows_INetCacheW
, /* relative path */
1803 NULL
, /* localized */
1805 NULL
, /* security */
1807 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1808 &GUID_NULL
/* typeid */
1810 { /* 0x21 - CSIDL_COOKIES */
1816 KF_CATEGORY_PERUSER
, /* category */
1817 CookiesW
, /* name */
1818 NULL
, /* description */
1819 &FOLDERID_LocalAppData
, /* parent */
1820 Microsoft_Windows_INetCookiesW
, /* relative path */
1823 NULL
, /* localized */
1825 NULL
, /* security */
1828 &GUID_NULL
/* typeid */
1830 { /* 0x22 - CSIDL_HISTORY */
1836 KF_CATEGORY_PERUSER
, /* category */
1837 HistoryW
, /* name */
1838 NULL
, /* description */
1839 &FOLDERID_LocalAppData
, /* parent */
1840 Microsoft_Windows_HistoryW
, /* relative path */
1843 NULL
, /* localized */
1845 NULL
, /* security */
1847 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
1848 &GUID_NULL
/* typeid */
1850 { /* 0x23 - CSIDL_COMMON_APPDATA */
1851 &FOLDERID_ProgramData
,
1852 CSIDL_Type_ProgramData
,
1856 KF_CATEGORY_FIXED
, /* category */
1857 Common_AppDataW
, /* name */
1858 NULL
, /* description */
1859 &GUID_NULL
, /* parent */
1860 NULL
, /* relative path */
1863 NULL
, /* localized */
1865 NULL
, /* security */
1868 &GUID_NULL
/* typeid */
1870 { /* 0x24 - CSIDL_WINDOWS */
1872 CSIDL_Type_WindowsPath
,
1876 KF_CATEGORY_FIXED
, /* category */
1877 WindowsW
, /* name */
1878 NULL
, /* description */
1879 &GUID_NULL
, /* parent */
1880 NULL
, /* relative path */
1883 NULL
, /* localized */
1885 NULL
, /* security */
1888 &GUID_NULL
/* typeid */
1890 { /* 0x25 - CSIDL_SYSTEM */
1892 CSIDL_Type_SystemPath
,
1896 KF_CATEGORY_FIXED
, /* category */
1898 NULL
, /* description */
1899 &GUID_NULL
, /* parent */
1900 NULL
, /* relative path */
1903 NULL
, /* localized */
1905 NULL
, /* security */
1908 &GUID_NULL
/* typeid */
1910 { /* 0x26 - CSIDL_PROGRAM_FILES */
1911 &FOLDERID_ProgramFiles
,
1916 KF_CATEGORY_FIXED
, /* category */
1917 ProgramFilesW
, /* name */
1918 NULL
, /* description */
1919 &GUID_NULL
, /* parent */
1920 NULL
, /* relative path */
1923 NULL
, /* localized */
1925 NULL
, /* security */
1926 FILE_ATTRIBUTE_READONLY
, /* attributes */
1928 &GUID_NULL
/* typeid */
1930 { /* 0x27 - CSIDL_MYPICTURES */
1936 KF_CATEGORY_PERUSER
, /* category */
1937 My_PicturesW
, /* name */
1938 NULL
, /* description */
1939 &FOLDERID_Profile
, /* parent */
1940 PicturesW
, /* relative path */
1941 PicturesParsingNameW
, /* parsing */
1943 NULL
, /* localized */
1945 NULL
, /* security */
1946 FILE_ATTRIBUTE_READONLY
, /* attributes */
1947 KFDF_ROAMABLE
| KFDF_PRECREATE
, /* flags */
1948 &GUID_NULL
/* typeid */
1950 { /* 0x28 - CSIDL_PROFILE */
1956 KF_CATEGORY_FIXED
, /* category */
1957 ProfileW
, /* name */
1958 NULL
, /* description */
1959 &GUID_NULL
, /* parent */
1960 NULL
, /* relative path */
1963 NULL
, /* localized */
1965 NULL
, /* security */
1968 &GUID_NULL
/* typeid */
1970 { /* 0x29 - CSIDL_SYSTEMX86 */
1971 &FOLDERID_SystemX86
,
1972 CSIDL_Type_SystemX86Path
,
1976 KF_CATEGORY_FIXED
, /* category */
1977 SystemX86W
, /* name */
1978 NULL
, /* description */
1979 &GUID_NULL
, /* parent */
1980 NULL
, /* relative path */
1983 NULL
, /* localized */
1985 NULL
, /* security */
1988 &GUID_NULL
/* typeid */
1990 { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
1991 &FOLDERID_ProgramFilesX86
,
1993 ProgramFilesDirX86W
,
1996 KF_CATEGORY_FIXED
, /* category */
1997 ProgramFilesX86W
, /* name */
1998 NULL
, /* description */
1999 &GUID_NULL
, /* parent */
2000 NULL
, /* relative path */
2003 NULL
, /* localized */
2005 NULL
, /* security */
2006 FILE_ATTRIBUTE_READONLY
, /* attributes */
2008 &GUID_NULL
/* typeid */
2010 { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
2011 &FOLDERID_ProgramFilesCommon
,
2014 Program_Files_Common_FilesW
,
2016 KF_CATEGORY_FIXED
, /* category */
2017 ProgramFilesCommonW
, /* name */
2018 NULL
, /* description */
2019 &GUID_NULL
, /* parent */
2020 NULL
, /* relative path */
2023 NULL
, /* localized */
2025 NULL
, /* security */
2028 &GUID_NULL
/* typeid */
2030 { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
2031 &FOLDERID_ProgramFilesCommonX86
,
2034 Program_Files_x86_Common_FilesW
,
2036 KF_CATEGORY_FIXED
, /* category */
2037 ProgramFilesCommonX86W
, /* name */
2038 NULL
, /* description */
2039 &GUID_NULL
, /* parent */
2040 NULL
, /* relative path */
2043 NULL
, /* localized */
2045 NULL
, /* security */
2048 &GUID_NULL
/* typeid */
2050 { /* 0x2d - CSIDL_COMMON_TEMPLATES */
2051 &FOLDERID_CommonTemplates
,
2052 CSIDL_Type_ProgramData
,
2056 KF_CATEGORY_COMMON
, /* category */
2057 Common_TemplatesW
, /* name */
2058 NULL
, /* description */
2059 &FOLDERID_ProgramData
, /* parent */
2060 Microsoft_Windows_TemplatesW
, /* relative path */
2063 NULL
, /* localized */
2065 NULL
, /* security */
2068 &GUID_NULL
/* typeid */
2070 { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
2071 &FOLDERID_PublicDocuments
,
2072 CSIDL_Type_AllUsers
,
2076 KF_CATEGORY_COMMON
, /* category */
2077 Common_DocumentsW
, /* name */
2078 NULL
, /* description */
2079 &FOLDERID_Public
, /* parent */
2080 DocumentsW
, /* relative path */
2083 NULL
, /* localized */
2085 NULL
, /* security */
2086 FILE_ATTRIBUTE_READONLY
, /* attributes */
2087 KFDF_PRECREATE
, /* flags */
2088 &GUID_NULL
/* typeid */
2090 { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
2091 &FOLDERID_CommonAdminTools
,
2092 CSIDL_Type_ProgramData
,
2093 Common_Administrative_ToolsW
,
2096 KF_CATEGORY_COMMON
, /* category */
2097 Common_Administrative_ToolsW
, /* name */
2098 NULL
, /* description */
2099 &FOLDERID_CommonPrograms
, /* parent */
2100 Administrative_ToolsW
, /* relative path */
2103 NULL
, /* localized */
2105 NULL
, /* security */
2106 FILE_ATTRIBUTE_READONLY
, /* attributes */
2107 KFDF_PRECREATE
, /* flags */
2108 &GUID_NULL
/* typeid */
2110 { /* 0x30 - CSIDL_ADMINTOOLS */
2111 &FOLDERID_AdminTools
,
2113 Administrative_ToolsW
,
2116 KF_CATEGORY_PERUSER
, /* category */
2117 Administrative_ToolsW
, /* name */
2118 NULL
, /* description */
2119 &FOLDERID_Programs
, /* parent */
2120 Administrative_ToolsW
, /* relative path */
2123 NULL
, /* localized */
2125 NULL
, /* security */
2126 FILE_ATTRIBUTE_READONLY
, /* attributes */
2127 KFDF_PRECREATE
, /* flags */
2128 &GUID_NULL
/* typeid */
2130 { /* 0x31 - CSIDL_CONNECTIONS */
2131 &FOLDERID_ConnectionsFolder
,
2132 CSIDL_Type_Disallowed
,
2136 KF_CATEGORY_VIRTUAL
, /* category */
2137 ConnectionsFolderW
, /* name */
2138 NULL
, /* description */
2139 &GUID_NULL
, /* parent */
2140 Administrative_ToolsW
, /* relative path */
2141 ConnectionsFolderParsingNameW
, /* parsing */
2143 NULL
, /* localized */
2145 NULL
, /* security */
2148 &GUID_NULL
/* typeid */
2150 { /* 0x32 - unassigned */
2152 CSIDL_Type_Disallowed
,
2156 { /* 0x33 - unassigned */
2158 CSIDL_Type_Disallowed
,
2162 { /* 0x34 - unassigned */
2164 CSIDL_Type_Disallowed
,
2168 { /* 0x35 - CSIDL_COMMON_MUSIC */
2169 &FOLDERID_PublicMusic
,
2170 CSIDL_Type_AllUsers
,
2174 KF_CATEGORY_COMMON
, /* category */
2175 CommonMusicW
, /* name */
2176 NULL
, /* description */
2177 &FOLDERID_Public
, /* parent */
2178 MusicW
, /* relative path */
2181 NULL
, /* localized */
2183 NULL
, /* security */
2184 FILE_ATTRIBUTE_READONLY
, /* attributes */
2185 KFDF_PRECREATE
, /* flags */
2186 &GUID_NULL
/* typeid */
2188 { /* 0x36 - CSIDL_COMMON_PICTURES */
2189 &FOLDERID_PublicPictures
,
2190 CSIDL_Type_AllUsers
,
2194 KF_CATEGORY_COMMON
, /* category */
2195 CommonPicturesW
, /* name */
2196 NULL
, /* description */
2197 &FOLDERID_Public
, /* parent */
2198 PicturesW
, /* relative path */
2201 NULL
, /* localized */
2203 NULL
, /* security */
2204 FILE_ATTRIBUTE_READONLY
, /* attributes */
2205 KFDF_PRECREATE
, /* flags */
2206 &GUID_NULL
/* typeid */
2208 { /* 0x37 - CSIDL_COMMON_VIDEO */
2209 &FOLDERID_PublicVideos
,
2210 CSIDL_Type_AllUsers
,
2214 KF_CATEGORY_COMMON
, /* category */
2215 CommonVideoW
, /* name */
2216 NULL
, /* description */
2217 &FOLDERID_Public
, /* parent */
2218 VideosW
, /* relative path */
2221 NULL
, /* localized */
2223 NULL
, /* security */
2224 FILE_ATTRIBUTE_READONLY
, /* attributes */
2225 KFDF_PRECREATE
, /* flags */
2226 &GUID_NULL
/* typeid */
2228 { /* 0x38 - CSIDL_RESOURCES */
2229 &FOLDERID_ResourceDir
,
2230 CSIDL_Type_WindowsPath
,
2234 KF_CATEGORY_FIXED
, /* category */
2235 ResourceDirW
, /* name */
2236 NULL
, /* description */
2237 &GUID_NULL
, /* parent */
2238 NULL
, /* relative path */
2241 NULL
, /* localized */
2243 NULL
, /* security */
2246 &GUID_NULL
/* typeid */
2248 { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
2249 &FOLDERID_LocalizedResourcesDir
,
2250 CSIDL_Type_NonExistent
,
2254 KF_CATEGORY_FIXED
, /* category */
2255 LocalizedResourcesDirW
, /* name */
2256 NULL
, /* description */
2257 &GUID_NULL
, /* parent */
2258 NULL
, /* relative path */
2261 NULL
, /* localized */
2263 NULL
, /* security */
2266 &GUID_NULL
/* typeid */
2268 { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
2269 &FOLDERID_CommonOEMLinks
,
2270 CSIDL_Type_ProgramData
,
2274 KF_CATEGORY_COMMON
, /* category */
2275 OEM_LinksW
, /* name */
2276 NULL
, /* description */
2277 &FOLDERID_ProgramData
, /* parent */
2278 OEM_LinksW
, /* relative path */
2281 NULL
, /* localized */
2283 NULL
, /* security */
2286 &GUID_NULL
/* typeid */
2288 { /* 0x3b - CSIDL_CDBURN_AREA */
2289 &FOLDERID_CDBurning
,
2294 KF_CATEGORY_PERUSER
, /* category */
2295 CD_BurningW
, /* name */
2296 NULL
, /* description */
2297 &FOLDERID_LocalAppData
, /* parent */
2298 Microsoft_Windows_Burn_BurnW
, /* relative path */
2301 NULL
, /* localized */
2303 NULL
, /* security */
2304 FILE_ATTRIBUTE_READONLY
, /* attributes */
2305 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2306 &GUID_NULL
/* typeid */
2308 { /* 0x3c unassigned */
2310 CSIDL_Type_Disallowed
,
2314 { /* 0x3d - CSIDL_COMPUTERSNEARME */
2316 CSIDL_Type_Disallowed
, /* FIXME */
2320 { /* 0x3e - CSIDL_PROFILES */
2322 CSIDL_Type_Disallowed
, /* oddly, this matches WinXP */
2327 &FOLDERID_AddNewPrograms
,
2328 CSIDL_Type_Disallowed
,
2332 KF_CATEGORY_VIRTUAL
, /* category */
2333 AddNewProgramsFolderW
, /* name */
2334 NULL
, /* description */
2335 &GUID_NULL
, /* parent */
2336 NULL
, /* relative path */
2337 AddNewProgramsParsingNameW
, /* parsing */
2339 NULL
, /* localized */
2341 NULL
, /* security */
2344 &GUID_NULL
/* typeid */
2347 &FOLDERID_AppUpdates
,
2348 CSIDL_Type_Disallowed
,
2352 KF_CATEGORY_VIRTUAL
, /* category */
2353 AppUpdatesFolderW
, /* name */
2354 NULL
, /* description */
2355 &GUID_NULL
, /* parent */
2356 NULL
, /* relative path */
2357 AppUpdatesParsingNameW
, /* parsing */
2359 NULL
, /* localized */
2361 NULL
, /* security */
2364 &GUID_NULL
/* typeid */
2367 &FOLDERID_ChangeRemovePrograms
,
2368 CSIDL_Type_Disallowed
,
2372 KF_CATEGORY_VIRTUAL
, /* category */
2373 ChangeRemoveProgramsFolderW
, /* name */
2374 NULL
, /* description */
2375 &GUID_NULL
, /* parent */
2376 NULL
, /* relative path */
2377 ChangeRemoveProgramsParsingNameW
, /* parsing */
2379 NULL
, /* localized */
2381 NULL
, /* security */
2384 &GUID_NULL
/* typeid */
2387 &FOLDERID_ConflictFolder
,
2388 CSIDL_Type_Disallowed
,
2392 KF_CATEGORY_VIRTUAL
, /* category */
2393 ConflictFolderW
, /* name */
2394 NULL
, /* description */
2395 &GUID_NULL
, /* parent */
2396 NULL
, /* relative path */
2397 ConflictFolderParsingNameW
, /* parsing */
2399 NULL
, /* localized */
2401 NULL
, /* security */
2404 &GUID_NULL
/* typeid */
2406 { /* 0x43 - CSIDL_CONTACTS */
2412 KF_CATEGORY_PERUSER
, /* category */
2413 ContactsW
, /* name */
2414 NULL
, /* description */
2415 &FOLDERID_Profile
, /* parent */
2416 ContactsW
, /* relative path */
2417 ContactsParsingNameW
, /* parsing */
2419 NULL
, /* localized */
2421 NULL
, /* security */
2422 FILE_ATTRIBUTE_READONLY
, /* attributes */
2423 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2424 &GUID_NULL
/* typeid */
2427 &FOLDERID_DeviceMetadataStore
,
2428 CSIDL_Type_Disallowed
, /* FIXME */
2432 KF_CATEGORY_COMMON
, /* category */
2433 Device_Metadata_StoreW
, /* name */
2434 NULL
, /* description */
2435 &FOLDERID_ProgramData
, /* parent */
2436 Microsoft_Windows_DeviceMetadataStoreW
, /* relative path */
2439 NULL
, /* localized */
2441 NULL
, /* security */
2444 &GUID_NULL
/* typeid */
2448 CSIDL_Type_Disallowed
,
2453 &FOLDERID_DocumentsLibrary
,
2454 CSIDL_Type_Disallowed
, /* FIXME */
2458 KF_CATEGORY_PERUSER
, /* category */
2459 DocumentsLibraryW
, /* name */
2460 NULL
, /* description */
2461 &FOLDERID_Libraries
, /* parent */
2462 Documents_librarymsW
, /* relative path */
2463 DocumentsLibraryParsingNameW
, /* parsing */
2465 NULL
, /* localized */
2467 NULL
, /* security */
2469 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2470 &GUID_NULL
/* typeid */
2472 { /* 0x47 - CSIDL_DOWNLOADS */
2473 &FOLDERID_Downloads
,
2478 KF_CATEGORY_PERUSER
, /* category */
2479 DownloadsW
, /* name */
2480 NULL
, /* description */
2481 &FOLDERID_Profile
, /* parent */
2482 DownloadsW
, /* relative path */
2485 NULL
, /* localized */
2487 NULL
, /* security */
2488 FILE_ATTRIBUTE_READONLY
, /* attributes */
2489 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2490 &GUID_NULL
/* typeid */
2494 CSIDL_Type_Disallowed
,
2498 KF_CATEGORY_VIRTUAL
, /* category */
2500 NULL
, /* description */
2501 &GUID_NULL
, /* parent */
2502 NULL
, /* relative path */
2503 GamesParsingNameW
, /* parsing */
2505 NULL
, /* localized */
2507 NULL
, /* security */
2510 &GUID_NULL
/* typeid */
2513 &FOLDERID_GameTasks
,
2514 CSIDL_Type_Disallowed
, /* FIXME */
2518 KF_CATEGORY_PERUSER
, /* category */
2519 GameTasksW
, /* name */
2520 NULL
, /* description */
2521 &FOLDERID_LocalAppData
, /* parent */
2522 Microsoft_Windows_GameExplorerW
, /* relative path */
2525 NULL
, /* localized */
2527 NULL
, /* security */
2529 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2530 &GUID_NULL
/* typeid */
2533 &FOLDERID_HomeGroup
,
2534 CSIDL_Type_Disallowed
,
2538 KF_CATEGORY_VIRTUAL
, /* category */
2539 HomeGroupFolderW
, /* name */
2540 NULL
, /* description */
2541 &GUID_NULL
, /* parent */
2542 NULL
, /* relative path */
2543 HomeGroupParsingNameW
, /* parsing */
2545 NULL
, /* localized */
2547 NULL
, /* security */
2550 &GUID_NULL
/* typeid */
2553 &FOLDERID_ImplicitAppShortcuts
,
2554 CSIDL_Type_Disallowed
, /* FIXME */
2558 KF_CATEGORY_PERUSER
, /* category */
2559 ImplicitAppShortcutsW
, /* name */
2560 NULL
, /* description */
2561 &FOLDERID_UserPinned
, /* parent */
2562 ImplicitAppShortcutsW
, /* relative path */
2565 NULL
, /* localized */
2567 NULL
, /* security */
2569 KFDF_PRECREATE
, /* flags */
2570 &GUID_NULL
/* typeid */
2573 &FOLDERID_Libraries
,
2574 CSIDL_Type_Disallowed
, /* FIXME */
2578 KF_CATEGORY_PERUSER
, /* category */
2579 LibrariesW
, /* name */
2580 NULL
, /* description */
2581 &FOLDERID_RoamingAppData
, /* parent */
2582 Microsoft_Windows_LibrariesW
, /* relative path */
2585 NULL
, /* localized */
2587 NULL
, /* security */
2589 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2590 &GUID_NULL
/* typeid */
2592 { /* 0x4d - CSIDL_LINKS */
2598 KF_CATEGORY_PERUSER
, /* category */
2600 NULL
, /* description */
2601 &FOLDERID_Profile
, /* parent */
2602 LinksW
, /* relative path */
2603 LinksParsingNameW
, /* parsing */
2605 NULL
, /* localized */
2607 NULL
, /* security */
2608 FILE_ATTRIBUTE_READONLY
, /* attributes */
2609 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2610 &GUID_NULL
/* typeid */
2612 { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
2613 &FOLDERID_LocalAppDataLow
,
2618 KF_CATEGORY_PERUSER
, /* category */
2619 LocalAppDataLowW
, /* name */
2620 NULL
, /* description */
2621 &FOLDERID_Profile
, /* parent */
2622 AppData_LocalLowW
, /* relative path */
2625 NULL
, /* localized */
2627 NULL
, /* security */
2628 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
, /* attributes */
2629 KFDF_LOCAL_REDIRECT_ONLY
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
2630 &GUID_NULL
/* typeid */
2633 &FOLDERID_MusicLibrary
,
2634 CSIDL_Type_Disallowed
, /* FIXME */
2638 KF_CATEGORY_PERUSER
, /* category */
2639 MusicLibraryW
, /* name */
2640 NULL
, /* description */
2641 &FOLDERID_Libraries
, /* parent */
2642 Music_librarymsW
, /* relative path */
2643 MusicLibraryParsingNameW
, /* parsing */
2645 NULL
, /* localized */
2647 NULL
, /* security */
2649 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2650 &GUID_NULL
/* typeid */
2653 &FOLDERID_OriginalImages
,
2654 CSIDL_Type_Disallowed
, /* FIXME */
2658 KF_CATEGORY_PERUSER
, /* category */
2659 Original_ImagesW
, /* name */
2660 NULL
, /* description */
2661 &FOLDERID_LocalAppData
, /* parent */
2662 Microsoft_Windows_Photo_Gallery_Original_ImagesW
, /* relative path */
2665 NULL
, /* localized */
2667 NULL
, /* security */
2670 &GUID_NULL
/* typeid */
2673 &FOLDERID_PhotoAlbums
,
2678 KF_CATEGORY_PERUSER
, /* category */
2679 PhotoAlbumsW
, /* name */
2680 NULL
, /* description */
2681 &FOLDERID_Pictures
, /* parent */
2682 Slide_ShowsW
, /* relative path */
2685 NULL
, /* localized */
2687 NULL
, /* security */
2688 FILE_ATTRIBUTE_READONLY
, /* attributes */
2690 &GUID_NULL
/* typeid */
2693 &FOLDERID_PicturesLibrary
,
2694 CSIDL_Type_Disallowed
, /* FIXME */
2698 KF_CATEGORY_PERUSER
, /* category */
2699 PicturesLibraryW
, /* name */
2700 NULL
, /* description */
2701 &FOLDERID_Libraries
, /* parent */
2702 Pictures_librarymsW
, /* relative path */
2703 PicturesLibraryParsingNameW
, /* parsing */
2705 NULL
, /* localized */
2707 NULL
, /* security */
2709 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2710 &GUID_NULL
/* typeid */
2713 &FOLDERID_Playlists
,
2718 KF_CATEGORY_PERUSER
, /* category */
2719 PlaylistsW
, /* name */
2720 NULL
, /* description */
2721 &FOLDERID_Music
, /* parent */
2722 PlaylistsW
, /* relative path */
2725 NULL
, /* localized */
2727 NULL
, /* security */
2728 FILE_ATTRIBUTE_READONLY
, /* attributes */
2730 &GUID_NULL
/* typeid */
2733 &FOLDERID_ProgramFilesX64
,
2739 CSIDL_Type_NonExistent
,
2744 KF_CATEGORY_FIXED
, /* category */
2745 ProgramFilesX64W
, /* name */
2746 NULL
, /* description */
2747 &GUID_NULL
, /* parent */
2748 NULL
, /* relative path */
2751 NULL
, /* localized */
2753 NULL
, /* security */
2756 &GUID_NULL
/* typeid */
2759 &FOLDERID_ProgramFilesCommonX64
,
2762 ProgramFilesCommonX64W
,
2763 Program_Files_Common_FilesW
,
2765 CSIDL_Type_NonExistent
,
2770 KF_CATEGORY_FIXED
, /* category */
2771 ProgramFilesCommonX64W
, /* name */
2772 NULL
, /* description */
2773 &GUID_NULL
, /* parent */
2774 NULL
, /* relative path */
2777 NULL
, /* localized */
2779 NULL
, /* security */
2782 &GUID_NULL
/* typeid */
2786 CSIDL_Type_AllUsers
,
2790 KF_CATEGORY_FIXED
, /* category */
2792 NULL
, /* description */
2793 &GUID_NULL
, /* parent */
2794 NULL
, /* relative path */
2795 PublicParsingNameW
, /* parsing */
2797 NULL
, /* localized */
2799 NULL
, /* security */
2800 FILE_ATTRIBUTE_READONLY
, /* attributes */
2801 KFDF_PRECREATE
, /* flags */
2802 &GUID_NULL
/* typeid */
2805 &FOLDERID_PublicDownloads
,
2806 CSIDL_Type_AllUsers
,
2810 KF_CATEGORY_COMMON
, /* category */
2811 CommonDownloadsW
, /* name */
2812 NULL
, /* description */
2813 &FOLDERID_Public
, /* parent */
2814 DownloadsW
, /* relative path */
2817 NULL
, /* localized */
2819 NULL
, /* security */
2820 FILE_ATTRIBUTE_READONLY
, /* attributes */
2821 KFDF_PRECREATE
, /* flags */
2822 &GUID_NULL
/* typeid */
2825 &FOLDERID_PublicGameTasks
,
2826 CSIDL_Type_ProgramData
,
2830 KF_CATEGORY_COMMON
, /* category */
2831 PublicGameTasksW
, /* name */
2832 NULL
, /* description */
2833 &FOLDERID_ProgramData
, /* parent */
2834 Microsoft_Windows_GameExplorerW
, /* relative path */
2837 NULL
, /* localized */
2839 NULL
, /* security */
2841 KFDF_LOCAL_REDIRECT_ONLY
, /* flags */
2842 &GUID_NULL
/* typeid */
2845 &FOLDERID_PublicLibraries
,
2846 CSIDL_Type_AllUsers
,
2850 KF_CATEGORY_COMMON
, /* category */
2851 PublicLibrariesW
, /* name */
2852 NULL
, /* description */
2853 &FOLDERID_Public
, /* parent */
2854 LibrariesW
, /* relative path */
2857 NULL
, /* localized */
2859 NULL
, /* security */
2860 FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
, /* attributes */
2861 KFDF_PRECREATE
, /* flags */
2862 &GUID_NULL
/* typeid */
2865 &FOLDERID_PublicRingtones
,
2866 CSIDL_Type_ProgramData
,
2870 KF_CATEGORY_COMMON
, /* category */
2871 CommonRingtonesW
, /* name */
2872 NULL
, /* description */
2873 &FOLDERID_ProgramData
, /* parent */
2874 Microsoft_Windows_RingtonesW
, /* relative path */
2877 NULL
, /* localized */
2879 NULL
, /* security */
2881 KFDF_PRECREATE
, /* flags */
2882 &GUID_NULL
/* typeid */
2885 &FOLDERID_QuickLaunch
,
2886 CSIDL_Type_Disallowed
, /* FIXME */
2890 KF_CATEGORY_PERUSER
, /* category */
2891 Quick_LaunchW
, /* name */
2892 NULL
, /* description */
2893 &FOLDERID_RoamingAppData
, /* parent */
2894 Microsoft_Internet_Explorer_Quick_LaunchW
, /* relative path */
2897 NULL
, /* localized */
2899 NULL
, /* security */
2902 &GUID_NULL
/* typeid */
2905 &FOLDERID_RecordedTVLibrary
,
2906 CSIDL_Type_Disallowed
, /* FIXME */
2910 KF_CATEGORY_COMMON
, /* category */
2911 RecordedTVLibraryW
, /* name */
2912 NULL
, /* description */
2913 &FOLDERID_PublicLibraries
, /* parent */
2914 RecordedTV_librarymsW
, /* relative path */
2917 NULL
, /* localized */
2919 NULL
, /* security */
2921 KFDF_PRECREATE
| KFDF_STREAM
, /* flags */
2922 &GUID_NULL
/* typeid */
2925 &FOLDERID_Ringtones
,
2926 CSIDL_Type_Disallowed
, /* FIXME */
2930 KF_CATEGORY_PERUSER
, /* category */
2931 RingtonesW
, /* name */
2932 NULL
, /* description */
2933 &FOLDERID_LocalAppData
, /* parent */
2934 Microsoft_Windows_RingtonesW
, /* relative path */
2937 NULL
, /* localized */
2939 NULL
, /* security */
2941 KFDF_PRECREATE
, /* flags */
2942 &GUID_NULL
/* typeid */
2945 &FOLDERID_SampleMusic
,
2946 CSIDL_Type_AllUsers
,
2950 KF_CATEGORY_COMMON
, /* category */
2951 SampleMusicW
, /* name */
2952 NULL
, /* description */
2953 &FOLDERID_PublicMusic
, /* parent */
2954 Sample_MusicW
, /* relative path */
2957 NULL
, /* localized */
2959 NULL
, /* security */
2960 FILE_ATTRIBUTE_READONLY
, /* attributes */
2961 KFDF_PRECREATE
, /* flags */
2962 &GUID_NULL
/* typeid */
2965 &FOLDERID_SamplePictures
,
2966 CSIDL_Type_AllUsers
,
2970 KF_CATEGORY_COMMON
, /* category */
2971 SamplePicturesW
, /* name */
2972 NULL
, /* description */
2973 &FOLDERID_PublicPictures
, /* parent */
2974 Sample_PicturesW
, /* relative path */
2977 NULL
, /* localized */
2979 NULL
, /* security */
2980 FILE_ATTRIBUTE_READONLY
, /* attributes */
2981 KFDF_PRECREATE
, /* flags */
2982 &GUID_NULL
/* typeid */
2985 &FOLDERID_SamplePlaylists
,
2986 CSIDL_Type_AllUsers
,
2990 KF_CATEGORY_COMMON
, /* category */
2991 SamplePlaylistsW
, /* name */
2992 NULL
, /* description */
2993 &FOLDERID_PublicMusic
, /* parent */
2994 Sample_PlaylistsW
, /* relative path */
2997 NULL
, /* localized */
2999 NULL
, /* security */
3000 FILE_ATTRIBUTE_READONLY
, /* attributes */
3001 KFDF_PRECREATE
, /* flags */
3002 &GUID_NULL
/* typeid */
3005 &FOLDERID_SampleVideos
,
3006 CSIDL_Type_AllUsers
,
3010 KF_CATEGORY_COMMON
, /* category */
3011 SampleVideosW
, /* name */
3012 NULL
, /* description */
3013 &FOLDERID_PublicVideos
, /* parent */
3014 Sample_VideosW
, /* relative path */
3017 NULL
, /* localized */
3019 NULL
, /* security */
3020 FILE_ATTRIBUTE_READONLY
, /* attributes */
3021 KFDF_PRECREATE
, /* flags */
3022 &GUID_NULL
/* typeid */
3024 { /* 0x62 - CSIDL_SAVED_GAMES */
3025 &FOLDERID_SavedGames
,
3030 KF_CATEGORY_PERUSER
, /* category */
3031 SavedGamesW
, /* name */
3032 NULL
, /* description */
3033 &FOLDERID_Profile
, /* parent */
3034 Saved_GamesW
, /* relative path */
3035 SavedGamesParsingNameW
, /* parsing */
3037 NULL
, /* localized */
3039 NULL
, /* security */
3040 FILE_ATTRIBUTE_READONLY
, /* attributes */
3041 KFDF_ROAMABLE
| KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
3042 &GUID_NULL
/* typeid */
3044 { /* 0x63 - CSIDL_SEARCHES */
3045 &FOLDERID_SavedSearches
,
3050 KF_CATEGORY_PERUSER
, /* category */
3051 SearchesW
, /* name */
3052 NULL
, /* description */
3053 &FOLDERID_Profile
, /* parent */
3054 SearchesW
, /* relative path */
3055 SavedSearchesParsingNameW
, /* parsing */
3057 NULL
, /* localized */
3059 NULL
, /* security */
3060 FILE_ATTRIBUTE_READONLY
, /* attributes */
3061 KFDF_PRECREATE
| KFDF_PUBLISHEXPANDEDPATH
, /* flags */
3062 &GUID_NULL
/* typeid */
3065 &FOLDERID_SEARCH_CSC
,
3066 CSIDL_Type_Disallowed
,
3070 KF_CATEGORY_VIRTUAL
, /* category */
3071 CSCFolderW
, /* name */
3072 NULL
, /* description */
3073 &GUID_NULL
, /* parent */
3074 NULL
, /* relative path */
3075 SEARCH_CSCParsingNameW
, /* parsing */
3077 NULL
, /* localized */
3079 NULL
, /* security */
3082 &GUID_NULL
/* typeid */
3085 &FOLDERID_SEARCH_MAPI
,
3086 CSIDL_Type_Disallowed
,
3090 KF_CATEGORY_VIRTUAL
, /* category */
3091 MAPIFolderW
, /* name */
3092 NULL
, /* description */
3093 &GUID_NULL
, /* parent */
3094 NULL
, /* relative path */
3095 SEARCH_MAPIParsingNameW
, /* parsing */
3097 NULL
, /* localized */
3099 NULL
, /* security */
3102 &GUID_NULL
/* typeid */
3105 &FOLDERID_SearchHome
,
3106 CSIDL_Type_Disallowed
,
3110 KF_CATEGORY_VIRTUAL
, /* category */
3111 SearchHomeFolderW
, /* name */
3112 NULL
, /* description */
3113 &GUID_NULL
, /* parent */
3114 NULL
, /* relative path */
3115 SearchHomeParsingNameW
, /* parsing */
3117 NULL
, /* localized */
3119 NULL
, /* security */
3122 &GUID_NULL
/* typeid */
3125 &FOLDERID_SidebarDefaultParts
,
3126 CSIDL_Type_Disallowed
, /* FIXME */
3130 KF_CATEGORY_COMMON
, /* category */
3131 Default_GadgetsW
, /* name */
3132 NULL
, /* description */
3133 &FOLDERID_ProgramFiles
, /* parent */
3134 Windows_Sidebar_GadgetsW
, /* relative path */
3137 NULL
, /* localized */
3139 NULL
, /* security */
3142 &GUID_NULL
/* typeid */
3145 &FOLDERID_SidebarParts
,
3146 CSIDL_Type_Disallowed
, /* FIXME */
3150 KF_CATEGORY_PERUSER
, /* category */
3151 GadgetsW
, /* name */
3152 NULL
, /* description */
3153 &FOLDERID_LocalAppData
, /* parent */
3154 Microsoft_Windows_Sidebar_GadgetsW
, /* relative path */
3157 NULL
, /* localized */
3159 NULL
, /* security */
3162 &GUID_NULL
/* typeid */
3165 &FOLDERID_SyncManagerFolder
,
3166 CSIDL_Type_Disallowed
,
3170 KF_CATEGORY_VIRTUAL
, /* category */
3171 SyncCenterFolderW
, /* name */
3172 NULL
, /* description */
3173 &GUID_NULL
, /* parent */
3174 NULL
, /* relative path */
3175 SyncManagerFolderParsingNameW
, /* parsing */
3177 NULL
, /* localized */
3179 NULL
, /* security */
3182 &GUID_NULL
/* typeid */
3185 &FOLDERID_SyncResultsFolder
,
3186 CSIDL_Type_Disallowed
,
3190 KF_CATEGORY_VIRTUAL
, /* category */
3191 SyncResultsFolderW
, /* name */
3192 NULL
, /* description */
3193 &GUID_NULL
, /* parent */
3194 NULL
, /* relative path */
3195 SyncResultsFolderParsingNameW
, /* parsing */
3197 NULL
, /* localized */
3199 NULL
, /* security */
3202 &GUID_NULL
/* typeid */
3205 &FOLDERID_SyncSetupFolder
,
3206 CSIDL_Type_Disallowed
,
3210 KF_CATEGORY_VIRTUAL
, /* category */
3211 SyncSetupFolderW
, /* name */
3212 NULL
, /* description */
3213 &GUID_NULL
, /* parent */
3214 NULL
, /* relative path */
3215 SyncSetupFolderParsingNameW
, /* parsing */
3217 NULL
, /* localized */
3219 NULL
, /* security */
3222 &GUID_NULL
/* typeid */
3225 &FOLDERID_UserPinned
,
3226 CSIDL_Type_Disallowed
, /* FIXME */
3230 KF_CATEGORY_PERUSER
, /* category */
3231 User_PinnedW
, /* name */
3232 NULL
, /* description */
3233 &FOLDERID_QuickLaunch
, /* parent */
3234 User_PinnedW
, /* relative path */
3237 NULL
, /* localized */
3239 NULL
, /* security */
3240 FILE_ATTRIBUTE_HIDDEN
, /* attributes */
3241 KFDF_PRECREATE
, /* flags */
3242 &GUID_NULL
/* typeid */
3245 &FOLDERID_UserProfiles
,
3250 KF_CATEGORY_FIXED
, /* category */
3251 UserProfilesW
, /* name */
3252 NULL
, /* description */
3253 &GUID_NULL
, /* parent */
3254 NULL
, /* relative path */
3257 NULL
, /* localized */
3259 NULL
, /* security */
3260 FILE_ATTRIBUTE_READONLY
, /* attributes */
3261 KFDF_PRECREATE
, /* flags */
3262 &GUID_NULL
/* typeid */
3265 &FOLDERID_UserProgramFiles
,
3266 CSIDL_Type_Disallowed
, /* FIXME */
3270 KF_CATEGORY_PERUSER
, /* category */
3271 UserProgramFilesW
, /* name */
3272 NULL
, /* description */
3273 &FOLDERID_LocalAppData
, /* parent */
3274 ProgramsW
, /* relative path */
3277 NULL
, /* localized */
3279 NULL
, /* security */
3282 &GUID_NULL
/* typeid */
3285 &FOLDERID_UserProgramFilesCommon
,
3286 CSIDL_Type_Disallowed
, /* FIXME */
3290 KF_CATEGORY_PERUSER
, /* category */
3291 UserProgramFilesCommonW
, /* name */
3292 NULL
, /* description */
3293 &FOLDERID_UserProgramFiles
, /* parent */
3294 CommonW
, /* relative path */
3297 NULL
, /* localized */
3299 NULL
, /* security */
3302 &GUID_NULL
/* typeid */
3305 &FOLDERID_UsersFiles
,
3306 CSIDL_Type_Disallowed
,
3310 KF_CATEGORY_VIRTUAL
, /* category */
3311 UsersFilesFolderW
, /* name */
3312 NULL
, /* description */
3313 &GUID_NULL
, /* parent */
3314 NULL
, /* relative path */
3315 UsersFilesParsingNameW
, /* parsing */
3317 NULL
, /* localized */
3319 NULL
, /* security */
3322 &GUID_NULL
/* typeid */
3325 &FOLDERID_UsersLibraries
,
3326 CSIDL_Type_Disallowed
,
3330 KF_CATEGORY_VIRTUAL
, /* category */
3331 UsersLibrariesFolderW
, /* name */
3332 NULL
, /* description */
3333 &GUID_NULL
, /* parent */
3334 NULL
, /* relative path */
3335 UsersLibrariesParsingNameW
, /* parsing */
3337 NULL
, /* localized */
3339 NULL
, /* security */
3342 &GUID_NULL
/* typeid */
3345 &FOLDERID_VideosLibrary
,
3346 CSIDL_Type_Disallowed
, /* FIXME */
3350 KF_CATEGORY_PERUSER
, /* category */
3351 VideosLibraryW
, /* name */
3352 NULL
, /* description */
3353 &GUID_NULL
, /* parent */
3354 Videos_librarymsW
, /* relative path */
3355 VideosLibraryParsingNameW
, /* parsing */
3357 NULL
, /* localized */
3359 NULL
, /* security */
3362 &GUID_NULL
/* typeid */
3366 static int csidl_from_id( const KNOWNFOLDERID
*id
)
3369 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
3370 if (IsEqualGUID( CSIDL_Data
[i
].id
, id
)) return i
;
3374 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
);
3376 /* Gets the value named value from the registry key
3377 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
3378 * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
3379 * is assumed to be MAX_PATH WCHARs in length.
3380 * If it exists, expands the value and writes the expanded value to
3381 * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
3382 * Returns successful error code if the value was retrieved from the registry,
3383 * and a failure otherwise.
3385 static HRESULT
_SHGetUserShellFolderPath(HKEY rootKey
, LPCWSTR userPrefix
,
3386 LPCWSTR value
, LPWSTR path
)
3389 WCHAR shellFolderPath
[MAX_PATH
], userShellFolderPath
[MAX_PATH
];
3390 LPCWSTR pShellFolderPath
, pUserShellFolderPath
;
3391 HKEY userShellFolderKey
, shellFolderKey
;
3392 DWORD dwType
, dwPathLen
;
3394 TRACE("%p,%s,%s,%p\n",rootKey
, debugstr_w(userPrefix
), debugstr_w(value
),
3399 strcpyW(shellFolderPath
, userPrefix
);
3400 PathAddBackslashW(shellFolderPath
);
3401 strcatW(shellFolderPath
, szSHFolders
);
3402 pShellFolderPath
= shellFolderPath
;
3403 strcpyW(userShellFolderPath
, userPrefix
);
3404 PathAddBackslashW(userShellFolderPath
);
3405 strcatW(userShellFolderPath
, szSHUserFolders
);
3406 pUserShellFolderPath
= userShellFolderPath
;
3410 pUserShellFolderPath
= szSHUserFolders
;
3411 pShellFolderPath
= szSHFolders
;
3414 if (RegCreateKeyW(rootKey
, pShellFolderPath
, &shellFolderKey
))
3416 TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath
));
3419 if (RegCreateKeyW(rootKey
, pUserShellFolderPath
, &userShellFolderKey
))
3421 TRACE("Failed to create %s\n",
3422 debugstr_w(pUserShellFolderPath
));
3423 RegCloseKey(shellFolderKey
);
3427 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3428 if (!RegQueryValueExW(userShellFolderKey
, value
, NULL
, &dwType
,
3429 (LPBYTE
)path
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3433 path
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3434 if (dwType
== REG_EXPAND_SZ
&& path
[0] == '%')
3436 WCHAR szTemp
[MAX_PATH
];
3438 _SHExpandEnvironmentStrings(path
, szTemp
);
3439 lstrcpynW(path
, szTemp
, MAX_PATH
);
3441 ret
= RegSetValueExW(shellFolderKey
, value
, 0, REG_SZ
, (LPBYTE
)path
,
3442 (strlenW(path
) + 1) * sizeof(WCHAR
));
3443 if (ret
!= ERROR_SUCCESS
)
3444 hr
= HRESULT_FROM_WIN32(ret
);
3450 RegCloseKey(shellFolderKey
);
3451 RegCloseKey(userShellFolderKey
);
3452 TRACE("returning 0x%08x\n", hr
);
3456 static void append_relative_path(BYTE folder
, WCHAR
*pszPath
)
3458 if (CSIDL_Data
[folder
].pszRelativePath
)
3460 PathAddBackslashW(pszPath
);
3461 strcatW(pszPath
, CSIDL_Data
[folder
].pszRelativePath
);
3463 else if (CSIDL_Data
[folder
].szDefaultPath
)
3465 PathAddBackslashW(pszPath
);
3466 strcatW(pszPath
, CSIDL_Data
[folder
].szDefaultPath
);
3470 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
3471 * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
3472 * - Depending on the entry's type, the path may begin with an (unexpanded)
3473 * environment variable name. The caller is responsible for expanding
3474 * environment strings if so desired.
3475 * The types that are prepended with environment variables are:
3476 * CSIDL_Type_User: %USERPROFILE%
3477 * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
3478 * CSIDL_Type_CurrVer: %SystemDrive%
3479 * (Others might make sense too, but as yet are unneeded.)
3481 static HRESULT
_SHGetDefaultValue(BYTE folder
, LPWSTR pszPath
)
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 (IsEqualGUID(CSIDL_Data
[folder
].fidParent
, &GUID_NULL
))
3514 /* hit the root, sub in env var */
3515 switch (CSIDL_Data
[folder
].type
)
3517 case CSIDL_Type_User
:
3518 strcpyW(pszPath
, UserProfileW
);
3520 case CSIDL_Type_AllUsers
:
3521 strcpyW(pszPath
, PublicProfileW
);
3523 case CSIDL_Type_ProgramData
:
3524 strcpyW(pszPath
, ProgramDataVarW
);
3526 case CSIDL_Type_CurrVer
:
3527 strcpyW(pszPath
, SystemDriveW
);
3530 ; /* no corresponding env. var, do nothing */
3534 /* prepend with parent */
3535 hr
= _SHGetDefaultValue(csidl_from_id(CSIDL_Data
[folder
].fidParent
), pszPath
);
3539 append_relative_path(folder
, pszPath
);
3541 TRACE("returning 0x%08x\n", hr
);
3545 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
3546 * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
3547 * can be overridden in the HKLM\\szCurrentVersion key.
3548 * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
3549 * the registry, uses _SHGetDefaultValue to get the value.
3551 static HRESULT
_SHGetCurrentVersionPath(DWORD dwFlags
, BYTE folder
,
3556 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3558 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3559 return E_INVALIDARG
;
3560 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_CurrVer
)
3561 return E_INVALIDARG
;
3563 return E_INVALIDARG
;
3565 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3566 hr
= _SHGetDefaultValue(folder
, pszPath
);
3571 if (RegCreateKeyW(HKEY_LOCAL_MACHINE
, szCurrentVersion
, &hKey
))
3575 DWORD dwType
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3577 if (RegQueryValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, NULL
,
3578 &dwType
, (LPBYTE
)pszPath
, &dwPathLen
) ||
3579 (dwType
!= REG_SZ
&& dwType
!= REG_EXPAND_SZ
))
3581 hr
= _SHGetDefaultValue(folder
, pszPath
);
3582 dwType
= REG_EXPAND_SZ
;
3585 case CSIDL_PROGRAM_FILESX86
:
3586 case CSIDL_PROGRAM_FILES_COMMONX86
:
3587 /* these two should never be set on 32-bit setups */
3591 IsWow64Process( GetCurrentProcess(), &is_wow64
);
3592 if (!is_wow64
) break;
3596 RegSetValueExW(hKey
, CSIDL_Data
[folder
].szValueName
, 0, dwType
,
3597 (LPBYTE
)pszPath
, (strlenW(pszPath
)+1)*sizeof(WCHAR
));
3602 pszPath
[dwPathLen
/ sizeof(WCHAR
)] = '\0';
3608 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3612 static LPWSTR
_GetUserSidStringFromToken(HANDLE Token
)
3614 char InfoBuffer
[64];
3615 PTOKEN_USER UserInfo
;
3619 UserInfo
= (PTOKEN_USER
) InfoBuffer
;
3620 if (! GetTokenInformation(Token
, TokenUser
, InfoBuffer
, sizeof(InfoBuffer
),
3623 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
3625 UserInfo
= heap_alloc(InfoSize
);
3626 if (UserInfo
== NULL
)
3628 if (! GetTokenInformation(Token
, TokenUser
, UserInfo
, InfoSize
,
3631 heap_free(UserInfo
);
3636 if (! ConvertSidToStringSidW(UserInfo
->User
.Sid
, &SidStr
))
3639 if (UserInfo
!= (PTOKEN_USER
) InfoBuffer
)
3640 heap_free(UserInfo
);
3645 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
3646 * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
3647 * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
3648 * - if hToken is -1, looks in HKEY_USERS\.Default
3649 * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
3650 * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
3651 * calls _SHGetDefaultValue for it.
3653 static HRESULT
_SHGetUserProfilePath(HANDLE hToken
, DWORD dwFlags
, BYTE folder
,
3656 const WCHAR
*szValueName
;
3660 TRACE("%p,0x%08x,0x%02x,%p\n", hToken
, dwFlags
, folder
, pszPath
);
3662 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3663 return E_INVALIDARG
;
3664 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_User
)
3665 return E_INVALIDARG
;
3667 return E_INVALIDARG
;
3669 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3671 if (hToken
!= NULL
&& hToken
!= (HANDLE
)-1)
3673 FIXME("unsupported for user other than current or default\n");
3676 hr
= _SHGetDefaultValue(folder
, pszPath
);
3680 LPCWSTR userPrefix
= NULL
;
3683 if (hToken
== (HANDLE
)-1)
3685 hRootKey
= HKEY_USERS
;
3686 userPrefix
= DefaultW
;
3688 else if (hToken
== NULL
)
3689 hRootKey
= HKEY_CURRENT_USER
;
3692 hRootKey
= HKEY_USERS
;
3693 userPrefix
= _GetUserSidStringFromToken(hToken
);
3694 if (userPrefix
== NULL
)
3701 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
3702 szValueName
= CSIDL_Data
[folder
].szValueName
;
3705 StringFromGUID2( CSIDL_Data
[folder
].id
, buffer
, 39 );
3706 szValueName
= &buffer
[0];
3709 hr
= _SHGetUserShellFolderPath(hRootKey
, userPrefix
, szValueName
, pszPath
);
3710 if (FAILED(hr
) && hRootKey
!= HKEY_LOCAL_MACHINE
)
3711 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
, szValueName
, pszPath
);
3713 hr
= _SHGetDefaultValue(folder
, pszPath
);
3714 if (userPrefix
!= NULL
&& userPrefix
!= DefaultW
)
3715 LocalFree((HLOCAL
) userPrefix
);
3718 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3722 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
3723 * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
3724 * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
3725 * If this fails, falls back to _SHGetDefaultValue.
3727 static HRESULT
_SHGetAllUsersProfilePath(DWORD dwFlags
, BYTE folder
,
3732 TRACE("0x%08x,0x%02x,%p\n", dwFlags
, folder
, pszPath
);
3734 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
3735 return E_INVALIDARG
;
3736 if (CSIDL_Data
[folder
].type
!= CSIDL_Type_AllUsers
&& CSIDL_Data
[folder
].type
!= CSIDL_Type_ProgramData
)
3737 return E_INVALIDARG
;
3739 return E_INVALIDARG
;
3741 if (dwFlags
& SHGFP_TYPE_DEFAULT
)
3742 hr
= _SHGetDefaultValue(folder
, pszPath
);
3745 hr
= _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE
, NULL
,
3746 CSIDL_Data
[folder
].szValueName
, pszPath
);
3748 hr
= _SHGetDefaultValue(folder
, pszPath
);
3750 TRACE("returning 0x%08x (output path is %s)\n", hr
, debugstr_w(pszPath
));
3754 static HRESULT
_SHOpenProfilesKey(PHKEY pKey
)
3759 lRet
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
, ProfileListW
, 0, NULL
, 0,
3760 KEY_ALL_ACCESS
, NULL
, pKey
, &disp
);
3761 return HRESULT_FROM_WIN32(lRet
);
3764 /* Reads the value named szValueName from the key profilesKey (assumed to be
3765 * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
3766 * WCHARs in length. If it doesn't exist, returns szDefault (and saves
3767 * szDefault to the registry).
3769 static HRESULT
_SHGetProfilesValue(HKEY profilesKey
, LPCWSTR szValueName
,
3770 LPWSTR szValue
, LPCWSTR szDefault
)
3773 DWORD type
, dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
3776 TRACE("%p,%s,%p,%s\n", profilesKey
, debugstr_w(szValueName
), szValue
,
3777 debugstr_w(szDefault
));
3778 lRet
= RegQueryValueExW(profilesKey
, szValueName
, NULL
, &type
,
3779 (LPBYTE
)szValue
, &dwPathLen
);
3780 if (!lRet
&& (type
== REG_SZ
|| type
== REG_EXPAND_SZ
) && dwPathLen
3783 dwPathLen
/= sizeof(WCHAR
);
3784 szValue
[dwPathLen
] = '\0';
3789 /* Missing or invalid value, set a default */
3790 lstrcpynW(szValue
, szDefault
, MAX_PATH
);
3791 TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName
),
3792 debugstr_w(szValue
));
3793 lRet
= RegSetValueExW(profilesKey
, szValueName
, 0, REG_EXPAND_SZ
,
3795 (strlenW(szValue
) + 1) * sizeof(WCHAR
));
3797 hr
= HRESULT_FROM_WIN32(lRet
);
3801 TRACE("returning 0x%08x (output value is %s)\n", hr
, debugstr_w(szValue
));
3805 /* Attempts to expand environment variables from szSrc into szDest, which is
3806 * assumed to be MAX_PATH characters in length. Before referring to the
3807 * environment, handles a few variables directly, because the environment
3808 * variables may not be set when this is called (as during Wine's installation
3809 * when default values are being written to the registry).
3810 * The directly handled environment variables, and their source, are:
3811 * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
3812 * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
3814 * If one of the directly handled environment variables is expanded, only
3815 * expands a single variable, and only in the beginning of szSrc.
3817 static HRESULT
_SHExpandEnvironmentStrings(LPCWSTR szSrc
, LPWSTR szDest
)
3820 WCHAR szTemp
[MAX_PATH
], szProfilesPrefix
[MAX_PATH
] = { 0 };
3823 TRACE("%s, %p\n", debugstr_w(szSrc
), szDest
);
3825 if (!szSrc
|| !szDest
) return E_INVALIDARG
;
3827 /* short-circuit if there's nothing to expand */
3828 if (szSrc
[0] != '%')
3830 strcpyW(szDest
, szSrc
);
3834 /* Get the profile prefix, we'll probably be needing it */
3835 hr
= _SHOpenProfilesKey(&key
);
3838 WCHAR def_val
[MAX_PATH
];
3840 /* get the system drive */
3841 GetSystemDirectoryW(def_val
, MAX_PATH
);
3842 strcpyW( def_val
+ 3, szDefaultProfileDirW
);
3844 hr
= _SHGetProfilesValue(key
, ProfilesDirectoryW
, szProfilesPrefix
, def_val
);
3848 strcpyW(szTemp
, szSrc
);
3849 while (SUCCEEDED(hr
) && szTemp
[0] == '%')
3851 if (!strncmpiW(szTemp
, AllUsersProfileW
, strlenW(AllUsersProfileW
)))
3853 WCHAR szAllUsers
[MAX_PATH
], def_val
[MAX_PATH
];
3855 GetSystemDirectoryW(def_val
, MAX_PATH
);
3856 strcpyW( def_val
+ 3, UsersPublicW
);
3858 hr
= _SHGetProfilesValue(key
, PublicW
, szAllUsers
, def_val
);
3859 PathAppendW(szDest
, szAllUsers
);
3860 PathAppendW(szDest
, szTemp
+ strlenW(AllUsersProfileW
));
3862 else if (!strncmpiW(szTemp
, PublicProfileW
, strlenW(PublicProfileW
)))
3864 WCHAR szAllUsers
[MAX_PATH
], def_val
[MAX_PATH
];
3866 GetSystemDirectoryW(def_val
, MAX_PATH
);
3867 strcpyW( def_val
+ 3, UsersPublicW
);
3869 hr
= _SHGetProfilesValue(key
, PublicW
, szAllUsers
, def_val
);
3870 PathAppendW(szDest
, szAllUsers
);
3871 PathAppendW(szDest
, szTemp
+ strlenW(PublicProfileW
));
3873 else if (!strncmpiW(szTemp
, ProgramDataVarW
, strlenW(ProgramDataVarW
)))
3875 WCHAR szProgramData
[MAX_PATH
], def_val
[MAX_PATH
];
3876 HKEY shellFolderKey
;
3877 DWORD dwType
, dwPathLen
= sizeof(def_val
);
3878 BOOL in_registry
= FALSE
;
3880 if (!RegCreateKeyW(HKEY_LOCAL_MACHINE
, szSHFolders
, &shellFolderKey
))
3882 if (!RegQueryValueExW(shellFolderKey
, Common_AppDataW
, NULL
, &dwType
,
3883 (LPBYTE
)def_val
, &dwPathLen
) && (dwType
== REG_EXPAND_SZ
|| dwType
== REG_SZ
))
3886 RegCloseKey(shellFolderKey
);
3891 GetSystemDirectoryW(def_val
, MAX_PATH
);
3892 strcpyW( def_val
+ 3, ProgramDataW
);
3895 hr
= _SHGetProfilesValue(key
, ProgramDataW
, szProgramData
, def_val
);
3896 PathAppendW(szDest
, szProgramData
);
3897 PathAppendW(szDest
, szTemp
+ strlenW(ProgramDataVarW
));
3899 else if (!strncmpiW(szTemp
, UserProfileW
, strlenW(UserProfileW
)))
3901 WCHAR userName
[MAX_PATH
];
3902 DWORD userLen
= MAX_PATH
;
3904 strcpyW(szDest
, szProfilesPrefix
);
3905 GetUserNameW(userName
, &userLen
);
3906 PathAppendW(szDest
, userName
);
3907 PathAppendW(szDest
, szTemp
+ strlenW(UserProfileW
));
3909 else if (!strncmpiW(szTemp
, SystemDriveW
, strlenW(SystemDriveW
)))
3911 GetSystemDirectoryW(szDest
, MAX_PATH
);
3912 strcpyW(szDest
+ 3, szTemp
+ strlenW(SystemDriveW
) + 1);
3916 DWORD ret
= ExpandEnvironmentStringsW(szTemp
, szDest
, MAX_PATH
);
3919 hr
= E_NOT_SUFFICIENT_BUFFER
;
3921 hr
= HRESULT_FROM_WIN32(GetLastError());
3922 else if (!strcmpW( szTemp
, szDest
)) break; /* nothing expanded */
3924 if (SUCCEEDED(hr
)) strcpyW(szTemp
, szDest
);
3929 TRACE("returning 0x%08x (input was %s, output is %s)\n", hr
,
3930 debugstr_w(szSrc
), debugstr_w(szDest
));
3934 /*************************************************************************
3935 * _SHGetXDGUserDirs [Internal]
3937 * Get XDG directories paths from XDG configuration.
3940 * xdg_dirs [I] Array of XDG directories to look for.
3941 * num_dirs [I] Number of elements in xdg_dirs.
3942 * xdg_results [O] An array of the XDG directories paths.
3944 static inline void _SHGetXDGUserDirs(const char * const *xdg_dirs
, const unsigned int num_dirs
, char *** xdg_results
) {
3947 hr
= XDG_UserDirLookup(xdg_dirs
, num_dirs
, xdg_results
);
3948 if (FAILED(hr
)) *xdg_results
= NULL
;
3951 /*************************************************************************
3952 * _SHFreeXDGUserDirs [Internal]
3954 * Free resources allocated by XDG_UserDirLookup().
3957 * num_dirs [I] Number of elements in xdg_results.
3958 * xdg_results [I] An array of the XDG directories paths.
3960 static inline void _SHFreeXDGUserDirs(const unsigned int num_dirs
, char ** xdg_results
) {
3965 for (i
= 0; i
< num_dirs
; i
++)
3966 heap_free(xdg_results
[i
]);
3967 heap_free(xdg_results
);
3971 /*************************************************************************
3972 * _SHAppendToUnixPath [Internal]
3974 * Helper function for _SHCreateSymbolicLinks. Appends pwszSubPath (or the
3975 * corresponding resource, if IS_INTRESOURCE) to the unix base path 'szBasePath'
3976 * and replaces backslashes with slashes.
3979 * szBasePath [IO] The unix base path, which will be appended to (CP_UNXICP).
3980 * pwszSubPath [I] Sub-path or resource id (use MAKEINTRESOURCEW).
3986 static inline BOOL
_SHAppendToUnixPath(char *szBasePath
, LPCWSTR pwszSubPath
) {
3987 WCHAR wszSubPath
[MAX_PATH
];
3988 int cLen
= strlen(szBasePath
);
3991 if (IS_INTRESOURCE(pwszSubPath
)) {
3992 if (!LoadStringW(shell32_hInstance
, LOWORD(pwszSubPath
), wszSubPath
, MAX_PATH
)) {
3993 /* Fall back to hard coded defaults. */
3994 switch (LOWORD(pwszSubPath
)) {
3996 lstrcpyW(wszSubPath
, DocumentsW
);
3999 lstrcpyW(wszSubPath
, My_MusicW
);
4001 case IDS_MYPICTURES
:
4002 lstrcpyW(wszSubPath
, My_PicturesW
);
4005 lstrcpyW(wszSubPath
, My_VideosW
);
4008 lstrcpyW(wszSubPath
, DownloadsW
);
4011 lstrcpyW(wszSubPath
, TemplatesW
);
4014 ERR("LoadString(%d) failed!\n", LOWORD(pwszSubPath
));
4019 lstrcpyW(wszSubPath
, pwszSubPath
);
4022 if (szBasePath
[cLen
-1] != '/') szBasePath
[cLen
++] = '/';
4024 if (!WideCharToMultiByte(CP_UNIXCP
, 0, wszSubPath
, -1, szBasePath
+ cLen
,
4025 FILENAME_MAX
- cLen
, NULL
, NULL
))
4030 pBackslash
= szBasePath
+ cLen
;
4031 while ((pBackslash
= strchr(pBackslash
, '\\'))) *pBackslash
= '/';
4036 /******************************************************************************
4037 * _SHGetFolderUnixPath [Internal]
4039 * Create a shell folder and get its unix path.
4042 * nFolder [I] CSIDL identifying the folder.
4044 static inline char * _SHGetFolderUnixPath(const int nFolder
)
4046 WCHAR wszTempPath
[MAX_PATH
];
4049 hr
= SHGetFolderPathW(NULL
, nFolder
, NULL
,
4050 SHGFP_TYPE_CURRENT
, wszTempPath
);
4051 if (FAILED(hr
)) return NULL
;
4053 return wine_get_unix_file_name(wszTempPath
);
4056 /******************************************************************************
4057 * _SHCreateMyDocumentsSubDirs [Internal]
4059 * Create real directories for various shell folders under 'My Documents'. For
4060 * Windows and homeless styles. Fails silently for already existing sub dirs.
4063 * aidsMyStuff [I] Array of IDS_* resources to create sub dirs for.
4064 * num [I] Number of elements in aidsMyStuff.
4065 * szPersonalTarget [I] Unix path to 'My Documents' directory.
4067 static void _SHCreateMyDocumentsSubDirs(const UINT
* aidsMyStuff
, const UINT num
, const char * szPersonalTarget
)
4069 char szMyStuffTarget
[FILENAME_MAX
];
4072 if (aidsMyStuff
&& szPersonalTarget
)
4074 for (i
= 0; i
< num
; i
++)
4076 strcpy(szMyStuffTarget
, szPersonalTarget
);
4077 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])))
4078 mkdir(szMyStuffTarget
, 0777);
4083 /******************************************************************************
4084 * _SHCreateMyDocumentsSymbolicLink [Internal]
4086 * Sets up a symbolic link for the 'My Documents' shell folder to point into
4087 * the users home directory.
4090 * aidsMyStuff [I] Array of IDS_* resources to create sub dirs for.
4091 * aids_num [I] Number of elements in aidsMyStuff.
4093 static void _SHCreateMyDocumentsSymbolicLink(const UINT
* aidsMyStuff
, const UINT aids_num
)
4095 static const char * const xdg_dirs
[] = { "DOCUMENTS" };
4096 static const unsigned int num
= ARRAY_SIZE(xdg_dirs
);
4097 char szPersonalTarget
[FILENAME_MAX
], *pszPersonal
;
4098 struct stat statFolder
;
4099 const char *pszHome
;
4100 char ** xdg_results
;
4102 /* Get the unix path of 'My Documents'. */
4103 pszPersonal
= _SHGetFolderUnixPath(CSIDL_PERSONAL
|CSIDL_FLAG_DONT_VERIFY
);
4104 if (!pszPersonal
) return;
4106 _SHGetXDGUserDirs(xdg_dirs
, num
, &xdg_results
);
4108 pszHome
= getenv("HOME");
4109 if (pszHome
&& !stat(pszHome
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4113 /* Check if there's already a Wine-specific 'My Documents' folder */
4114 strcpy(szPersonalTarget
, pszHome
);
4115 if (_SHAppendToUnixPath(szPersonalTarget
, MAKEINTRESOURCEW(IDS_PERSONAL
)) &&
4116 !stat(szPersonalTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4118 /* '$HOME/My Documents' exists. Create subfolders for
4119 * 'My Pictures', 'My Videos', 'My Music' etc. or fail silently
4120 * if they already exist.
4122 _SHCreateMyDocumentsSubDirs(aidsMyStuff
, aids_num
, szPersonalTarget
);
4126 /* Try to point to the XDG Documents folder */
4127 if (xdg_results
&& xdg_results
[0] &&
4128 !stat(xdg_results
[0], &statFolder
) &&
4129 S_ISDIR(statFolder
.st_mode
))
4131 strcpy(szPersonalTarget
, xdg_results
[0]);
4135 /* Or the hardcoded / OS X Documents folder */
4136 strcpy(szPersonalTarget
, pszHome
);
4137 if (_SHAppendToUnixPath(szPersonalTarget
, DocumentsW
) &&
4138 !stat(szPersonalTarget
, &statFolder
) &&
4139 S_ISDIR(statFolder
.st_mode
))
4142 /* As a last resort point to $HOME. */
4143 strcpy(szPersonalTarget
, pszHome
);
4147 /* Create symbolic link to 'My Documents' or fail silently if a directory
4148 * or symlink exists. */
4149 symlink(szPersonalTarget
, pszPersonal
);
4153 /* '$HOME' doesn't exist. Create subdirs for 'My Pictures', 'My Videos',
4154 * 'My Music' etc. in '%USERPROFILE%\My Documents' or fail silently if
4155 * they already exist. */
4157 strcpy(szPersonalTarget
, pszPersonal
);
4158 _SHCreateMyDocumentsSubDirs(aidsMyStuff
, aids_num
, szPersonalTarget
);
4161 heap_free(pszPersonal
);
4163 _SHFreeXDGUserDirs(num
, xdg_results
);
4166 /******************************************************************************
4167 * _SHCreateMyStuffSymbolicLink [Internal]
4169 * Sets up a symbolic link for one of the 'My Whatever' shell folders to point
4170 * into the users home directory.
4173 * nFolder [I] CSIDL identifying the folder.
4175 static void _SHCreateMyStuffSymbolicLink(int nFolder
)
4177 static const UINT aidsMyStuff
[] = {
4178 IDS_MYPICTURES
, IDS_MYVIDEOS
, IDS_MYMUSIC
, IDS_DOWNLOADS
, IDS_TEMPLATES
4180 static const WCHAR
* const MyOSXStuffW
[] = {
4181 PicturesW
, MoviesW
, MusicW
, DownloadsW
, TemplatesW
4183 static const int acsidlMyStuff
[] = {
4184 CSIDL_MYPICTURES
, CSIDL_MYVIDEO
, CSIDL_MYMUSIC
, CSIDL_DOWNLOADS
, CSIDL_TEMPLATES
4186 static const char * const xdg_dirs
[] = {
4187 "PICTURES", "VIDEOS", "MUSIC", "DOWNLOAD", "TEMPLATES"
4189 static const unsigned int num
= ARRAY_SIZE(xdg_dirs
);
4190 char szPersonalTarget
[FILENAME_MAX
], *pszPersonal
;
4191 char szMyStuffTarget
[FILENAME_MAX
], *pszMyStuff
;
4192 struct stat statFolder
;
4193 const char *pszHome
;
4194 char ** xdg_results
;
4195 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
4198 for (i
= 0; i
< ARRAY_SIZE(acsidlMyStuff
) && acsidlMyStuff
[i
] != folder
; i
++);
4199 if (i
>= ARRAY_SIZE(acsidlMyStuff
)) return;
4201 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4202 pszPersonal
= _SHGetFolderUnixPath(CSIDL_PERSONAL
|CSIDL_FLAG_CREATE
);
4203 if (!pszPersonal
) return;
4205 strcpy(szPersonalTarget
, pszPersonal
);
4206 if (!stat(pszPersonal
, &statFolder
) && S_ISLNK(statFolder
.st_mode
))
4208 int cLen
= readlink(pszPersonal
, szPersonalTarget
, FILENAME_MAX
-1);
4209 if (cLen
>= 0) szPersonalTarget
[cLen
] = '\0';
4211 heap_free(pszPersonal
);
4213 _SHGetXDGUserDirs(xdg_dirs
, num
, &xdg_results
);
4215 pszHome
= getenv("HOME");
4219 /* Get the current 'My Whatever' folder unix path. */
4220 pszMyStuff
= _SHGetFolderUnixPath(acsidlMyStuff
[i
]|CSIDL_FLAG_DONT_VERIFY
);
4221 if (!pszMyStuff
) break;
4225 /* Check for the Wine-specific '$HOME/My Documents' subfolder */
4226 strcpy(szMyStuffTarget
, szPersonalTarget
);
4227 if (_SHAppendToUnixPath(szMyStuffTarget
, MAKEINTRESOURCEW(aidsMyStuff
[i
])) &&
4228 !stat(szMyStuffTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
))
4231 /* Try the XDG_XXX_DIR folder */
4232 if (xdg_results
&& xdg_results
[i
])
4234 strcpy(szMyStuffTarget
, xdg_results
[i
]);
4238 /* Or the OS X folder (these are never localized) */
4241 strcpy(szMyStuffTarget
, pszHome
);
4242 if (_SHAppendToUnixPath(szMyStuffTarget
, MyOSXStuffW
[i
]) &&
4243 !stat(szMyStuffTarget
, &statFolder
) &&
4244 S_ISDIR(statFolder
.st_mode
))
4248 /* As a last resort point to the same location as 'My Documents' */
4249 strcpy(szMyStuffTarget
, szPersonalTarget
);
4252 symlink(szMyStuffTarget
, pszMyStuff
);
4253 heap_free(pszMyStuff
);
4257 _SHFreeXDGUserDirs(num
, xdg_results
);
4260 /******************************************************************************
4261 * _SHCreateDesktopSymbolicLink [Internal]
4263 * Sets up a symbolic link for the 'Desktop' shell folder to point into the
4264 * users home directory.
4266 static void _SHCreateDesktopSymbolicLink(void)
4268 static const char * const xdg_dirs
[] = { "DESKTOP" };
4269 static const unsigned int num
= ARRAY_SIZE(xdg_dirs
);
4271 char szDesktopTarget
[FILENAME_MAX
], *pszDesktop
;
4272 struct stat statFolder
;
4273 const char *pszHome
;
4274 char ** xdg_results
;
4275 char * xdg_desktop_dir
;
4277 /* Create all necessary profile sub-dirs up to 'My Documents' and get the unix path. */
4278 pszPersonal
= _SHGetFolderUnixPath(CSIDL_PERSONAL
|CSIDL_FLAG_CREATE
);
4279 if (!pszPersonal
) return;
4281 _SHGetXDGUserDirs(xdg_dirs
, num
, &xdg_results
);
4283 pszHome
= getenv("HOME");
4286 strcpy(szDesktopTarget
, pszHome
);
4288 strcpy(szDesktopTarget
, pszPersonal
);
4289 heap_free(pszPersonal
);
4291 xdg_desktop_dir
= xdg_results
? xdg_results
[0] : NULL
;
4292 if (xdg_desktop_dir
||
4293 (_SHAppendToUnixPath(szDesktopTarget
, DesktopW
) &&
4294 !stat(szDesktopTarget
, &statFolder
) && S_ISDIR(statFolder
.st_mode
)))
4296 pszDesktop
= _SHGetFolderUnixPath(CSIDL_DESKTOPDIRECTORY
|CSIDL_FLAG_DONT_VERIFY
);
4299 if (xdg_desktop_dir
)
4300 symlink(xdg_desktop_dir
, pszDesktop
);
4302 symlink(szDesktopTarget
, pszDesktop
);
4303 heap_free(pszDesktop
);
4307 _SHFreeXDGUserDirs(num
, xdg_results
);
4310 /******************************************************************************
4311 * _SHCreateSymbolicLink [Internal]
4313 * Sets up a symbolic link for one of the special shell folders to point into
4314 * the users home directory.
4317 * nFolder [I] CSIDL identifying the folder.
4319 static void _SHCreateSymbolicLink(int nFolder
)
4321 static const UINT aidsMyStuff
[] = {
4322 IDS_MYPICTURES
, IDS_MYVIDEOS
, IDS_MYMUSIC
, IDS_DOWNLOADS
, IDS_TEMPLATES
4324 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
4327 case CSIDL_PERSONAL
:
4328 _SHCreateMyDocumentsSymbolicLink(aidsMyStuff
, ARRAY_SIZE(aidsMyStuff
));
4330 case CSIDL_MYPICTURES
:
4333 case CSIDL_DOWNLOADS
:
4334 case CSIDL_TEMPLATES
:
4335 _SHCreateMyStuffSymbolicLink(folder
);
4337 case CSIDL_DESKTOPDIRECTORY
:
4338 _SHCreateDesktopSymbolicLink();
4343 /******************************************************************************
4344 * _SHCreateSymbolicLinks [Internal]
4346 * Sets up symbol links for various shell folders to point into the user's home
4347 * directory. We do an educated guess about what the user would probably want:
4348 * - If there is a 'My Documents' directory in $HOME, the user probably wants
4349 * wine's 'My Documents' to point there. Furthermore, we infer that the user
4350 * is a Windows lover and has no problem with wine creating subfolders for
4351 * 'My Pictures', 'My Music', 'My Videos' etc. under '$HOME/My Documents', if
4352 * those do not already exist. We put appropriate symbolic links in place for
4354 * - If there is no 'My Documents' directory in $HOME, we let 'My Documents'
4355 * point directly to $HOME. We assume the user to be a unix hacker who does not
4356 * want wine to create anything anywhere besides the .wine directory. So, if
4357 * there already is a 'My Music' directory in $HOME, we symlink the 'My Music'
4358 * shell folder to it. But if not, then we check XDG_MUSIC_DIR - "well known"
4359 * directory, and try to link to that. If that fails, then we symlink to
4360 * $HOME directly. The same holds for 'My Pictures', 'My Videos' etc.
4361 * - The Desktop shell folder is symlinked to XDG_DESKTOP_DIR. If that does not
4362 * exist, then we try '$HOME/Desktop'. If that does not exist, then we leave
4364 * ('My Music',... above in fact means LoadString(IDS_MYMUSIC))
4366 static void _SHCreateSymbolicLinks(void)
4368 static const int acsidlMyStuff
[] = {
4369 CSIDL_MYPICTURES
, CSIDL_MYVIDEO
, CSIDL_MYMUSIC
, CSIDL_DOWNLOADS
, CSIDL_TEMPLATES
, CSIDL_PERSONAL
, CSIDL_DESKTOPDIRECTORY
4373 for (i
=0; i
< ARRAY_SIZE(acsidlMyStuff
); i
++)
4374 _SHCreateSymbolicLink(acsidlMyStuff
[i
]);
4377 /******************************************************************************
4378 * SHGetFolderPathW [SHELL32.@]
4380 * Convert nFolder to path.
4384 * Failure: standard HRESULT error codes.
4387 * Most values can be overridden in either
4388 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
4389 * or in the same location in HKLM.
4390 * The "Shell Folders" registry key was used in NT4 and earlier systems.
4391 * Beginning with Windows 2000, the "User Shell Folders" key is used, so
4392 * changes made to it are made to the former key too. This synchronization is
4393 * done on-demand: not until someone requests the value of one of these paths
4394 * (by calling one of the SHGet functions) is the value synchronized.
4395 * Furthermore, the HKCU paths take precedence over the HKLM paths.
4397 HRESULT WINAPI
SHGetFolderPathW(
4398 HWND hwndOwner
, /* [I] owner window */
4399 int nFolder
, /* [I] CSIDL identifying the folder */
4400 HANDLE hToken
, /* [I] access token */
4401 DWORD dwFlags
, /* [I] which path to return */
4402 LPWSTR pszPath
) /* [O] converted path */
4404 HRESULT hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, NULL
, pszPath
);
4405 if(HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) == hr
)
4406 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
4410 HRESULT WINAPI
SHGetFolderPathAndSubDirA(
4411 HWND hwndOwner
, /* [I] owner window */
4412 int nFolder
, /* [I] CSIDL identifying the folder */
4413 HANDLE hToken
, /* [I] access token */
4414 DWORD dwFlags
, /* [I] which path to return */
4415 LPCSTR pszSubPath
, /* [I] sub directory of the specified folder */
4416 LPSTR pszPath
) /* [O] converted path */
4420 LPWSTR pszSubPathW
= NULL
;
4421 LPWSTR pszPathW
= NULL
;
4423 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, debugstr_a(pszSubPath
), pszPath
);
4426 pszPathW
= heap_alloc(MAX_PATH
* sizeof(WCHAR
));
4428 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
4432 TRACE("%08x,%08x,%s\n",nFolder
, dwFlags
, debugstr_w(pszSubPathW
));
4434 /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
4435 * set (null), or an empty string.therefore call it without the parameter set
4436 * if pszSubPath is an empty string
4438 if (pszSubPath
&& pszSubPath
[0]) {
4439 length
= MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, NULL
, 0);
4440 pszSubPathW
= heap_alloc(length
* sizeof(WCHAR
));
4442 hr
= HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY
);
4445 MultiByteToWideChar(CP_ACP
, 0, pszSubPath
, -1, pszSubPathW
, length
);
4448 hr
= SHGetFolderPathAndSubDirW(hwndOwner
, nFolder
, hToken
, dwFlags
, pszSubPathW
, pszPathW
);
4450 if (SUCCEEDED(hr
) && pszPath
)
4451 WideCharToMultiByte(CP_ACP
, 0, pszPathW
, -1, pszPath
, MAX_PATH
, NULL
, NULL
);
4454 heap_free(pszPathW
);
4455 heap_free(pszSubPathW
);
4459 /*************************************************************************
4460 * SHGetFolderPathAndSubDirW [SHELL32.@]
4462 HRESULT WINAPI
SHGetFolderPathAndSubDirW(
4463 HWND hwndOwner
, /* [I] owner window */
4464 int nFolder
, /* [I] CSIDL identifying the folder */
4465 HANDLE hToken
, /* [I] access token */
4466 DWORD dwFlags
, /* [I] which path to return */
4467 LPCWSTR pszSubPath
,/* [I] sub directory of the specified folder */
4468 LPWSTR pszPath
) /* [O] converted path */
4471 WCHAR szBuildPath
[MAX_PATH
], szTemp
[MAX_PATH
];
4472 DWORD folder
= nFolder
& CSIDL_FOLDER_MASK
;
4476 TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, debugstr_w(pszSubPath
), pszPath
);
4478 /* Windows always NULL-terminates the resulting path regardless of success
4479 * or failure, so do so first
4484 if (folder
>= ARRAY_SIZE(CSIDL_Data
))
4485 return E_INVALIDARG
;
4486 if ((SHGFP_TYPE_CURRENT
!= dwFlags
) && (SHGFP_TYPE_DEFAULT
!= dwFlags
))
4487 return E_INVALIDARG
;
4489 type
= CSIDL_Data
[folder
].type
;
4492 case CSIDL_Type_Disallowed
:
4495 case CSIDL_Type_NonExistent
:
4498 case CSIDL_Type_WindowsPath
:
4499 GetWindowsDirectoryW(szTemp
, MAX_PATH
);
4500 append_relative_path(folder
, szTemp
);
4503 case CSIDL_Type_SystemPath
:
4504 GetSystemDirectoryW(szTemp
, MAX_PATH
);
4505 append_relative_path(folder
, szTemp
);
4508 case CSIDL_Type_SystemX86Path
:
4509 if (!GetSystemWow64DirectoryW(szTemp
, MAX_PATH
)) GetSystemDirectoryW(szTemp
, MAX_PATH
);
4510 append_relative_path(folder
, szTemp
);
4513 case CSIDL_Type_CurrVer
:
4514 hr
= _SHGetCurrentVersionPath(dwFlags
, folder
, szTemp
);
4516 case CSIDL_Type_User
:
4517 hr
= _SHGetUserProfilePath(hToken
, dwFlags
, folder
, szTemp
);
4519 case CSIDL_Type_AllUsers
:
4520 case CSIDL_Type_ProgramData
:
4521 hr
= _SHGetAllUsersProfilePath(dwFlags
, folder
, szTemp
);
4524 FIXME("bogus type %d, please fix\n", type
);
4529 /* Expand environment strings if necessary */
4531 hr
= _SHExpandEnvironmentStrings(szTemp
, szBuildPath
);
4533 strcpyW(szBuildPath
, szTemp
);
4535 if (FAILED(hr
)) goto end
;
4538 /* make sure the new path does not exceed the buffer length
4539 * and remember to backslash and terminate it */
4540 if(MAX_PATH
< (lstrlenW(szBuildPath
) + lstrlenW(pszSubPath
) + 2)) {
4541 hr
= HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE
);
4544 PathAppendW(szBuildPath
, pszSubPath
);
4545 PathRemoveBackslashW(szBuildPath
);
4547 /* Copy the path if it's available before we might return */
4548 if (SUCCEEDED(hr
) && pszPath
)
4549 strcpyW(pszPath
, szBuildPath
);
4551 /* if we don't care about existing directories we are ready */
4552 if(nFolder
& CSIDL_FLAG_DONT_VERIFY
) goto end
;
4554 if (PathFileExistsW(szBuildPath
)) goto end
;
4556 /* not existing but we are not allowed to create it. The return value
4557 * is verified against shell32 version 6.0.
4559 if (!(nFolder
& CSIDL_FLAG_CREATE
))
4561 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
4565 /* create symbolic links rather than directories for specific
4566 * user shell folders */
4567 _SHCreateSymbolicLink(folder
);
4569 /* create directory/directories */
4570 ret
= SHCreateDirectoryExW(hwndOwner
, szBuildPath
, NULL
);
4571 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
4573 ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath
));
4578 TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath
));
4580 TRACE("returning 0x%08x (final path is %s)\n", hr
, debugstr_w(szBuildPath
));
4584 /*************************************************************************
4585 * SHGetFolderPathA [SHELL32.@]
4587 * See SHGetFolderPathW.
4589 HRESULT WINAPI
SHGetFolderPathA(
4596 WCHAR szTemp
[MAX_PATH
];
4599 TRACE("%p,%d,%p,%#x,%p\n", hwndOwner
, nFolder
, hToken
, dwFlags
, pszPath
);
4603 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
, dwFlags
, szTemp
);
4604 if (SUCCEEDED(hr
) && pszPath
)
4605 WideCharToMultiByte(CP_ACP
, 0, szTemp
, -1, pszPath
, MAX_PATH
, NULL
,
4611 /* For each folder in folders, if its value has not been set in the registry,
4612 * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
4613 * folder's type) to get the unexpanded value first.
4614 * Writes the unexpanded value to User Shell Folders, and queries it with
4615 * SHGetFolderPathW to force the creation of the directory if it doesn't
4616 * already exist. SHGetFolderPathW also returns the expanded value, which
4617 * this then writes to Shell Folders.
4619 static HRESULT
_SHRegisterFolders(HKEY hRootKey
, HANDLE hToken
,
4620 LPCWSTR szUserShellFolderPath
, LPCWSTR szShellFolderPath
, const UINT folders
[],
4623 const WCHAR
*szValueName
;
4626 WCHAR path
[MAX_PATH
];
4628 HKEY hUserKey
= NULL
, hKey
= NULL
;
4629 DWORD dwType
, dwPathLen
;
4632 TRACE("%p,%p,%s,%p,%u\n", hRootKey
, hToken
,
4633 debugstr_w(szUserShellFolderPath
), folders
, foldersLen
);
4635 ret
= RegCreateKeyW(hRootKey
, szUserShellFolderPath
, &hUserKey
);
4637 hr
= HRESULT_FROM_WIN32(ret
);
4640 ret
= RegCreateKeyW(hRootKey
, szShellFolderPath
, &hKey
);
4642 hr
= HRESULT_FROM_WIN32(ret
);
4644 for (i
= 0; SUCCEEDED(hr
) && i
< foldersLen
; i
++)
4646 dwPathLen
= MAX_PATH
* sizeof(WCHAR
);
4648 /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
4649 szValueName
= CSIDL_Data
[folders
[i
]].szValueName
;
4650 if (!szValueName
&& CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4652 StringFromGUID2( CSIDL_Data
[folders
[i
]].id
, buffer
, 39 );
4653 szValueName
= &buffer
[0];
4656 if (RegQueryValueExW(hUserKey
, szValueName
, NULL
,
4657 &dwType
, (LPBYTE
)path
, &dwPathLen
) || (dwType
!= REG_SZ
&&
4658 dwType
!= REG_EXPAND_SZ
))
4661 if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_User
)
4662 _SHGetUserProfilePath(hToken
, SHGFP_TYPE_DEFAULT
, folders
[i
],
4664 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_AllUsers
||
4665 CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_ProgramData
)
4666 _SHGetAllUsersProfilePath(SHGFP_TYPE_DEFAULT
, folders
[i
], path
);
4667 else if (CSIDL_Data
[folders
[i
]].type
== CSIDL_Type_WindowsPath
)
4669 GetWindowsDirectoryW(path
, MAX_PATH
);
4670 append_relative_path(folders
[i
], path
);
4676 ret
= RegSetValueExW(hUserKey
, szValueName
, 0, REG_EXPAND_SZ
,
4677 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4679 hr
= HRESULT_FROM_WIN32(ret
);
4682 hr
= SHGetFolderPathW(NULL
, folders
[i
] | CSIDL_FLAG_CREATE
,
4683 hToken
, SHGFP_TYPE_DEFAULT
, path
);
4684 ret
= RegSetValueExW(hKey
, szValueName
, 0, REG_SZ
,
4685 (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
));
4687 hr
= HRESULT_FROM_WIN32(ret
);
4693 /* create the default dir, which may be different from the path
4694 * stored in the registry. */
4695 SHGetFolderPathW(NULL
, folders
[i
] | CSIDL_FLAG_CREATE
,
4696 hToken
, SHGFP_TYPE_DEFAULT
, path
);
4700 RegCloseKey(hUserKey
);
4704 TRACE("returning 0x%08x\n", hr
);
4708 static HRESULT
_SHRegisterUserShellFolders(BOOL bDefault
)
4710 static const UINT folders
[] = {
4721 CSIDL_DESKTOPDIRECTORY
,
4725 CSIDL_LOCAL_APPDATA
,
4726 CSIDL_INTERNET_CACHE
,
4735 CSIDL_APPDATA_LOCALLOW
,
4739 WCHAR userShellFolderPath
[MAX_PATH
], shellFolderPath
[MAX_PATH
];
4740 LPCWSTR pUserShellFolderPath
, pShellFolderPath
;
4745 TRACE("%s\n", bDefault
? "TRUE" : "FALSE");
4748 hToken
= (HANDLE
)-1;
4749 hRootKey
= HKEY_USERS
;
4750 strcpyW(userShellFolderPath
, DefaultW
);
4751 PathAddBackslashW(userShellFolderPath
);
4752 strcatW(userShellFolderPath
, szSHUserFolders
);
4753 pUserShellFolderPath
= userShellFolderPath
;
4754 strcpyW(shellFolderPath
, DefaultW
);
4755 PathAddBackslashW(shellFolderPath
);
4756 strcatW(shellFolderPath
, szSHFolders
);
4757 pShellFolderPath
= shellFolderPath
;
4762 hRootKey
= HKEY_CURRENT_USER
;
4763 pUserShellFolderPath
= szSHUserFolders
;
4764 pShellFolderPath
= szSHFolders
;
4767 hr
= _SHRegisterFolders(hRootKey
, hToken
, pUserShellFolderPath
,
4768 pShellFolderPath
, folders
, ARRAY_SIZE(folders
));
4769 TRACE("returning 0x%08x\n", hr
);
4773 static HRESULT
_SHRegisterCommonShellFolders(void)
4775 static const UINT folders
[] = {
4776 CSIDL_COMMON_STARTMENU
,
4777 CSIDL_COMMON_PROGRAMS
,
4778 CSIDL_COMMON_STARTUP
,
4779 CSIDL_COMMON_DESKTOPDIRECTORY
,
4780 CSIDL_COMMON_FAVORITES
,
4781 CSIDL_COMMON_APPDATA
,
4782 CSIDL_COMMON_TEMPLATES
,
4783 CSIDL_COMMON_DOCUMENTS
,
4784 CSIDL_COMMON_ADMINTOOLS
,
4786 CSIDL_COMMON_PICTURES
,
4792 hr
= _SHRegisterFolders(HKEY_LOCAL_MACHINE
, NULL
, szSHUserFolders
,
4793 szSHFolders
, folders
, ARRAY_SIZE(folders
));
4794 TRACE("returning 0x%08x\n", hr
);
4798 /******************************************************************************
4799 * create_extra_folders [Internal]
4801 * Create some extra folders that don't have a standard CSIDL definition.
4803 static HRESULT
create_extra_folders(void)
4805 static const WCHAR environW
[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
4806 static const WCHAR microsoftW
[] = {'M','i','c','r','o','s','o','f','t',0};
4807 static const WCHAR TempW
[] = {'T','e','m','p',0};
4808 static const WCHAR TEMPW
[] = {'T','E','M','P',0};
4809 static const WCHAR TMPW
[] = {'T','M','P',0};
4810 WCHAR path
[MAX_PATH
+5];
4813 DWORD type
, size
, ret
;
4815 ret
= RegCreateKeyW( HKEY_CURRENT_USER
, environW
, &hkey
);
4816 if (ret
) return HRESULT_FROM_WIN32( ret
);
4818 /* FIXME: should be under AppData, but we don't want spaces in the temp path */
4819 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_PROFILE
| CSIDL_FLAG_CREATE
, NULL
,
4820 SHGFP_TYPE_DEFAULT
, TempW
, path
);
4823 size
= sizeof(path
);
4824 if (RegQueryValueExW( hkey
, TEMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4825 RegSetValueExW( hkey
, TEMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4826 size
= sizeof(path
);
4827 if (RegQueryValueExW( hkey
, TMPW
, NULL
, &type
, (LPBYTE
)path
, &size
))
4828 RegSetValueExW( hkey
, TMPW
, 0, REG_SZ
, (LPBYTE
)path
, (strlenW(path
) + 1) * sizeof(WCHAR
) );
4830 RegCloseKey( hkey
);
4834 hr
= SHGetFolderPathAndSubDirW( 0, CSIDL_COMMON_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4835 SHGFP_TYPE_DEFAULT
, microsoftW
, path
);
4839 hr
= SHGetFolderPathAndSubDirW(0, CSIDL_APPDATA
| CSIDL_FLAG_CREATE
, NULL
,
4840 SHGFP_TYPE_DEFAULT
, Microsoft_Windows_ThemesW
, path
);
4846 /******************************************************************************
4847 * set_folder_attributes
4849 * Set the various folder attributes registry keys.
4851 static HRESULT
set_folder_attributes(void)
4853 static const WCHAR clsidW
[] = {'C','L','S','I','D','\\',0 };
4854 static const WCHAR shellfolderW
[] = {'\\','S','h','e','l','l','F','o','l','d','e','r', 0 };
4855 static const WCHAR wfparsingW
[] = {'W','a','n','t','s','F','O','R','P','A','R','S','I','N','G',0};
4856 static const WCHAR wfdisplayW
[] = {'W','a','n','t','s','F','O','R','D','I','S','P','L','A','Y',0};
4857 static const WCHAR hideasdeleteW
[] = {'H','i','d','e','A','s','D','e','l','e','t','e','P','e','r','U','s','e','r',0};
4858 static const WCHAR cfattributesW
[] = {'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0};
4859 static const WCHAR emptyW
[] = {0};
4868 DWORD call_for_attr
;
4871 { &CLSID_UnixFolder
, TRUE
, FALSE
, FALSE
},
4872 { &CLSID_UnixDosFolder
, TRUE
, FALSE
, FALSE
,
4873 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4874 { &CLSID_FolderShortcut
, FALSE
, FALSE
, FALSE
,
4875 SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_LINK
,
4876 SFGAO_HASSUBFOLDER
|SFGAO_FILESYSTEM
|SFGAO_FOLDER
|SFGAO_FILESYSANCESTOR
},
4877 { &CLSID_MyDocuments
, TRUE
, FALSE
, FALSE
,
4878 SFGAO_FILESYSANCESTOR
|SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
, SFGAO_FILESYSTEM
},
4879 { &CLSID_RecycleBin
, FALSE
, FALSE
, FALSE
,
4880 SFGAO_FOLDER
|SFGAO_DROPTARGET
|SFGAO_HASPROPSHEET
},
4881 { &CLSID_ControlPanel
, FALSE
, TRUE
, TRUE
,
4882 SFGAO_FOLDER
|SFGAO_HASSUBFOLDER
}
4886 WCHAR buffer
[39 + ARRAY_SIZE(clsidW
) + ARRAY_SIZE(shellfolderW
)];
4890 for (i
= 0; i
< ARRAY_SIZE(folders
); i
++)
4892 strcpyW( buffer
, clsidW
);
4893 StringFromGUID2( folders
[i
].clsid
, buffer
+ strlenW(buffer
), 39 );
4894 strcatW( buffer
, shellfolderW
);
4895 res
= RegCreateKeyExW( HKEY_CLASSES_ROOT
, buffer
, 0, NULL
, 0,
4896 KEY_READ
| KEY_WRITE
, NULL
, &hkey
, NULL
);
4897 if (res
) return HRESULT_FROM_WIN32( res
);
4898 if (folders
[i
].wfparsing
)
4899 res
= RegSetValueExW( hkey
, wfparsingW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4900 if (folders
[i
].wfdisplay
)
4901 res
= RegSetValueExW( hkey
, wfdisplayW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4902 if (folders
[i
].hideasdel
)
4903 res
= RegSetValueExW( hkey
, hideasdeleteW
, 0, REG_SZ
, (const BYTE
*)emptyW
, sizeof(emptyW
) );
4904 if (folders
[i
].attr
)
4905 res
= RegSetValueExW( hkey
, szAttributes
, 0, REG_DWORD
,
4906 (const BYTE
*)&folders
[i
].attr
, sizeof(DWORD
));
4907 if (folders
[i
].call_for_attr
)
4908 res
= RegSetValueExW( hkey
, cfattributesW
, 0, REG_DWORD
,
4909 (const BYTE
*)&folders
[i
].call_for_attr
, sizeof(DWORD
));
4910 RegCloseKey( hkey
);
4915 /*************************************************************************
4916 * SHGetSpecialFolderPathA [SHELL32.@]
4918 BOOL WINAPI
SHGetSpecialFolderPathA (
4924 return SHGetFolderPathA(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4928 /*************************************************************************
4929 * SHGetSpecialFolderPathW
4931 BOOL WINAPI
SHGetSpecialFolderPathW (
4937 return SHGetFolderPathW(hwndOwner
, nFolder
+ (bCreate
? CSIDL_FLAG_CREATE
: 0), NULL
, 0,
4941 /*************************************************************************
4942 * SHGetSpecialFolderPath (SHELL32.175)
4944 BOOL WINAPI
SHGetSpecialFolderPathAW (
4951 if (SHELL_OsIsUnicode())
4952 return SHGetSpecialFolderPathW (hwndOwner
, szPath
, nFolder
, bCreate
);
4953 return SHGetSpecialFolderPathA (hwndOwner
, szPath
, nFolder
, bCreate
);
4956 /*************************************************************************
4957 * SHGetFolderLocation [SHELL32.@]
4959 * Gets the folder locations from the registry and creates a pidl.
4963 * nFolder [I] CSIDL_xxxxx
4964 * hToken [I] token representing user, or NULL for current user, or -1 for
4966 * dwReserved [I] must be zero
4967 * ppidl [O] PIDL of a special folder
4971 * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
4974 * Creates missing reg keys and directories.
4975 * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
4976 * virtual folders that are handled here.
4978 HRESULT WINAPI
SHGetFolderLocation(
4983 LPITEMIDLIST
*ppidl
)
4985 HRESULT hr
= E_INVALIDARG
;
4987 TRACE("%p 0x%08x %p 0x%08x %p\n",
4988 hwndOwner
, nFolder
, hToken
, dwReserved
, ppidl
);
4991 return E_INVALIDARG
;
4993 return E_INVALIDARG
;
4995 /* The virtual folders' locations are not user-dependent */
4997 switch (nFolder
& CSIDL_FOLDER_MASK
)
5000 *ppidl
= _ILCreateDesktop();
5003 case CSIDL_PERSONAL
:
5004 *ppidl
= _ILCreateMyDocuments();
5007 case CSIDL_INTERNET
:
5008 *ppidl
= _ILCreateIExplore();
5011 case CSIDL_CONTROLS
:
5012 *ppidl
= _ILCreateControlPanel();
5015 case CSIDL_PRINTERS
:
5016 *ppidl
= _ILCreatePrinters();
5019 case CSIDL_BITBUCKET
:
5020 *ppidl
= _ILCreateBitBucket();
5024 *ppidl
= _ILCreateMyComputer();
5028 *ppidl
= _ILCreateNetwork();
5033 WCHAR szPath
[MAX_PATH
];
5035 hr
= SHGetFolderPathW(hwndOwner
, nFolder
, hToken
,
5036 SHGFP_TYPE_CURRENT
, szPath
);
5041 TRACE("Value=%s\n", debugstr_w(szPath
));
5042 hr
= SHILCreateFromPathW(szPath
, ppidl
, &attributes
);
5044 else if (hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
))
5046 /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
5047 * version 6.0 returns E_FAIL for nonexistent paths
5056 TRACE("-- (new pidl %p)\n",*ppidl
);
5060 /*************************************************************************
5061 * SHGetSpecialFolderLocation [SHELL32.@]
5064 * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
5067 HRESULT WINAPI
SHGetSpecialFolderLocation(
5070 LPITEMIDLIST
* ppidl
)
5072 HRESULT hr
= E_INVALIDARG
;
5074 TRACE("(%p,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
5077 return E_INVALIDARG
;
5079 hr
= SHGetFolderLocation(hwndOwner
, nFolder
, NULL
, 0, ppidl
);
5083 /*************************************************************************
5084 * SHGetKnownFolderPath [SHELL32.@]
5086 HRESULT WINAPI
SHGetKnownFolderPath(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, WCHAR
**ret_path
)
5088 WCHAR pathW
[MAX_PATH
], tempW
[MAX_PATH
];
5092 int folder
= csidl_from_id(rfid
), shgfp_flags
;
5094 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, ret_path
);
5099 return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
5101 if (flags
& ~(KF_FLAG_CREATE
|KF_FLAG_SIMPLE_IDLIST
|KF_FLAG_DONT_UNEXPAND
|
5102 KF_FLAG_DONT_VERIFY
|KF_FLAG_NO_ALIAS
|KF_FLAG_INIT
|KF_FLAG_DEFAULT_PATH
))
5104 FIXME("flags 0x%08x not supported\n", flags
);
5105 return E_INVALIDARG
;
5108 shgfp_flags
= flags
& KF_FLAG_DEFAULT_PATH
? SHGFP_TYPE_DEFAULT
: SHGFP_TYPE_CURRENT
;
5110 type
= CSIDL_Data
[folder
].type
;
5113 case CSIDL_Type_Disallowed
:
5116 case CSIDL_Type_NonExistent
:
5120 case CSIDL_Type_WindowsPath
:
5121 GetWindowsDirectoryW(tempW
, MAX_PATH
);
5122 append_relative_path(folder
, tempW
);
5125 case CSIDL_Type_SystemPath
:
5126 GetSystemDirectoryW(tempW
, MAX_PATH
);
5127 append_relative_path(folder
, tempW
);
5130 case CSIDL_Type_SystemX86Path
:
5131 if (!GetSystemWow64DirectoryW(tempW
, MAX_PATH
)) GetSystemDirectoryW(tempW
, MAX_PATH
);
5132 append_relative_path(folder
, tempW
);
5135 case CSIDL_Type_CurrVer
:
5136 hr
= _SHGetCurrentVersionPath(shgfp_flags
, folder
, tempW
);
5138 case CSIDL_Type_User
:
5139 hr
= _SHGetUserProfilePath(token
, shgfp_flags
, folder
, tempW
);
5141 case CSIDL_Type_AllUsers
:
5142 case CSIDL_Type_ProgramData
:
5143 hr
= _SHGetAllUsersProfilePath(shgfp_flags
, folder
, tempW
);
5146 FIXME("bogus type %d, please fix\n", type
);
5154 /* Expand environment strings if necessary */
5157 hr
= _SHExpandEnvironmentStrings(tempW
, pathW
);
5162 strcpyW(pathW
, tempW
);
5164 /* if we don't care about existing directories we are ready */
5165 if (flags
& KF_FLAG_DONT_VERIFY
) goto done
;
5167 if (PathFileExistsW(pathW
)) goto done
;
5169 /* Does not exist but we are not allowed to create it. The return value
5170 * is verified against shell32 version 6.0.
5172 if (!(flags
& KF_FLAG_CREATE
))
5174 hr
= HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
);
5178 /* create symbolic links rather than directories for specific
5179 * user shell folders */
5180 _SHCreateSymbolicLink(folder
);
5182 /* create directory/directories */
5183 ret
= SHCreateDirectoryExW(NULL
, pathW
, NULL
);
5184 if (ret
&& ret
!= ERROR_ALREADY_EXISTS
)
5186 ERR("Failed to create directory %s.\n", debugstr_w(pathW
));
5191 TRACE("Created missing system directory %s\n", debugstr_w(pathW
));
5194 TRACE("Final path is %s, %#x\n", debugstr_w(pathW
), hr
);
5196 *ret_path
= CoTaskMemAlloc((strlenW(pathW
) + 1) * sizeof(WCHAR
));
5198 return E_OUTOFMEMORY
;
5199 strcpyW(*ret_path
, pathW
);
5204 TRACE("Failed to get folder path, %#x.\n", hr
);
5209 /*************************************************************************
5210 * SHGetFolderPathEx [SHELL32.@]
5212 HRESULT WINAPI
SHGetFolderPathEx(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, LPWSTR path
, DWORD len
)
5217 TRACE("%s, 0x%08x, %p, %p, %u\n", debugstr_guid(rfid
), flags
, token
, path
, len
);
5219 if (!path
|| !len
) return E_INVALIDARG
;
5221 hr
= SHGetKnownFolderPath( rfid
, flags
, token
, &buffer
);
5222 if (SUCCEEDED( hr
))
5224 if (strlenW( buffer
) + 1 > len
)
5226 CoTaskMemFree( buffer
);
5227 return HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER
);
5229 strcpyW( path
, buffer
);
5230 CoTaskMemFree( buffer
);
5236 * Internal function to convert known folder identifier to path of registry key
5237 * associated with known folder.
5240 * rfid [I] pointer to known folder identifier (may be NULL)
5241 * lpStringGuid [I] string with known folder identifier (used when rfid is NULL)
5242 * lpPath [O] place to store string address. String should be
5243 * later freed using HeapFree(GetProcessHeap(),0, ... )
5245 static HRESULT
get_known_folder_registry_path(
5246 REFKNOWNFOLDERID rfid
,
5247 LPWSTR lpStringGuid
,
5250 static const WCHAR sBackslash
[] = {'\\',0};
5255 TRACE("(%s, %s, %p)\n", debugstr_guid(rfid
), debugstr_w(lpStringGuid
), lpPath
);
5258 StringFromGUID2(rfid
, sGuid
, ARRAY_SIZE(sGuid
));
5260 lstrcpyW(sGuid
, lpStringGuid
);
5262 length
= lstrlenW(szKnownFolderDescriptions
)+51;
5263 *lpPath
= heap_alloc(length
*sizeof(WCHAR
));
5269 lstrcpyW(*lpPath
, szKnownFolderDescriptions
);
5270 lstrcatW(*lpPath
, sBackslash
);
5271 lstrcatW(*lpPath
, sGuid
);
5277 static HRESULT
get_known_folder_wstr(const WCHAR
*regpath
, const WCHAR
*value
, WCHAR
**out
)
5283 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
));
5287 *out
= CoTaskMemAlloc(size
);
5289 return E_OUTOFMEMORY
;
5291 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, regpath
, value
, RRF_RT_REG_SZ
, NULL
, *out
, &size
));
5293 CoTaskMemFree(*out
);
5300 static HRESULT
get_known_folder_dword(const WCHAR
*registryPath
, const WCHAR
*value
, DWORD
*out
)
5302 DWORD dwSize
= sizeof(DWORD
);
5304 return HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, value
, RRF_RT_DWORD
, &dwType
, out
, &dwSize
));
5308 * Internal function to get place where folder redirection information are stored.
5311 * rfid [I] pointer to known folder identifier (may be NULL)
5312 * rootKey [O] root key where the redirection information are stored
5313 * It can be HKLM for COMMON folders, and HKCU for PERUSER folders.
5314 * However, besides root key, path is always that same, and is stored
5315 * as "szKnownFolderRedirections" constant
5317 static HRESULT
get_known_folder_redirection_place(
5318 REFKNOWNFOLDERID rfid
,
5322 LPWSTR lpRegistryPath
= NULL
;
5323 KF_CATEGORY category
;
5325 /* first, get known folder's category */
5326 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5329 hr
= get_known_folder_dword(lpRegistryPath
, szCategory
, &category
);
5333 if(category
== KF_CATEGORY_COMMON
)
5335 *rootKey
= HKEY_LOCAL_MACHINE
;
5338 else if(category
== KF_CATEGORY_PERUSER
)
5340 *rootKey
= HKEY_CURRENT_USER
;
5347 heap_free(lpRegistryPath
);
5351 static HRESULT
get_known_folder_path_by_id(REFKNOWNFOLDERID folderId
, LPWSTR lpRegistryPath
, DWORD dwFlags
, LPWSTR
*ppszPath
);
5353 static HRESULT
redirect_known_folder(
5354 REFKNOWNFOLDERID rfid
,
5356 KF_REDIRECT_FLAGS flags
,
5357 LPCWSTR pszTargetPath
,
5359 KNOWNFOLDERID
const *pExclusion
,
5363 HKEY rootKey
= HKEY_LOCAL_MACHINE
, hKey
;
5365 LPWSTR lpRegistryPath
= NULL
, lpSrcPath
= NULL
;
5366 TRACE("(%s, %p, 0x%08x, %s, %d, %p, %p)\n", debugstr_guid(rfid
), hwnd
, flags
, debugstr_w(pszTargetPath
), cFolders
, pExclusion
, ppszError
);
5368 if (ppszError
) *ppszError
= NULL
;
5370 hr
= get_known_folder_registry_path(rfid
, NULL
, &lpRegistryPath
);
5373 hr
= get_known_folder_path_by_id(rfid
, lpRegistryPath
, 0, &lpSrcPath
);
5375 heap_free(lpRegistryPath
);
5377 /* get path to redirection storage */
5379 hr
= get_known_folder_redirection_place(rfid
, &rootKey
);
5381 /* write redirection information */
5383 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(rootKey
, szKnownFolderRedirections
, 0, NULL
, 0, KEY_WRITE
, NULL
, &hKey
, NULL
));
5387 StringFromGUID2(rfid
, sGuid
, ARRAY_SIZE(sGuid
));
5389 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, sGuid
, 0, REG_SZ
, (LPBYTE
)pszTargetPath
, (lstrlenW(pszTargetPath
)+1)*sizeof(WCHAR
)));
5394 /* make sure destination path exists */
5395 SHCreateDirectory(NULL
, pszTargetPath
);
5397 /* copy content if required */
5398 if(SUCCEEDED(hr
) && (flags
& KF_REDIRECT_COPY_CONTENTS
) )
5400 static const WCHAR sWildcard
[] = {'\\','*',0};
5401 WCHAR srcPath
[MAX_PATH
+1], dstPath
[MAX_PATH
+1];
5402 SHFILEOPSTRUCTW fileOp
;
5404 ZeroMemory(srcPath
, sizeof(srcPath
));
5405 lstrcpyW(srcPath
, lpSrcPath
);
5406 lstrcatW(srcPath
, sWildcard
);
5408 ZeroMemory(dstPath
, sizeof(dstPath
));
5409 lstrcpyW(dstPath
, pszTargetPath
);
5411 ZeroMemory(&fileOp
, sizeof(fileOp
));
5413 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5414 fileOp
.wFunc
= FO_MOVE
;
5416 fileOp
.wFunc
= FO_COPY
;
5418 fileOp
.pFrom
= srcPath
;
5419 fileOp
.pTo
= dstPath
;
5420 fileOp
.fFlags
= FOF_NO_UI
;
5422 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5424 if(flags
& KF_REDIRECT_DEL_SOURCE_CONTENTS
)
5426 ZeroMemory(srcPath
, sizeof(srcPath
));
5427 lstrcpyW(srcPath
, lpSrcPath
);
5429 ZeroMemory(&fileOp
, sizeof(fileOp
));
5430 fileOp
.wFunc
= FO_DELETE
;
5431 fileOp
.pFrom
= srcPath
;
5432 fileOp
.fFlags
= FOF_NO_UI
;
5434 hr
= (SHFileOperationW(&fileOp
)==0 ? S_OK
: E_FAIL
);
5438 CoTaskMemFree(lpSrcPath
);
5446 IKnownFolder IKnownFolder_iface
;
5449 LPWSTR registryPath
;
5452 static inline struct knownfolder
*impl_from_IKnownFolder( IKnownFolder
*iface
)
5454 return CONTAINING_RECORD( iface
, struct knownfolder
, IKnownFolder_iface
);
5457 static ULONG WINAPI
knownfolder_AddRef(
5458 IKnownFolder
*iface
)
5460 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5461 return InterlockedIncrement( &knownfolder
->refs
);
5464 static ULONG WINAPI
knownfolder_Release(
5465 IKnownFolder
*iface
)
5467 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5468 LONG refs
= InterlockedDecrement( &knownfolder
->refs
);
5471 TRACE("destroying %p\n", knownfolder
);
5472 heap_free( knownfolder
->registryPath
);
5473 heap_free( knownfolder
);
5478 static HRESULT WINAPI
knownfolder_QueryInterface(
5479 IKnownFolder
*iface
,
5483 struct knownfolder
*This
= impl_from_IKnownFolder( iface
);
5485 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5488 if ( IsEqualGUID( riid
, &IID_IKnownFolder
) ||
5489 IsEqualGUID( riid
, &IID_IUnknown
) )
5493 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5495 TRACE("IID_IMarshal returning NULL.\n");
5496 return E_NOINTERFACE
;
5500 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5501 return E_NOINTERFACE
;
5503 IKnownFolder_AddRef( iface
);
5507 static HRESULT
knownfolder_set_id(
5508 struct knownfolder
*knownfolder
,
5509 const KNOWNFOLDERID
*kfid
)
5514 TRACE("%s\n", debugstr_guid(kfid
));
5516 knownfolder
->id
= *kfid
;
5518 /* check is it registry-registered folder */
5519 hr
= get_known_folder_registry_path(kfid
, NULL
, &knownfolder
->registryPath
);
5521 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, 0, 0, &hKey
));
5530 /* This known folder is not registered. To mark it, we set registryPath to NULL */
5531 heap_free(knownfolder
->registryPath
);
5532 knownfolder
->registryPath
= NULL
;
5539 static HRESULT WINAPI
knownfolder_GetId(
5540 IKnownFolder
*iface
,
5541 KNOWNFOLDERID
*pkfid
)
5543 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5545 TRACE("%p\n", pkfid
);
5547 *pkfid
= knownfolder
->id
;
5551 static HRESULT WINAPI
knownfolder_GetCategory(
5552 IKnownFolder
*iface
,
5553 KF_CATEGORY
*pCategory
)
5555 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5558 TRACE("%p, %p\n", knownfolder
, pCategory
);
5560 /* we cannot get a category for a folder which is not registered */
5561 if(!knownfolder
->registryPath
)
5565 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, pCategory
);
5570 static HRESULT WINAPI
knownfolder_GetShellItem(
5571 IKnownFolder
*iface
,
5576 struct knownfolder
*knownfolder
= impl_from_IKnownFolder(iface
);
5577 TRACE("(%p, 0x%08x, %s, %p)\n", knownfolder
, flags
, debugstr_guid(riid
), ppv
);
5578 return SHGetKnownFolderItem(&knownfolder
->id
, flags
, NULL
, riid
, ppv
);
5581 static HRESULT
get_known_folder_path(
5583 LPWSTR registryPath
,
5586 static const WCHAR sBackslash
[] = {'\\',0};
5588 DWORD dwSize
, dwType
;
5589 WCHAR path
[MAX_PATH
] = {0};
5590 WCHAR parentGuid
[39];
5591 KF_CATEGORY category
;
5592 LPWSTR parentRegistryPath
, parentPath
;
5593 HKEY hRedirectionRootKey
= NULL
;
5595 TRACE("(%s, %p)\n", debugstr_w(registryPath
), ppszPath
);
5598 /* check if folder has parent */
5599 dwSize
= sizeof(parentGuid
);
5600 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szParentFolder
, RRF_RT_REG_SZ
, &dwType
, parentGuid
, &dwSize
));
5601 if(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)) hr
= S_FALSE
;
5605 /* get parent's known folder path (recursive) */
5606 hr
= get_known_folder_registry_path(NULL
, parentGuid
, &parentRegistryPath
);
5607 if(FAILED(hr
)) return hr
;
5609 hr
= get_known_folder_path(parentGuid
, parentRegistryPath
, &parentPath
);
5611 heap_free(parentRegistryPath
);
5615 lstrcatW(path
, parentPath
);
5616 lstrcatW(path
, sBackslash
);
5618 heap_free(parentRegistryPath
);
5619 heap_free(parentPath
);
5622 /* check, if folder was redirected */
5624 hr
= get_known_folder_dword(registryPath
, szCategory
, &category
);
5628 if(category
== KF_CATEGORY_COMMON
)
5629 hRedirectionRootKey
= HKEY_LOCAL_MACHINE
;
5630 else if(category
== KF_CATEGORY_PERUSER
)
5631 hRedirectionRootKey
= HKEY_CURRENT_USER
;
5633 if(hRedirectionRootKey
)
5635 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, NULL
, &dwSize
));
5639 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5640 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5645 lstrcpyW(*ppszPath
, path
);
5646 hr
= HRESULT_FROM_WIN32(RegGetValueW(hRedirectionRootKey
, szKnownFolderRedirections
, sFolderId
, RRF_RT_REG_SZ
, NULL
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5652 /* no redirection, use previous way - read the relative path from folder definition */
5653 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, NULL
, &dwSize
));
5657 *ppszPath
= CoTaskMemAlloc(dwSize
+(lstrlenW(path
)+1)*sizeof(WCHAR
));
5658 if(!*ppszPath
) hr
= E_OUTOFMEMORY
;
5663 lstrcpyW(*ppszPath
, path
);
5664 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, registryPath
, szRelativePath
, RRF_RT_REG_SZ
, &dwType
, *ppszPath
+ lstrlenW(path
), &dwSize
));
5669 TRACE("returning path: %s\n", debugstr_w(*ppszPath
));
5673 static HRESULT
get_known_folder_path_by_id(
5674 REFKNOWNFOLDERID folderId
,
5675 LPWSTR lpRegistryPath
,
5679 HRESULT hr
= E_FAIL
;
5683 TRACE("(%s, %s, 0x%08x, %p)\n", debugstr_guid(folderId
), debugstr_w(lpRegistryPath
), dwFlags
, ppszPath
);
5685 /* if this is registry-registered known folder, get path from registry */
5688 StringFromGUID2(folderId
, sGuid
, ARRAY_SIZE(sGuid
));
5690 hr
= get_known_folder_path(sGuid
, lpRegistryPath
, ppszPath
);
5692 /* in other case, use older way */
5695 hr
= SHGetKnownFolderPath( folderId
, dwFlags
, NULL
, ppszPath
);
5697 if (FAILED(hr
)) return hr
;
5699 /* check if known folder really exists */
5700 dwAttributes
= GetFileAttributesW(*ppszPath
);
5701 if(dwAttributes
== INVALID_FILE_ATTRIBUTES
|| !(dwAttributes
& FILE_ATTRIBUTE_DIRECTORY
) )
5703 TRACE("directory %s not found\n", debugstr_w(*ppszPath
));
5704 CoTaskMemFree(*ppszPath
);
5706 hr
= HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
);
5712 static HRESULT WINAPI
knownfolder_GetPath(
5713 IKnownFolder
*iface
,
5717 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5718 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, dwFlags
, ppszPath
);
5720 return get_known_folder_path_by_id(&knownfolder
->id
, knownfolder
->registryPath
, dwFlags
, ppszPath
);
5723 static HRESULT WINAPI
knownfolder_SetPath(
5724 IKnownFolder
*iface
,
5728 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5731 TRACE("(%p, 0x%08x, %s)\n", knownfolder
, dwFlags
, debugstr_w(pszPath
));
5733 /* check if the known folder is registered */
5734 if(!knownfolder
->registryPath
)
5738 hr
= redirect_known_folder(&knownfolder
->id
, NULL
, 0, pszPath
, 0, NULL
, NULL
);
5743 static HRESULT WINAPI
knownfolder_GetIDList(
5744 IKnownFolder
*iface
,
5746 PIDLIST_ABSOLUTE
*ppidl
)
5748 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5749 TRACE("(%p, 0x%08x, %p)\n", knownfolder
, flags
, ppidl
);
5750 return SHGetKnownFolderIDList(&knownfolder
->id
, flags
, NULL
, ppidl
);
5753 static HRESULT WINAPI
knownfolder_GetFolderType(
5754 IKnownFolder
*iface
,
5755 FOLDERTYPEID
*pftid
)
5757 FIXME("%p\n", pftid
);
5761 static HRESULT WINAPI
knownfolder_GetRedirectionCapabilities(
5762 IKnownFolder
*iface
,
5763 KF_REDIRECTION_CAPABILITIES
*pCapabilities
)
5765 FIXME("%p stub\n", pCapabilities
);
5766 if(!pCapabilities
) return E_INVALIDARG
;
5767 *pCapabilities
= KF_REDIRECTION_CAPABILITIES_DENY_ALL
;
5771 static HRESULT WINAPI
knownfolder_GetFolderDefinition(
5772 IKnownFolder
*iface
,
5773 KNOWNFOLDER_DEFINITION
*pKFD
)
5775 struct knownfolder
*knownfolder
= impl_from_IKnownFolder( iface
);
5778 WCHAR parentGuid
[39];
5779 TRACE("(%p, %p)\n", knownfolder
, pKFD
);
5781 if(!pKFD
) return E_INVALIDARG
;
5783 ZeroMemory(pKFD
, sizeof(*pKFD
));
5785 /* required fields */
5786 hr
= get_known_folder_dword(knownfolder
->registryPath
, szCategory
, &pKFD
->category
);
5790 hr
= get_known_folder_wstr(knownfolder
->registryPath
, szName
, &pKFD
->pszName
);
5794 /* optional fields */
5795 dwSize
= sizeof(parentGuid
);
5796 hr
= HRESULT_FROM_WIN32(RegGetValueW(HKEY_LOCAL_MACHINE
, knownfolder
->registryPath
, szParentFolder
,
5797 RRF_RT_REG_SZ
, NULL
, parentGuid
, &dwSize
));
5800 hr
= IIDFromString(parentGuid
, &pKFD
->fidParent
);
5805 get_known_folder_dword(knownfolder
->registryPath
, szAttributes
, &pKFD
->dwAttributes
);
5807 get_known_folder_wstr(knownfolder
->registryPath
, szRelativePath
, &pKFD
->pszRelativePath
);
5809 get_known_folder_wstr(knownfolder
->registryPath
, szParsingName
, &pKFD
->pszParsingName
);
5814 static const struct IKnownFolderVtbl knownfolder_vtbl
=
5816 knownfolder_QueryInterface
,
5818 knownfolder_Release
,
5820 knownfolder_GetCategory
,
5821 knownfolder_GetShellItem
,
5822 knownfolder_GetPath
,
5823 knownfolder_SetPath
,
5824 knownfolder_GetIDList
,
5825 knownfolder_GetFolderType
,
5826 knownfolder_GetRedirectionCapabilities
,
5827 knownfolder_GetFolderDefinition
5830 static HRESULT
knownfolder_create( struct knownfolder
**knownfolder
)
5832 struct knownfolder
*kf
;
5834 kf
= heap_alloc( sizeof(*kf
) );
5835 if (!kf
) return E_OUTOFMEMORY
;
5837 kf
->IKnownFolder_iface
.lpVtbl
= &knownfolder_vtbl
;
5839 memset( &kf
->id
, 0, sizeof(kf
->id
) );
5840 kf
->registryPath
= NULL
;
5844 TRACE("returning iface %p\n", &kf
->IKnownFolder_iface
);
5848 struct foldermanager
5850 IKnownFolderManager IKnownFolderManager_iface
;
5856 static inline struct foldermanager
*impl_from_IKnownFolderManager( IKnownFolderManager
*iface
)
5858 return CONTAINING_RECORD( iface
, struct foldermanager
, IKnownFolderManager_iface
);
5861 static ULONG WINAPI
foldermanager_AddRef(
5862 IKnownFolderManager
*iface
)
5864 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5865 return InterlockedIncrement( &foldermanager
->refs
);
5868 static ULONG WINAPI
foldermanager_Release(
5869 IKnownFolderManager
*iface
)
5871 struct foldermanager
*foldermanager
= impl_from_IKnownFolderManager( iface
);
5872 LONG refs
= InterlockedDecrement( &foldermanager
->refs
);
5875 TRACE("destroying %p\n", foldermanager
);
5876 heap_free( foldermanager
->ids
);
5877 heap_free( foldermanager
);
5882 static HRESULT WINAPI
foldermanager_QueryInterface(
5883 IKnownFolderManager
*iface
,
5887 struct foldermanager
*This
= impl_from_IKnownFolderManager( iface
);
5889 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppv
);
5892 if ( IsEqualGUID( riid
, &IID_IKnownFolderManager
) ||
5893 IsEqualGUID( riid
, &IID_IUnknown
) )
5897 else if ( IsEqualGUID( riid
, &IID_IMarshal
) )
5899 TRACE("IID_IMarshal returning NULL.\n");
5900 return E_NOINTERFACE
;
5904 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
5905 return E_NOINTERFACE
;
5907 IKnownFolderManager_AddRef( iface
);
5911 static HRESULT WINAPI
foldermanager_FolderIdFromCsidl(
5912 IKnownFolderManager
*iface
,
5914 KNOWNFOLDERID
*pfid
)
5916 TRACE("%d, %p\n", nCsidl
, pfid
);
5918 if (nCsidl
>= ARRAY_SIZE(CSIDL_Data
))
5919 return E_INVALIDARG
;
5920 *pfid
= *CSIDL_Data
[nCsidl
].id
;
5924 static HRESULT WINAPI
foldermanager_FolderIdToCsidl(
5925 IKnownFolderManager
*iface
,
5926 REFKNOWNFOLDERID rfid
,
5931 TRACE("%s, %p\n", debugstr_guid(rfid
), pnCsidl
);
5933 csidl
= csidl_from_id( rfid
);
5934 if (csidl
== -1) return E_INVALIDARG
;
5939 static HRESULT WINAPI
foldermanager_GetFolderIds(
5940 IKnownFolderManager
*iface
,
5941 KNOWNFOLDERID
**ppKFId
,
5944 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5946 TRACE("%p, %p\n", ppKFId
, pCount
);
5948 *ppKFId
= CoTaskMemAlloc(fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5949 memcpy(*ppKFId
, fm
->ids
, fm
->num_ids
* sizeof(KNOWNFOLDERID
));
5950 *pCount
= fm
->num_ids
;
5954 static BOOL
is_knownfolder( struct foldermanager
*fm
, const KNOWNFOLDERID
*id
)
5958 LPWSTR registryPath
= NULL
;
5961 /* TODO: move all entries from "CSIDL_Data" static array to registry known folder descriptions */
5962 for (i
= 0; i
< fm
->num_ids
; i
++)
5963 if (IsEqualGUID( &fm
->ids
[i
], id
)) return TRUE
;
5965 hr
= get_known_folder_registry_path(id
, NULL
, ®istryPath
);
5968 hr
= HRESULT_FROM_WIN32(RegOpenKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, 0, &hKey
));
5969 heap_free(registryPath
);
5981 static HRESULT WINAPI
foldermanager_GetFolder(
5982 IKnownFolderManager
*iface
,
5983 REFKNOWNFOLDERID rfid
,
5984 IKnownFolder
**ppkf
)
5986 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
5987 struct knownfolder
*kf
;
5990 TRACE("%s, %p\n", debugstr_guid(rfid
), ppkf
);
5992 if (!is_knownfolder( fm
, rfid
))
5994 WARN("unknown folder\n");
5995 return E_INVALIDARG
;
5997 hr
= knownfolder_create( &kf
);
5998 if (SUCCEEDED( hr
))
6000 hr
= knownfolder_set_id( kf
, rfid
);
6001 *ppkf
= &kf
->IKnownFolder_iface
;
6009 static HRESULT WINAPI
foldermanager_GetFolderByName(
6010 IKnownFolderManager
*iface
,
6011 LPCWSTR pszCanonicalName
,
6012 IKnownFolder
**ppkf
)
6014 struct foldermanager
*fm
= impl_from_IKnownFolderManager( iface
);
6015 struct knownfolder
*kf
;
6020 TRACE( "%s, %p\n", debugstr_w(pszCanonicalName
), ppkf
);
6022 for (i
= 0; i
< fm
->num_ids
; i
++)
6025 hr
= get_known_folder_registry_path( &fm
->ids
[i
], NULL
, &path
);
6026 if (FAILED( hr
)) return hr
;
6028 hr
= get_known_folder_wstr( path
, szName
, &name
);
6030 if (FAILED( hr
)) return hr
;
6032 found
= !strcmpiW( pszCanonicalName
, name
);
6033 CoTaskMemFree( name
);
6039 hr
= knownfolder_create( &kf
);
6040 if (FAILED( hr
)) return hr
;
6042 hr
= knownfolder_set_id( kf
, &fm
->ids
[i
] );
6045 IKnownFolder_Release( &kf
->IKnownFolder_iface
);
6048 *ppkf
= &kf
->IKnownFolder_iface
;
6052 hr
= HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND
);
6059 static HRESULT
register_folder(const KNOWNFOLDERID
*rfid
, const KNOWNFOLDER_DEFINITION
*pKFD
)
6064 LPWSTR registryPath
= NULL
;
6066 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
6067 TRACE("registry path: %s\n", debugstr_w(registryPath
));
6070 hr
= HRESULT_FROM_WIN32(RegCreateKeyExW(HKEY_LOCAL_MACHINE
, registryPath
, 0, NULL
, 0, KEY_WRITE
, 0, &hKey
, &dwDisp
));
6074 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szCategory
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->category
, sizeof(pKFD
->category
)));
6076 if(SUCCEEDED(hr
) && pKFD
->dwAttributes
!= 0)
6077 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szAttributes
, 0, REG_DWORD
, (LPBYTE
)&pKFD
->dwAttributes
, sizeof(pKFD
->dwAttributes
)));
6080 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszName
, (lstrlenW(pKFD
->pszName
)+1)*sizeof(WCHAR
) ));
6082 if(SUCCEEDED(hr
) && pKFD
->pszParsingName
)
6083 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParsingName
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszParsingName
, (lstrlenW(pKFD
->pszParsingName
)+1)*sizeof(WCHAR
) ));
6085 if(SUCCEEDED(hr
) && !IsEqualGUID(&pKFD
->fidParent
, &GUID_NULL
))
6087 WCHAR sParentGuid
[39];
6088 StringFromGUID2(&pKFD
->fidParent
, sParentGuid
, ARRAY_SIZE(sParentGuid
));
6090 /* this known folder has parent folder */
6091 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szParentFolder
, 0, REG_SZ
, (LPBYTE
)sParentGuid
, sizeof(sParentGuid
)));
6094 if(SUCCEEDED(hr
) && pKFD
->category
!= KF_CATEGORY_VIRTUAL
&& pKFD
->pszRelativePath
)
6095 hr
= HRESULT_FROM_WIN32(RegSetValueExW(hKey
, szRelativePath
, 0, REG_SZ
, (LPBYTE
)pKFD
->pszRelativePath
, (lstrlenW(pKFD
->pszRelativePath
)+1)*sizeof(WCHAR
) ));
6100 SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
);
6103 heap_free(registryPath
);
6107 static HRESULT WINAPI
foldermanager_RegisterFolder(
6108 IKnownFolderManager
*iface
,
6109 REFKNOWNFOLDERID rfid
,
6110 KNOWNFOLDER_DEFINITION
const *pKFD
)
6112 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(rfid
), pKFD
);
6113 return register_folder(rfid
, pKFD
);
6116 static HRESULT WINAPI
foldermanager_UnregisterFolder(
6117 IKnownFolderManager
*iface
,
6118 REFKNOWNFOLDERID rfid
)
6121 LPWSTR registryPath
= NULL
;
6122 TRACE("(%p, %s)\n", iface
, debugstr_guid(rfid
));
6124 hr
= get_known_folder_registry_path(rfid
, NULL
, ®istryPath
);
6127 hr
= HRESULT_FROM_WIN32(SHDeleteKeyW(HKEY_LOCAL_MACHINE
, registryPath
));
6129 heap_free(registryPath
);
6133 static HRESULT WINAPI
foldermanager_FindFolderFromPath(
6134 IKnownFolderManager
*iface
,
6137 IKnownFolder
**ppkf
)
6139 FIXME("%s, 0x%08x, %p\n", debugstr_w(pszPath
), mode
, ppkf
);
6143 static HRESULT WINAPI
foldermanager_FindFolderFromIDList(
6144 IKnownFolderManager
*iface
,
6145 PCIDLIST_ABSOLUTE pidl
,
6146 IKnownFolder
**ppkf
)
6148 FIXME("%p, %p\n", pidl
, ppkf
);
6152 static HRESULT WINAPI
foldermanager_Redirect(
6153 IKnownFolderManager
*iface
,
6154 REFKNOWNFOLDERID rfid
,
6156 KF_REDIRECT_FLAGS flags
,
6157 LPCWSTR pszTargetPath
,
6159 KNOWNFOLDERID
const *pExclusion
,
6162 return redirect_known_folder(rfid
, hwnd
, flags
, pszTargetPath
, cFolders
, pExclusion
, ppszError
);
6165 static const struct IKnownFolderManagerVtbl foldermanager_vtbl
=
6167 foldermanager_QueryInterface
,
6168 foldermanager_AddRef
,
6169 foldermanager_Release
,
6170 foldermanager_FolderIdFromCsidl
,
6171 foldermanager_FolderIdToCsidl
,
6172 foldermanager_GetFolderIds
,
6173 foldermanager_GetFolder
,
6174 foldermanager_GetFolderByName
,
6175 foldermanager_RegisterFolder
,
6176 foldermanager_UnregisterFolder
,
6177 foldermanager_FindFolderFromPath
,
6178 foldermanager_FindFolderFromIDList
,
6179 foldermanager_Redirect
6182 static HRESULT
foldermanager_create( void **ppv
)
6185 struct foldermanager
*fm
;
6187 fm
= heap_alloc( sizeof(*fm
) );
6188 if (!fm
) return E_OUTOFMEMORY
;
6190 fm
->IKnownFolderManager_iface
.lpVtbl
= &foldermanager_vtbl
;
6194 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
6196 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
)) fm
->num_ids
++;
6198 fm
->ids
= heap_alloc( fm
->num_ids
* sizeof(KNOWNFOLDERID
) );
6202 return E_OUTOFMEMORY
;
6204 for (i
= j
= 0; i
< ARRAY_SIZE(CSIDL_Data
); i
++)
6206 if (!IsEqualGUID( CSIDL_Data
[i
].id
, &GUID_NULL
))
6208 fm
->ids
[j
] = *CSIDL_Data
[i
].id
;
6212 TRACE("found %u known folders\n", fm
->num_ids
);
6213 *ppv
= &fm
->IKnownFolderManager_iface
;
6215 TRACE("returning iface %p\n", *ppv
);
6219 HRESULT WINAPI
KnownFolderManager_Constructor( IUnknown
*punk
, REFIID riid
, void **ppv
)
6221 TRACE("%p, %s, %p\n", punk
, debugstr_guid(riid
), ppv
);
6226 return CLASS_E_NOAGGREGATION
;
6228 return foldermanager_create( ppv
);
6231 HRESULT WINAPI
SHGetKnownFolderIDList(REFKNOWNFOLDERID rfid
, DWORD flags
, HANDLE token
, PIDLIST_ABSOLUTE
*pidl
)
6233 TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid
), flags
, token
, pidl
);
6236 return E_INVALIDARG
;
6239 FIXME("unsupported flags: 0x%08x\n", flags
);
6242 FIXME("user token is not used.\n");
6245 if (IsEqualIID(rfid
, &FOLDERID_Desktop
))
6246 *pidl
= _ILCreateDesktop();
6247 else if (IsEqualIID(rfid
, &FOLDERID_RecycleBinFolder
))
6248 *pidl
= _ILCreateBitBucket();
6249 else if (IsEqualIID(rfid
, &FOLDERID_ComputerFolder
))
6250 *pidl
= _ILCreateMyComputer();
6251 else if (IsEqualIID(rfid
, &FOLDERID_PrintersFolder
))
6252 *pidl
= _ILCreatePrinters();
6253 else if (IsEqualIID(rfid
, &FOLDERID_ControlPanelFolder
))
6254 *pidl
= _ILCreateControlPanel();
6255 else if (IsEqualIID(rfid
, &FOLDERID_NetworkFolder
))
6256 *pidl
= _ILCreateNetwork();
6257 else if (IsEqualIID(rfid
, &FOLDERID_Documents
))
6258 *pidl
= _ILCreateMyDocuments();
6261 DWORD attributes
= 0;
6265 hr
= SHGetKnownFolderPath(rfid
, flags
, token
, &pathW
);
6269 hr
= SHILCreateFromPathW(pathW
, pidl
, &attributes
);
6270 CoTaskMemFree(pathW
);
6274 return *pidl
? S_OK
: E_FAIL
;
6277 HRESULT WINAPI
SHGetKnownFolderItem(REFKNOWNFOLDERID rfid
, KNOWN_FOLDER_FLAG flags
, HANDLE hToken
,
6278 REFIID riid
, void **ppv
)
6280 PIDLIST_ABSOLUTE pidl
;
6283 TRACE("%s, 0x%08x, %p, %s, %p\n", debugstr_guid(rfid
), flags
, hToken
, debugstr_guid(riid
), ppv
);
6285 hr
= SHGetKnownFolderIDList(rfid
, flags
, hToken
, &pidl
);
6292 hr
= SHCreateItemFromIDList(pidl
, riid
, ppv
);
6293 CoTaskMemFree(pidl
);
6297 static void register_system_knownfolders(void)
6301 for (i
= 0; i
< ARRAY_SIZE(CSIDL_Data
); ++i
)
6303 const CSIDL_DATA
*folder
= &CSIDL_Data
[i
];
6304 if(folder
->pszName
){
6305 KNOWNFOLDER_DEFINITION kfd
;
6307 /* register_folder won't modify kfd, so cast away const instead of
6309 kfd
.category
= folder
->category
;
6310 kfd
.pszName
= (WCHAR
*)folder
->pszName
;
6311 kfd
.pszDescription
= (WCHAR
*)folder
->pszDescription
;
6312 memcpy(&kfd
.fidParent
, folder
->fidParent
, sizeof(KNOWNFOLDERID
));
6313 kfd
.pszRelativePath
= (WCHAR
*)folder
->pszRelativePath
;
6314 kfd
.pszParsingName
= (WCHAR
*)folder
->pszParsingName
;
6315 kfd
.pszTooltip
= (WCHAR
*)folder
->pszTooltip
;
6316 kfd
.pszLocalizedName
= (WCHAR
*)folder
->pszLocalizedName
;
6317 kfd
.pszIcon
= (WCHAR
*)folder
->pszIcon
;
6318 kfd
.pszSecurity
= (WCHAR
*)folder
->pszSecurity
;
6319 kfd
.dwAttributes
= folder
->dwAttributes
;
6320 kfd
.kfdFlags
= folder
->kfdFlags
;
6321 memcpy(&kfd
.ftidType
, folder
->ftidType
, sizeof(FOLDERTYPEID
));
6323 register_folder(folder
->id
, &kfd
);
6328 HRESULT
SHELL_RegisterShellFolders(void)
6332 /* Set up '$HOME' targeted symlinks for 'My Documents', 'My Pictures',
6333 * 'My Videos', 'My Music', 'Desktop' etc. in advance, so that the
6334 * _SHRegister*ShellFolders() functions will find everything nice and clean
6335 * and thus will not attempt to create them in the profile directory. */
6336 _SHCreateSymbolicLinks();
6338 hr
= _SHRegisterUserShellFolders(TRUE
);
6340 hr
= _SHRegisterUserShellFolders(FALSE
);
6342 hr
= _SHRegisterCommonShellFolders();
6344 hr
= create_extra_folders();
6346 hr
= set_folder_attributes();
6348 register_system_knownfolders();