ReactOS  0.4.15-dev-3297-g037c744
shellpath.c
Go to the documentation of this file.
1 /*
2  * Path Functions
3  *
4  * Copyright 1998, 1999, 2000 Juergen Schmied
5  * Copyright 2004 Juan Lang
6  * Copyright 2018-2021 Katayama Hirofumi MZ
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  *
22  * NOTES:
23  *
24  * Many of these functions are in SHLWAPI.DLL also
25  *
26  */
27 
28 #define WIN32_NO_STATUS
29 #define _INC_WINDOWS
30 #define COBJMACROS
31 
32 #include <wine/config.h>
33 
34 #include <windef.h>
35 #include <winbase.h>
36 #include <shlobj.h>
37 #include <undocshell.h>
38 #include <shlwapi.h>
39 #include <sddl.h>
40 #include <strsafe.h>
41 #include <wine/debug.h>
42 #include <wine/unicode.h>
43 
44 #include <shlwapi_undoc.h>
45 #include <shellutils.h>
46 
47 #include <userenv.h>
48 
49 #include "pidl.h"
50 #include "shell32_main.h"
51 #include "shresdef.h"
52 
53 #undef _WIN32_WINNT
54 #define _WIN32_WINNT _WIN32_WINNT_WS03
55 
57 
58 static const BOOL is_win64 = sizeof(void *) > sizeof(int);
59 
60 #ifdef __REACTOS__
61 /* FIXME: Remove this */
62 typedef enum _NT_PRODUCT_TYPE
63 {
64  NtProductWinNt = 1,
68 
69 /* FIXME: We cannot refresh the RtlGetNtProductType value before reboot. */
70 static BOOL
71 DoGetProductType(PNT_PRODUCT_TYPE ProductType)
72 {
73  static const WCHAR ProductOptions[] = L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions";
74  HKEY hKey;
75  LONG error;
76  WCHAR szValue[9];
77  DWORD cbValue;
78  static DWORD s_dwProductType = 0;
79 
80  if (s_dwProductType != 0)
81  {
82  *ProductType = s_dwProductType;
83  return TRUE;
84  }
85 
86  *ProductType = NtProductServer;
87 
88  error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, ProductOptions, 0, KEY_READ, &hKey);
89  if (error)
90  return FALSE;
91 
92  cbValue = sizeof(szValue);
93  error = RegGetValueW(hKey, NULL, L"ProductType", RRF_RT_REG_SZ, NULL, (PVOID)szValue, &cbValue);
94  if (!error)
95  {
96  if (lstrcmpW(szValue, L"WinNT") == 0)
97  *ProductType = NtProductWinNt;
98  else if (lstrcmpW(szValue, L"LanmanNT") == 0)
99  *ProductType = NtProductLanManNt;
100  }
101 
102  s_dwProductType = *ProductType;
103 
104  RegCloseKey(hKey);
105  return TRUE;
106 }
107 #endif
108 /*
109  ########## Combining and Constructing paths ##########
110 */
111 
112 /* @implemented */
113 static BOOL WINAPI
114 PathSearchOnExtensionsW(LPWSTR pszPath, LPCWSTR *ppszDirs, BOOL bDoSearch, DWORD dwWhich)
115 {
116  if (*PathFindExtensionW(pszPath) != 0)
117  return FALSE;
118 
119  if (bDoSearch)
120  return PathFindOnPathExW(pszPath, ppszDirs, dwWhich);
121  else
122  return PathFileExistsDefExtW(pszPath, dwWhich);
123 }
124 
125 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
126 /* @implemented */
128 {
129  return PathIsUNCW(path) || (PathGetDriveNumberW(path) != -1 && path[2] == L'\\');
130 }
131 
132 /* @implemented */
134 {
136  DWORD cch;
137 
138  if (path == NULL)
139  return FALSE;
141  if (!cch || cch > _countof(path1))
142  return FALSE;
143  return (PathCombineW(path, path1, path) != NULL);
144 }
145 #endif
146 
147 /* NOTE: GetShortPathName fails if the pathname didn't exist.
148  GetShortPathNameAbsentW should set the short path name that even doesn't exist. */
149 static DWORD GetShortPathNameAbsentW(LPCWSTR pszLong, LPWSTR pszShort, DWORD cchShort)
150 {
151  FIXME("GetShortPathNameAbsentW(%ls, %p, %ld): stub\n", pszLong, pszShort, cchShort);
152  StringCchCopyW(pszShort, cchShort, pszLong);
153  return lstrlenW(pszShort);
154 }
155 
156 BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath);
157 
158 /* @unconfirmed */
160 {
161  WCHAR szRoot[MAX_PATH], szCopy[MAX_PATH], szCurDir[MAX_PATH];
162  LPWSTR pch;
163  LONG cch;
164  BOOL bCheckLFN;
165 
166  if (FAILED(StringCchCopyW(szCopy, _countof(szCopy), pszPath)))
167  return;
168 
169  FixSlashesAndColonW(szCopy);
170 
171  if (pszDir)
172  {
173  cch = GetCurrentDirectoryW(_countof(szCurDir), szCurDir);
175  pszDir = NULL;
176  }
177 
178  if (!GetFullPathNameW(szCopy, _countof(szRoot), szRoot, NULL))
179  goto Quit;
180 
181  if (PathIsUNCW(szRoot)) /* it begins with double backslash */
182  {
183  pch = StrChrW(&szRoot[2], L'\\');
184  if (pch)
185  {
186  pch = StrChrW(&pch[1], L'\\');
187  if (pch)
188  *pch = 0;
189  if (!PathAddBackslashW(szRoot))
190  goto Quit;
191  /* szRoot is like \\MyServer\MyShare\ */
192  bCheckLFN = TRUE;
193  }
194  else
195  {
196  bCheckLFN = FALSE;
197  }
198  }
199  else
200  {
201  if (!PathStripToRootW(szRoot) || !PathAddBackslashW(szRoot))
202  goto Quit;
203  /* szRoot is like X:\ */
204  bCheckLFN = TRUE;
205  }
206 
207  if (bCheckLFN && !IsLFNDriveW(szRoot)) /* not a long filename drive */
208  {
209  if (!GetFullPathNameW(szCopy, _countof(szRoot), szRoot, NULL))
210  goto Quit;
211  if (!GetShortPathNameW(szRoot, szCopy, _countof(szCopy)) &&
212  !GetShortPathNameAbsentW(szRoot, szCopy, _countof(szCopy)))
213  {
214  goto Quit;
215  }
216  }
217 
218  PathRemoveBackslashW(szCopy);
219  StringCchCopyW(pszPath, MAX_PATH, szCopy);
220 
221  if ((dwFlags & 1) == 0)
222  {
223  cch = lstrlenW(pszPath);
224  if (cch > 0 && pszPath[cch - 1] == L'.')
225  pszPath[cch - 1] = 0;
226  }
227 
228 Quit:
229  if (pszDir)
230  SetCurrentDirectoryW(szCurDir);
231 }
232 
233 /*************************************************************************
234  * PathAppend [SHELL32.36]
235  */
237  LPVOID lpszPath1,
238  LPCVOID lpszPath2)
239 {
240  if (SHELL_OsIsUnicode())
241  return PathAppendW(lpszPath1, lpszPath2);
242  return PathAppendA(lpszPath1, lpszPath2);
243 }
244 
245 /*************************************************************************
246  * PathGetExtensionA [internal]
247  *
248  * NOTES
249  * exported by ordinal
250  * return value points to the first char after the dot
251  */
253 {
254  TRACE("(%s)\n",lpszPath);
255 
256  lpszPath = PathFindExtensionA(lpszPath);
257  return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath);
258 }
259 
260 /*************************************************************************
261  * PathGetExtensionW [internal]
262  */
264 {
265  TRACE("(%s)\n",debugstr_w(lpszPath));
266 
267  lpszPath = PathFindExtensionW(lpszPath);
268  return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath);
269 }
270 
271 /*************************************************************************
272  * SHPathGetExtension [SHELL32.158]
273  */
275 {
276  return PathGetExtensionW(lpszPath);
277 }
278 
279 /*************************************************************************
280  * PathRemoveFileSpec [SHELL32.35]
281  */
283 {
284  if (SHELL_OsIsUnicode())
285  return PathRemoveFileSpecW(lpszPath);
286  return PathRemoveFileSpecA(lpszPath);
287 }
288 
289 /*
290  Path Manipulations
291 */
292 
293 /*************************************************************************
294  * PathGetShortPathA [internal]
295  */
296 static void PathGetShortPathA(LPSTR pszPath)
297 {
298  CHAR path[MAX_PATH];
299 
300  TRACE("%s\n", pszPath);
301 
302  if (GetShortPathNameA(pszPath, path, MAX_PATH))
303  {
304  lstrcpyA(pszPath, path);
305  }
306 }
307 
308 /*************************************************************************
309  * PathGetShortPathW [internal]
310  */
311 static void PathGetShortPathW(LPWSTR pszPath)
312 {
314 
315  TRACE("%s\n", debugstr_w(pszPath));
316 
317  if (GetShortPathNameW(pszPath, path, MAX_PATH))
318  {
319  lstrcpyW(pszPath, path);
320  }
321 }
322 
323 /*************************************************************************
324  * PathGetShortPath [SHELL32.92]
325  */
327 {
328  if(SHELL_OsIsUnicode())
329  PathGetShortPathW(pszPath);
330  PathGetShortPathA(pszPath);
331 }
332 
333 /*
334  ########## Path Testing ##########
335 */
336 
337 /*************************************************************************
338  * PathIsRoot [SHELL32.29]
339  */
341 {
342  if (SHELL_OsIsUnicode())
343  return PathIsRootW(lpszPath);
344  return PathIsRootA(lpszPath);
345 }
346 
347 /*************************************************************************
348  * PathIsExeA [internal]
349  */
350 static BOOL PathIsExeA (LPCSTR lpszPath)
351 {
352  LPCSTR lpszExtension = PathGetExtensionA(lpszPath);
353  int i;
354  static const char * const lpszExtensions[] =
355  {"exe", "com", "pif", "cmd", "bat", "scf", "scr", NULL };
356 
357  TRACE("path=%s\n",lpszPath);
358 
359  for(i=0; lpszExtensions[i]; i++)
360  if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE;
361 
362  return FALSE;
363 }
364 
365 /*************************************************************************
366  * PathIsExeW [internal]
367  */
369 {
370  LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
371  int i;
372  static const WCHAR lpszExtensions[][4] =
373  {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','f','\0'},
374  {'c','m','d','\0'}, {'b','a','t','\0'}, {'s','c','f','\0'},
375  {'s','c','r','\0'}, {'\0'} };
376 
377  TRACE("path=%s\n",debugstr_w(lpszPath));
378 
379  for(i=0; lpszExtensions[i][0]; i++)
380  if (!strcmpiW(lpszExtension,lpszExtensions[i])) return TRUE;
381 
382  return FALSE;
383 }
384 
385 /*************************************************************************
386  * PathIsExe [SHELL32.43]
387  */
389 {
390  if (SHELL_OsIsUnicode())
391  return PathIsExeW (path);
392  return PathIsExeA(path);
393 }
394 
395 /*************************************************************************
396  * PathFileExists [SHELL32.45]
397  */
399 {
400  if (SHELL_OsIsUnicode())
401  return PathFileExistsW (lpszPath);
402  return PathFileExistsA (lpszPath);
403 }
404 
405 /*************************************************************************
406  * IsLFNDriveA [SHELL32.41]
407  */
409 {
410  DWORD fnlen;
411 
412  if (!GetVolumeInformationA(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
413  return FALSE;
414  return fnlen > 12;
415 }
416 
417 /*************************************************************************
418  * IsLFNDriveW [SHELL32.42]
419  */
421 {
422  DWORD fnlen;
423 
424  if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
425  return FALSE;
426  return fnlen > 12;
427 }
428 
429 /*************************************************************************
430  * IsLFNDrive [SHELL32.119]
431  */
433 {
434  if (SHELL_OsIsUnicode())
435  return IsLFNDriveW(lpszPath);
436  return IsLFNDriveA(lpszPath);
437 }
438 
439 /*
440  ########## Creating Something Unique ##########
441 */
442 /*************************************************************************
443  * PathMakeUniqueNameA [internal]
444  */
446  LPSTR lpszBuffer,
447  DWORD dwBuffSize,
448  LPCSTR lpszShortName,
449  LPCSTR lpszLongName,
450  LPCSTR lpszPathName)
451 {
452  FIXME("%p %u %s %s %s stub\n",
453  lpszBuffer, dwBuffSize, debugstr_a(lpszShortName),
454  debugstr_a(lpszLongName), debugstr_a(lpszPathName));
455  return TRUE;
456 }
457 
458 /*************************************************************************
459  * PathMakeUniqueNameW [internal]
460  */
462  LPWSTR lpszBuffer,
463  DWORD dwBuffSize,
464  LPCWSTR lpszShortName,
465  LPCWSTR lpszLongName,
466  LPCWSTR lpszPathName)
467 {
468  FIXME("%p %u %s %s %s stub\n",
469  lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
470  debugstr_w(lpszLongName), debugstr_w(lpszPathName));
471  return TRUE;
472 }
473 
474 /*************************************************************************
475  * PathMakeUniqueName [SHELL32.47]
476  */
478  LPVOID lpszBuffer,
479  DWORD dwBuffSize,
480  LPCVOID lpszShortName,
481  LPCVOID lpszLongName,
482  LPCVOID lpszPathName)
483 {
484  if (SHELL_OsIsUnicode())
485  return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
486  return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
487 }
488 
489 /*************************************************************************
490  * PathYetAnotherMakeUniqueName [SHELL32.75]
491  */
493 {
494  WCHAR pathW[MAX_PATH], retW[MAX_PATH];
495  const WCHAR *file, *ext;
496  int i = 2;
497 
498  TRACE("(%p, %s, %s, %s)\n", buffer, debugstr_w(path), debugstr_w(shortname), debugstr_w(longname));
499 
500  file = longname ? longname : shortname;
501  PathCombineW(pathW, path, file);
502  strcpyW(retW, pathW);
503  PathRemoveExtensionW(pathW);
504 
506 
507  /* now try to make it unique */
508  while (PathFileExistsW(retW))
509  {
510  static const WCHAR fmtW[] = {'%','s',' ','(','%','d',')','%','s',0};
511 
512  sprintfW(retW, fmtW, pathW, i, ext);
513  i++;
514  }
515 
516  strcpyW(buffer, retW);
517  TRACE("ret - %s\n", debugstr_w(buffer));
518 
519  return TRUE;
520 }
521 
522 /*
523  ########## cleaning and resolving paths ##########
524  */
525 
526 /*************************************************************************
527  * PathCleanupSpec [SHELL32.171]
528  *
529  * lpszFile is changed in place.
530  */
531 int WINAPI PathCleanupSpec( LPCWSTR lpszPathW, LPWSTR lpszFileW )
532 {
533  int i = 0;
534  DWORD rc = 0;
535  int length = 0;
536 
537  if (SHELL_OsIsUnicode())
538  {
539  LPWSTR p = lpszFileW;
540 
541  TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
542 
543  if (lpszPathW)
544  length = strlenW(lpszPathW);
545 
546  while (*p)
547  {
548  int gct = PathGetCharTypeW(*p);
549  if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
550  {
551  lpszFileW[i]='-';
552  rc |= PCS_REPLACEDCHAR;
553  }
554  else
555  lpszFileW[i]=*p;
556  i++;
557  p++;
558  if (length + i == MAX_PATH)
559  {
560  rc |= PCS_FATAL | PCS_PATHTOOLONG;
561  break;
562  }
563  }
564  lpszFileW[i]=0;
565  }
566  else
567  {
568  LPSTR lpszFileA = (LPSTR)lpszFileW;
569  LPCSTR lpszPathA = (LPCSTR)lpszPathW;
570  LPSTR p = lpszFileA;
571 
572  TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
573 
574  if (lpszPathA)
575  length = strlen(lpszPathA);
576 
577  while (*p)
578  {
579  int gct = PathGetCharTypeA(*p);
580  if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
581  {
582  lpszFileA[i]='-';
583  rc |= PCS_REPLACEDCHAR;
584  }
585  else
586  lpszFileA[i]=*p;
587  i++;
588  p++;
589  if (length + i == MAX_PATH)
590  {
591  rc |= PCS_FATAL | PCS_PATHTOOLONG;
592  break;
593  }
594  }
595  lpszFileA[i]=0;
596  }
597  return rc;
598 }
599 
600 /*************************************************************************
601  * PathQualifyA [SHELL32]
602  */
604 {
606  TRACE("%s\n",pszPath);
609  SHUnicodeToAnsi(szPath, pszPath, MAX_PATH);
610 }
611 
612 /*************************************************************************
613  * PathQualifyW [SHELL32]
614  */
616 {
617  TRACE("%s\n",debugstr_w(pszPath));
618  PathQualifyExW(pszPath, NULL, 0);
619 }
620 
621 /*************************************************************************
622  * PathQualify [SHELL32.49]
623  */
625 {
626  if (SHELL_OsIsUnicode())
627  PathQualifyW(pszPath);
628  else
629  PathQualifyA(pszPath);
630 }
631 
633 {
634  BOOL ret = FALSE;
635  LPWSTR *dirsW = NULL;
636  DWORD iDir, cDirs, cbDirs;
637  WCHAR pathW[MAX_PATH];
638 
639  TRACE("PathResolveA(%s,%p,0x%08x)\n", debugstr_a(path), dirs, flags);
640 
641  if (dirs)
642  {
643  for (cDirs = 0; dirs[cDirs]; ++cDirs)
644  ;
645 
646  cbDirs = (cDirs + 1) * sizeof(LPWSTR);
647  dirsW = SHAlloc(cbDirs);
648  if (!dirsW)
649  goto Cleanup;
650 
651  ZeroMemory(dirsW, cbDirs);
652  for (iDir = 0; iDir < cDirs; ++iDir)
653  {
654  __SHCloneStrAtoW(&dirsW[iDir], dirs[iDir]);
655  if (dirsW[iDir] == NULL)
656  goto Cleanup;
657  }
658  }
659 
660  SHAnsiToUnicode(path, pathW, _countof(pathW));
661 
662  ret = PathResolveW(pathW, (LPCWSTR*)dirsW, flags);
663  if (ret)
664  SHUnicodeToAnsi(pathW, path, MAX_PATH);
665 
666 Cleanup:
667  if (dirsW)
668  {
669  for (iDir = 0; iDir < cDirs; ++iDir)
670  {
671  SHFree(dirsW[iDir]);
672  }
673  SHFree(dirsW);
674  }
675  return ret;
676 }
677 
679 {
681 
682  TRACE("PathResolveW(%s,%p,0x%08x)\n", debugstr_w(path), dirs, flags);
683 
684  if (flags & PRF_VERIFYEXISTS)
686 
688 
689  if (PathIsRootW(path))
690  {
691  if ((path[0] == L'\\' && path[1] == 0) ||
693  {
694  if (flags & PRF_FIRSTDIRDEF)
695  PathQualifyExW(path, dirs[0], 0);
696  else
697  PathQualifyExW(path, NULL, 0);
698  }
699 
700  if (flags & PRF_VERIFYEXISTS)
702  return TRUE;
703  }
704  else if (PathIsFileSpecW(path))
705  {
706  if ((flags & PRF_TRYPROGRAMEXTENSIONS) && PathSearchOnExtensionsW(path, dirs, TRUE, dwWhich))
707  return TRUE;
708 
709  if (PathFindOnPathW(path, dirs))
710  {
711 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
712  if (!(flags & PRF_REQUIREABSOLUTE))
713  return TRUE;
714 
715  if (!PathIsAbsoluteW(path))
717 #else
718  return TRUE;
719 #endif
720  }
721  }
722  else if (!PathIsURLW(path))
723  {
724  if (flags & PRF_FIRSTDIRDEF)
725  PathQualifyExW(path, *dirs, 1);
726  else
727  PathQualifyExW(path, NULL, 1);
728 
729  if (flags & PRF_VERIFYEXISTS)
730  {
732  PathSearchOnExtensionsW(path, dirs, FALSE, dwWhich))
733  {
734  return TRUE;
735  }
737  {
738  return FALSE;
739  }
740  }
741 
742 #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
744  {
745  if (!PathIsAbsoluteW(path))
747  }
748 #endif
749  return TRUE;
750  }
751 
752  return FALSE;
753 }
754 
755 /*************************************************************************
756  * PathResolve [SHELL32.51]
757  */
759 {
760  if (SHELL_OsIsUnicode())
761  return PathResolveW(path, (LPCWSTR*)paths, flags);
762  else
763  return PathResolveA(path, (LPCSTR*)paths, flags);
764 }
765 
766 /*************************************************************************
767 * PathProcessCommandA
768 */
770  LPCSTR lpszPath,
771  LPSTR lpszBuff,
772  DWORD dwBuffSize,
773  DWORD dwFlags)
774 {
775  FIXME("%s %p 0x%04x 0x%04x stub\n",
776  lpszPath, lpszBuff, dwBuffSize, dwFlags);
777  if(!lpszPath) return -1;
778  if(lpszBuff) strcpy(lpszBuff, lpszPath);
779  return strlen(lpszPath);
780 }
781 
782 /*************************************************************************
783 * PathProcessCommandW
784 */
786  LPCWSTR lpszPath,
787  LPWSTR lpszBuff,
788  DWORD dwBuffSize,
789  DWORD dwFlags)
790 {
791  FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
792  debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
793  if(!lpszPath) return -1;
794  if(lpszBuff) strcpyW(lpszBuff, lpszPath);
795  return strlenW(lpszPath);
796 }
797 
798 /*************************************************************************
799 * PathProcessCommand (SHELL32.653)
800 */
802  LPCVOID lpszPath,
803  LPVOID lpszBuff,
804  DWORD dwBuffSize,
805  DWORD dwFlags)
806 {
807  if (SHELL_OsIsUnicode())
808  return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
809  return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
810 }
811 
812 /*
813  ########## special ##########
814 */
815 
816 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'};
817 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'};
818 static const WCHAR AppDataW[] = {'A','p','p','D','a','t','a','\0'};
819 #ifndef __REACTOS__
820 static const WCHAR AppData_LocalLowW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','L','o','w','\0'};
821 static const WCHAR Application_DataW[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
822 #endif
823 static const WCHAR CacheW[] = {'C','a','c','h','e','\0'};
824 static const WCHAR CD_BurningW[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
825 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'};
826 static const WCHAR Common_AppDataW[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'};
827 static const WCHAR Common_DesktopW[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'};
828 static const WCHAR Common_DocumentsW[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'};
829 static const WCHAR Common_FavoritesW[] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'};
830 static const WCHAR CommonFilesDirW[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'};
831 static const WCHAR CommonFilesDirX86W[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
832 static const WCHAR CommonMusicW[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'};
833 static const WCHAR CommonPicturesW[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'};
834 static const WCHAR Common_ProgramsW[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'};
835 static const WCHAR Common_StartUpW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'};
836 static const WCHAR Common_Start_MenuW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'};
837 static const WCHAR Common_TemplatesW[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'};
838 static const WCHAR CommonVideoW[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
839 #ifndef __REACTOS__
840 static const WCHAR ContactsW[] = {'C','o','n','t','a','c','t','s','\0'};
841 #endif
842 static const WCHAR CookiesW[] = {'C','o','o','k','i','e','s','\0'};
843 static const WCHAR DesktopW[] = {'D','e','s','k','t','o','p','\0'};
844 #ifndef __REACTOS__
845 static const WCHAR DocumentsW[] = {'D','o','c','u','m','e','n','t','s','\0'};
846 static const WCHAR DownloadsW[] = {'D','o','w','n','l','o','a','d','s','\0'};
847 #endif
848 static const WCHAR FavoritesW[] = {'F','a','v','o','r','i','t','e','s','\0'};
849 static const WCHAR FontsW[] = {'F','o','n','t','s','\0'};
850 static const WCHAR HistoryW[] = {'H','i','s','t','o','r','y','\0'};
851 #ifndef __REACTOS__
852 static const WCHAR LinksW[] = {'L','i','n','k','s','\0'};
853 #endif
854 static const WCHAR Local_AppDataW[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
855 #ifndef __REACTOS__
856 static const WCHAR Local_Settings_Application_DataW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
857 #endif
858 static const WCHAR Local_Settings_CD_BurningW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\\','M','i','c','r','o','s','o','f','t','\\','C','D',' ','B','u','r','n','i','n','g','\0'};
859 #ifndef __REACTOS__
860 static const WCHAR Local_Settings_HistoryW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','H','i','s','t','o','r','y','\0'};
861 static const WCHAR Local_Settings_Temporary_Internet_FilesW[] = {'L','o','c','a','l',' ','S','e','t','t','i','n','g','s','\\','T','e','m','p','o','r','a','r','y',' ','I','n','t','e','r','n','e','t',' ','F','i','l','e','s','\0'};
862 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'};
863 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'};
864 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'};
865 static const WCHAR MusicW[] = {'M','u','s','i','c','\0'};
866 static const WCHAR Music_PlaylistsW[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
867 static const WCHAR Music_Sample_MusicW[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
868 static const WCHAR Music_Sample_PlaylistsW[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','P','l','a','y','l','i','s','t','s','\0'};
869 #endif
870 static const WCHAR My_MusicW[] = {'M','y',' ','M','u','s','i','c','\0'};
871 static const WCHAR My_PicturesW[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
872 static const WCHAR My_VideoW[] = {'M','y',' ','V','i','d','e','o','\0'};
873 static const WCHAR NetHoodW[] = {'N','e','t','H','o','o','d','\0'};
874 static const WCHAR OEM_LinksW[] = {'O','E','M',' ','L','i','n','k','s','\0'};
875 static const WCHAR PersonalW[] = {'P','e','r','s','o','n','a','l','\0'};
876 #ifndef __REACTOS__
877 static const WCHAR PicturesW[] = {'P','i','c','t','u','r','e','s','\0'};
878 static const WCHAR Pictures_Sample_PicturesW[] = {'P','i','c','t','u','r','e','s','\\','S','a','m','p','l','e',' ','P','i','c','t','u','r','e','s','\0'};
879 static const WCHAR Pictures_Slide_ShowsW[] = {'P','i','c','t','u','r','e','s','\\','S','l','i','d','e',' ','S','h','o','w','s','\0'};
880 #endif
881 static const WCHAR PrintHoodW[] = {'P','r','i','n','t','H','o','o','d','\0'};
882 #ifndef __REACTOS__
883 static const WCHAR Program_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
884 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'};
885 #endif
886 static const WCHAR Program_Files_x86W[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
887 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'};
888 static const WCHAR ProgramFilesDirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
889 static const WCHAR ProgramFilesDirX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
890 static const WCHAR ProgramsW[] = {'P','r','o','g','r','a','m','s','\0'};
891 #ifndef __REACTOS__
892 static const WCHAR PublicW[] = {'P','u','b','l','i','c',0};
893 #endif
894 static const WCHAR RecentW[] = {'R','e','c','e','n','t','\0'};
895 static const WCHAR ResourcesW[] = {'R','e','s','o','u','r','c','e','s','\0'};
896 #ifndef __REACTOS__
897 static const WCHAR Saved_GamesW[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
898 static const WCHAR SearchesW[] = {'S','e','a','r','c','h','e','s','\0'};
899 #endif
900 static const WCHAR SendToW[] = {'S','e','n','d','T','o','\0'};
901 static const WCHAR StartUpW[] = {'S','t','a','r','t','U','p','\0'};
902 static const WCHAR Start_MenuW[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
903 #ifndef __REACTOS__
904 static const WCHAR Start_Menu_ProgramsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
905 static const WCHAR Start_Menu_Admin_ToolsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','A','d','m','i','n','i','s','t','r','a','t','i','v','e',' ','T','o','o','l','s','\0'};
906 static const WCHAR Start_Menu_StartupW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\\','S','t','a','r','t','U','p','\0'};
907 #endif
908 static const WCHAR TemplatesW[] = {'T','e','m','p','l','a','t','e','s','\0'};
909 #ifndef __REACTOS__
910 static const WCHAR UsersW[] = {'U','s','e','r','s','\0'};
911 static const WCHAR UsersPublicW[] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'};
912 static const WCHAR VideosW[] = {'V','i','d','e','o','s','\0'};
913 static const WCHAR Videos_Sample_VideosW[] = {'V','i','d','e','o','s','\\','S','a','m','p','l','e',' ','V','i','d','e','o','s','\0'};
914 #endif
915 static const WCHAR DefaultW[] = {'.','D','e','f','a','u','l','t','\0'};
916 static const WCHAR AllUsersProfileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
917 #ifndef __REACTOS__
918 static const WCHAR PublicProfileW[] = {'%','P','U','B','L','I','C','%',0};
919 #endif
920 static const WCHAR UserProfileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
921 static const WCHAR SystemDriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
922 #ifndef __REACTOS__
923 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};
924 static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
925 static const WCHAR AllUsersProfileValueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
926 #endif
927 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'};
928 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'};
929 static const WCHAR szDefaultProfileDirW[] = {'u','s','e','r','s',0};
930 #ifndef __REACTOS__
931 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'};
932 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};
933 #endif
934 static const WCHAR AllUsersW[] = {'P','u','b','l','i','c',0};
935 
936 typedef enum _CSIDL_Type {
938 #ifdef __REACTOS__
939  CSIDL_Type_InMyDocuments,
940 #endif
948 } CSIDL_Type;
949 
950 /* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
951 #ifndef __REACTOS__
952 #define CSIDL_CONTACTS 0x0043
953 #define CSIDL_DOWNLOADS 0x0047
954 #define CSIDL_LINKS 0x004d
955 #define CSIDL_APPDATA_LOCALLOW 0x004e
956 #define CSIDL_SAVED_GAMES 0x0062
957 #define CSIDL_SEARCHES 0x0063
958 #endif
959 
960 typedef struct
961 {
965  LPCWSTR szDefaultPath; /* fallback string or resource ID */
967 } CSIDL_DATA;
968 
969 static const CSIDL_DATA CSIDL_Data[] =
970 {
971  { /* 0x00 - CSIDL_DESKTOP */
972  &FOLDERID_Desktop,
974  DesktopW,
976 #ifdef __REACTOS__
977  0
978 #else
980 #endif
981  },
982  { /* 0x01 - CSIDL_INTERNET */
983  &FOLDERID_InternetFolder,
985  NULL,
986  NULL
987  },
988  { /* 0x02 - CSIDL_PROGRAMS */
989  &FOLDERID_Programs,
991  ProgramsW,
993 #ifdef __REACTOS__
994  0
995 #else
997 #endif
998  },
999  { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
1000  &FOLDERID_ControlPanelFolder,
1002  NULL,
1003  NULL,
1005  },
1006  { /* 0x04 - CSIDL_PRINTERS */
1007  &FOLDERID_PrintersFolder,
1009  NULL,
1010  NULL,
1012  },
1013  { /* 0x05 - CSIDL_PERSONAL */
1014  &FOLDERID_Documents,
1016  PersonalW,
1019  },
1020  { /* 0x06 - CSIDL_FAVORITES */
1021  &FOLDERID_Favorites,
1023  FavoritesW,
1026  },
1027  { /* 0x07 - CSIDL_STARTUP */
1028  &FOLDERID_Startup,
1030  StartUpW,
1032  },
1033  { /* 0x08 - CSIDL_RECENT */
1034  &FOLDERID_Recent,
1036  RecentW,
1039  },
1040  { /* 0x09 - CSIDL_SENDTO */
1041  &FOLDERID_SendTo,
1043  SendToW,
1045  },
1046  { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
1047  &FOLDERID_RecycleBinFolder,
1049  NULL,
1050  NULL
1051  },
1052  { /* 0x0b - CSIDL_STARTMENU */
1053  &FOLDERID_StartMenu,
1055  Start_MenuW,
1058  },
1059  { /* 0x0c - CSIDL_MYDOCUMENTS */
1060  &GUID_NULL,
1061  CSIDL_Type_Disallowed, /* matches WinXP--can't get its path */
1062  NULL,
1063  NULL,
1065  },
1066  { /* 0x0d - CSIDL_MYMUSIC */
1067  &FOLDERID_Music,
1068 #ifdef __REACTOS__
1069  CSIDL_Type_InMyDocuments,
1070 #else
1072 #endif
1073  My_MusicW,
1076  },
1077  { /* 0x0e - CSIDL_MYVIDEO */
1078  &FOLDERID_Videos,
1079 #ifdef __REACTOS__
1080  CSIDL_Type_InMyDocuments,
1081 #else
1083 #endif
1084  My_VideoW,
1087  },
1088  { /* 0x0f - unassigned */
1089  &GUID_NULL,
1091  NULL,
1092  NULL,
1093  },
1094  { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
1095  &FOLDERID_Desktop,
1097  DesktopW,
1099 #ifdef __REACTOS__
1100  0
1101 #else
1103 #endif
1104  },
1105  { /* 0x11 - CSIDL_DRIVES */
1106  &FOLDERID_ComputerFolder,
1108  NULL,
1109  NULL,
1111  },
1112  { /* 0x12 - CSIDL_NETWORK */
1113  &FOLDERID_NetworkFolder,
1115  NULL,
1116  NULL,
1118  },
1119  { /* 0x13 - CSIDL_NETHOOD */
1120  &FOLDERID_NetHood,
1122  NetHoodW,
1125  },
1126  { /* 0x14 - CSIDL_FONTS */
1127  &FOLDERID_Fonts,
1129  FontsW,
1130  FontsW,
1132  },
1133  { /* 0x15 - CSIDL_TEMPLATES */
1134  &FOLDERID_Templates,
1136  TemplatesW,
1138  },
1139  { /* 0x16 - CSIDL_COMMON_STARTMENU */
1140  &FOLDERID_CommonStartMenu,
1145  },
1146  { /* 0x17 - CSIDL_COMMON_PROGRAMS */
1147  &FOLDERID_CommonPrograms,
1151 #ifdef __REACTOS__
1152  0
1153 #else
1155 #endif
1156  },
1157  { /* 0x18 - CSIDL_COMMON_STARTUP */
1158  &FOLDERID_CommonStartup,
1162  },
1163  { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
1164  &FOLDERID_PublicDesktop,
1168 #ifdef __REACTOS__
1169  0
1170 #else
1172 #endif
1173  },
1174  { /* 0x1a - CSIDL_APPDATA */
1175  &FOLDERID_RoamingAppData,
1177  AppDataW,
1179  },
1180  { /* 0x1b - CSIDL_PRINTHOOD */
1181  &FOLDERID_PrintHood,
1183  PrintHoodW,
1186  },
1187  { /* 0x1c - CSIDL_LOCAL_APPDATA */
1188  &FOLDERID_LocalAppData,
1192  },
1193  { /* 0x1d - CSIDL_ALTSTARTUP */
1194  &GUID_NULL,
1196  NULL,
1197  NULL
1198  },
1199  { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
1200  &GUID_NULL,
1202  NULL,
1203  NULL
1204  },
1205  { /* 0x1f - CSIDL_COMMON_FAVORITES */
1206  &FOLDERID_Favorites,
1211  },
1212  { /* 0x20 - CSIDL_INTERNET_CACHE */
1213  &FOLDERID_InternetCache,
1215  CacheW,
1217  },
1218  { /* 0x21 - CSIDL_COOKIES */
1219  &FOLDERID_Cookies,
1221  CookiesW,
1223  },
1224  { /* 0x22 - CSIDL_HISTORY */
1225  &FOLDERID_History,
1227  HistoryW,
1229  },
1230  { /* 0x23 - CSIDL_COMMON_APPDATA */
1231  &FOLDERID_ProgramData,
1235  },
1236  { /* 0x24 - CSIDL_WINDOWS */
1237  &FOLDERID_Windows,
1239  NULL,
1240  NULL,
1242  },
1243  { /* 0x25 - CSIDL_SYSTEM */
1244  &FOLDERID_System,
1246  NULL,
1247  NULL,
1249  },
1250  { /* 0x26 - CSIDL_PROGRAM_FILES */
1251  &FOLDERID_ProgramFiles,
1255 #ifdef __REACTOS__
1256  0
1257 #else
1259 #endif
1260  },
1261  { /* 0x27 - CSIDL_MYPICTURES */
1262  &FOLDERID_Pictures,
1263 #ifdef __REACTOS__
1264  CSIDL_Type_InMyDocuments,
1265 #else
1267 #endif
1268  My_PicturesW,
1271  },
1272  { /* 0x28 - CSIDL_PROFILE */
1273  &FOLDERID_Profile,
1275  NULL,
1276  NULL
1277  },
1278  { /* 0x29 - CSIDL_SYSTEMX86 */
1279  &FOLDERID_SystemX86,
1281  NULL,
1282  NULL,
1284  },
1285  { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
1286  &FOLDERID_ProgramFilesX86,
1291  },
1292  { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
1293  &FOLDERID_ProgramFilesCommon,
1298  },
1299  { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
1300  &FOLDERID_ProgramFilesCommonX86,
1305  },
1306  { /* 0x2d - CSIDL_COMMON_TEMPLATES */
1307  &FOLDERID_CommonTemplates,
1311  },
1312  { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
1313  &FOLDERID_PublicDocuments,
1318  },
1319  { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
1320  &FOLDERID_CommonAdminTools,
1324  },
1325  { /* 0x30 - CSIDL_ADMINTOOLS */
1326  &FOLDERID_AdminTools,
1330  },
1331  { /* 0x31 - CSIDL_CONNECTIONS */
1332  &FOLDERID_ConnectionsFolder,
1334  NULL,
1335  NULL,
1337  },
1338  { /* 0x32 - unassigned */
1339  &GUID_NULL,
1341  NULL,
1342  NULL
1343  },
1344  { /* 0x33 - unassigned */
1345  &GUID_NULL,
1347  NULL,
1348  NULL
1349  },
1350  { /* 0x34 - unassigned */
1351  &GUID_NULL,
1353  NULL,
1354  NULL
1355  },
1356  { /* 0x35 - CSIDL_COMMON_MUSIC */
1357  &FOLDERID_PublicMusic,
1359  CommonMusicW,
1362  },
1363  { /* 0x36 - CSIDL_COMMON_PICTURES */
1364  &FOLDERID_PublicPictures,
1369  },
1370  { /* 0x37 - CSIDL_COMMON_VIDEO */
1371  &FOLDERID_PublicVideos,
1373  CommonVideoW,
1376  },
1377  { /* 0x38 - CSIDL_RESOURCES */
1378  &FOLDERID_ResourceDir,
1380  NULL,
1381  ResourcesW
1382  },
1383  { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
1384  &FOLDERID_LocalizedResourcesDir,
1386  NULL,
1387  NULL
1388  },
1389  { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
1390  &FOLDERID_CommonOEMLinks,
1392  NULL,
1393  OEM_LinksW
1394  },
1395  { /* 0x3b - CSIDL_CDBURN_AREA */
1396  &FOLDERID_CDBurning,
1398  CD_BurningW,
1400  },
1401  { /* 0x3c unassigned */
1402  &GUID_NULL,
1404  NULL,
1405  NULL
1406  },
1407  { /* 0x3d - CSIDL_COMPUTERSNEARME */
1408  &GUID_NULL,
1409  CSIDL_Type_Disallowed, /* FIXME */
1410  NULL,
1411  NULL
1412  },
1413  { /* 0x3e - CSIDL_PROFILES */
1414  &GUID_NULL,
1415  CSIDL_Type_Disallowed, /* oddly, this matches WinXP */
1416  NULL,
1417  NULL
1418  },
1419 /* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
1420 #ifndef __REACTOS__
1421  { /* 0x3f */
1422  &FOLDERID_AddNewPrograms,
1424  NULL,
1425  NULL
1426  },
1427  { /* 0x40 */
1428  &FOLDERID_AppUpdates,
1430  NULL,
1431  NULL
1432  },
1433  { /* 0x41 */
1434  &FOLDERID_ChangeRemovePrograms,
1436  NULL,
1437  NULL
1438  },
1439  { /* 0x42 */
1440  &FOLDERID_ConflictFolder,
1442  NULL,
1443  NULL
1444  },
1445  { /* 0x43 - CSIDL_CONTACTS */
1446  &FOLDERID_Contacts,
1448  NULL,
1449  ContactsW
1450  },
1451  { /* 0x44 */
1452  &FOLDERID_DeviceMetadataStore,
1453  CSIDL_Type_Disallowed, /* FIXME */
1454  NULL,
1455  NULL
1456  },
1457  { /* 0x45 */
1458  &GUID_NULL,
1460  NULL,
1461  DocumentsW
1462  },
1463  { /* 0x46 */
1464  &FOLDERID_DocumentsLibrary,
1465  CSIDL_Type_Disallowed, /* FIXME */
1466  NULL,
1467  NULL
1468  },
1469  { /* 0x47 - CSIDL_DOWNLOADS */
1470  &FOLDERID_Downloads,
1471 #ifdef __REACTOS__
1472  CSIDL_Type_InMyDocuments,
1473 #else
1475 #endif
1476  NULL,
1477  DownloadsW
1478  },
1479  { /* 0x48 */
1480  &FOLDERID_Games,
1482  NULL,
1483  NULL
1484  },
1485  { /* 0x49 */
1486  &FOLDERID_GameTasks,
1487  CSIDL_Type_Disallowed, /* FIXME */
1488  NULL,
1489  NULL
1490  },
1491  { /* 0x4a */
1492  &FOLDERID_HomeGroup,
1494  NULL,
1495  NULL
1496  },
1497  { /* 0x4b */
1498  &FOLDERID_ImplicitAppShortcuts,
1499  CSIDL_Type_Disallowed, /* FIXME */
1500  NULL,
1501  NULL
1502  },
1503  { /* 0x4c */
1504  &FOLDERID_Libraries,
1505  CSIDL_Type_Disallowed, /* FIXME */
1506  NULL,
1507  NULL
1508  },
1509  { /* 0x4d - CSIDL_LINKS */
1510  &FOLDERID_Links,
1512  NULL,
1513  LinksW
1514  },
1515  { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
1516  &FOLDERID_LocalAppDataLow,
1518  NULL,
1520  },
1521  { /* 0x4f */
1522  &FOLDERID_MusicLibrary,
1523  CSIDL_Type_Disallowed, /* FIXME */
1524  NULL,
1525  NULL
1526  },
1527  { /* 0x50 */
1528  &FOLDERID_OriginalImages,
1529  CSIDL_Type_Disallowed, /* FIXME */
1530  NULL,
1531  NULL
1532  },
1533  { /* 0x51 */
1534  &FOLDERID_PhotoAlbums,
1536  NULL,
1538  },
1539  { /* 0x52 */
1540  &FOLDERID_PicturesLibrary,
1541  CSIDL_Type_Disallowed, /* FIXME */
1542  NULL,
1543  NULL
1544  },
1545  { /* 0x53 */
1546  &FOLDERID_Playlists,
1548  NULL,
1550  },
1551  { /* 0x54 */
1552  &FOLDERID_ProgramFilesX64,
1554  NULL,
1555  NULL
1556  },
1557  { /* 0x55 */
1558  &FOLDERID_ProgramFilesCommonX64,
1560  NULL,
1561  NULL
1562  },
1563  { /* 0x56 */
1564  &FOLDERID_Public,
1565  CSIDL_Type_CurrVer, /* FIXME */
1566  NULL,
1567  UsersPublicW
1568  },
1569  { /* 0x57 */
1570  &FOLDERID_PublicDownloads,
1572  NULL,
1573  DownloadsW
1574  },
1575  { /* 0x58 */
1576  &FOLDERID_PublicGameTasks,
1578  NULL,
1580  },
1581  { /* 0x59 */
1582  &FOLDERID_PublicLibraries,
1584  NULL,
1586  },
1587  { /* 0x5a */
1588  &FOLDERID_PublicRingtones,
1590  NULL,
1592  },
1593  { /* 0x5b */
1594  &FOLDERID_QuickLaunch,
1595  CSIDL_Type_Disallowed, /* FIXME */
1596  NULL,
1597  NULL
1598  },
1599  { /* 0x5c */
1600  &FOLDERID_RecordedTVLibrary,
1601  CSIDL_Type_Disallowed, /* FIXME */
1602  NULL,
1603  NULL
1604  },
1605  { /* 0x5d */
1606  &FOLDERID_Ringtones,
1607  CSIDL_Type_Disallowed, /* FIXME */
1608  NULL,
1609  NULL
1610  },
1611  { /* 0x5e */
1612  &FOLDERID_SampleMusic,
1614  NULL,
1616  },
1617  { /* 0x5f */
1618  &FOLDERID_SamplePictures,
1620  NULL,
1622  },
1623  { /* 0x60 */
1624  &FOLDERID_SamplePlaylists,
1626  NULL,
1628  },
1629  { /* 0x61 */
1630  &FOLDERID_SampleVideos,
1632  NULL,
1634  },
1635  { /* 0x62 - CSIDL_SAVED_GAMES */
1636  &FOLDERID_SavedGames,
1638  NULL,
1639  Saved_GamesW
1640  },
1641  { /* 0x63 - CSIDL_SEARCHES */
1642  &FOLDERID_SavedSearches,
1644  NULL,
1645  SearchesW
1646  },
1647  { /* 0x64 */
1648  &FOLDERID_SEARCH_CSC,
1650  NULL,
1651  NULL
1652  },
1653  { /* 0x65 */
1654  &FOLDERID_SEARCH_MAPI,
1656  NULL,
1657  NULL
1658  },
1659  { /* 0x66 */
1660  &FOLDERID_SearchHome,
1662  NULL,
1663  NULL
1664  },
1665  { /* 0x67 */
1666  &FOLDERID_SidebarDefaultParts,
1667  CSIDL_Type_Disallowed, /* FIXME */
1668  NULL,
1669  NULL
1670  },
1671  { /* 0x68 */
1672  &FOLDERID_SidebarParts,
1673  CSIDL_Type_Disallowed, /* FIXME */
1674  NULL,
1675  NULL
1676  },
1677  { /* 0x69 */
1678  &FOLDERID_SyncManagerFolder,
1680  NULL,
1681  NULL
1682  },
1683  { /* 0x6a */
1684  &FOLDERID_SyncResultsFolder,
1686  NULL,
1687  NULL
1688  },
1689  { /* 0x6b */
1690  &FOLDERID_SyncSetupFolder,
1692  NULL,
1693  NULL
1694  },
1695  { /* 0x6c */
1696  &FOLDERID_UserPinned,
1697  CSIDL_Type_Disallowed, /* FIXME */
1698  NULL,
1699  NULL
1700  },
1701  { /* 0x6d */
1702  &FOLDERID_UserProfiles,
1704  UsersW,
1705  UsersW
1706  },
1707  { /* 0x6e */
1708  &FOLDERID_UserProgramFiles,
1709  CSIDL_Type_Disallowed, /* FIXME */
1710  NULL,
1711  NULL
1712  },
1713  { /* 0x6f */
1714  &FOLDERID_UserProgramFilesCommon,
1715  CSIDL_Type_Disallowed, /* FIXME */
1716  NULL,
1717  NULL
1718  },
1719  { /* 0x70 */
1720  &FOLDERID_UsersFiles,
1722  NULL,
1723  NULL
1724  },
1725  { /* 0x71 */
1726  &FOLDERID_UsersLibraries,
1728  NULL,
1729  NULL
1730  },
1731  { /* 0x72 */
1732  &FOLDERID_VideosLibrary,
1733  CSIDL_Type_Disallowed, /* FIXME */
1734  NULL,
1735  NULL
1736  }
1737 #endif
1738 };
1739 
1740 #ifndef __REACTOS__
1741 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest);
1742 #else
1743 static HRESULT _SHExpandEnvironmentStrings(HANDLE hToken, LPCWSTR szSrc, LPWSTR szDest, DWORD cchDest);
1744 #endif
1745 
1746 /* Gets the value named value from the registry key
1747  * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
1748  * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
1749  * is assumed to be MAX_PATH WCHARs in length.
1750  * If it exists, expands the value and writes the expanded value to
1751  * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
1752  * Returns successful error code if the value was retrieved from the registry,
1753  * and a failure otherwise.
1754  */
1755 #ifndef __REACTOS__
1756 static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
1757 #else
1758 static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, HANDLE hToken, LPCWSTR userPrefix,
1759 #endif
1761 {
1762  HRESULT hr;
1763  WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
1764  LPCWSTR pShellFolderPath, pUserShellFolderPath;
1765  HKEY userShellFolderKey, shellFolderKey;
1766  DWORD dwType, dwPathLen;
1767 
1768  TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
1769  path);
1770 
1771  if (userPrefix)
1772  {
1773  strcpyW(shellFolderPath, userPrefix);
1774  PathAddBackslashW(shellFolderPath);
1775  strcatW(shellFolderPath, szSHFolders);
1776  pShellFolderPath = shellFolderPath;
1777  strcpyW(userShellFolderPath, userPrefix);
1778  PathAddBackslashW(userShellFolderPath);
1779  strcatW(userShellFolderPath, szSHUserFolders);
1780  pUserShellFolderPath = userShellFolderPath;
1781  }
1782  else
1783  {
1784  pUserShellFolderPath = szSHUserFolders;
1785  pShellFolderPath = szSHFolders;
1786  }
1787 
1788  if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
1789  {
1790  TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
1791  return E_FAIL;
1792  }
1793  if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
1794  {
1795  TRACE("Failed to create %s\n",
1796  debugstr_w(pUserShellFolderPath));
1797  RegCloseKey(shellFolderKey);
1798  return E_FAIL;
1799  }
1800 
1801  dwPathLen = MAX_PATH * sizeof(WCHAR);
1802  if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
1803  (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
1804  {
1805  LONG ret;
1806 
1807  path[dwPathLen / sizeof(WCHAR)] = '\0';
1808  if (dwType == REG_EXPAND_SZ && path[0] == '%')
1809  {
1810  WCHAR szTemp[MAX_PATH];
1811 
1812 #ifndef __REACTOS__
1814 #else
1815  hr = _SHExpandEnvironmentStrings(hToken, path, szTemp, _countof(szTemp));
1816  if (FAILED(hr))
1817  goto end;
1818 #endif
1819  lstrcpynW(path, szTemp, MAX_PATH);
1820  }
1821  ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
1822  (strlenW(path) + 1) * sizeof(WCHAR));
1823  if (ret != ERROR_SUCCESS)
1825  else
1826  hr = S_OK;
1827  }
1828  else
1829  hr = E_FAIL;
1830 #ifdef __REACTOS__
1831 end:
1832 #endif
1833  RegCloseKey(shellFolderKey);
1834  RegCloseKey(userShellFolderKey);
1835  TRACE("returning 0x%08x\n", hr);
1836  return hr;
1837 }
1838 
1840 {
1841  BOOL result;
1842  if (!hToken)
1843  {
1845  result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1846  CloseHandle(hToken);
1847  }
1848  else if ((INT) hToken == -1)
1849  {
1851  }
1852  else
1853  {
1854  result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1855  }
1856  TRACE("_SHGetUserProfileDirectoryW returning %S\n", szPath);
1857  return result;
1858 }
1859 
1860 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
1861  * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
1862  * - The entry's szDefaultPath may be either a string value or an integer
1863  * resource identifier. In the latter case, the string value of the resource
1864  * is written.
1865  * - Depending on the entry's type, the path may begin with an (unexpanded)
1866  * environment variable name. The caller is responsible for expanding
1867  * environment strings if so desired.
1868  * The types that are prepended with environment variables are:
1869  * CSIDL_Type_User: %USERPROFILE%
1870  * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
1871  * CSIDL_Type_CurrVer: %SystemDrive%
1872  * (Others might make sense too, but as yet are unneeded.)
1873  */
1874 #ifndef __REACTOS__
1876 #else
1877 static HRESULT _SHGetDefaultValue(HANDLE hToken, BYTE folder, LPWSTR pszPath)
1878 #endif
1879 {
1880  HRESULT hr;
1881  WCHAR resourcePath[MAX_PATH];
1882 #ifdef __REACTOS__
1883  NT_PRODUCT_TYPE ProductType;
1884 #endif
1885 
1886  TRACE("0x%02x,%p\n", folder, pszPath);
1887 
1888  if (folder >= ARRAY_SIZE(CSIDL_Data))
1889  return E_INVALIDARG;
1890 
1891  if (!pszPath)
1892  return E_INVALIDARG;
1893 
1894 #ifdef __REACTOS__
1895  if (hToken != NULL && hToken != (HANDLE)-1)
1896  {
1897  FIXME("unsupported for user other than current or default\n");
1898  }
1899 #endif
1900 
1901  if (!is_win64)
1902  {
1903  BOOL is_wow64;
1904 
1905  switch (folder)
1906  {
1907  case CSIDL_PROGRAM_FILES:
1911  break;
1916  break;
1917  }
1918  }
1919 
1920  switch (CSIDL_Data[folder].type)
1921  {
1922  case CSIDL_Type_User:
1923  strcpyW(pszPath, UserProfileW);
1924  break;
1925 #ifdef __REACTOS__
1926  case CSIDL_Type_InMyDocuments:
1927  strcpyW(pszPath, UserProfileW);
1928  if (DoGetProductType(&ProductType) && ProductType == NtProductWinNt)
1929  {
1930  if (IS_INTRESOURCE(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath))
1931  {
1932  WCHAR szItem[MAX_PATH];
1934  LOWORD(CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath),
1935  szItem, ARRAY_SIZE(szItem));
1936  PathAppendW(pszPath, szItem);
1937  }
1938  else
1939  {
1940  PathAppendW(pszPath, CSIDL_Data[CSIDL_MYDOCUMENTS].szDefaultPath);
1941  }
1942  }
1943  break;
1944 #endif
1945  case CSIDL_Type_AllUsers:
1946 #ifndef __REACTOS__
1947  strcpyW(pszPath, PublicProfileW);
1948 #else
1949  strcpyW(pszPath, AllUsersProfileW);
1950 #endif
1951  break;
1952  case CSIDL_Type_CurrVer:
1953  strcpyW(pszPath, SystemDriveW);
1954  break;
1955  default:
1956  ; /* no corresponding env. var, do nothing */
1957  }
1958 
1959  hr = S_OK;
1960  if (CSIDL_Data[folder].szDefaultPath)
1961  {
1962  if (IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
1963  {
1965  LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
1966  {
1967  PathAppendW(pszPath, resourcePath);
1968  }
1969  else
1970  {
1971  ERR("(%d,%s), LoadString failed, missing translation?\n", folder,
1972  debugstr_w(pszPath));
1973  hr = E_FAIL;
1974  }
1975  }
1976  else
1977  {
1978  PathAppendW(pszPath, CSIDL_Data[folder].szDefaultPath);
1979  }
1980  }
1981  TRACE("returning 0x%08x\n", hr);
1982  return hr;
1983 }
1984 
1985 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
1986  * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
1987  * can be overridden in the HKLM\\szCurrentVersion key.
1988  * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
1989  * the registry, uses _SHGetDefaultValue to get the value.
1990  */
1992  LPWSTR pszPath)
1993 {
1994  HRESULT hr;
1995 
1996  TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
1997 
1998  if (folder >= ARRAY_SIZE(CSIDL_Data))
1999  return E_INVALIDARG;
2001  return E_INVALIDARG;
2002  if (!pszPath)
2003  return E_INVALIDARG;
2004 
2006 #ifndef __REACTOS__
2007  hr = _SHGetDefaultValue(folder, pszPath);
2008 #else
2009  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2010 #endif
2011  else
2012  {
2013  HKEY hKey;
2014 
2016  hr = E_FAIL;
2017  else
2018  {
2019  DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
2020 
2021  if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
2022  &dwType, (LPBYTE)pszPath, &dwPathLen) ||
2023  (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
2024  {
2025 #ifndef __REACTOS__
2026  hr = _SHGetDefaultValue(folder, pszPath);
2027 #else
2028  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2029 #endif
2030  dwType = REG_EXPAND_SZ;
2031  switch (folder)
2032  {
2035  /* these two should never be set on 32-bit setups */
2036  if (!is_win64)
2037  {
2038  BOOL is_wow64;
2040  if (!is_wow64) break;
2041  }
2042  /* fall through */
2043  default:
2044  RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
2045  (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
2046  }
2047  }
2048  else
2049  {
2050  pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
2051  hr = S_OK;
2052  }
2053  RegCloseKey(hKey);
2054  }
2055  }
2056  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2057  return hr;
2058 }
2059 
2061 {
2062  char InfoBuffer[64];
2063  PTOKEN_USER UserInfo;
2064  DWORD InfoSize;
2065  LPWSTR SidStr;
2066 
2067  UserInfo = (PTOKEN_USER) InfoBuffer;
2068  if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
2069  &InfoSize))
2070  {
2072  return NULL;
2073  UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
2074  if (UserInfo == NULL)
2075  return NULL;
2076  if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
2077  &InfoSize))
2078  {
2079  HeapFree(GetProcessHeap(), 0, UserInfo);
2080  return NULL;
2081  }
2082  }
2083 
2084  if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
2085  SidStr = NULL;
2086 
2087  if (UserInfo != (PTOKEN_USER) InfoBuffer)
2088  HeapFree(GetProcessHeap(), 0, UserInfo);
2089 
2090  return SidStr;
2091 }
2092 
2093 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
2094  * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
2095  * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
2096  * - if hToken is -1, looks in HKEY_USERS\.Default
2097  * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
2098  * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
2099  * calls _SHGetDefaultValue for it.
2100  */
2102  LPWSTR pszPath)
2103 {
2104  const WCHAR *szValueName;
2105  WCHAR buffer[40];
2106  HRESULT hr;
2107 
2108  TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
2109 
2110  if (folder >= ARRAY_SIZE(CSIDL_Data))
2111  return E_INVALIDARG;
2112 #ifdef __REACTOS__
2114  CSIDL_Data[folder].type != CSIDL_Type_InMyDocuments)
2115 #else
2117 #endif
2118  {
2119  return E_INVALIDARG;
2120  }
2121  if (!pszPath)
2122  return E_INVALIDARG;
2123 
2125  {
2126 #ifndef __REACTOS__
2127  hr = _SHGetDefaultValue(folder, pszPath);
2128 #else
2129  hr = _SHGetDefaultValue(hToken, folder, pszPath);
2130 #endif
2131  }
2132  else
2133  {
2134  LPCWSTR userPrefix = NULL;
2135  HKEY hRootKey;
2136 
2137  if (hToken == (HANDLE)-1)
2138  {
2139  hRootKey = HKEY_USERS;
2140  userPrefix = DefaultW;
2141  }
2142  else if (hToken == NULL)
2143  hRootKey = HKEY_CURRENT_USER;
2144  else
2145  {
2146  hRootKey = HKEY_USERS;
2147  userPrefix = _GetUserSidStringFromToken(hToken);
2148  if (userPrefix == NULL)
2149  {
2150  hr = E_FAIL;
2151  goto error;
2152  }
2153  }
2154 
2155  /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2156  szValueName = CSIDL_Data[folder].szValueName;
2157  if (!szValueName)
2158  {
2160  szValueName = &buffer[0];
2161  }
2162 
2163 #ifndef __REACTOS__
2164  hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
2165  if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2166  hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
2167  if (FAILED(hr))
2168  hr = _SHGetDefaultValue(folder, pszPath);
2169 #else
2170  hr = _SHGetUserShellFolderPath(hRootKey, hToken, userPrefix, szValueName, pszPath);
2171  if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
2172  hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, hToken, NULL, szValueName, pszPath);
2173  if (FAILED(hr))
2174  hr = _SHGetDefaultValue(hToken, folder, pszPath);
2175 #endif
2176  if (userPrefix != NULL && userPrefix != DefaultW)
2177  LocalFree((HLOCAL) userPrefix);
2178  }
2179 error:
2180  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2181  return hr;
2182 }
2183 
2184 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
2185  * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
2186  * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
2187  * If this fails, falls back to _SHGetDefaultValue.
2188  */
2190  LPWSTR pszPath)
2191 {
2192  HRESULT hr;
2193 
2194  TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
2195 
2196  if (folder >= ARRAY_SIZE(CSIDL_Data))
2197  return E_INVALIDARG;
2199  return E_INVALIDARG;
2200  if (!pszPath)
2201  return E_INVALIDARG;
2202 
2204 #ifndef __REACTOS__
2205  hr = _SHGetDefaultValue(folder, pszPath);
2206 #else
2207  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2208 #endif
2209  else
2210  {
2211 #ifndef __REACTOS__
2213 #else
2215 #endif
2216  CSIDL_Data[folder].szValueName, pszPath);
2217  if (FAILED(hr))
2218 #ifndef __REACTOS__
2219  hr = _SHGetDefaultValue(folder, pszPath);
2220 #else
2221  hr = _SHGetDefaultValue(NULL, folder, pszPath);
2222 #endif
2223  }
2224  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
2225  return hr;
2226 }
2227 
2228 #ifndef __REACTOS__
2230 {
2231  LONG lRet;
2232  DWORD disp;
2233 
2235  KEY_ALL_ACCESS, NULL, pKey, &disp);
2236  return HRESULT_FROM_WIN32(lRet);
2237 }
2238 
2239 /* Reads the value named szValueName from the key profilesKey (assumed to be
2240  * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
2241  * WCHARs in length. If it doesn't exist, returns szDefault (and saves
2242  * szDefault to the registry).
2243  */
2244 static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName,
2245  LPWSTR szValue, LPCWSTR szDefault)
2246 {
2247  HRESULT hr;
2248  DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
2249  LONG lRet;
2250 
2251  TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
2252  debugstr_w(szDefault));
2253  lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
2254  (LPBYTE)szValue, &dwPathLen);
2255  if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
2256  && *szValue)
2257  {
2258  dwPathLen /= sizeof(WCHAR);
2259  szValue[dwPathLen] = '\0';
2260  hr = S_OK;
2261  }
2262  else
2263  {
2264  /* Missing or invalid value, set a default */
2265  lstrcpynW(szValue, szDefault, MAX_PATH);
2266  TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
2267  debugstr_w(szValue));
2268  lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
2269  (LPBYTE)szValue,
2270  (strlenW(szValue) + 1) * sizeof(WCHAR));
2271  if (lRet)
2272  hr = HRESULT_FROM_WIN32(lRet);
2273  else
2274  hr = S_OK;
2275  }
2276  TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
2277  return hr;
2278 }
2279 #endif
2280 
2281 /* Attempts to expand environment variables from szSrc into szDest, which is
2282  * assumed to be MAX_PATH characters in length. Before referring to the
2283  * environment, handles a few variables directly, because the environment
2284  * variables may not be set when this is called (as during Wine's installation
2285  * when default values are being written to the registry).
2286  * The directly handled environment variables, and their source, are:
2287  * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
2288  * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
2289  * path
2290  * If one of the directly handled environment variables is expanded, only
2291  * expands a single variable, and only in the beginning of szSrc.
2292  */
2293 #ifndef __REACTOS__
2295 #else
2296 static HRESULT _SHExpandEnvironmentStrings(HANDLE hToken, LPCWSTR szSrc, LPWSTR szDest, DWORD cchDest)
2297 #endif
2298 {
2299  HRESULT hr;
2300 #ifndef __REACTOS__
2301  WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
2302  HKEY key = NULL;
2303 #else
2304  WCHAR szTemp[MAX_PATH];
2305 #endif
2306 
2307  TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
2308 
2309  if (!szSrc || !szDest) return E_INVALIDARG;
2310 
2311  /* short-circuit if there's nothing to expand */
2312  if (szSrc[0] != '%')
2313  {
2314  strcpyW(szDest, szSrc);
2315  hr = S_OK;
2316  goto end;
2317  }
2318 #ifndef __REACTOS__
2319  /* Get the profile prefix, we'll probably be needing it */
2321  if (SUCCEEDED(hr))
2322  {
2323  WCHAR def_val[MAX_PATH];
2324 
2325  /* get the system drive */
2326  GetSystemDirectoryW(def_val, MAX_PATH);
2327  strcpyW( def_val + 3, szDefaultProfileDirW );
2328 
2329  hr = _SHGetProfilesValue(key, ProfilesDirectoryW, szProfilesPrefix, def_val );
2330  }
2331 #else
2332  hr = S_OK;
2333 #endif
2334 
2335  *szDest = 0;
2336  strcpyW(szTemp, szSrc);
2337  while (SUCCEEDED(hr) && szTemp[0] == '%')
2338  {
2340  {
2341 #ifndef __REACTOS__
2343 
2344  strcpyW(szDest, szProfilesPrefix);
2347  PathAppendW(szDest, szAllUsers);
2348 #else
2349  DWORD cchSize = cchDest;
2350  if (!GetAllUsersProfileDirectoryW(szDest, &cchSize))
2351  goto fallback_expand;
2352 #endif
2353  PathAppendW(szDest, szTemp + strlenW(AllUsersProfileW));
2354  }
2355 #ifndef __REACTOS__
2356  else if (!strncmpiW(szTemp, PublicProfileW, strlenW(PublicProfileW)))
2357  {
2358  WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
2359 
2360  GetSystemDirectoryW(def_val, MAX_PATH);
2361  strcpyW( def_val + 3, UsersPublicW );
2362 
2364  PathAppendW(szDest, szAllUsers);
2365  PathAppendW(szDest, szTemp + strlenW(PublicProfileW));
2366  }
2367 #endif
2368  else if (!strncmpiW(szTemp, UserProfileW, strlenW(UserProfileW)))
2369  {
2370 #ifndef __REACTOS__
2372  DWORD userLen = MAX_PATH;
2373 
2374  strcpyW(szDest, szProfilesPrefix);
2375  GetUserNameW(userName, &userLen);
2376  PathAppendW(szDest, userName);
2377 #else
2378  DWORD cchSize = cchDest;
2379  if (!_SHGetUserProfileDirectoryW(hToken, szDest, &cchSize))
2380  goto fallback_expand;
2381 #endif
2382  PathAppendW(szDest, szTemp + strlenW(UserProfileW));
2383  }
2384  else if (!strncmpiW(szTemp, SystemDriveW, strlenW(SystemDriveW)))
2385  {
2386 #ifndef __REACTOS__
2387  GetSystemDirectoryW(szDest, MAX_PATH);
2388 #else
2389  if (!GetSystemDirectoryW(szDest, cchDest))
2390  goto fallback_expand;
2391 #endif
2392  strcpyW(szDest + 3, szTemp + strlenW(SystemDriveW) + 1);
2393  }
2394  else
2395 #ifdef __REACTOS__
2396 fallback_expand:
2397 #endif
2398  {
2399 #ifndef __REACTOS__
2400  DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
2401 #else
2402  DWORD ret = SHExpandEnvironmentStringsForUserW(hToken, szTemp, szDest, cchDest);
2403 #endif
2404 
2405 #ifndef __REACTOS__
2406  if (ret > MAX_PATH)
2407 #else
2408  if (ret > cchDest)
2409 #endif
2411  else if (ret == 0)
2413  else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
2414  }
2415  if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
2416  }
2417 end:
2418 #ifndef __REACTOS__
2419  if (key)
2420  RegCloseKey(key);
2421 #endif
2422  TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
2423  debugstr_w(szSrc), debugstr_w(szDest));
2424  return hr;
2425 }
2426 
2427 /*************************************************************************
2428  * SHGetFolderPathW [SHELL32.@]
2429  *
2430  * Convert nFolder to path.
2431  *
2432  * RETURNS
2433  * Success: S_OK
2434  * Failure: standard HRESULT error codes.
2435  *
2436  * NOTES
2437  * Most values can be overridden in either
2438  * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
2439  * or in the same location in HKLM.
2440  * The "Shell Folders" registry key was used in NT4 and earlier systems.
2441  * Beginning with Windows 2000, the "User Shell Folders" key is used, so
2442  * changes made to it are made to the former key too. This synchronization is
2443  * done on-demand: not until someone requests the value of one of these paths
2444  * (by calling one of the SHGet functions) is the value synchronized.
2445  * Furthermore, the HKCU paths take precedence over the HKLM paths.
2446  */
2448  HWND hwndOwner, /* [I] owner window */
2449  int nFolder, /* [I] CSIDL identifying the folder */
2450  HANDLE hToken, /* [I] access token */
2451  DWORD dwFlags, /* [I] which path to return */
2452  LPWSTR pszPath) /* [O] converted path */
2453 {
2454  HRESULT hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, NULL, pszPath);
2457  return hr;
2458 }
2459 
2461  HWND hwndOwner, /* [I] owner window */
2462  int nFolder, /* [I] CSIDL identifying the folder */
2463  HANDLE hToken, /* [I] access token */
2464  DWORD dwFlags, /* [I] which path to return */
2465  LPCSTR pszSubPath, /* [I] sub directory of the specified folder */
2466  LPSTR pszPath) /* [O] converted path */
2467 {
2468  int length;
2469  HRESULT hr = S_OK;
2470  LPWSTR pszSubPathW = NULL;
2471  LPWSTR pszPathW = NULL;
2472 
2473  TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
2474 
2475  if(pszPath) {
2476  pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
2477  if(!pszPathW) {
2479  goto cleanup;
2480  }
2481  }
2482  TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
2483 
2484  /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
2485  * set (null), or an empty string.therefore call it without the parameter set
2486  * if pszSubPath is an empty string
2487  */
2488  if (pszSubPath && pszSubPath[0]) {
2489  length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
2490  pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
2491  if(!pszSubPathW) {
2493  goto cleanup;
2494  }
2495  MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
2496  }
2497 
2498  hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
2499 
2500  if (SUCCEEDED(hr) && pszPath)
2501  WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
2502 
2503 cleanup:
2504  HeapFree(GetProcessHeap(), 0, pszPathW);
2505  HeapFree(GetProcessHeap(), 0, pszSubPathW);
2506  return hr;
2507 }
2508 
2509 /*************************************************************************
2510  * SHGetFolderPathAndSubDirW [SHELL32.@]
2511  */
2513  HWND hwndOwner, /* [I] owner window */
2514  int nFolder, /* [I] CSIDL identifying the folder */
2515  HANDLE hToken, /* [I] access token */
2516  DWORD dwFlags, /* [I] which path to return */
2517  LPCWSTR pszSubPath,/* [I] sub directory of the specified folder */
2518  LPWSTR pszPath) /* [O] converted path */
2519 {
2520  HRESULT hr;
2521  WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
2523  CSIDL_Type type;
2524  int ret;
2525 
2526  TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
2527 
2528  /* Windows always NULL-terminates the resulting path regardless of success
2529  * or failure, so do so first
2530  */
2531  if (pszPath)
2532  *pszPath = '\0';
2533 
2534  if (folder >= ARRAY_SIZE(CSIDL_Data))
2535  return E_INVALIDARG;
2537  return E_INVALIDARG;
2538  szTemp[0] = 0;
2540  switch (type)
2541  {
2542  case CSIDL_Type_Disallowed:
2543  hr = E_INVALIDARG;
2544  break;
2546  hr = S_FALSE;
2547  break;
2549  GetWindowsDirectoryW(szTemp, MAX_PATH);
2550  if (CSIDL_Data[folder].szDefaultPath &&
2551  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2552  *CSIDL_Data[folder].szDefaultPath)
2553  {
2554  PathAddBackslashW(szTemp);
2555  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2556  }
2557  hr = S_OK;
2558  break;
2559  case CSIDL_Type_SystemPath:
2560  GetSystemDirectoryW(szTemp, MAX_PATH);
2561  if (CSIDL_Data[folder].szDefaultPath &&
2562  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2563  *CSIDL_Data[folder].szDefaultPath)
2564  {
2565  PathAddBackslashW(szTemp);
2566  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2567  }
2568  hr = S_OK;
2569  break;
2572  if (CSIDL_Data[folder].szDefaultPath &&
2573  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2574  *CSIDL_Data[folder].szDefaultPath)
2575  {
2576  PathAddBackslashW(szTemp);
2577  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2578  }
2579  hr = S_OK;
2580  break;
2581  case CSIDL_Type_CurrVer:
2583  break;
2584  case CSIDL_Type_User:
2585 #ifdef __REACTOS__
2586  case CSIDL_Type_InMyDocuments:
2587 #endif
2588  hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
2589  break;
2590  case CSIDL_Type_AllUsers:
2592  break;
2593  default:
2594  FIXME("bogus type %d, please fix\n", type);
2595  hr = E_INVALIDARG;
2596  break;
2597  }
2598 
2599  /* Expand environment strings if necessary */
2600  if (*szTemp == '%')
2601 #ifndef __REACTOS__
2602  hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
2603 #else
2604  hr = _SHExpandEnvironmentStrings(hToken, szTemp, szBuildPath, _countof(szBuildPath));
2605 #endif
2606  else
2607  strcpyW(szBuildPath, szTemp);
2608 
2609  if (FAILED(hr)) goto end;
2610 
2611  if(pszSubPath) {
2612  /* make sure the new path does not exceed the buffer length
2613  * and remember to backslash and terminate it */
2614  if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
2616  goto end;
2617  }
2618  PathAppendW(szBuildPath, pszSubPath);
2619  PathRemoveBackslashW(szBuildPath);
2620  }
2621  /* Copy the path if it's available before we might return */
2622  if (SUCCEEDED(hr) && pszPath)
2623  strcpyW(pszPath, szBuildPath);
2624 
2625  /* if we don't care about existing directories we are ready */
2626  if(nFolder & CSIDL_FLAG_DONT_VERIFY) goto end;
2627 
2628  if (PathFileExistsW(szBuildPath)) goto end;
2629 
2630  /* not existing but we are not allowed to create it. The return value
2631  * is verified against shell32 version 6.0.
2632  */
2633  if (!(nFolder & CSIDL_FLAG_CREATE))
2634  {
2636  goto end;
2637  }
2638 
2639  /* create directory/directories */
2640  ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
2641  if (ret && ret != ERROR_ALREADY_EXISTS)
2642  {
2643  ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
2644  hr = E_FAIL;
2645  goto end;
2646  }
2647 
2648  TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
2649 
2650 end:
2651  /* create desktop.ini for custom icon */
2652  if ((nFolder & CSIDL_FLAG_CREATE) &&
2653  CSIDL_Data[folder].nShell32IconIndex)
2654  {
2655  static const WCHAR s_szFormat[] = L"%%SystemRoot%%\\system32\\shell32.dll,%d";
2656  WCHAR szIconLocation[MAX_PATH];
2658 
2659  /* make the directory a read-only folder */
2660  dwAttributes = GetFileAttributesW(szBuildPath);
2662  SetFileAttributesW(szBuildPath, dwAttributes);
2663 
2664  /* build the desktop.ini file path */
2665  PathAppendW(szBuildPath, L"desktop.ini");
2666 
2667  /* build the icon location */
2668  StringCchPrintfW(szIconLocation, _countof(szIconLocation), s_szFormat,
2669  CSIDL_Data[folder].nShell32IconIndex);
2670 
2671  /* write desktop.ini */
2672  WritePrivateProfileStringW(L".ShellClassInfo", L"IconResource", szIconLocation, szBuildPath);
2673 
2674  /* flush! */
2675  WritePrivateProfileStringW(NULL, NULL, NULL, szBuildPath);
2676 
2677  /* make the desktop.ini a system and hidden file */
2678  dwAttributes = GetFileAttributesW(szBuildPath);
2680  SetFileAttributesW(szBuildPath, dwAttributes);
2681  }
2682 
2683  TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
2684  return hr;
2685 }
2686 
2687 /*************************************************************************
2688  * SHGetFolderPathA [SHELL32.@]
2689  *
2690  * See SHGetFolderPathW.
2691  */
2693  HWND hwndOwner,
2694  int nFolder,
2695  HANDLE hToken,
2696  DWORD dwFlags,
2697  LPSTR pszPath)
2698 {
2699  WCHAR szTemp[MAX_PATH];
2700  HRESULT hr;
2701 
2702  TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
2703 
2704  if (pszPath)
2705  *pszPath = '\0';
2706  hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
2707  if (SUCCEEDED(hr) && pszPath)
2708  WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
2709  NULL);
2710 
2711  return hr;
2712 }
2713 
2714 /* For each folder in folders, if its value has not been set in the registry,
2715  * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
2716  * folder's type) to get the unexpanded value first.
2717  * Writes the unexpanded value to User Shell Folders, and queries it with
2718  * SHGetFolderPathW to force the creation of the directory if it doesn't
2719  * already exist. SHGetFolderPathW also returns the expanded value, which
2720  * this then writes to Shell Folders.
2721  */
2722 static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken,
2723  LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[],
2724  UINT foldersLen)
2725 {
2726  const WCHAR *szValueName;
2727  WCHAR buffer[40];
2728  UINT i;
2729  WCHAR path[MAX_PATH];
2730  HRESULT hr = S_OK;
2731  HKEY hUserKey = NULL, hKey = NULL;
2732  DWORD dwType, dwPathLen;
2733  LONG ret;
2734 
2735  TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
2736  debugstr_w(szUserShellFolderPath), folders, foldersLen);
2737 
2738  ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
2739  if (ret)
2741  else
2742  {
2743  ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
2744  if (ret)
2746  }
2747  for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
2748  {
2749  dwPathLen = MAX_PATH * sizeof(WCHAR);
2750 
2751  /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2752  szValueName = CSIDL_Data[folders[i]].szValueName;
2753 #ifdef __REACTOS__
2754  if (!szValueName &&
2755  (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
2756  CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments))
2757 #else
2758  if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2759 #endif
2760  {
2761  StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
2762  szValueName = &buffer[0];
2763  }
2764 
2765  if (!RegQueryValueExW(hUserKey, szValueName, NULL,
2766  &dwType, (LPBYTE)path, &dwPathLen) &&
2767  (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
2768  {
2769  hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
2770  hToken, SHGFP_TYPE_CURRENT, path);
2771  }
2772  else
2773  {
2774  *path = '\0';
2775 #ifdef __REACTOS__
2776  if (CSIDL_Data[folders[i]].type == CSIDL_Type_User ||
2777  CSIDL_Data[folders[i]].type == CSIDL_Type_InMyDocuments)
2778 #else
2779  if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2780 #endif
2781  _SHGetUserProfilePath(hToken, SHGFP_TYPE_CURRENT, folders[i],
2782  path);
2783  else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers)
2785  else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
2786  {
2788  if (CSIDL_Data[folders[i]].szDefaultPath &&
2789  !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
2790  {
2792  strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
2793  }
2794  }
2795  else
2796  hr = E_FAIL;
2797  if (*path)
2798  {
2799  ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
2800  (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2801  if (ret)
2803  else
2804  {
2805  hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
2806  hToken, SHGFP_TYPE_CURRENT, path);
2807  ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
2808  (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2809  if (ret)
2811  }
2812  }
2813  }
2814  }
2815  if (hUserKey)
2816  RegCloseKey(hUserKey);
2817  if (hKey)
2818  RegCloseKey(hKey);
2819 
2820  TRACE("returning 0x%08x\n", hr);
2821  return hr;
2822 }
2823 
2825 {
2826  static const UINT folders[] = {
2830  CSIDL_APPDATA,
2831  CSIDL_STARTUP,
2832  CSIDL_RECENT,
2833  CSIDL_SENDTO,
2835  CSIDL_MYMUSIC,
2836  CSIDL_MYVIDEO,
2838  CSIDL_NETHOOD,
2843  CSIDL_COOKIES,
2844  CSIDL_HISTORY,
2846  CSIDL_FONTS,
2848 /* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
2849 #ifndef __REACTOS__
2852  CSIDL_LINKS,
2856 #endif
2857  };
2858  WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
2859  LPCWSTR pUserShellFolderPath, pShellFolderPath;
2860  HRESULT hr = S_OK;
2861  HKEY hRootKey;
2862  HANDLE hToken;
2863 
2864  TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
2865  if (bDefault)
2866  {
2867  hToken = (HANDLE)-1;
2868  hRootKey = HKEY_USERS;
2869  strcpyW(userShellFolderPath, DefaultW);
2870  PathAddBackslashW(userShellFolderPath);
2871  strcatW(userShellFolderPath, szSHUserFolders);
2872  pUserShellFolderPath = userShellFolderPath;
2873  strcpyW(shellFolderPath, DefaultW);
2874  PathAddBackslashW(shellFolderPath);
2875  strcatW(shellFolderPath, szSHFolders);
2876  pShellFolderPath = shellFolderPath;
2877  }
2878  else
2879  {
2880  hToken = NULL;
2881  hRootKey = HKEY_CURRENT_USER;
2882  pUserShellFolderPath = szSHUserFolders;
2883  pShellFolderPath = szSHFolders;
2884  }
2885 
2886  hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
2887  pShellFolderPath, folders, ARRAY_SIZE(folders));
2888  TRACE("returning 0x%08x\n", hr);
2889  return hr;
2890 }
2891 
2893 {
2894  static const UINT folders[] = {
2907  };
2908  HRESULT hr;
2909 
2910  TRACE("\n");
2912  szSHFolders, folders, ARRAY_SIZE(folders));
2913  TRACE("returning 0x%08x\n", hr);
2914  return hr;
2915 }
2916 
2917 /* Register the default values in the registry, as some apps seem to depend
2918  * on their presence. The set registered was taken from Windows XP.
2919  */
2921 {
2922  HRESULT hr;
2923 
2925  if (SUCCEEDED(hr))
2927  if (SUCCEEDED(hr))
2929  return hr;
2930 }
2931 
2932 /*************************************************************************
2933  * SHGetSpecialFolderPathA [SHELL32.@]
2934  */
2936  HWND hwndOwner,
2937  LPSTR szPath,
2938  int nFolder,
2939  BOOL bCreate)
2940 {
2941  return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
2942  szPath) == S_OK;
2943 }
2944 
2945 /*************************************************************************
2946  * SHGetSpecialFolderPathW
2947  */
2949  HWND hwndOwner,
2950  LPWSTR szPath,
2951  int nFolder,
2952  BOOL bCreate)
2953 {
2954  return SHGetFolderPathW(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
2955  szPath) == S_OK;
2956 }
2957 
2958 /*************************************************************************
2959  * SHGetFolderLocation [SHELL32.@]
2960  *
2961  * Gets the folder locations from the registry and creates a pidl.
2962  *
2963  * PARAMS
2964  * hwndOwner [I]
2965  * nFolder [I] CSIDL_xxxxx
2966  * hToken [I] token representing user, or NULL for current user, or -1 for
2967  * default user
2968  * dwReserved [I] must be zero
2969  * ppidl [O] PIDL of a special folder
2970  *
2971  * RETURNS
2972  * Success: S_OK
2973  * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
2974  *
2975  * NOTES
2976  * Creates missing reg keys and directories.
2977  * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
2978  * virtual folders that are handled here.
2979  */
2981  HWND hwndOwner,
2982  int nFolder,
2983  HANDLE hToken,
2984  DWORD dwReserved,
2985  LPITEMIDLIST *ppidl)
2986 {
2988 
2989  TRACE("%p 0x%08x %p 0x%08x %p\n",
2990  hwndOwner, nFolder, hToken, dwReserved, ppidl);
2991 
2992  if (!ppidl)
2993  return E_INVALIDARG;
2994  if (dwReserved)
2995  return E_INVALIDARG;
2996 
2997  /* The virtual folders' locations are not user-dependent */
2998  *ppidl = NULL;
2999  switch (nFolder & CSIDL_FOLDER_MASK)
3000  {
3001  case CSIDL_DESKTOP:
3002  *ppidl = _ILCreateDesktop();
3003  break;
3004 
3005  case CSIDL_PERSONAL:
3006  *ppidl = _ILCreateMyDocuments();
3007  break;
3008 
3009  case CSIDL_INTERNET:
3010  *ppidl = _ILCreateIExplore();
3011  break;
3012 
3013  case CSIDL_CONTROLS:
3014  *ppidl = _ILCreateControlPanel();
3015  break;
3016 
3017  case CSIDL_PRINTERS:
3018  *ppidl = _ILCreatePrinters();
3019  break;
3020 
3021  case CSIDL_BITBUCKET:
3022  *ppidl = _ILCreateBitBucket();
3023  break;
3024 
3025  case CSIDL_DRIVES:
3026  *ppidl = _ILCreateMyComputer();
3027  break;
3028 
3029  case CSIDL_NETWORK:
3030  *ppidl = _ILCreateNetwork();
3031  break;
3032 
3033  default:
3034  {
3036 
3037  hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
3039  if (SUCCEEDED(hr))
3040  {
3041  DWORD attributes=0;
3042 
3043  TRACE("Value=%s\n", debugstr_w(szPath));
3044  hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
3045  }
3047  {
3048  /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
3049  * version 6.0 returns E_FAIL for nonexistent paths
3050  */
3051  hr = E_FAIL;
3052  }
3053  }
3054  }
3055  if(*ppidl)
3056  hr = S_OK;
3057 
3058  TRACE("-- (new pidl %p)\n",*ppidl);
3059  return hr;
3060 }
3061 
3062 /*************************************************************************
3063  * SHGetSpecialFolderLocation [SHELL32.@]
3064  *
3065  * NOTES
3066  * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
3067  * directory.
3068  */
3070  HWND hwndOwner,
3071  INT nFolder,
3072  LPITEMIDLIST * ppidl)
3073 {
3075 
3076  TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
3077 
3078  if (!ppidl)
3079  return E_INVALIDARG;
3080 
3081  hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
3082  return hr;
3083 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define HKEY_USERS
Definition: winreg.h:13
static HRESULT _SHRegisterCommonShellFolders(void)
Definition: shellpath.c:2892
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:794
static const WCHAR Common_DesktopW[]
Definition: shellpath.c:827
static const WCHAR FavoritesW[]
Definition: shellpath.c:848
static LONG PathProcessCommandA(LPCSTR lpszPath, LPSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:769
static const WCHAR UsersW[]
Definition: shellpath.c:910
#define IDI_SHELL_RECENT_DOCUMENTS
Definition: shresdef.h:542
static const WCHAR PublicProfileW[]
Definition: shellpath.c:918
static const WCHAR ContactsW[]
Definition: shellpath.c:840
#define CSIDL_COOKIES
Definition: shlobj.h:2044
BOOL WINAPI GetDefaultUserProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1443
BOOL WINAPI PathAppendAW(LPVOID lpszPath1, LPCVOID lpszPath2)
Definition: shellpath.c:236
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
Definition: pdh_main.c:93
#define IDS_STARTMENU
Definition: shresdef.h:92
BOOL WINAPI PathFileExistsAndAttributesW(LPCWSTR lpszPath, DWORD *dwAttr)
Definition: path.c:1831
static const WCHAR DocumentsW[]
Definition: shellpath.c:845
static const WCHAR Microsoft_Windows_LibrariesW[]
Definition: shellpath.c:863
#define WHICH_DEFAULT
#define CloseHandle
Definition: compat.h:598
LPCWSTR szDefaultPath
Definition: shellpath.c:965
static const WCHAR RecentW[]
Definition: shellpath.c:894
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1602
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
Definition: fci.c:115
static LONG PathProcessCommandW(LPCWSTR lpszPath, LPWSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:785
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static const WCHAR UserProfileW[]
Definition: shellpath.c:920
#define ERROR_SUCCESS
Definition: deptool.c:10
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define CSIDL_MYVIDEO
Definition: shlobj.h:2026
static const WCHAR szKnownFolderRedirections[]
Definition: shellpath.c:932
#define WideCharToMultiByte
Definition: compat.h:111
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
GLuint64EXT * result
Definition: glext.h:11304
static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
Definition: shellpath.c:2294
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1650
int WINAPI PathCleanupSpec(LPCWSTR lpszPathW, LPWSTR lpszFileW)
Definition: shellpath.c:531
static const WCHAR FontsW[]
Definition: shellpath.c:849
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2073
BOOL WINAPI GetUserProfileDirectoryW(_In_ HANDLE hToken, _Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1792
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2036
static const WCHAR Common_ProgramsW[]
Definition: shellpath.c:834
#define CSIDL_MYPICTURES
Definition: shlobj.h:2050
#define IDS_APPDATA
Definition: shresdef.h:98
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const WCHAR CommonFilesDirW[]
Definition: shellpath.c:830
#define IDI_SHELL_CONTROL_PANEL
Definition: shresdef.h:543
static const WCHAR Microsoft_Windows_RingtonesW[]
Definition: shellpath.c:864
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define CSIDL_DESKTOP
Definition: shlobj.h:2012
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2042
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1991
#define CSIDL_CONTACTS
Definition: shellpath.c:952
#define PRF_FIRSTDIRDEF
Definition: PathResolve.cpp:32
#define CP_ACP
Definition: compat.h:109
#define PRF_DONTFINDLNK
Definition: PathResolve.cpp:33
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
LONG WINAPI PathProcessCommandAW(LPCVOID lpszPath, LPVOID lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:801
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken, LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[], UINT foldersLen)
Definition: shellpath.c:2722
char CHAR
Definition: xmlstorage.h:175
#define IDS_COMMON_MUSIC
Definition: shresdef.h:109
#define IDI_SHELL_COMPUTER_FOLDER
Definition: shresdef.h:564
#define PRF_VERIFYEXISTS
Definition: PathResolve.cpp:29
BOOL WINAPI PathAppendA(LPSTR lpszPath, LPCSTR lpszAppend)
Definition: path.c:106
static BOOL PathMakeUniqueNameW(LPWSTR lpszBuffer, DWORD dwBuffSize, LPCWSTR lpszShortName, LPCWSTR lpszLongName, LPCWSTR lpszPathName)
Definition: shellpath.c:461
#define IDS_INTERNET_CACHE
Definition: shresdef.h:101
static const WCHAR SendToW[]
Definition: shellpath.c:900
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:615
static const WCHAR Program_FilesW[]
Definition: shellpath.c:883
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:969
static const WCHAR VideosW[]
Definition: shellpath.c:912
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2035
#define IDS_PERSONAL
Definition: shresdef.h:267
#define IDI_SHELL_FAVORITES
Definition: shresdef.h:565
#define IDS_FAVORITES
Definition: resource.h:31
_In_ int nFolder
Definition: shlobj.h:1444
enum _CSIDL_Type CSIDL_Type
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define RRF_RT_REG_SZ
Definition: driver.c:575
BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
Definition: path.c:1754
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1664
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
UINT WINAPI PathGetCharTypeW(WCHAR ch)
Definition: path.c:3035
#define IDI_SHELL_MY_MOVIES
Definition: shresdef.h:650
GLuint buffer
Definition: glext.h:5915
static const WCHAR OEM_LinksW[]
Definition: shellpath.c:874
#define CSIDL_BITBUCKET
Definition: shlobj.h:2022
static const WCHAR TemplatesW[]
Definition: shellpath.c:908
#define CSIDL_HISTORY
Definition: shlobj.h:2045
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2049
LPVOID WINAPI SHPathGetExtensionW(LPCWSTR lpszPath, DWORD void1, DWORD void2)
Definition: shellpath.c:274
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2062
static const WCHAR szCurrentVersion[]
Definition: shellpath.c:816
#define IDI_SHELL_PROGRAMS_FOLDER
Definition: shresdef.h:541
static const WCHAR ProfilesDirectoryW[]
Definition: shellpath.c:924
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:130
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static LPSTR
Definition: shellpath.c:88
static const WCHAR AppDataW[]
Definition: shellpath.c:818
BOOL WINAPI GetVolumeInformationA(IN LPCSTR lpRootPathName, IN LPSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:32
char * LPSTR
Definition: xmlstorage.h:182
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
Definition: security.c:3259
#define PCS_FATAL
Definition: shlobj.h:331
#define CSIDL_FONTS
Definition: shlobj.h:2031
#define lstrlenW
Definition: compat.h:609
#define E_FAIL
Definition: ddrawi.h:102
static const WCHAR Local_AppDataW[]
Definition: shellpath.c:854
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
Definition: path.c:586
static const WCHAR Common_FavoritesW[]
Definition: shellpath.c:829
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2043
static const WCHAR ProgramsW[]
Definition: shellpath.c:890
BOOL WINAPI IsLFNDriveAW(LPCVOID lpszPath)
Definition: shellpath.c:432
DWORD dwAttributes
Definition: vdmdbg.h:34
#define pch(ap)
Definition: match.c:418
#define PRF_TRYPROGRAMEXTENSIONS
Definition: PathResolve.cpp:31
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2056
#define IDI_SHELL_PRINTERS_FOLDER
Definition: shresdef.h:559
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
#define lstrcpynW
Definition: compat.h:597
BOOL WINAPI PathIsURLW(LPCWSTR lpstrPath)
Definition: url.c:2432
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
#define CSIDL_CONTROLS
Definition: shlobj.h:2015
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2053
static const WCHAR szSHUserFolders[]
Definition: shellpath.c:928
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2034
static BOOL WINAPI PathIsAbsoluteW(LPCWSTR path)
Definition: shellpath.c:127
static const WCHAR Common_TemplatesW[]
Definition: shellpath.c:837
static const WCHAR MusicW[]
Definition: shellpath.c:865
static const WCHAR Music_PlaylistsW[]
Definition: shellpath.c:866
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2024
#define CSIDL_RECENT
Definition: shlobj.h:2020
static const WCHAR ProgramFilesDirW[]
Definition: shellpath.c:888
VOID WINAPI FixSlashesAndColonW(LPWSTR lpwstr)
Definition: ordinal.c:4401
static const WCHAR Local_Settings_Application_DataW[]
Definition: shellpath.c:856
#define CSIDL_FOLDER_MASK
Definition: shlobj.h:2070
enum _NT_PRODUCT_TYPE * PNT_PRODUCT_TYPE
static const WCHAR Program_Files_x86W[]
Definition: shellpath.c:886
#define IDS_PRINTHOOD
Definition: shresdef.h:99
#define PCS_PATHTOOLONG
Definition: shlobj.h:335
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2935
#define CSIDL_PRINTERS
Definition: shlobj.h:2016
#define IDI_SHELL_DESKTOP
Definition: shresdef.h:556
#define CSIDL_DRIVES
Definition: shlobj.h:2028
#define GCT_WILD
Definition: shlwapi.h:778
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
static const WCHAR Administrative_ToolsW[]
Definition: shellpath.c:817
#define FALSE
Definition: types.h:117
#define CSIDL_FAVORITES
Definition: shlobj.h:2018
BOOL WINAPI PathStripToRootW(LPWSTR lpszPath)
Definition: path.c:733
static const WCHAR PublicW[]
Definition: shellpath.c:892
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
BOOL _SHGetUserProfileDirectoryW(HANDLE hToken, LPWSTR szPath, LPDWORD lpcchPath)
Definition: shellpath.c:1839
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static const WCHAR Videos_Sample_VideosW[]
Definition: shellpath.c:913
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI PathIsRootAW(LPCVOID lpszPath)
Definition: shellpath.c:340
if SUCCEEDED(hr)
#define GCT_INVALID
Definition: shlwapi.h:775
static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
Definition: shellpath.c:2824
BOOL WINAPI PathIsUNCServerShareW(LPCWSTR lpszPath)
Definition: path.c:2377
#define IDS_STARTUP
Definition: shresdef.h:89
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define debugstr_w
Definition: kernel32.h:32
#define IDS_PROGRAMS
Definition: resource.h:69
#define PRF_REQUIREABSOLUTE
Definition: PathResolve.cpp:36
#define FIXME(fmt,...)
Definition: debug.h:111
static void PathGetShortPathW(LPWSTR pszPath)
Definition: shellpath.c:311
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static const WCHAR AllUsersProfileW[]
Definition: shellpath.c:916
static const WCHAR Common_StartUpW[]
Definition: shellpath.c:835
#define S_FALSE
Definition: winerror.h:2357
BOOL WINAPI PathRemoveFileSpecAW(LPVOID lpszPath)
Definition: shellpath.c:282
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI PathIsFileSpecW(LPCWSTR lpszPath)
Definition: path.c:2132
static const WCHAR Program_Files_x86_Common_FilesW[]
Definition: shellpath.c:887
static const WCHAR Common_Start_MenuW[]
Definition: shellpath.c:836
static const BOOL is_win64
Definition: shellpath.c:58
char ext[3]
Definition: mkdosfs.c:358
#define IDS_DESKTOPDIRECTORY
Definition: shresdef.h:95
#define IDI_SHELL_TSKBAR_STARTMENU
Definition: shresdef.h:561
#define CSIDL_SEARCHES
Definition: shellpath.c:957
static const WCHAR UsersPublicW[]
Definition: shellpath.c:911
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2033
#define IDI_SHELL_NETWORK
Definition: shresdef.h:536
BOOL WINAPI PathResolveW(LPWSTR path, LPCWSTR *dirs, DWORD flags)
Definition: shellpath.c:678
#define IDS_COMMON_VIDEO
Definition: shresdef.h:111
BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
Definition: shellpath.c:420
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1776
static const WCHAR Start_MenuW[]
Definition: shellpath.c:902
const char * LPCSTR
Definition: xmlstorage.h:183
LPITEMIDLIST _ILCreateMyComputer(void)
Definition: pidl.c:1613
static const WCHAR ProgramFilesDirX86W[]
Definition: shellpath.c:889
static const WCHAR Microsoft_Windows_GameExplorerW[]
Definition: shellpath.c:862
static const WCHAR Common_AppDataW[]
Definition: shellpath.c:826
struct CFFOLDER folder
Definition: fdi.c:102
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HRESULT _SHOpenProfilesKey(PHKEY pKey)
Definition: shellpath.c:2229
static const WCHAR Program_Files_Common_FilesW[]
Definition: shellpath.c:884
static const WCHAR path1[]
Definition: path.c:28
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2058
static const WCHAR szKnownFolderDescriptions[]
Definition: shellpath.c:931
#define IDI_SHELL_FONTS_FOLDER
Definition: shresdef.h:560
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1975
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
UINT WINAPI PathGetCharTypeA(UCHAR ch)
Definition: path.c:3025
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1641
static const WCHAR Pictures_Slide_ShowsW[]
Definition: shellpath.c:879
#define IDI_SHELL_NETWORK_FOLDER
Definition: resource.h:5
#define IDS_TEMPLATES
Definition: shresdef.h:97
const KNOWNFOLDERID * id
Definition: shellpath.c:962
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR StartUpW[]
Definition: shellpath.c:901
static const WCHAR szAllUsers[]
Definition: msipriv.h:1138
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:893
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define CSIDL_ADMINTOOLS
Definition: shlobj.h:2059
BOOL WINAPI PathMakeUniqueNameAW(LPVOID lpszBuffer, DWORD dwBuffSize, LPCVOID lpszShortName, LPCVOID lpszLongName, LPCVOID lpszPathName)
Definition: shellpath.c:477
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2101
#define debugstr_a
Definition: kernel32.h:31
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3069
LONG HRESULT
Definition: typedefs.h:79
static const WCHAR Common_Administrative_ToolsW[]
Definition: shellpath.c:825
#define _countof(array)
Definition: sndvol32.h:68
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2039
static const WCHAR SystemDriveW[]
Definition: shellpath.c:921
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1832
static BOOL is_wow64
Definition: loader.c:55
#define CSIDL_SENDTO
Definition: shlobj.h:2021
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1751
_In_ LPCSTR pszDir
Definition: shellapi.h:582
#define CSIDL_APPDATA
Definition: shlobj.h:2037
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
const char file[]
Definition: icontest.c:11
static const WCHAR AppData_LocalLowW[]
Definition: shellpath.c:820
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
#define GCT_SEPARATOR
Definition: shlwapi.h:779
BOOL PathIsExeW(LPCWSTR lpszPath)
Definition: shellpath.c:368
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2659
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath)
Definition: shellpath.c:408
#define IDS_COOKIES
Definition: shresdef.h:102
#define SetLastError(x)
Definition: compat.h:611
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2063
GLbitfield flags
Definition: glext.h:7161
static void PathGetShortPathA(LPSTR pszPath)
Definition: shellpath.c:296
#define IDS_RECENT
Definition: shresdef.h:90
GLuint GLuint end
Definition: gl.h:1545
static const WCHAR CommonFilesDirX86W[]
Definition: shellpath.c:831
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1875
static const WCHAR HistoryW[]
Definition: shellpath.c:850
static HANDLE
Definition: shellpath.c:88
int ret
static const WCHAR CD_BurningW[]
Definition: shellpath.c:824
static const WCHAR Start_Menu_ProgramsW[]
Definition: shellpath.c:904
static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:2189
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI GetSystemWow64DirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2420
#define CSIDL_COMMON_APPDATA
Definition: shlobj.h:2046
static const WCHAR CommonVideoW[]
Definition: shellpath.c:838
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static const WCHAR Saved_GamesW[]
Definition: shellpath.c:897
static const WCHAR Start_Menu_StartupW[]
Definition: shellpath.c:906
VOID WINAPI PathQualifyW(LPWSTR pszPath)
Definition: shellpath.c:615
static const WCHAR CacheW[]
Definition: shellpath.c:823
#define IDS_COMMON_PICTURES
Definition: shresdef.h:110
static const WCHAR My_PicturesW[]
Definition: shellpath.c:871
#define IDS_PROGRAM_FILES_COMMON
Definition: shresdef.h:106
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2783
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define GUID_NULL
Definition: ks.h:106
#define GetCurrentProcess()
Definition: compat.h:618
#define IDS_HISTORY
Definition: shresdef.h:103
static const WCHAR Local_Settings_CD_BurningW[]
Definition: shellpath.c:858
BOOL WINAPI PathFileExistsAW(LPCVOID lpszPath)
Definition: shellpath.c:398
static const WCHAR Cleanup[]
Definition: register.c:80
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
static BOOL WINAPI PathSearchOnExtensionsW(LPWSTR pszPath, LPCWSTR *ppszDirs, BOOL bDoSearch, DWORD dwWhich)
Definition: shellpath.c:114
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:867
static VOID WINAPI PathQualifyExW(LPWSTR pszPath, LPCWSTR pszDir, DWORD dwFlags)
Definition: shellpath.c:159
unsigned char BYTE
Definition: xxhash.c:193
#define PCS_REPLACEDCHAR
Definition: shlobj.h:332
static const WCHAR DownloadsW[]
Definition: shellpath.c:846
BOOL WINAPI WritePrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR string, LPCWSTR filename)
Definition: profile.c:1453
GLsizei const GLuint * paths
Definition: glext.h:11717
#define CSIDL_PROGRAM_FILES_COMMONX86
Definition: shlobj.h:2055
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define CSIDL_STARTUP
Definition: shlobj.h:2019
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2054
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2061
#define CSIDL_LINKS
Definition: shellpath.c:954
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1601
FxRegKey * pKey
#define ERR(fmt,...)
Definition: debug.h:110
static const WCHAR Local_Settings_HistoryW[]
Definition: shellpath.c:860
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
#define CSIDL_APPDATA_LOCALLOW
Definition: shellpath.c:955
static const WCHAR DesktopW[]
Definition: shellpath.c:843
BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath, DWORD dwWhich)
Definition: path.c:1117
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1669
static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
Definition: shell32_main.h:160
#define S_OK
Definition: intsafe.h:52
static const WCHAR szDefaultProfileDirW[]
Definition: shellpath.c:929
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define shell32_hInstance
#define IDI_SHELL_MY_MUSIC
Definition: shresdef.h:649
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1444
_NT_PRODUCT_TYPE
#define IDI_SHELL_MY_DOCUMENTS
Definition: shresdef.h:647
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define lstrcpyW
Definition: compat.h:608
#define IDI_SHELL_SYSTEM_GEAR
Definition: shresdef.h:686
LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
Definition: path.c:422
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2948
BOOL WINAPI PathResolveAW(LPVOID path, LPCVOID *paths, DWORD flags)
Definition: shellpath.c:758
static BOOL PathIsExeA(LPCSTR lpszPath)
Definition: shellpath.c:350
#define CSIDL_DOWNLOADS
Definition: shellpath.c:953
BOOL WINAPI GetAllUsersProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1310
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2692
#define WHICH_LNK
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
FxAutoRegKey hKey
LPCWSTR szPath
Definition: env.c:37
#define ARRAY_SIZE(a)
Definition: main.h:24
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
int WINAPI SHCreateDirectoryExW(HWND hWnd, LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
Definition: shlfileop.cpp:846
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
static LPWSTR _GetUserSidStringFromToken(HANDLE Token)
Definition: shellpath.c:2060
static const WCHAR ProfileListW[]
Definition: shellpath.c:923
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2038
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
static const WCHAR LinksW[]
Definition: shellpath.c:852
INT nShell32IconIndex
Definition: shellpath.c:966
static const WCHAR AllUsersW[]
Definition: shellpath.c:934
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define IDI_SHELL_NETWORK_CONNECTIONS
Definition: shresdef.h:606
#define sprintfW
Definition: unicode.h:58
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2057
static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName, LPWSTR szValue, LPCWSTR szDefault)
Definition: shellpath.c:2244
BOOL WINAPI PathResolveA(LPSTR path, LPCSTR *dirs, DWORD flags)
Definition: shellpath.c:632
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define IDI_SHELL_MY_PICTURES
Definition: shresdef.h:648
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define CSIDL_FLAG_CREATE
#define CSIDL_INTERNET
Definition: shlobj.h:2013
CSIDL_Type type
Definition: shellpath.c:963
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
BOOL WINAPI PathIsUNCServerW(LPCWSTR lpszPath)
Definition: path.c:2322
VOID WINAPI PathQualifyA(LPSTR pszPath)
Definition: shellpath.c:603
HRESULT WINAPI SHGetFolderPathAndSubDirA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCSTR pszSubPath, LPSTR pszPath)
Definition: shellpath.c:2460
#define MultiByteToWideChar
Definition: compat.h:110
#define IDS_MYVIDEO
Definition: shresdef.h:94
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:553
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:263
#define IDS_PROGRAM_FILES
Definition: shresdef.h:104
#define CSIDL_SAVED_GAMES
Definition: shellpath.c:956
static const WCHAR Common_DocumentsW[]
Definition: shellpath.c:828
#define CSIDL_NETHOOD
Definition: shlobj.h:2030
static const WCHAR ResourcesW[]
Definition: shellpath.c:895
static const WCHAR userName[]
Definition: wnet.c:2154
static const WCHAR AllUsersProfileValueW[]
Definition: shellpath.c:925
static const WCHAR szSHFolders[]
Definition: shellpath.c:927
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
#define CSIDL_PERSONAL
Definition: shlobj.h:2017
CONST void * LPCVOID
Definition: windef.h:191
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2447
#define CSIDL_STARTMENU
Definition: shlobj.h:2023
static const WCHAR Music_Sample_PlaylistsW[]
Definition: shellpath.c:868
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
static DWORD GetShortPathNameAbsentW(LPCWSTR pszLong, LPWSTR pszShort, DWORD cchShort)
Definition: shellpath.c:149
LPCWSTR szValueName
Definition: shellpath.c:964
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
static const WCHAR Application_DataW[]
Definition: shellpath.c:821
uint32_t * LPDWORD
Definition: typedefs.h:59
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static LPSTR PathGetExtensionA(LPCSTR lpszPath)
Definition: shellpath.c:252
static const WCHAR My_VideoW[]
Definition: shellpath.c:872
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
static BOOL WINAPI PathMakeAbsoluteW(LPWSTR path)
Definition: shellpath.c:133
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
static const WCHAR Pictures_Sample_PicturesW[]
Definition: shellpath.c:878
static const WCHAR NetHoodW[]
Definition: shellpath.c:873
BOOL WINAPI PathIsExeAW(LPCVOID path)
Definition: shellpath.c:388
struct _TOKEN_USER * PTOKEN_USER
SID_AND_ATTRIBUTES User
Definition: setypes.h:975
char * cleanup(char *str)
Definition: wpickclick.c:99
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2980
#define IDS_ADMINTOOLS
Definition: shresdef.h:108
static const WCHAR CookiesW[]
Definition: shellpath.c:842
#define IDS_MYMUSIC
Definition: shresdef.h:93
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1625
#define IDS_MYPICTURES
Definition: shresdef.h:105
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:492
#define IDS_NETHOOD
Definition: shresdef.h:96
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static const WCHAR Local_Settings_Temporary_Internet_FilesW[]
Definition: shellpath.c:861
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2027
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2265
GLfloat GLfloat p
Definition: glext.h:8902
static const WCHAR SearchesW[]
Definition: shellpath.c:898
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1619
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1631
#define CSIDL_NETWORK
Definition: shlobj.h:2029
IN PCTCH IN DWORD cch
Definition: pager.h:36
HRESULT WINAPI SHGetFolderPathAndSubDirW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCWSTR pszSubPath, LPWSTR pszPath)
Definition: shellpath.c:2512
static const WCHAR My_MusicW[]
Definition: shellpath.c:870
#define CSIDL_PROGRAMS
Definition: shlobj.h:2014
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:194
#define CSIDL_TEMPLATES
Definition: shlobj.h:2032
static const WCHAR Music_Sample_MusicW[]
Definition: shellpath.c:867
BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
Definition: path.c:1350
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const WCHAR Start_Menu_Admin_ToolsW[]
Definition: shellpath.c:905
static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
Definition: shellpath.c:1756
static const WCHAR PersonalW[]
Definition: shellpath.c:875
BOOL WINAPI PathFindOnPathW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs)
Definition: path.c:1402
#define LOWORD(l)
Definition: pedump.c:82
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
static BOOL PathMakeUniqueNameA(LPSTR lpszBuffer, DWORD dwBuffSize, LPCSTR lpszShortName, LPCSTR lpszLongName, LPCSTR lpszPathName)
Definition: shellpath.c:445
#define HeapFree(x, y, z)
Definition: compat.h:594
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1675
#define IDS_SENDTO
Definition: shresdef.h:91
static const WCHAR PrintHoodW[]
Definition: shellpath.c:881
static const WCHAR DefaultW[]
Definition: shellpath.c:915
#define IDS_LOCAL_APPDATA
Definition: shresdef.h:100
static const WCHAR CommonPicturesW[]
Definition: shellpath.c:833
static const WCHAR PicturesW[]
Definition: shellpath.c:877
_CSIDL_Type
Definition: shellpath.c:936
static const WCHAR CommonMusicW[]
Definition: shellpath.c:832
VOID WINAPI PathQualifyAW(LPVOID pszPath)
Definition: shellpath.c:624
VOID WINAPI PathGetShortPathAW(LPVOID pszPath)
Definition: shellpath.c:326
Definition: path.c:41
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define CSIDL_MYMUSIC
Definition: shlobj.h:2025
HRESULT SHELL_RegisterShellFolders(void)
Definition: shellpath.c:2920
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22