ReactOS  0.4.14-dev-608-gd495a4f
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-2019 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 
54 
55 static const BOOL is_win64 = sizeof(void *) > sizeof(int);
56 
57 /*
58  ########## Combining and Constructing paths ##########
59 */
60 
61 /*************************************************************************
62  * PathAppend [SHELL32.36]
63  */
65  LPVOID lpszPath1,
66  LPCVOID lpszPath2)
67 {
68  if (SHELL_OsIsUnicode())
69  return PathAppendW(lpszPath1, lpszPath2);
70  return PathAppendA(lpszPath1, lpszPath2);
71 }
72 
73 /*************************************************************************
74  * PathGetExtensionA [internal]
75  *
76  * NOTES
77  * exported by ordinal
78  * return value points to the first char after the dot
79  */
80 static LPSTR PathGetExtensionA(LPCSTR lpszPath)
81 {
82  TRACE("(%s)\n",lpszPath);
83 
84  lpszPath = PathFindExtensionA(lpszPath);
85  return (LPSTR)(*lpszPath?(lpszPath+1):lpszPath);
86 }
87 
88 /*************************************************************************
89  * PathGetExtensionW [internal]
90  */
92 {
93  TRACE("(%s)\n",debugstr_w(lpszPath));
94 
95  lpszPath = PathFindExtensionW(lpszPath);
96  return (LPWSTR)(*lpszPath?(lpszPath+1):lpszPath);
97 }
98 
99 /*************************************************************************
100  * SHPathGetExtension [SHELL32.158]
101  */
103 {
104  return PathGetExtensionW(lpszPath);
105 }
106 
107 /*************************************************************************
108  * PathRemoveFileSpec [SHELL32.35]
109  */
111 {
112  if (SHELL_OsIsUnicode())
113  return PathRemoveFileSpecW(lpszPath);
114  return PathRemoveFileSpecA(lpszPath);
115 }
116 
117 /*
118  Path Manipulations
119 */
120 
121 /*************************************************************************
122  * PathGetShortPathA [internal]
123  */
124 static void PathGetShortPathA(LPSTR pszPath)
125 {
126  CHAR path[MAX_PATH];
127 
128  TRACE("%s\n", pszPath);
129 
130  if (GetShortPathNameA(pszPath, path, MAX_PATH))
131  {
132  lstrcpyA(pszPath, path);
133  }
134 }
135 
136 /*************************************************************************
137  * PathGetShortPathW [internal]
138  */
139 static void PathGetShortPathW(LPWSTR pszPath)
140 {
142 
143  TRACE("%s\n", debugstr_w(pszPath));
144 
145  if (GetShortPathNameW(pszPath, path, MAX_PATH))
146  {
147  lstrcpyW(pszPath, path);
148  }
149 }
150 
151 /*************************************************************************
152  * PathGetShortPath [SHELL32.92]
153  */
155 {
156  if(SHELL_OsIsUnicode())
157  PathGetShortPathW(pszPath);
158  PathGetShortPathA(pszPath);
159 }
160 
161 /*
162  ########## Path Testing ##########
163 */
164 
165 /*************************************************************************
166  * PathIsRoot [SHELL32.29]
167  */
169 {
170  if (SHELL_OsIsUnicode())
171  return PathIsRootW(lpszPath);
172  return PathIsRootA(lpszPath);
173 }
174 
175 /*************************************************************************
176  * PathIsExeA [internal]
177  */
178 static BOOL PathIsExeA (LPCSTR lpszPath)
179 {
180  LPCSTR lpszExtension = PathGetExtensionA(lpszPath);
181  int i;
182  static const char * const lpszExtensions[] =
183  {"exe", "com", "pif", "cmd", "bat", "scf", "scr", NULL };
184 
185  TRACE("path=%s\n",lpszPath);
186 
187  for(i=0; lpszExtensions[i]; i++)
188  if (!lstrcmpiA(lpszExtension,lpszExtensions[i])) return TRUE;
189 
190  return FALSE;
191 }
192 
193 /*************************************************************************
194  * PathIsExeW [internal]
195  */
197 {
198  LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
199  int i;
200  static const WCHAR lpszExtensions[][4] =
201  {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','f','\0'},
202  {'c','m','d','\0'}, {'b','a','t','\0'}, {'s','c','f','\0'},
203  {'s','c','r','\0'}, {'\0'} };
204 
205  TRACE("path=%s\n",debugstr_w(lpszPath));
206 
207  for(i=0; lpszExtensions[i][0]; i++)
208  if (!strcmpiW(lpszExtension,lpszExtensions[i])) return TRUE;
209 
210  return FALSE;
211 }
212 
213 /*************************************************************************
214  * PathIsExe [SHELL32.43]
215  */
217 {
218  if (SHELL_OsIsUnicode())
219  return PathIsExeW (path);
220  return PathIsExeA(path);
221 }
222 
223 /*************************************************************************
224  * PathFileExists [SHELL32.45]
225  */
227 {
228  if (SHELL_OsIsUnicode())
229  return PathFileExistsW (lpszPath);
230  return PathFileExistsA (lpszPath);
231 }
232 
233 /*************************************************************************
234  * IsLFNDriveA [SHELL32.41]
235  */
237 {
238  DWORD fnlen;
239 
240  if (!GetVolumeInformationA(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
241  return FALSE;
242  return fnlen > 12;
243 }
244 
245 /*************************************************************************
246  * IsLFNDriveW [SHELL32.42]
247  */
249 {
250  DWORD fnlen;
251 
252  if (!GetVolumeInformationW(lpszPath, NULL, 0, NULL, &fnlen, NULL, NULL, 0))
253  return FALSE;
254  return fnlen > 12;
255 }
256 
257 /*************************************************************************
258  * IsLFNDrive [SHELL32.119]
259  */
261 {
262  if (SHELL_OsIsUnicode())
263  return IsLFNDriveW(lpszPath);
264  return IsLFNDriveA(lpszPath);
265 }
266 
267 /*
268  ########## Creating Something Unique ##########
269 */
270 /*************************************************************************
271  * PathMakeUniqueNameA [internal]
272  */
274  LPSTR lpszBuffer,
275  DWORD dwBuffSize,
276  LPCSTR lpszShortName,
277  LPCSTR lpszLongName,
278  LPCSTR lpszPathName)
279 {
280  FIXME("%p %u %s %s %s stub\n",
281  lpszBuffer, dwBuffSize, debugstr_a(lpszShortName),
282  debugstr_a(lpszLongName), debugstr_a(lpszPathName));
283  return TRUE;
284 }
285 
286 /*************************************************************************
287  * PathMakeUniqueNameW [internal]
288  */
290  LPWSTR lpszBuffer,
291  DWORD dwBuffSize,
292  LPCWSTR lpszShortName,
293  LPCWSTR lpszLongName,
294  LPCWSTR lpszPathName)
295 {
296  FIXME("%p %u %s %s %s stub\n",
297  lpszBuffer, dwBuffSize, debugstr_w(lpszShortName),
298  debugstr_w(lpszLongName), debugstr_w(lpszPathName));
299  return TRUE;
300 }
301 
302 /*************************************************************************
303  * PathMakeUniqueName [SHELL32.47]
304  */
306  LPVOID lpszBuffer,
307  DWORD dwBuffSize,
308  LPCVOID lpszShortName,
309  LPCVOID lpszLongName,
310  LPCVOID lpszPathName)
311 {
312  if (SHELL_OsIsUnicode())
313  return PathMakeUniqueNameW(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
314  return PathMakeUniqueNameA(lpszBuffer,dwBuffSize, lpszShortName,lpszLongName,lpszPathName);
315 }
316 
317 /*************************************************************************
318  * PathYetAnotherMakeUniqueName [SHELL32.75]
319  */
321 {
322  WCHAR pathW[MAX_PATH], retW[MAX_PATH];
323  const WCHAR *file, *ext;
324  int i = 2;
325 
326  TRACE("(%p, %s, %s, %s)\n", buffer, debugstr_w(path), debugstr_w(shortname), debugstr_w(longname));
327 
328  file = longname ? longname : shortname;
329  PathCombineW(pathW, path, file);
330  strcpyW(retW, pathW);
331  PathRemoveExtensionW(pathW);
332 
334 
335  /* now try to make it unique */
336  while (PathFileExistsW(retW))
337  {
338  static const WCHAR fmtW[] = {'%','s',' ','(','%','d',')','%','s',0};
339 
340  sprintfW(retW, fmtW, pathW, i, ext);
341  i++;
342  }
343 
344  strcpyW(buffer, retW);
345  TRACE("ret - %s\n", debugstr_w(buffer));
346 
347  return TRUE;
348 }
349 
350 /*
351  ########## cleaning and resolving paths ##########
352  */
353 
354 /*************************************************************************
355  * PathCleanupSpec [SHELL32.171]
356  *
357  * lpszFile is changed in place.
358  */
359 int WINAPI PathCleanupSpec( LPCWSTR lpszPathW, LPWSTR lpszFileW )
360 {
361  int i = 0;
362  DWORD rc = 0;
363  int length = 0;
364 
365  if (SHELL_OsIsUnicode())
366  {
367  LPWSTR p = lpszFileW;
368 
369  TRACE("Cleanup %s\n",debugstr_w(lpszFileW));
370 
371  if (lpszPathW)
372  length = strlenW(lpszPathW);
373 
374  while (*p)
375  {
376  int gct = PathGetCharTypeW(*p);
377  if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
378  {
379  lpszFileW[i]='-';
380  rc |= PCS_REPLACEDCHAR;
381  }
382  else
383  lpszFileW[i]=*p;
384  i++;
385  p++;
386  if (length + i == MAX_PATH)
387  {
388  rc |= PCS_FATAL | PCS_PATHTOOLONG;
389  break;
390  }
391  }
392  lpszFileW[i]=0;
393  }
394  else
395  {
396  LPSTR lpszFileA = (LPSTR)lpszFileW;
397  LPCSTR lpszPathA = (LPCSTR)lpszPathW;
398  LPSTR p = lpszFileA;
399 
400  TRACE("Cleanup %s\n",debugstr_a(lpszFileA));
401 
402  if (lpszPathA)
403  length = strlen(lpszPathA);
404 
405  while (*p)
406  {
407  int gct = PathGetCharTypeA(*p);
408  if (gct == GCT_INVALID || gct == GCT_WILD || gct == GCT_SEPARATOR)
409  {
410  lpszFileA[i]='-';
411  rc |= PCS_REPLACEDCHAR;
412  }
413  else
414  lpszFileA[i]=*p;
415  i++;
416  p++;
417  if (length + i == MAX_PATH)
418  {
419  rc |= PCS_FATAL | PCS_PATHTOOLONG;
420  break;
421  }
422  }
423  lpszFileA[i]=0;
424  }
425  return rc;
426 }
427 
428 /*************************************************************************
429  * PathQualifyA [SHELL32]
430  */
431 static BOOL PathQualifyA(LPCSTR pszPath)
432 {
433  FIXME("%s\n",pszPath);
434  return FALSE;
435 }
436 
437 /*************************************************************************
438  * PathQualifyW [SHELL32]
439  */
440 static BOOL PathQualifyW(LPCWSTR pszPath)
441 {
442  FIXME("%s\n",debugstr_w(pszPath));
443  return FALSE;
444 }
445 
446 /*************************************************************************
447  * PathQualify [SHELL32.49]
448  */
450 {
451  if (SHELL_OsIsUnicode())
452  return PathQualifyW(pszPath);
453  return PathQualifyA(pszPath);
454 }
455 
457 {
458  FIXME("(%s,%p,0x%08x),stub!\n", debugstr_a(path), paths, flags);
459  return FALSE;
460 }
461 
463 {
464  FIXME("(%s,%p,0x%08x),stub!\n", debugstr_w(path), paths, flags);
465  return FALSE;
466 }
467 
468 /*************************************************************************
469  * PathResolve [SHELL32.51]
470  */
472 {
473  if (SHELL_OsIsUnicode())
474  return PathResolveW(path, (LPCWSTR*)paths, flags);
475  else
476  return PathResolveA(path, (LPCSTR*)paths, flags);
477 }
478 
479 /*************************************************************************
480 * PathProcessCommandA
481 */
483  LPCSTR lpszPath,
484  LPSTR lpszBuff,
485  DWORD dwBuffSize,
486  DWORD dwFlags)
487 {
488  FIXME("%s %p 0x%04x 0x%04x stub\n",
489  lpszPath, lpszBuff, dwBuffSize, dwFlags);
490  if(!lpszPath) return -1;
491  if(lpszBuff) strcpy(lpszBuff, lpszPath);
492  return strlen(lpszPath);
493 }
494 
495 /*************************************************************************
496 * PathProcessCommandW
497 */
499  LPCWSTR lpszPath,
500  LPWSTR lpszBuff,
501  DWORD dwBuffSize,
502  DWORD dwFlags)
503 {
504  FIXME("(%s, %p, 0x%04x, 0x%04x) stub\n",
505  debugstr_w(lpszPath), lpszBuff, dwBuffSize, dwFlags);
506  if(!lpszPath) return -1;
507  if(lpszBuff) strcpyW(lpszBuff, lpszPath);
508  return strlenW(lpszPath);
509 }
510 
511 /*************************************************************************
512 * PathProcessCommand (SHELL32.653)
513 */
515  LPCVOID lpszPath,
516  LPVOID lpszBuff,
517  DWORD dwBuffSize,
518  DWORD dwFlags)
519 {
520  if (SHELL_OsIsUnicode())
521  return PathProcessCommandW(lpszPath, lpszBuff, dwBuffSize, dwFlags);
522  return PathProcessCommandA(lpszPath, lpszBuff, dwBuffSize, dwFlags);
523 }
524 
525 /*
526  ########## special ##########
527 */
528 
529 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'};
530 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'};
531 static const WCHAR AppDataW[] = {'A','p','p','D','a','t','a','\0'};
532 #ifndef __REACTOS__
533 static const WCHAR AppData_LocalLowW[] = {'A','p','p','D','a','t','a','\\','L','o','c','a','l','L','o','w','\0'};
534 static const WCHAR Application_DataW[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','D','a','t','a','\0'};
535 #endif
536 static const WCHAR CacheW[] = {'C','a','c','h','e','\0'};
537 static const WCHAR CD_BurningW[] = {'C','D',' ','B','u','r','n','i','n','g','\0'};
538 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'};
539 static const WCHAR Common_AppDataW[] = {'C','o','m','m','o','n',' ','A','p','p','D','a','t','a','\0'};
540 static const WCHAR Common_DesktopW[] = {'C','o','m','m','o','n',' ','D','e','s','k','t','o','p','\0'};
541 static const WCHAR Common_DocumentsW[] = {'C','o','m','m','o','n',' ','D','o','c','u','m','e','n','t','s','\0'};
542 static const WCHAR Common_FavoritesW[] = {'C','o','m','m','o','n',' ','F','a','v','o','r','i','t','e','s','\0'};
543 static const WCHAR CommonFilesDirW[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r','\0'};
544 static const WCHAR CommonFilesDirX86W[] = {'C','o','m','m','o','n','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
545 static const WCHAR CommonMusicW[] = {'C','o','m','m','o','n','M','u','s','i','c','\0'};
546 static const WCHAR CommonPicturesW[] = {'C','o','m','m','o','n','P','i','c','t','u','r','e','s','\0'};
547 static const WCHAR Common_ProgramsW[] = {'C','o','m','m','o','n',' ','P','r','o','g','r','a','m','s','\0'};
548 static const WCHAR Common_StartUpW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t','U','p','\0'};
549 static const WCHAR Common_Start_MenuW[] = {'C','o','m','m','o','n',' ','S','t','a','r','t',' ','M','e','n','u','\0'};
550 static const WCHAR Common_TemplatesW[] = {'C','o','m','m','o','n',' ','T','e','m','p','l','a','t','e','s','\0'};
551 static const WCHAR CommonVideoW[] = {'C','o','m','m','o','n','V','i','d','e','o','\0'};
552 #ifndef __REACTOS__
553 static const WCHAR ContactsW[] = {'C','o','n','t','a','c','t','s','\0'};
554 #endif
555 static const WCHAR CookiesW[] = {'C','o','o','k','i','e','s','\0'};
556 static const WCHAR DesktopW[] = {'D','e','s','k','t','o','p','\0'};
557 #ifndef __REACTOS__
558 static const WCHAR DocumentsW[] = {'D','o','c','u','m','e','n','t','s','\0'};
559 static const WCHAR DownloadsW[] = {'D','o','w','n','l','o','a','d','s','\0'};
560 #endif
561 static const WCHAR FavoritesW[] = {'F','a','v','o','r','i','t','e','s','\0'};
562 static const WCHAR FontsW[] = {'F','o','n','t','s','\0'};
563 static const WCHAR HistoryW[] = {'H','i','s','t','o','r','y','\0'};
564 #ifndef __REACTOS__
565 static const WCHAR LinksW[] = {'L','i','n','k','s','\0'};
566 #endif
567 static const WCHAR Local_AppDataW[] = {'L','o','c','a','l',' ','A','p','p','D','a','t','a','\0'};
568 #ifndef __REACTOS__
569 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'};
570 #endif
571 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'};
572 #ifndef __REACTOS__
573 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'};
574 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'};
575 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'};
576 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'};
577 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'};
578 static const WCHAR MusicW[] = {'M','u','s','i','c','\0'};
579 static const WCHAR Music_PlaylistsW[] = {'M','u','s','i','c','\\','P','l','a','y','l','i','s','t','s','\0'};
580 static const WCHAR Music_Sample_MusicW[] = {'M','u','s','i','c','\\','S','a','m','p','l','e',' ','M','u','s','i','c','\0'};
581 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'};
582 #endif
583 static const WCHAR My_MusicW[] = {'M','y',' ','M','u','s','i','c','\0'};
584 static const WCHAR My_PicturesW[] = {'M','y',' ','P','i','c','t','u','r','e','s','\0'};
585 static const WCHAR My_VideoW[] = {'M','y',' ','V','i','d','e','o','\0'};
586 static const WCHAR NetHoodW[] = {'N','e','t','H','o','o','d','\0'};
587 static const WCHAR OEM_LinksW[] = {'O','E','M',' ','L','i','n','k','s','\0'};
588 static const WCHAR PersonalW[] = {'P','e','r','s','o','n','a','l','\0'};
589 #ifndef __REACTOS__
590 static const WCHAR PicturesW[] = {'P','i','c','t','u','r','e','s','\0'};
591 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'};
592 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'};
593 #endif
594 static const WCHAR PrintHoodW[] = {'P','r','i','n','t','H','o','o','d','\0'};
595 #ifndef __REACTOS__
596 static const WCHAR Program_FilesW[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s','\0'};
597 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'};
598 #endif
599 static const WCHAR Program_Files_x86W[] = {'P','r','o','g','r','a','m',' ','F','i','l','e','s',' ','(','x','8','6',')','\0'};
600 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'};
601 static const WCHAR ProgramFilesDirW[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r','\0'};
602 static const WCHAR ProgramFilesDirX86W[] = {'P','r','o','g','r','a','m','F','i','l','e','s','D','i','r',' ','(','x','8','6',')','\0'};
603 static const WCHAR ProgramsW[] = {'P','r','o','g','r','a','m','s','\0'};
604 #ifndef __REACTOS__
605 static const WCHAR PublicW[] = {'P','u','b','l','i','c',0};
606 #endif
607 static const WCHAR RecentW[] = {'R','e','c','e','n','t','\0'};
608 static const WCHAR ResourcesW[] = {'R','e','s','o','u','r','c','e','s','\0'};
609 #ifndef __REACTOS__
610 static const WCHAR Saved_GamesW[] = {'S','a','v','e','d',' ','G','a','m','e','s','\0'};
611 static const WCHAR SearchesW[] = {'S','e','a','r','c','h','e','s','\0'};
612 #endif
613 static const WCHAR SendToW[] = {'S','e','n','d','T','o','\0'};
614 static const WCHAR StartUpW[] = {'S','t','a','r','t','U','p','\0'};
615 static const WCHAR Start_MenuW[] = {'S','t','a','r','t',' ','M','e','n','u','\0'};
616 #ifndef __REACTOS__
617 static const WCHAR Start_Menu_ProgramsW[] = {'S','t','a','r','t',' ','M','e','n','u','\\','P','r','o','g','r','a','m','s','\0'};
618 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'};
619 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'};
620 #endif
621 static const WCHAR TemplatesW[] = {'T','e','m','p','l','a','t','e','s','\0'};
622 #ifndef __REACTOS__
623 static const WCHAR UsersW[] = {'U','s','e','r','s','\0'};
624 static const WCHAR UsersPublicW[] = {'U','s','e','r','s','\\','P','u','b','l','i','c','\0'};
625 static const WCHAR VideosW[] = {'V','i','d','e','o','s','\0'};
626 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'};
627 #endif
628 static const WCHAR DefaultW[] = {'.','D','e','f','a','u','l','t','\0'};
629 static const WCHAR AllUsersProfileW[] = {'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%','\0'};
630 #ifndef __REACTOS__
631 static const WCHAR PublicProfileW[] = {'%','P','U','B','L','I','C','%',0};
632 #endif
633 static const WCHAR UserProfileW[] = {'%','U','S','E','R','P','R','O','F','I','L','E','%','\0'};
634 static const WCHAR SystemDriveW[] = {'%','S','y','s','t','e','m','D','r','i','v','e','%','\0'};
635 #ifndef __REACTOS__
636 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};
637 static const WCHAR ProfilesDirectoryW[] = {'P','r','o','f','i','l','e','s','D','i','r','e','c','t','o','r','y',0};
638 static const WCHAR AllUsersProfileValueW[] = {'A','l','l','U','s','e','r','s','P','r','o','f','i','l','e','\0'};
639 #endif
640 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'};
641 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'};
642 static const WCHAR szDefaultProfileDirW[] = {'u','s','e','r','s',0};
643 #ifndef __REACTOS__
644 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'};
645 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};
646 #endif
647 static const WCHAR AllUsersW[] = {'P','u','b','l','i','c',0};
648 
649 typedef enum _CSIDL_Type {
658 } CSIDL_Type;
659 
660 /* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
661 #ifndef __REACTOS__
662 #define CSIDL_CONTACTS 0x0043
663 #define CSIDL_DOWNLOADS 0x0047
664 #define CSIDL_LINKS 0x004d
665 #define CSIDL_APPDATA_LOCALLOW 0x004e
666 #define CSIDL_SAVED_GAMES 0x0062
667 #define CSIDL_SEARCHES 0x0063
668 #endif
669 
670 typedef struct
671 {
675  LPCWSTR szDefaultPath; /* fallback string or resource ID */
677 } CSIDL_DATA;
678 
679 static const CSIDL_DATA CSIDL_Data[] =
680 {
681  { /* 0x00 - CSIDL_DESKTOP */
682  &FOLDERID_Desktop,
684  DesktopW,
687  },
688  { /* 0x01 - CSIDL_INTERNET */
689  &FOLDERID_InternetFolder,
691  NULL,
692  NULL
693  },
694  { /* 0x02 - CSIDL_PROGRAMS */
695  &FOLDERID_Programs,
697  ProgramsW,
700  },
701  { /* 0x03 - CSIDL_CONTROLS (.CPL files) */
702  &FOLDERID_ControlPanelFolder,
704  NULL,
705  NULL,
707  },
708  { /* 0x04 - CSIDL_PRINTERS */
709  &FOLDERID_PrintersFolder,
711  NULL,
712  NULL,
714  },
715  { /* 0x05 - CSIDL_PERSONAL */
716  &FOLDERID_Documents,
718  PersonalW,
721  },
722  { /* 0x06 - CSIDL_FAVORITES */
723  &FOLDERID_Favorites,
725  FavoritesW,
728  },
729  { /* 0x07 - CSIDL_STARTUP */
730  &FOLDERID_Startup,
732  StartUpW,
734  },
735  { /* 0x08 - CSIDL_RECENT */
736  &FOLDERID_Recent,
738  RecentW,
741  },
742  { /* 0x09 - CSIDL_SENDTO */
743  &FOLDERID_SendTo,
745  SendToW,
747  },
748  { /* 0x0a - CSIDL_BITBUCKET - Recycle Bin */
749  &FOLDERID_RecycleBinFolder,
751  NULL,
752  NULL
753  },
754  { /* 0x0b - CSIDL_STARTMENU */
755  &FOLDERID_StartMenu,
757  Start_MenuW,
760  },
761  { /* 0x0c - CSIDL_MYDOCUMENTS */
762  &GUID_NULL,
763  CSIDL_Type_Disallowed, /* matches WinXP--can't get its path */
764  NULL,
765  NULL,
767  },
768  { /* 0x0d - CSIDL_MYMUSIC */
769  &FOLDERID_Music,
771  My_MusicW,
774  },
775  { /* 0x0e - CSIDL_MYVIDEO */
776  &FOLDERID_Videos,
778  My_VideoW,
781  },
782  { /* 0x0f - unassigned */
783  &GUID_NULL,
785  NULL,
786  NULL,
787  },
788  { /* 0x10 - CSIDL_DESKTOPDIRECTORY */
789  &FOLDERID_Desktop,
791  DesktopW,
794  },
795  { /* 0x11 - CSIDL_DRIVES */
796  &FOLDERID_ComputerFolder,
798  NULL,
799  NULL,
801  },
802  { /* 0x12 - CSIDL_NETWORK */
803  &FOLDERID_NetworkFolder,
805  NULL,
806  NULL,
808  },
809  { /* 0x13 - CSIDL_NETHOOD */
810  &FOLDERID_NetHood,
812  NetHoodW,
815  },
816  { /* 0x14 - CSIDL_FONTS */
817  &FOLDERID_Fonts,
819  FontsW,
820  FontsW,
822  },
823  { /* 0x15 - CSIDL_TEMPLATES */
824  &FOLDERID_Templates,
826  TemplatesW,
828  },
829  { /* 0x16 - CSIDL_COMMON_STARTMENU */
830  &FOLDERID_CommonStartMenu,
835  },
836  { /* 0x17 - CSIDL_COMMON_PROGRAMS */
837  &FOLDERID_CommonPrograms,
842  },
843  { /* 0x18 - CSIDL_COMMON_STARTUP */
844  &FOLDERID_CommonStartup,
848  },
849  { /* 0x19 - CSIDL_COMMON_DESKTOPDIRECTORY */
850  &FOLDERID_PublicDesktop,
855  },
856  { /* 0x1a - CSIDL_APPDATA */
857  &FOLDERID_RoamingAppData,
859  AppDataW,
861  },
862  { /* 0x1b - CSIDL_PRINTHOOD */
863  &FOLDERID_PrintHood,
865  PrintHoodW,
868  },
869  { /* 0x1c - CSIDL_LOCAL_APPDATA */
870  &FOLDERID_LocalAppData,
874  },
875  { /* 0x1d - CSIDL_ALTSTARTUP */
876  &GUID_NULL,
878  NULL,
879  NULL
880  },
881  { /* 0x1e - CSIDL_COMMON_ALTSTARTUP */
882  &GUID_NULL,
884  NULL,
885  NULL
886  },
887  { /* 0x1f - CSIDL_COMMON_FAVORITES */
888  &FOLDERID_Favorites,
893  },
894  { /* 0x20 - CSIDL_INTERNET_CACHE */
895  &FOLDERID_InternetCache,
897  CacheW,
899  },
900  { /* 0x21 - CSIDL_COOKIES */
901  &FOLDERID_Cookies,
903  CookiesW,
905  },
906  { /* 0x22 - CSIDL_HISTORY */
907  &FOLDERID_History,
909  HistoryW,
911  },
912  { /* 0x23 - CSIDL_COMMON_APPDATA */
913  &FOLDERID_ProgramData,
917  },
918  { /* 0x24 - CSIDL_WINDOWS */
919  &FOLDERID_Windows,
921  NULL,
922  NULL,
924  },
925  { /* 0x25 - CSIDL_SYSTEM */
926  &FOLDERID_System,
928  NULL,
929  NULL,
931  },
932  { /* 0x26 - CSIDL_PROGRAM_FILES */
933  &FOLDERID_ProgramFiles,
938  },
939  { /* 0x27 - CSIDL_MYPICTURES */
940  &FOLDERID_Pictures,
942  My_PicturesW,
945  },
946  { /* 0x28 - CSIDL_PROFILE */
947  &FOLDERID_Profile,
949  NULL,
950  NULL
951  },
952  { /* 0x29 - CSIDL_SYSTEMX86 */
953  &FOLDERID_SystemX86,
955  NULL,
956  NULL,
958  },
959  { /* 0x2a - CSIDL_PROGRAM_FILESX86 */
960  &FOLDERID_ProgramFilesX86,
965  },
966  { /* 0x2b - CSIDL_PROGRAM_FILES_COMMON */
967  &FOLDERID_ProgramFilesCommon,
972  },
973  { /* 0x2c - CSIDL_PROGRAM_FILES_COMMONX86 */
974  &FOLDERID_ProgramFilesCommonX86,
979  },
980  { /* 0x2d - CSIDL_COMMON_TEMPLATES */
981  &FOLDERID_CommonTemplates,
985  },
986  { /* 0x2e - CSIDL_COMMON_DOCUMENTS */
987  &FOLDERID_PublicDocuments,
992  },
993  { /* 0x2f - CSIDL_COMMON_ADMINTOOLS */
994  &FOLDERID_CommonAdminTools,
998  },
999  { /* 0x30 - CSIDL_ADMINTOOLS */
1000  &FOLDERID_AdminTools,
1004  },
1005  { /* 0x31 - CSIDL_CONNECTIONS */
1006  &FOLDERID_ConnectionsFolder,
1008  NULL,
1009  NULL,
1011  },
1012  { /* 0x32 - unassigned */
1013  &GUID_NULL,
1015  NULL,
1016  NULL
1017  },
1018  { /* 0x33 - unassigned */
1019  &GUID_NULL,
1021  NULL,
1022  NULL
1023  },
1024  { /* 0x34 - unassigned */
1025  &GUID_NULL,
1027  NULL,
1028  NULL
1029  },
1030  { /* 0x35 - CSIDL_COMMON_MUSIC */
1031  &FOLDERID_PublicMusic,
1033  CommonMusicW,
1036  },
1037  { /* 0x36 - CSIDL_COMMON_PICTURES */
1038  &FOLDERID_PublicPictures,
1043  },
1044  { /* 0x37 - CSIDL_COMMON_VIDEO */
1045  &FOLDERID_PublicVideos,
1047  CommonVideoW,
1050  },
1051  { /* 0x38 - CSIDL_RESOURCES */
1052  &FOLDERID_ResourceDir,
1054  NULL,
1055  ResourcesW
1056  },
1057  { /* 0x39 - CSIDL_RESOURCES_LOCALIZED */
1058  &FOLDERID_LocalizedResourcesDir,
1060  NULL,
1061  NULL
1062  },
1063  { /* 0x3a - CSIDL_COMMON_OEM_LINKS */
1064  &FOLDERID_CommonOEMLinks,
1066  NULL,
1067  OEM_LinksW
1068  },
1069  { /* 0x3b - CSIDL_CDBURN_AREA */
1070  &FOLDERID_CDBurning,
1072  CD_BurningW,
1074  },
1075  { /* 0x3c unassigned */
1076  &GUID_NULL,
1078  NULL,
1079  NULL
1080  },
1081  { /* 0x3d - CSIDL_COMPUTERSNEARME */
1082  &GUID_NULL,
1083  CSIDL_Type_Disallowed, /* FIXME */
1084  NULL,
1085  NULL
1086  },
1087  { /* 0x3e - CSIDL_PROFILES */
1088  &GUID_NULL,
1089  CSIDL_Type_Disallowed, /* oddly, this matches WinXP */
1090  NULL,
1091  NULL
1092  },
1093 /* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
1094 #ifndef __REACTOS__
1095  { /* 0x3f */
1096  &FOLDERID_AddNewPrograms,
1098  NULL,
1099  NULL
1100  },
1101  { /* 0x40 */
1102  &FOLDERID_AppUpdates,
1104  NULL,
1105  NULL
1106  },
1107  { /* 0x41 */
1108  &FOLDERID_ChangeRemovePrograms,
1110  NULL,
1111  NULL
1112  },
1113  { /* 0x42 */
1114  &FOLDERID_ConflictFolder,
1116  NULL,
1117  NULL
1118  },
1119  { /* 0x43 - CSIDL_CONTACTS */
1120  &FOLDERID_Contacts,
1122  NULL,
1123  ContactsW
1124  },
1125  { /* 0x44 */
1126  &FOLDERID_DeviceMetadataStore,
1127  CSIDL_Type_Disallowed, /* FIXME */
1128  NULL,
1129  NULL
1130  },
1131  { /* 0x45 */
1132  &GUID_NULL,
1134  NULL,
1135  DocumentsW
1136  },
1137  { /* 0x46 */
1138  &FOLDERID_DocumentsLibrary,
1139  CSIDL_Type_Disallowed, /* FIXME */
1140  NULL,
1141  NULL
1142  },
1143  { /* 0x47 - CSIDL_DOWNLOADS */
1144  &FOLDERID_Downloads,
1146  NULL,
1147  DownloadsW
1148  },
1149  { /* 0x48 */
1150  &FOLDERID_Games,
1152  NULL,
1153  NULL
1154  },
1155  { /* 0x49 */
1156  &FOLDERID_GameTasks,
1157  CSIDL_Type_Disallowed, /* FIXME */
1158  NULL,
1159  NULL
1160  },
1161  { /* 0x4a */
1162  &FOLDERID_HomeGroup,
1164  NULL,
1165  NULL
1166  },
1167  { /* 0x4b */
1168  &FOLDERID_ImplicitAppShortcuts,
1169  CSIDL_Type_Disallowed, /* FIXME */
1170  NULL,
1171  NULL
1172  },
1173  { /* 0x4c */
1174  &FOLDERID_Libraries,
1175  CSIDL_Type_Disallowed, /* FIXME */
1176  NULL,
1177  NULL
1178  },
1179  { /* 0x4d - CSIDL_LINKS */
1180  &FOLDERID_Links,
1182  NULL,
1183  LinksW
1184  },
1185  { /* 0x4e - CSIDL_APPDATA_LOCALLOW */
1186  &FOLDERID_LocalAppDataLow,
1188  NULL,
1190  },
1191  { /* 0x4f */
1192  &FOLDERID_MusicLibrary,
1193  CSIDL_Type_Disallowed, /* FIXME */
1194  NULL,
1195  NULL
1196  },
1197  { /* 0x50 */
1198  &FOLDERID_OriginalImages,
1199  CSIDL_Type_Disallowed, /* FIXME */
1200  NULL,
1201  NULL
1202  },
1203  { /* 0x51 */
1204  &FOLDERID_PhotoAlbums,
1206  NULL,
1208  },
1209  { /* 0x52 */
1210  &FOLDERID_PicturesLibrary,
1211  CSIDL_Type_Disallowed, /* FIXME */
1212  NULL,
1213  NULL
1214  },
1215  { /* 0x53 */
1216  &FOLDERID_Playlists,
1218  NULL,
1220  },
1221  { /* 0x54 */
1222  &FOLDERID_ProgramFilesX64,
1224  NULL,
1225  NULL
1226  },
1227  { /* 0x55 */
1228  &FOLDERID_ProgramFilesCommonX64,
1230  NULL,
1231  NULL
1232  },
1233  { /* 0x56 */
1234  &FOLDERID_Public,
1235  CSIDL_Type_CurrVer, /* FIXME */
1236  NULL,
1237  UsersPublicW
1238  },
1239  { /* 0x57 */
1240  &FOLDERID_PublicDownloads,
1242  NULL,
1243  DownloadsW
1244  },
1245  { /* 0x58 */
1246  &FOLDERID_PublicGameTasks,
1248  NULL,
1250  },
1251  { /* 0x59 */
1252  &FOLDERID_PublicLibraries,
1254  NULL,
1256  },
1257  { /* 0x5a */
1258  &FOLDERID_PublicRingtones,
1260  NULL,
1262  },
1263  { /* 0x5b */
1264  &FOLDERID_QuickLaunch,
1265  CSIDL_Type_Disallowed, /* FIXME */
1266  NULL,
1267  NULL
1268  },
1269  { /* 0x5c */
1270  &FOLDERID_RecordedTVLibrary,
1271  CSIDL_Type_Disallowed, /* FIXME */
1272  NULL,
1273  NULL
1274  },
1275  { /* 0x5d */
1276  &FOLDERID_Ringtones,
1277  CSIDL_Type_Disallowed, /* FIXME */
1278  NULL,
1279  NULL
1280  },
1281  { /* 0x5e */
1282  &FOLDERID_SampleMusic,
1284  NULL,
1286  },
1287  { /* 0x5f */
1288  &FOLDERID_SamplePictures,
1290  NULL,
1292  },
1293  { /* 0x60 */
1294  &FOLDERID_SamplePlaylists,
1296  NULL,
1298  },
1299  { /* 0x61 */
1300  &FOLDERID_SampleVideos,
1302  NULL,
1304  },
1305  { /* 0x62 - CSIDL_SAVED_GAMES */
1306  &FOLDERID_SavedGames,
1308  NULL,
1309  Saved_GamesW
1310  },
1311  { /* 0x63 - CSIDL_SEARCHES */
1312  &FOLDERID_SavedSearches,
1314  NULL,
1315  SearchesW
1316  },
1317  { /* 0x64 */
1318  &FOLDERID_SEARCH_CSC,
1320  NULL,
1321  NULL
1322  },
1323  { /* 0x65 */
1324  &FOLDERID_SEARCH_MAPI,
1326  NULL,
1327  NULL
1328  },
1329  { /* 0x66 */
1330  &FOLDERID_SearchHome,
1332  NULL,
1333  NULL
1334  },
1335  { /* 0x67 */
1336  &FOLDERID_SidebarDefaultParts,
1337  CSIDL_Type_Disallowed, /* FIXME */
1338  NULL,
1339  NULL
1340  },
1341  { /* 0x68 */
1342  &FOLDERID_SidebarParts,
1343  CSIDL_Type_Disallowed, /* FIXME */
1344  NULL,
1345  NULL
1346  },
1347  { /* 0x69 */
1348  &FOLDERID_SyncManagerFolder,
1350  NULL,
1351  NULL
1352  },
1353  { /* 0x6a */
1354  &FOLDERID_SyncResultsFolder,
1356  NULL,
1357  NULL
1358  },
1359  { /* 0x6b */
1360  &FOLDERID_SyncSetupFolder,
1362  NULL,
1363  NULL
1364  },
1365  { /* 0x6c */
1366  &FOLDERID_UserPinned,
1367  CSIDL_Type_Disallowed, /* FIXME */
1368  NULL,
1369  NULL
1370  },
1371  { /* 0x6d */
1372  &FOLDERID_UserProfiles,
1374  UsersW,
1375  UsersW
1376  },
1377  { /* 0x6e */
1378  &FOLDERID_UserProgramFiles,
1379  CSIDL_Type_Disallowed, /* FIXME */
1380  NULL,
1381  NULL
1382  },
1383  { /* 0x6f */
1384  &FOLDERID_UserProgramFilesCommon,
1385  CSIDL_Type_Disallowed, /* FIXME */
1386  NULL,
1387  NULL
1388  },
1389  { /* 0x70 */
1390  &FOLDERID_UsersFiles,
1392  NULL,
1393  NULL
1394  },
1395  { /* 0x71 */
1396  &FOLDERID_UsersLibraries,
1398  NULL,
1399  NULL
1400  },
1401  { /* 0x72 */
1402  &FOLDERID_VideosLibrary,
1403  CSIDL_Type_Disallowed, /* FIXME */
1404  NULL,
1405  NULL
1406  }
1407 #endif
1408 };
1409 
1410 #ifndef __REACTOS__
1411 static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest);
1412 #else
1413 static HRESULT _SHExpandEnvironmentStrings(HANDLE hToken, LPCWSTR szSrc, LPWSTR szDest, DWORD cchDest);
1414 #endif
1415 
1416 /* Gets the value named value from the registry key
1417  * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
1418  * (or from rootKey\userPrefix\... if userPrefix is not NULL) into path, which
1419  * is assumed to be MAX_PATH WCHARs in length.
1420  * If it exists, expands the value and writes the expanded value to
1421  * rootKey\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
1422  * Returns successful error code if the value was retrieved from the registry,
1423  * and a failure otherwise.
1424  */
1425 #ifndef __REACTOS__
1426 static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix,
1427 #else
1428 static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, HANDLE hToken, LPCWSTR userPrefix,
1429 #endif
1431 {
1432  HRESULT hr;
1433  WCHAR shellFolderPath[MAX_PATH], userShellFolderPath[MAX_PATH];
1434  LPCWSTR pShellFolderPath, pUserShellFolderPath;
1435  HKEY userShellFolderKey, shellFolderKey;
1436  DWORD dwType, dwPathLen;
1437 
1438  TRACE("%p,%s,%s,%p\n",rootKey, debugstr_w(userPrefix), debugstr_w(value),
1439  path);
1440 
1441  if (userPrefix)
1442  {
1443  strcpyW(shellFolderPath, userPrefix);
1444  PathAddBackslashW(shellFolderPath);
1445  strcatW(shellFolderPath, szSHFolders);
1446  pShellFolderPath = shellFolderPath;
1447  strcpyW(userShellFolderPath, userPrefix);
1448  PathAddBackslashW(userShellFolderPath);
1449  strcatW(userShellFolderPath, szSHUserFolders);
1450  pUserShellFolderPath = userShellFolderPath;
1451  }
1452  else
1453  {
1454  pUserShellFolderPath = szSHUserFolders;
1455  pShellFolderPath = szSHFolders;
1456  }
1457 
1458  if (RegCreateKeyW(rootKey, pShellFolderPath, &shellFolderKey))
1459  {
1460  TRACE("Failed to create %s\n", debugstr_w(pShellFolderPath));
1461  return E_FAIL;
1462  }
1463  if (RegCreateKeyW(rootKey, pUserShellFolderPath, &userShellFolderKey))
1464  {
1465  TRACE("Failed to create %s\n",
1466  debugstr_w(pUserShellFolderPath));
1467  RegCloseKey(shellFolderKey);
1468  return E_FAIL;
1469  }
1470 
1471  dwPathLen = MAX_PATH * sizeof(WCHAR);
1472  if (!RegQueryValueExW(userShellFolderKey, value, NULL, &dwType,
1473  (LPBYTE)path, &dwPathLen) && (dwType == REG_EXPAND_SZ || dwType == REG_SZ))
1474  {
1475  LONG ret;
1476 
1477  path[dwPathLen / sizeof(WCHAR)] = '\0';
1478  if (dwType == REG_EXPAND_SZ && path[0] == '%')
1479  {
1480  WCHAR szTemp[MAX_PATH];
1481 
1482 #ifndef __REACTOS__
1484 #else
1485  hr = _SHExpandEnvironmentStrings(hToken, path, szTemp, _countof(szTemp));
1486  if (FAILED(hr))
1487  goto end;
1488 #endif
1489  lstrcpynW(path, szTemp, MAX_PATH);
1490  }
1491  ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
1492  (strlenW(path) + 1) * sizeof(WCHAR));
1493  if (ret != ERROR_SUCCESS)
1495  else
1496  hr = S_OK;
1497  }
1498  else
1499  hr = E_FAIL;
1500 #ifdef __REACTOS__
1501 end:
1502 #endif
1503  RegCloseKey(shellFolderKey);
1504  RegCloseKey(userShellFolderKey);
1505  TRACE("returning 0x%08x\n", hr);
1506  return hr;
1507 }
1508 
1510 {
1511  BOOL result;
1512  if (!hToken)
1513  {
1515  result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1516  CloseHandle(hToken);
1517  }
1518  else if ((INT) hToken == -1)
1519  {
1521  }
1522  else
1523  {
1524  result = GetUserProfileDirectoryW(hToken, szPath, lpcchPath);
1525  }
1526  TRACE("_SHGetUserProfileDirectoryW returning %S\n", szPath);
1527  return result;
1528 }
1529 
1530 /* Gets a 'semi-expanded' default value of the CSIDL with index folder into
1531  * pszPath, based on the entries in CSIDL_Data. By semi-expanded, I mean:
1532  * - The entry's szDefaultPath may be either a string value or an integer
1533  * resource identifier. In the latter case, the string value of the resource
1534  * is written.
1535  * - Depending on the entry's type, the path may begin with an (unexpanded)
1536  * environment variable name. The caller is responsible for expanding
1537  * environment strings if so desired.
1538  * The types that are prepended with environment variables are:
1539  * CSIDL_Type_User: %USERPROFILE%
1540  * CSIDL_Type_AllUsers: %ALLUSERSPROFILE%
1541  * CSIDL_Type_CurrVer: %SystemDrive%
1542  * (Others might make sense too, but as yet are unneeded.)
1543  */
1544 #ifndef __REACTOS__
1546 #else
1547 static HRESULT _SHGetDefaultValue(HANDLE hToken, BYTE folder, LPWSTR pszPath)
1548 #endif
1549 {
1550  HRESULT hr;
1551  WCHAR resourcePath[MAX_PATH];
1552 
1553  TRACE("0x%02x,%p\n", folder, pszPath);
1554 
1555  if (folder >= ARRAY_SIZE(CSIDL_Data))
1556  return E_INVALIDARG;
1557 
1558  if (!pszPath)
1559  return E_INVALIDARG;
1560 
1561 #ifdef __REACTOS__
1562  if (hToken != NULL && hToken != (HANDLE)-1)
1563  {
1564  FIXME("unsupported for user other than current or default\n");
1565  }
1566 #endif
1567 
1568  if (!is_win64)
1569  {
1570  BOOL is_wow64;
1571 
1572  switch (folder)
1573  {
1574  case CSIDL_PROGRAM_FILES:
1578  break;
1583  break;
1584  }
1585  }
1586 
1587  switch (CSIDL_Data[folder].type)
1588  {
1589  case CSIDL_Type_User:
1590  strcpyW(pszPath, UserProfileW);
1591  break;
1592  case CSIDL_Type_AllUsers:
1593 #ifndef __REACTOS__
1594  strcpyW(pszPath, PublicProfileW);
1595 #else
1596  strcpyW(pszPath, AllUsersProfileW);
1597 #endif
1598  break;
1599  case CSIDL_Type_CurrVer:
1600  strcpyW(pszPath, SystemDriveW);
1601  break;
1602  default:
1603  ; /* no corresponding env. var, do nothing */
1604  }
1605 
1606  hr = S_OK;
1607  if (CSIDL_Data[folder].szDefaultPath)
1608  {
1609  if (IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath))
1610  {
1612  LOWORD(CSIDL_Data[folder].szDefaultPath), resourcePath, MAX_PATH))
1613  {
1614  PathAppendW(pszPath, resourcePath);
1615  }
1616  else
1617  {
1618  ERR("(%d,%s), LoadString failed, missing translation?\n", folder,
1619  debugstr_w(pszPath));
1620  hr = E_FAIL;
1621  }
1622  }
1623  else
1624  {
1625  PathAppendW(pszPath, CSIDL_Data[folder].szDefaultPath);
1626  }
1627  }
1628  TRACE("returning 0x%08x\n", hr);
1629  return hr;
1630 }
1631 
1632 /* Gets the (unexpanded) value of the folder with index folder into pszPath.
1633  * The folder's type is assumed to be CSIDL_Type_CurrVer. Its default value
1634  * can be overridden in the HKLM\\szCurrentVersion key.
1635  * If dwFlags has SHGFP_TYPE_DEFAULT set or if the value isn't overridden in
1636  * the registry, uses _SHGetDefaultValue to get the value.
1637  */
1639  LPWSTR pszPath)
1640 {
1641  HRESULT hr;
1642 
1643  TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
1644 
1645  if (folder >= ARRAY_SIZE(CSIDL_Data))
1646  return E_INVALIDARG;
1648  return E_INVALIDARG;
1649  if (!pszPath)
1650  return E_INVALIDARG;
1651 
1653 #ifndef __REACTOS__
1654  hr = _SHGetDefaultValue(folder, pszPath);
1655 #else
1656  hr = _SHGetDefaultValue(NULL, folder, pszPath);
1657 #endif
1658  else
1659  {
1660  HKEY hKey;
1661 
1663  hr = E_FAIL;
1664  else
1665  {
1666  DWORD dwType, dwPathLen = MAX_PATH * sizeof(WCHAR);
1667 
1668  if (RegQueryValueExW(hKey, CSIDL_Data[folder].szValueName, NULL,
1669  &dwType, (LPBYTE)pszPath, &dwPathLen) ||
1670  (dwType != REG_SZ && dwType != REG_EXPAND_SZ))
1671  {
1672 #ifndef __REACTOS__
1673  hr = _SHGetDefaultValue(folder, pszPath);
1674 #else
1675  hr = _SHGetDefaultValue(NULL, folder, pszPath);
1676 #endif
1677  dwType = REG_EXPAND_SZ;
1678  switch (folder)
1679  {
1682  /* these two should never be set on 32-bit setups */
1683  if (!is_win64)
1684  {
1685  BOOL is_wow64;
1687  if (!is_wow64) break;
1688  }
1689  /* fall through */
1690  default:
1691  RegSetValueExW(hKey, CSIDL_Data[folder].szValueName, 0, dwType,
1692  (LPBYTE)pszPath, (strlenW(pszPath)+1)*sizeof(WCHAR));
1693  }
1694  }
1695  else
1696  {
1697  pszPath[dwPathLen / sizeof(WCHAR)] = '\0';
1698  hr = S_OK;
1699  }
1700  RegCloseKey(hKey);
1701  }
1702  }
1703  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
1704  return hr;
1705 }
1706 
1708 {
1709  char InfoBuffer[64];
1710  PTOKEN_USER UserInfo;
1711  DWORD InfoSize;
1712  LPWSTR SidStr;
1713 
1714  UserInfo = (PTOKEN_USER) InfoBuffer;
1715  if (! GetTokenInformation(Token, TokenUser, InfoBuffer, sizeof(InfoBuffer),
1716  &InfoSize))
1717  {
1719  return NULL;
1720  UserInfo = HeapAlloc(GetProcessHeap(), 0, InfoSize);
1721  if (UserInfo == NULL)
1722  return NULL;
1723  if (! GetTokenInformation(Token, TokenUser, UserInfo, InfoSize,
1724  &InfoSize))
1725  {
1726  HeapFree(GetProcessHeap(), 0, UserInfo);
1727  return NULL;
1728  }
1729  }
1730 
1731  if (! ConvertSidToStringSidW(UserInfo->User.Sid, &SidStr))
1732  SidStr = NULL;
1733 
1734  if (UserInfo != (PTOKEN_USER) InfoBuffer)
1735  HeapFree(GetProcessHeap(), 0, UserInfo);
1736 
1737  return SidStr;
1738 }
1739 
1740 /* Gets the user's path (unexpanded) for the CSIDL with index folder:
1741  * If SHGFP_TYPE_DEFAULT is set, calls _SHGetDefaultValue for it. Otherwise
1742  * calls _SHGetUserShellFolderPath for it. Where it looks depends on hToken:
1743  * - if hToken is -1, looks in HKEY_USERS\.Default
1744  * - otherwise looks first in HKEY_CURRENT_USER, followed by HKEY_LOCAL_MACHINE
1745  * if HKEY_CURRENT_USER doesn't contain any entries. If both fail, finally
1746  * calls _SHGetDefaultValue for it.
1747  */
1749  LPWSTR pszPath)
1750 {
1751  const WCHAR *szValueName;
1752  WCHAR buffer[40];
1753  HRESULT hr;
1754 
1755  TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
1756 
1757  if (folder >= ARRAY_SIZE(CSIDL_Data))
1758  return E_INVALIDARG;
1760  return E_INVALIDARG;
1761  if (!pszPath)
1762  return E_INVALIDARG;
1763 
1765  {
1766 #ifndef __REACTOS__
1767  hr = _SHGetDefaultValue(folder, pszPath);
1768 #else
1769  hr = _SHGetDefaultValue(hToken, folder, pszPath);
1770 #endif
1771  }
1772  else
1773  {
1774  LPCWSTR userPrefix = NULL;
1775  HKEY hRootKey;
1776 
1777  if (hToken == (HANDLE)-1)
1778  {
1779  hRootKey = HKEY_USERS;
1780  userPrefix = DefaultW;
1781  }
1782  else if (hToken == NULL)
1783  hRootKey = HKEY_CURRENT_USER;
1784  else
1785  {
1786  hRootKey = HKEY_USERS;
1787  userPrefix = _GetUserSidStringFromToken(hToken);
1788  if (userPrefix == NULL)
1789  {
1790  hr = E_FAIL;
1791  goto error;
1792  }
1793  }
1794 
1795  /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
1796  szValueName = CSIDL_Data[folder].szValueName;
1797  if (!szValueName)
1798  {
1800  szValueName = &buffer[0];
1801  }
1802 
1803 #ifndef __REACTOS__
1804  hr = _SHGetUserShellFolderPath(hRootKey, userPrefix, szValueName, pszPath);
1805  if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
1806  hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, NULL, szValueName, pszPath);
1807  if (FAILED(hr))
1808  hr = _SHGetDefaultValue(folder, pszPath);
1809 #else
1810  hr = _SHGetUserShellFolderPath(hRootKey, hToken, userPrefix, szValueName, pszPath);
1811  if (FAILED(hr) && hRootKey != HKEY_LOCAL_MACHINE)
1812  hr = _SHGetUserShellFolderPath(HKEY_LOCAL_MACHINE, hToken, NULL, szValueName, pszPath);
1813  if (FAILED(hr))
1814  hr = _SHGetDefaultValue(hToken, folder, pszPath);
1815 #endif
1816  if (userPrefix != NULL && userPrefix != DefaultW)
1817  LocalFree((HLOCAL) userPrefix);
1818  }
1819 error:
1820  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
1821  return hr;
1822 }
1823 
1824 /* Gets the (unexpanded) path for the CSIDL with index folder. If dwFlags has
1825  * SHGFP_TYPE_DEFAULT set, calls _SHGetDefaultValue. Otherwise calls
1826  * _SHGetUserShellFolderPath for it, looking only in HKEY_LOCAL_MACHINE.
1827  * If this fails, falls back to _SHGetDefaultValue.
1828  */
1830  LPWSTR pszPath)
1831 {
1832  HRESULT hr;
1833 
1834  TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
1835 
1836  if (folder >= ARRAY_SIZE(CSIDL_Data))
1837  return E_INVALIDARG;
1839  return E_INVALIDARG;
1840  if (!pszPath)
1841  return E_INVALIDARG;
1842 
1844 #ifndef __REACTOS__
1845  hr = _SHGetDefaultValue(folder, pszPath);
1846 #else
1847  hr = _SHGetDefaultValue(NULL, folder, pszPath);
1848 #endif
1849  else
1850  {
1851 #ifndef __REACTOS__
1853 #else
1855 #endif
1856  CSIDL_Data[folder].szValueName, pszPath);
1857  if (FAILED(hr))
1858 #ifndef __REACTOS__
1859  hr = _SHGetDefaultValue(folder, pszPath);
1860 #else
1861  hr = _SHGetDefaultValue(NULL, folder, pszPath);
1862 #endif
1863  }
1864  TRACE("returning 0x%08x (output path is %s)\n", hr, debugstr_w(pszPath));
1865  return hr;
1866 }
1867 
1868 #ifndef __REACTOS__
1870 {
1871  LONG lRet;
1872  DWORD disp;
1873 
1875  KEY_ALL_ACCESS, NULL, pKey, &disp);
1876  return HRESULT_FROM_WIN32(lRet);
1877 }
1878 
1879 /* Reads the value named szValueName from the key profilesKey (assumed to be
1880  * opened by _SHOpenProfilesKey) into szValue, which is assumed to be MAX_PATH
1881  * WCHARs in length. If it doesn't exist, returns szDefault (and saves
1882  * szDefault to the registry).
1883  */
1884 static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName,
1885  LPWSTR szValue, LPCWSTR szDefault)
1886 {
1887  HRESULT hr;
1888  DWORD type, dwPathLen = MAX_PATH * sizeof(WCHAR);
1889  LONG lRet;
1890 
1891  TRACE("%p,%s,%p,%s\n", profilesKey, debugstr_w(szValueName), szValue,
1892  debugstr_w(szDefault));
1893  lRet = RegQueryValueExW(profilesKey, szValueName, NULL, &type,
1894  (LPBYTE)szValue, &dwPathLen);
1895  if (!lRet && (type == REG_SZ || type == REG_EXPAND_SZ) && dwPathLen
1896  && *szValue)
1897  {
1898  dwPathLen /= sizeof(WCHAR);
1899  szValue[dwPathLen] = '\0';
1900  hr = S_OK;
1901  }
1902  else
1903  {
1904  /* Missing or invalid value, set a default */
1905  lstrcpynW(szValue, szDefault, MAX_PATH);
1906  TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
1907  debugstr_w(szValue));
1908  lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
1909  (LPBYTE)szValue,
1910  (strlenW(szValue) + 1) * sizeof(WCHAR));
1911  if (lRet)
1912  hr = HRESULT_FROM_WIN32(lRet);
1913  else
1914  hr = S_OK;
1915  }
1916  TRACE("returning 0x%08x (output value is %s)\n", hr, debugstr_w(szValue));
1917  return hr;
1918 }
1919 #endif
1920 
1921 /* Attempts to expand environment variables from szSrc into szDest, which is
1922  * assumed to be MAX_PATH characters in length. Before referring to the
1923  * environment, handles a few variables directly, because the environment
1924  * variables may not be set when this is called (as during Wine's installation
1925  * when default values are being written to the registry).
1926  * The directly handled environment variables, and their source, are:
1927  * - ALLUSERSPROFILE, USERPROFILE: reads from the registry
1928  * - SystemDrive: uses GetSystemDirectoryW and uses the drive portion of its
1929  * path
1930  * If one of the directly handled environment variables is expanded, only
1931  * expands a single variable, and only in the beginning of szSrc.
1932  */
1933 #ifndef __REACTOS__
1935 #else
1936 static HRESULT _SHExpandEnvironmentStrings(HANDLE hToken, LPCWSTR szSrc, LPWSTR szDest, DWORD cchDest)
1937 #endif
1938 {
1939  HRESULT hr;
1940 #ifndef __REACTOS__
1941  WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 };
1942  HKEY key = NULL;
1943 #else
1944  WCHAR szTemp[MAX_PATH];
1945 #endif
1946 
1947  TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
1948 
1949  if (!szSrc || !szDest) return E_INVALIDARG;
1950 
1951  /* short-circuit if there's nothing to expand */
1952  if (szSrc[0] != '%')
1953  {
1954  strcpyW(szDest, szSrc);
1955  hr = S_OK;
1956  goto end;
1957  }
1958 #ifndef __REACTOS__
1959  /* Get the profile prefix, we'll probably be needing it */
1961  if (SUCCEEDED(hr))
1962  {
1963  WCHAR def_val[MAX_PATH];
1964 
1965  /* get the system drive */
1966  GetSystemDirectoryW(def_val, MAX_PATH);
1967  strcpyW( def_val + 3, szDefaultProfileDirW );
1968 
1969  hr = _SHGetProfilesValue(key, ProfilesDirectoryW, szProfilesPrefix, def_val );
1970  }
1971 #else
1972  hr = S_OK;
1973 #endif
1974 
1975  *szDest = 0;
1976  strcpyW(szTemp, szSrc);
1977  while (SUCCEEDED(hr) && szTemp[0] == '%')
1978  {
1980  {
1981 #ifndef __REACTOS__
1983 
1984  strcpyW(szDest, szProfilesPrefix);
1987  PathAppendW(szDest, szAllUsers);
1988 #else
1989  DWORD cchSize = cchDest;
1990  if (!GetAllUsersProfileDirectoryW(szDest, &cchSize))
1991  goto fallback_expand;
1992 #endif
1993  PathAppendW(szDest, szTemp + strlenW(AllUsersProfileW));
1994  }
1995 #ifndef __REACTOS__
1996  else if (!strncmpiW(szTemp, PublicProfileW, strlenW(PublicProfileW)))
1997  {
1998  WCHAR szAllUsers[MAX_PATH], def_val[MAX_PATH];
1999 
2000  GetSystemDirectoryW(def_val, MAX_PATH);
2001  strcpyW( def_val + 3, UsersPublicW );
2002 
2004  PathAppendW(szDest, szAllUsers);
2005  PathAppendW(szDest, szTemp + strlenW(PublicProfileW));
2006  }
2007 #endif
2008  else if (!strncmpiW(szTemp, UserProfileW, strlenW(UserProfileW)))
2009  {
2010 #ifndef __REACTOS__
2012  DWORD userLen = MAX_PATH;
2013 
2014  strcpyW(szDest, szProfilesPrefix);
2015  GetUserNameW(userName, &userLen);
2016  PathAppendW(szDest, userName);
2017 #else
2018  DWORD cchSize = cchDest;
2019  if (!_SHGetUserProfileDirectoryW(hToken, szDest, &cchSize))
2020  goto fallback_expand;
2021 #endif
2022  PathAppendW(szDest, szTemp + strlenW(UserProfileW));
2023  }
2024  else if (!strncmpiW(szTemp, SystemDriveW, strlenW(SystemDriveW)))
2025  {
2026 #ifndef __REACTOS__
2027  GetSystemDirectoryW(szDest, MAX_PATH);
2028 #else
2029  if (!GetSystemDirectoryW(szDest, cchDest))
2030  goto fallback_expand;
2031 #endif
2032  strcpyW(szDest + 3, szTemp + strlenW(SystemDriveW) + 1);
2033  }
2034  else
2035 #ifdef __REACTOS__
2036 fallback_expand:
2037 #endif
2038  {
2039 #ifndef __REACTOS__
2040  DWORD ret = ExpandEnvironmentStringsW(szTemp, szDest, MAX_PATH);
2041 #else
2042  DWORD ret = SHExpandEnvironmentStringsForUserW(hToken, szTemp, szDest, cchDest);
2043 #endif
2044 
2045 #ifndef __REACTOS__
2046  if (ret > MAX_PATH)
2047 #else
2048  if (ret > cchDest)
2049 #endif
2051  else if (ret == 0)
2053  else if (!strcmpW( szTemp, szDest )) break; /* nothing expanded */
2054  }
2055  if (SUCCEEDED(hr)) strcpyW(szTemp, szDest);
2056  }
2057 end:
2058 #ifndef __REACTOS__
2059  if (key)
2060  RegCloseKey(key);
2061 #endif
2062  TRACE("returning 0x%08x (input was %s, output is %s)\n", hr,
2063  debugstr_w(szSrc), debugstr_w(szDest));
2064  return hr;
2065 }
2066 
2067 /*************************************************************************
2068  * SHGetFolderPathW [SHELL32.@]
2069  *
2070  * Convert nFolder to path.
2071  *
2072  * RETURNS
2073  * Success: S_OK
2074  * Failure: standard HRESULT error codes.
2075  *
2076  * NOTES
2077  * Most values can be overridden in either
2078  * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
2079  * or in the same location in HKLM.
2080  * The "Shell Folders" registry key was used in NT4 and earlier systems.
2081  * Beginning with Windows 2000, the "User Shell Folders" key is used, so
2082  * changes made to it are made to the former key too. This synchronization is
2083  * done on-demand: not until someone requests the value of one of these paths
2084  * (by calling one of the SHGet functions) is the value synchronized.
2085  * Furthermore, the HKCU paths take precedence over the HKLM paths.
2086  */
2088  HWND hwndOwner, /* [I] owner window */
2089  int nFolder, /* [I] CSIDL identifying the folder */
2090  HANDLE hToken, /* [I] access token */
2091  DWORD dwFlags, /* [I] which path to return */
2092  LPWSTR pszPath) /* [O] converted path */
2093 {
2094  HRESULT hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, NULL, pszPath);
2097  return hr;
2098 }
2099 
2101  HWND hwndOwner, /* [I] owner window */
2102  int nFolder, /* [I] CSIDL identifying the folder */
2103  HANDLE hToken, /* [I] access token */
2104  DWORD dwFlags, /* [I] which path to return */
2105  LPCSTR pszSubPath, /* [I] sub directory of the specified folder */
2106  LPSTR pszPath) /* [O] converted path */
2107 {
2108  int length;
2109  HRESULT hr = S_OK;
2110  LPWSTR pszSubPathW = NULL;
2111  LPWSTR pszPathW = NULL;
2112 
2113  TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_a(pszSubPath), pszPath);
2114 
2115  if(pszPath) {
2116  pszPathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
2117  if(!pszPathW) {
2119  goto cleanup;
2120  }
2121  }
2122  TRACE("%08x,%08x,%s\n",nFolder, dwFlags, debugstr_w(pszSubPathW));
2123 
2124  /* SHGetFolderPathAndSubDirW does not distinguish if pszSubPath isn't
2125  * set (null), or an empty string.therefore call it without the parameter set
2126  * if pszSubPath is an empty string
2127  */
2128  if (pszSubPath && pszSubPath[0]) {
2129  length = MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, NULL, 0);
2130  pszSubPathW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR));
2131  if(!pszSubPathW) {
2133  goto cleanup;
2134  }
2135  MultiByteToWideChar(CP_ACP, 0, pszSubPath, -1, pszSubPathW, length);
2136  }
2137 
2138  hr = SHGetFolderPathAndSubDirW(hwndOwner, nFolder, hToken, dwFlags, pszSubPathW, pszPathW);
2139 
2140  if (SUCCEEDED(hr) && pszPath)
2141  WideCharToMultiByte(CP_ACP, 0, pszPathW, -1, pszPath, MAX_PATH, NULL, NULL);
2142 
2143 cleanup:
2144  HeapFree(GetProcessHeap(), 0, pszPathW);
2145  HeapFree(GetProcessHeap(), 0, pszSubPathW);
2146  return hr;
2147 }
2148 
2149 /*************************************************************************
2150  * SHGetFolderPathAndSubDirW [SHELL32.@]
2151  */
2153  HWND hwndOwner, /* [I] owner window */
2154  int nFolder, /* [I] CSIDL identifying the folder */
2155  HANDLE hToken, /* [I] access token */
2156  DWORD dwFlags, /* [I] which path to return */
2157  LPCWSTR pszSubPath,/* [I] sub directory of the specified folder */
2158  LPWSTR pszPath) /* [O] converted path */
2159 {
2160  HRESULT hr;
2161  WCHAR szBuildPath[MAX_PATH], szTemp[MAX_PATH];
2163  CSIDL_Type type;
2164  int ret;
2165 
2166  TRACE("%p,%#x,%p,%#x,%s,%p\n", hwndOwner, nFolder, hToken, dwFlags, debugstr_w(pszSubPath), pszPath);
2167 
2168  /* Windows always NULL-terminates the resulting path regardless of success
2169  * or failure, so do so first
2170  */
2171  if (pszPath)
2172  *pszPath = '\0';
2173 
2174  if (folder >= ARRAY_SIZE(CSIDL_Data))
2175  return E_INVALIDARG;
2177  return E_INVALIDARG;
2178  szTemp[0] = 0;
2180  switch (type)
2181  {
2182  case CSIDL_Type_Disallowed:
2183  hr = E_INVALIDARG;
2184  break;
2186  hr = S_FALSE;
2187  break;
2189  GetWindowsDirectoryW(szTemp, MAX_PATH);
2190  if (CSIDL_Data[folder].szDefaultPath &&
2191  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2192  *CSIDL_Data[folder].szDefaultPath)
2193  {
2194  PathAddBackslashW(szTemp);
2195  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2196  }
2197  hr = S_OK;
2198  break;
2199  case CSIDL_Type_SystemPath:
2200  GetSystemDirectoryW(szTemp, MAX_PATH);
2201  if (CSIDL_Data[folder].szDefaultPath &&
2202  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2203  *CSIDL_Data[folder].szDefaultPath)
2204  {
2205  PathAddBackslashW(szTemp);
2206  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2207  }
2208  hr = S_OK;
2209  break;
2212  if (CSIDL_Data[folder].szDefaultPath &&
2213  !IS_INTRESOURCE(CSIDL_Data[folder].szDefaultPath) &&
2214  *CSIDL_Data[folder].szDefaultPath)
2215  {
2216  PathAddBackslashW(szTemp);
2217  strcatW(szTemp, CSIDL_Data[folder].szDefaultPath);
2218  }
2219  hr = S_OK;
2220  break;
2221  case CSIDL_Type_CurrVer:
2223  break;
2224  case CSIDL_Type_User:
2225  hr = _SHGetUserProfilePath(hToken, dwFlags, folder, szTemp);
2226  break;
2227  case CSIDL_Type_AllUsers:
2229  break;
2230  default:
2231  FIXME("bogus type %d, please fix\n", type);
2232  hr = E_INVALIDARG;
2233  break;
2234  }
2235 
2236  /* Expand environment strings if necessary */
2237  if (*szTemp == '%')
2238 #ifndef __REACTOS__
2239  hr = _SHExpandEnvironmentStrings(szTemp, szBuildPath);
2240 #else
2241  hr = _SHExpandEnvironmentStrings(hToken, szTemp, szBuildPath, _countof(szBuildPath));
2242 #endif
2243  else
2244  strcpyW(szBuildPath, szTemp);
2245 
2246  if (FAILED(hr)) goto end;
2247 
2248  if(pszSubPath) {
2249  /* make sure the new path does not exceed the buffer length
2250  * and remember to backslash and terminate it */
2251  if(MAX_PATH < (lstrlenW(szBuildPath) + lstrlenW(pszSubPath) + 2)) {
2253  goto end;
2254  }
2255  PathAppendW(szBuildPath, pszSubPath);
2256  PathRemoveBackslashW(szBuildPath);
2257  }
2258  /* Copy the path if it's available before we might return */
2259  if (SUCCEEDED(hr) && pszPath)
2260  strcpyW(pszPath, szBuildPath);
2261 
2262  /* if we don't care about existing directories we are ready */
2263  if(nFolder & CSIDL_FLAG_DONT_VERIFY) goto end;
2264 
2265  if (PathFileExistsW(szBuildPath)) goto end;
2266 
2267  /* not existing but we are not allowed to create it. The return value
2268  * is verified against shell32 version 6.0.
2269  */
2270  if (!(nFolder & CSIDL_FLAG_CREATE))
2271  {
2273  goto end;
2274  }
2275 
2276  /* create directory/directories */
2277  ret = SHCreateDirectoryExW(hwndOwner, szBuildPath, NULL);
2278  if (ret && ret != ERROR_ALREADY_EXISTS)
2279  {
2280  ERR("Failed to create directory %s.\n", debugstr_w(szBuildPath));
2281  hr = E_FAIL;
2282  goto end;
2283  }
2284 
2285  TRACE("Created missing system directory %s\n", debugstr_w(szBuildPath));
2286 
2287 end:
2288  /* create desktop.ini for custom icon */
2289  if ((nFolder & CSIDL_FLAG_CREATE) &&
2290  CSIDL_Data[folder].nShell32IconIndex)
2291  {
2292  static const WCHAR s_szFormat[] = L"%%SystemRoot%%\\system32\\shell32.dll,%d";
2293  WCHAR szIconLocation[MAX_PATH];
2295 
2296  /* make the directory a system folder */
2297  dwAttributes = GetFileAttributesW(szBuildPath);
2299  SetFileAttributesW(szBuildPath, dwAttributes);
2300 
2301  /* build the desktop.ini file path */
2302  PathAppendW(szBuildPath, L"desktop.ini");
2303 
2304  /* build the icon location */
2305  StringCchPrintfW(szIconLocation, _countof(szIconLocation), s_szFormat,
2306  CSIDL_Data[folder].nShell32IconIndex);
2307 
2308  /* write desktop.ini */
2309  WritePrivateProfileStringW(L".ShellClassInfo", L"IconResource", szIconLocation, szBuildPath);
2310 
2311  /* flush! */
2312  WritePrivateProfileStringW(NULL, NULL, NULL, szBuildPath);
2313 
2314  /* make the desktop.ini a system and hidden file */
2315  dwAttributes = GetFileAttributesW(szBuildPath);
2317  SetFileAttributesW(szBuildPath, dwAttributes);
2318  }
2319 
2320  TRACE("returning 0x%08x (final path is %s)\n", hr, debugstr_w(szBuildPath));
2321  return hr;
2322 }
2323 
2324 /*************************************************************************
2325  * SHGetFolderPathA [SHELL32.@]
2326  *
2327  * See SHGetFolderPathW.
2328  */
2330  HWND hwndOwner,
2331  int nFolder,
2332  HANDLE hToken,
2333  DWORD dwFlags,
2334  LPSTR pszPath)
2335 {
2336  WCHAR szTemp[MAX_PATH];
2337  HRESULT hr;
2338 
2339  TRACE("%p,%d,%p,%#x,%p\n", hwndOwner, nFolder, hToken, dwFlags, pszPath);
2340 
2341  if (pszPath)
2342  *pszPath = '\0';
2343  hr = SHGetFolderPathW(hwndOwner, nFolder, hToken, dwFlags, szTemp);
2344  if (SUCCEEDED(hr) && pszPath)
2345  WideCharToMultiByte(CP_ACP, 0, szTemp, -1, pszPath, MAX_PATH, NULL,
2346  NULL);
2347 
2348  return hr;
2349 }
2350 
2351 /* For each folder in folders, if its value has not been set in the registry,
2352  * calls _SHGetUserProfilePath or _SHGetAllUsersProfilePath (depending on the
2353  * folder's type) to get the unexpanded value first.
2354  * Writes the unexpanded value to User Shell Folders, and queries it with
2355  * SHGetFolderPathW to force the creation of the directory if it doesn't
2356  * already exist. SHGetFolderPathW also returns the expanded value, which
2357  * this then writes to Shell Folders.
2358  */
2359 static HRESULT _SHRegisterFolders(HKEY hRootKey, HANDLE hToken,
2360  LPCWSTR szUserShellFolderPath, LPCWSTR szShellFolderPath, const UINT folders[],
2361  UINT foldersLen)
2362 {
2363  const WCHAR *szValueName;
2364  WCHAR buffer[40];
2365  UINT i;
2366  WCHAR path[MAX_PATH];
2367  HRESULT hr = S_OK;
2368  HKEY hUserKey = NULL, hKey = NULL;
2369  DWORD dwType, dwPathLen;
2370  LONG ret;
2371 
2372  TRACE("%p,%p,%s,%p,%u\n", hRootKey, hToken,
2373  debugstr_w(szUserShellFolderPath), folders, foldersLen);
2374 
2375  ret = RegCreateKeyW(hRootKey, szUserShellFolderPath, &hUserKey);
2376  if (ret)
2378  else
2379  {
2380  ret = RegCreateKeyW(hRootKey, szShellFolderPath, &hKey);
2381  if (ret)
2383  }
2384  for (i = 0; SUCCEEDED(hr) && i < foldersLen; i++)
2385  {
2386  dwPathLen = MAX_PATH * sizeof(WCHAR);
2387 
2388  /* For CSIDL_Type_User we also use the GUID if no szValueName is provided */
2389  szValueName = CSIDL_Data[folders[i]].szValueName;
2390  if (!szValueName && CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2391  {
2392  StringFromGUID2( CSIDL_Data[folders[i]].id, buffer, 39 );
2393  szValueName = &buffer[0];
2394  }
2395 
2396  if (!RegQueryValueExW(hUserKey, szValueName, NULL,
2397  &dwType, (LPBYTE)path, &dwPathLen) &&
2398  (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
2399  {
2400  hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
2401  hToken, SHGFP_TYPE_CURRENT, path);
2402  }
2403  else
2404  {
2405  *path = '\0';
2406  if (CSIDL_Data[folders[i]].type == CSIDL_Type_User)
2407  _SHGetUserProfilePath(hToken, SHGFP_TYPE_CURRENT, folders[i],
2408  path);
2409  else if (CSIDL_Data[folders[i]].type == CSIDL_Type_AllUsers)
2411  else if (CSIDL_Data[folders[i]].type == CSIDL_Type_WindowsPath)
2412  {
2414  if (CSIDL_Data[folders[i]].szDefaultPath &&
2415  !IS_INTRESOURCE(CSIDL_Data[folders[i]].szDefaultPath))
2416  {
2418  strcatW(path, CSIDL_Data[folders[i]].szDefaultPath);
2419  }
2420  }
2421  else
2422  hr = E_FAIL;
2423  if (*path)
2424  {
2425  ret = RegSetValueExW(hUserKey, szValueName, 0, REG_EXPAND_SZ,
2426  (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2427  if (ret)
2429  else
2430  {
2431  hr = SHGetFolderPathW(NULL, folders[i] | CSIDL_FLAG_CREATE,
2432  hToken, SHGFP_TYPE_CURRENT, path);
2433  ret = RegSetValueExW(hKey, szValueName, 0, REG_SZ,
2434  (LPBYTE)path, (strlenW(path) + 1) * sizeof(WCHAR));
2435  if (ret)
2437  }
2438  }
2439  }
2440  }
2441  if (hUserKey)
2442  RegCloseKey(hUserKey);
2443  if (hKey)
2444  RegCloseKey(hKey);
2445 
2446  TRACE("returning 0x%08x\n", hr);
2447  return hr;
2448 }
2449 
2451 {
2452  static const UINT folders[] = {
2456  CSIDL_APPDATA,
2457  CSIDL_STARTUP,
2458  CSIDL_RECENT,
2459  CSIDL_SENDTO,
2461  CSIDL_MYMUSIC,
2462  CSIDL_MYVIDEO,
2464  CSIDL_NETHOOD,
2469  CSIDL_COOKIES,
2470  CSIDL_HISTORY,
2472  CSIDL_FONTS,
2474 /* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */
2475 #ifndef __REACTOS__
2478  CSIDL_LINKS,
2482 #endif
2483  };
2484  WCHAR userShellFolderPath[MAX_PATH], shellFolderPath[MAX_PATH];
2485  LPCWSTR pUserShellFolderPath, pShellFolderPath;
2486  HRESULT hr = S_OK;
2487  HKEY hRootKey;
2488  HANDLE hToken;
2489 
2490  TRACE("%s\n", bDefault ? "TRUE" : "FALSE");
2491  if (bDefault)
2492  {
2493  hToken = (HANDLE)-1;
2494  hRootKey = HKEY_USERS;
2495  strcpyW(userShellFolderPath, DefaultW);
2496  PathAddBackslashW(userShellFolderPath);
2497  strcatW(userShellFolderPath, szSHUserFolders);
2498  pUserShellFolderPath = userShellFolderPath;
2499  strcpyW(shellFolderPath, DefaultW);
2500  PathAddBackslashW(shellFolderPath);
2501  strcatW(shellFolderPath, szSHFolders);
2502  pShellFolderPath = shellFolderPath;
2503  }
2504  else
2505  {
2506  hToken = NULL;
2507  hRootKey = HKEY_CURRENT_USER;
2508  pUserShellFolderPath = szSHUserFolders;
2509  pShellFolderPath = szSHFolders;
2510  }
2511 
2512  hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
2513  pShellFolderPath, folders, ARRAY_SIZE(folders));
2514  TRACE("returning 0x%08x\n", hr);
2515  return hr;
2516 }
2517 
2519 {
2520  static const UINT folders[] = {
2533  };
2534  HRESULT hr;
2535 
2536  TRACE("\n");
2538  szSHFolders, folders, ARRAY_SIZE(folders));
2539  TRACE("returning 0x%08x\n", hr);
2540  return hr;
2541 }
2542 
2543 /* Register the default values in the registry, as some apps seem to depend
2544  * on their presence. The set registered was taken from Windows XP.
2545  */
2547 {
2548  HRESULT hr;
2549 
2551  if (SUCCEEDED(hr))
2553  if (SUCCEEDED(hr))
2555  return hr;
2556 }
2557 
2558 /*************************************************************************
2559  * SHGetSpecialFolderPathA [SHELL32.@]
2560  */
2562  HWND hwndOwner,
2563  LPSTR szPath,
2564  int nFolder,
2565  BOOL bCreate)
2566 {
2567  return SHGetFolderPathA(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
2568  szPath) == S_OK;
2569 }
2570 
2571 /*************************************************************************
2572  * SHGetSpecialFolderPathW
2573  */
2575  HWND hwndOwner,
2576  LPWSTR szPath,
2577  int nFolder,
2578  BOOL bCreate)
2579 {
2580  return SHGetFolderPathW(hwndOwner, nFolder + (bCreate ? CSIDL_FLAG_CREATE : 0), NULL, 0,
2581  szPath) == S_OK;
2582 }
2583 
2584 /*************************************************************************
2585  * SHGetFolderLocation [SHELL32.@]
2586  *
2587  * Gets the folder locations from the registry and creates a pidl.
2588  *
2589  * PARAMS
2590  * hwndOwner [I]
2591  * nFolder [I] CSIDL_xxxxx
2592  * hToken [I] token representing user, or NULL for current user, or -1 for
2593  * default user
2594  * dwReserved [I] must be zero
2595  * ppidl [O] PIDL of a special folder
2596  *
2597  * RETURNS
2598  * Success: S_OK
2599  * Failure: Standard OLE-defined error result, S_FALSE or E_INVALIDARG
2600  *
2601  * NOTES
2602  * Creates missing reg keys and directories.
2603  * Mostly forwards to SHGetFolderPathW, but a few values of nFolder return
2604  * virtual folders that are handled here.
2605  */
2607  HWND hwndOwner,
2608  int nFolder,
2609  HANDLE hToken,
2610  DWORD dwReserved,
2611  LPITEMIDLIST *ppidl)
2612 {
2614 
2615  TRACE("%p 0x%08x %p 0x%08x %p\n",
2616  hwndOwner, nFolder, hToken, dwReserved, ppidl);
2617 
2618  if (!ppidl)
2619  return E_INVALIDARG;
2620  if (dwReserved)
2621  return E_INVALIDARG;
2622 
2623  /* The virtual folders' locations are not user-dependent */
2624  *ppidl = NULL;
2625  switch (nFolder & CSIDL_FOLDER_MASK)
2626  {
2627  case CSIDL_DESKTOP:
2628  *ppidl = _ILCreateDesktop();
2629  break;
2630 
2631  case CSIDL_PERSONAL:
2632  *ppidl = _ILCreateMyDocuments();
2633  break;
2634 
2635  case CSIDL_INTERNET:
2636  *ppidl = _ILCreateIExplore();
2637  break;
2638 
2639  case CSIDL_CONTROLS:
2640  *ppidl = _ILCreateControlPanel();
2641  break;
2642 
2643  case CSIDL_PRINTERS:
2644  *ppidl = _ILCreatePrinters();
2645  break;
2646 
2647  case CSIDL_BITBUCKET:
2648  *ppidl = _ILCreateBitBucket();
2649  break;
2650 
2651  case CSIDL_DRIVES:
2652  *ppidl = _ILCreateMyComputer();
2653  break;
2654 
2655  case CSIDL_NETWORK:
2656  *ppidl = _ILCreateNetwork();
2657  break;
2658 
2659  default:
2660  {
2662 
2663  hr = SHGetFolderPathW(hwndOwner, nFolder, hToken,
2665  if (SUCCEEDED(hr))
2666  {
2667  DWORD attributes=0;
2668 
2669  TRACE("Value=%s\n", debugstr_w(szPath));
2670  hr = SHILCreateFromPathW(szPath, ppidl, &attributes);
2671  }
2673  {
2674  /* unlike SHGetFolderPath, SHGetFolderLocation in shell32
2675  * version 6.0 returns E_FAIL for nonexistent paths
2676  */
2677  hr = E_FAIL;
2678  }
2679  }
2680  }
2681  if(*ppidl)
2682  hr = S_OK;
2683 
2684  TRACE("-- (new pidl %p)\n",*ppidl);
2685  return hr;
2686 }
2687 
2688 /*************************************************************************
2689  * SHGetSpecialFolderLocation [SHELL32.@]
2690  *
2691  * NOTES
2692  * In NT5, SHGetSpecialFolderLocation needs the <winntdir>/Recent
2693  * directory.
2694  */
2696  HWND hwndOwner,
2697  INT nFolder,
2698  LPITEMIDLIST * ppidl)
2699 {
2701 
2702  TRACE("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
2703 
2704  if (!ppidl)
2705  return E_INVALIDARG;
2706 
2707  hr = SHGetFolderLocation(hwndOwner, nFolder, NULL, 0, ppidl);
2708  return hr;
2709 }
#define HKEY_USERS
Definition: winreg.h:13
static HRESULT _SHRegisterCommonShellFolders(void)
Definition: shellpath.c:2518
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
static const WCHAR Common_DesktopW[]
Definition: shellpath.c:540
static const WCHAR FavoritesW[]
Definition: shellpath.c:561
static LONG PathProcessCommandA(LPCSTR lpszPath, LPSTR lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:482
static const WCHAR UsersW[]
Definition: shellpath.c:623
disp
Definition: i386-dis.c:3181
#define IDI_SHELL_RECENT_DOCUMENTS
Definition: shresdef.h:496
static const WCHAR PublicProfileW[]
Definition: shellpath.c:631
static const WCHAR ContactsW[]
Definition: shellpath.c:553
#define CSIDL_COOKIES
Definition: shlobj.h:2035
BOOL WINAPI GetDefaultUserProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1360
BOOL WINAPI PathAppendAW(LPVOID lpszPath1, LPCVOID lpszPath2)
Definition: shellpath.c:64
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:624
#define IDS_STARTMENU
Definition: shresdef.h:84
#define TRUE
Definition: types.h:120
static const WCHAR DocumentsW[]
Definition: shellpath.c:558
static const WCHAR Microsoft_Windows_LibrariesW[]
Definition: shellpath.c:576
#define CloseHandle
Definition: compat.h:406
LPCWSTR szDefaultPath
Definition: shellpath.c:675
static const WCHAR RecentW[]
Definition: shellpath.c:607
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1588
#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:498
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static const WCHAR UserProfileW[]
Definition: shellpath.c:633
#define ERROR_SUCCESS
Definition: deptool.c:10
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define CSIDL_MYVIDEO
Definition: shlobj.h:2017
static const WCHAR szKnownFolderRedirections[]
Definition: shellpath.c:645
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest)
Definition: shellpath.c:1934
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1636
int WINAPI PathCleanupSpec(LPCWSTR lpszPathW, LPWSTR lpszFileW)
Definition: shellpath.c:359
static const WCHAR FontsW[]
Definition: shellpath.c:562
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2064
BOOL WINAPI GetUserProfileDirectoryW(_In_ HANDLE hToken, _Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1709
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2027
static const WCHAR Common_ProgramsW[]
Definition: shellpath.c:547
#define CSIDL_MYPICTURES
Definition: shlobj.h:2041
#define IDS_APPDATA
Definition: shresdef.h:90
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const WCHAR CommonFilesDirW[]
Definition: shellpath.c:543
#define IDI_SHELL_CONTROL_PANEL
Definition: shresdef.h:497
static const WCHAR Microsoft_Windows_RingtonesW[]
Definition: shellpath.c:577
#define CSIDL_DESKTOP
Definition: shlobj.h:2003
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2033
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1638
#define CSIDL_CONTACTS
Definition: shellpath.c:662
#define CP_ACP
Definition: compat.h:99
#define _countof(array)
Definition: fontsub.cpp:30
LONG WINAPI PathProcessCommandAW(LPCVOID lpszPath, LPVOID lpszBuff, DWORD dwBuffSize, DWORD dwFlags)
Definition: shellpath.c:514
#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:2359
char CHAR
Definition: xmlstorage.h:175
#define IDS_COMMON_MUSIC
Definition: shresdef.h:101
#define IDI_SHELL_COMPUTER_FOLDER
Definition: shresdef.h:518
BOOL WINAPI PathAppendA(LPSTR lpszPath, LPCSTR lpszAppend)
Definition: path.c:101
static BOOL PathMakeUniqueNameW(LPWSTR lpszBuffer, DWORD dwBuffSize, LPCWSTR lpszShortName, LPCWSTR lpszLongName, LPCWSTR lpszPathName)
Definition: shellpath.c:289
#define IDS_INTERNET_CACHE
Definition: shresdef.h:93
static const WCHAR SendToW[]
Definition: shellpath.c:613
_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
static const WCHAR Program_FilesW[]
Definition: shellpath.c:596
static const CSIDL_DATA CSIDL_Data[]
Definition: shellpath.c:679
static const WCHAR VideosW[]
Definition: shellpath.c:625
#define CSIDL_COMMON_STARTUP
Definition: shlobj.h:2026
#define IDS_PERSONAL
Definition: shresdef.h:254
#define IDI_SHELL_FAVORITES
Definition: shresdef.h:519
#define IDS_FAVORITES
Definition: resource.h:31
_In_ int nFolder
Definition: shlobj.h:1435
enum _CSIDL_Type CSIDL_Type
static BOOL PathQualifyA(LPCSTR pszPath)
Definition: shellpath.c:431
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL WINAPI PathFileExistsA(LPCSTR lpszPath)
Definition: path.c:1734
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
UINT WINAPI PathGetCharTypeW(WCHAR ch)
Definition: path.c:3015
#define IDI_SHELL_MY_MOVIES
Definition: shresdef.h:604
GLuint buffer
Definition: glext.h:5915
static const WCHAR OEM_LinksW[]
Definition: shellpath.c:587
#define CSIDL_BITBUCKET
Definition: shlobj.h:2013
static const WCHAR TemplatesW[]
Definition: shellpath.c:621
#define CSIDL_HISTORY
Definition: shlobj.h:2036
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2040
LPVOID WINAPI SHPathGetExtensionW(LPCWSTR lpszPath, DWORD void1, DWORD void2)
Definition: shellpath.c:102
GLuint GLuint end
Definition: gl.h:1545
#define CSIDL_COMMON_PICTURES
Definition: shlobj.h:2053
static const WCHAR szCurrentVersion[]
Definition: shellpath.c:529
#define IDI_SHELL_PROGRAMS_FOLDER
Definition: shresdef.h:495
static const WCHAR ProfilesDirectoryW[]
Definition: shellpath.c:637
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:531
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:323
#define CSIDL_FONTS
Definition: shlobj.h:2022
#define lstrlenW
Definition: compat.h:415
#define E_FAIL
Definition: ddrawi.h:102
static const WCHAR Local_AppDataW[]
Definition: shellpath.c:567
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:56
BOOL WINAPI PathRemoveFileSpecA(LPSTR lpszPath)
Definition: path.c:581
static const WCHAR Common_FavoritesW[]
Definition: shellpath.c:542
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define CSIDL_INTERNET_CACHE
Definition: shlobj.h:2034
static const WCHAR ProgramsW[]
Definition: shellpath.c:603
BOOL WINAPI IsLFNDriveAW(LPCVOID lpszPath)
Definition: shellpath.c:260
DWORD dwAttributes
Definition: vdmdbg.h:34
#define CSIDL_COMMON_TEMPLATES
Definition: shlobj.h:2047
#define IDI_SHELL_PRINTERS_FOLDER
Definition: shresdef.h:513
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:405
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
#define CSIDL_CONTROLS
Definition: shlobj.h:2006
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
#define CSIDL_PROGRAM_FILESX86
Definition: shlobj.h:2044
static const WCHAR szSHUserFolders[]
Definition: shellpath.c:641
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2025
static const WCHAR Common_TemplatesW[]
Definition: shellpath.c:550
static const WCHAR MusicW[]
Definition: shellpath.c:578
static const WCHAR Music_PlaylistsW[]
Definition: shellpath.c:579
#define CSIDL_RECENT
Definition: shlobj.h:2011
static const WCHAR ProgramFilesDirW[]
Definition: shellpath.c:601
static const WCHAR Local_Settings_Application_DataW[]
Definition: shellpath.c:569
#define CSIDL_FOLDER_MASK
Definition: shlobj.h:2061
static const WCHAR Program_Files_x86W[]
Definition: shellpath.c:599
#define IDS_PRINTHOOD
Definition: shresdef.h:91
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 PCS_PATHTOOLONG
Definition: shlobj.h:327
BOOL WINAPI SHGetSpecialFolderPathA(HWND hwndOwner, LPSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2561
#define CSIDL_PRINTERS
Definition: shlobj.h:2007
#define IDI_SHELL_DESKTOP
Definition: shresdef.h:510
#define CSIDL_DRIVES
Definition: shlobj.h:2019
#define GCT_WILD
Definition: shlwapi.h:778
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
static const WCHAR Administrative_ToolsW[]
Definition: shellpath.c:530
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
static const WCHAR PublicW[]
Definition: shellpath.c:605
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:818
BOOL _SHGetUserProfileDirectoryW(HANDLE hToken, LPWSTR szPath, LPDWORD lpcchPath)
Definition: shellpath.c:1509
_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:289
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static const WCHAR Videos_Sample_VideosW[]
Definition: shellpath.c:626
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
BOOL WINAPI PathIsRootAW(LPCVOID lpszPath)
Definition: shellpath.c:168
#define GCT_INVALID
Definition: shlwapi.h:775
static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
Definition: shellpath.c:2450
#define IDS_STARTUP
Definition: shresdef.h:81
#define debugstr_w
Definition: kernel32.h:32
#define IDS_PROGRAMS
Definition: resource.h:69
#define FIXME(fmt,...)
Definition: debug.h:110
static void PathGetShortPathW(LPWSTR pszPath)
Definition: shellpath.c:139
static const WCHAR AllUsersProfileW[]
Definition: shellpath.c:629
static const WCHAR Common_StartUpW[]
Definition: shellpath.c:548
#define S_FALSE
Definition: winerror.h:2357
BOOL WINAPI PathRemoveFileSpecAW(LPVOID lpszPath)
Definition: shellpath.c:110
#define E_INVALIDARG
Definition: ddrawi.h:101
static const WCHAR Program_Files_x86_Common_FilesW[]
Definition: shellpath.c:600
static const WCHAR Common_Start_MenuW[]
Definition: shellpath.c:549
static const BOOL is_win64
Definition: shellpath.c:55
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
#define IDS_DESKTOPDIRECTORY
Definition: shresdef.h:87
#define IDI_SHELL_TSKBAR_STARTMENU
Definition: shresdef.h:515
#define CSIDL_SEARCHES
Definition: shellpath.c:667
static const WCHAR UsersPublicW[]
Definition: shellpath.c:624
#define CSIDL_COMMON_STARTMENU
Definition: shlobj.h:2024
#define IDI_SHELL_NETWORK
Definition: shresdef.h:490
#define IDS_COMMON_VIDEO
Definition: shresdef.h:103
BOOL WINAPI IsLFNDriveW(LPCWSTR lpszPath)
Definition: shellpath.c:248
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
static const WCHAR Start_MenuW[]
Definition: shellpath.c:615
const char * LPCSTR
Definition: xmlstorage.h:183
LPITEMIDLIST _ILCreateMyComputer(void)
Definition: pidl.c:1599
static const WCHAR ProgramFilesDirX86W[]
Definition: shellpath.c:602
static const WCHAR Microsoft_Windows_GameExplorerW[]
Definition: shellpath.c:575
static const WCHAR Common_AppDataW[]
Definition: shellpath.c:539
struct CFFOLDER folder
Definition: fdi.c:102
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static HRESULT _SHOpenProfilesKey(PHKEY pKey)
Definition: shellpath.c:1869
static const WCHAR Program_Files_Common_FilesW[]
Definition: shellpath.c:597
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2049
static const WCHAR szKnownFolderDescriptions[]
Definition: shellpath.c:644
#define IDI_SHELL_FONTS_FOLDER
Definition: shresdef.h:514
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:1974
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:3005
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1621
static const WCHAR Pictures_Slide_ShowsW[]
Definition: shellpath.c:592
#define IDI_SHELL_NETWORK_FOLDER
Definition: resource.h:5
#define IDS_TEMPLATES
Definition: shresdef.h:89
const KNOWNFOLDERID * id
Definition: shellpath.c:672
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:614
static const WCHAR szAllUsers[]
Definition: msipriv.h:1138
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
static BOOL PathResolveW(LPWSTR path, LPCWSTR *paths, DWORD flags)
Definition: shellpath.c:462
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TOKEN_QUERY
Definition: setypes.h:874
static BOOL PathQualifyW(LPCWSTR pszPath)
Definition: shellpath.c:440
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:2050
BOOL WINAPI PathMakeUniqueNameAW(LPVOID lpszBuffer, DWORD dwBuffSize, LPCVOID lpszShortName, LPCVOID lpszLongName, LPCVOID lpszPathName)
Definition: shellpath.c:305
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1748
#define debugstr_a
Definition: kernel32.h:31
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2695
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static const WCHAR Common_Administrative_ToolsW[]
Definition: shellpath.c:538
BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
Definition: shellpath.c:449
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2030
static const WCHAR SystemDriveW[]
Definition: shellpath.c:634
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
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:2012
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1751
#define CSIDL_APPDATA
Definition: shlobj.h:2028
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:6
const char file[]
Definition: icontest.c:11
static const WCHAR AppData_LocalLowW[]
Definition: shellpath.c:533
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:196
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI IsLFNDriveA(LPCSTR lpszPath)
Definition: shellpath.c:236
#define IDS_COOKIES
Definition: shresdef.h:94
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define CSIDL_COMMON_VIDEO
Definition: shlobj.h:2054
GLbitfield flags
Definition: glext.h:7161
static void PathGetShortPathA(LPSTR pszPath)
Definition: shellpath.c:124
#define IDS_RECENT
Definition: shresdef.h:82
static const WCHAR CommonFilesDirX86W[]
Definition: shellpath.c:544
static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1545
static const WCHAR HistoryW[]
Definition: shellpath.c:563
static HANDLE
Definition: shellpath.c:88
int ret
static const WCHAR CD_BurningW[]
Definition: shellpath.c:537
static const WCHAR Start_Menu_ProgramsW[]
Definition: shellpath.c:617
static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder, LPWSTR pszPath)
Definition: shellpath.c:1829
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:2037
static const WCHAR CommonVideoW[]
Definition: shellpath.c:551
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static const WCHAR Saved_GamesW[]
Definition: shellpath.c:610
static const WCHAR Start_Menu_StartupW[]
Definition: shellpath.c:619
static const WCHAR CacheW[]
Definition: shellpath.c:536
#define IDS_COMMON_PICTURES
Definition: shresdef.h:102
static const WCHAR My_PicturesW[]
Definition: shellpath.c:584
#define IDS_PROGRAM_FILES_COMMON
Definition: shresdef.h:98
unsigned char BYTE
Definition: mem.h:68
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define GUID_NULL
Definition: ks.h:106
#define IDS_HISTORY
Definition: shresdef.h:95
static const WCHAR Local_Settings_CD_BurningW[]
Definition: shellpath.c:571
BOOL WINAPI PathFileExistsAW(LPCVOID lpszPath)
Definition: shellpath.c:226
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:862
#define PCS_REPLACEDCHAR
Definition: shlobj.h:324
static const WCHAR DownloadsW[]
Definition: shellpath.c:559
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:2046
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define CSIDL_STARTUP
Definition: shlobj.h:2010
#define CSIDL_PROGRAM_FILES_COMMON
Definition: shlobj.h:2045
#define CSIDL_COMMON_MUSIC
Definition: shlobj.h:2052
#define CSIDL_LINKS
Definition: shellpath.c:664
BOOL WINAPI PathIsRootA(LPCSTR lpszPath)
Definition: path.c:1581
#define ERR(fmt,...)
Definition: debug.h:109
static const WCHAR Local_Settings_HistoryW[]
Definition: shellpath.c:573
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:665
static const WCHAR DesktopW[]
Definition: shellpath.c:556
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1655
#define S_OK
Definition: intsafe.h:59
static const WCHAR szDefaultProfileDirW[]
Definition: shellpath.c:642
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define IDI_SHELL_MY_MUSIC
Definition: shresdef.h:603
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1435
#define IDI_SHELL_MY_DOCUMENTS
Definition: shresdef.h:601
#define lstrcpyW
Definition: compat.h:414
#define IDI_SHELL_SYSTEM_GEAR
Definition: shresdef.h:640
LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
Definition: path.c:417
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2574
BOOL WINAPI PathResolveAW(LPVOID path, LPCVOID *paths, DWORD flags)
Definition: shellpath.c:471
static BOOL PathIsExeA(LPCSTR lpszPath)
Definition: shellpath.c:178
#define CSIDL_DOWNLOADS
Definition: shellpath.c:663
BOOL WINAPI GetAllUsersProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1227
HRESULT WINAPI SHGetFolderPathA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPSTR pszPath)
Definition: shellpath.c:2329
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
LPCWSTR szPath
Definition: env.c:35
#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:1707
static const WCHAR ProfileListW[]
Definition: shellpath.c:636
#define CSIDL_PRINTHOOD
Definition: shlobj.h:2029
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
static const WCHAR LinksW[]
Definition: shellpath.c:565
INT nShell32IconIndex
Definition: shellpath.c:676
static const WCHAR AllUsersW[]
Definition: shellpath.c:647
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define IDI_SHELL_NETWORK_CONNECTIONS
Definition: shresdef.h:560
#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:2048
static HRESULT _SHGetProfilesValue(HKEY profilesKey, LPCWSTR szValueName, LPWSTR szValue, LPCWSTR szDefault)
Definition: shellpath.c:1884
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define IDI_SHELL_MY_PICTURES
Definition: shresdef.h:602
static BOOL PathResolveA(LPSTR path, LPCSTR *paths, DWORD flags)
Definition: shellpath.c:456
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define CSIDL_FLAG_CREATE
#define CSIDL_INTERNET
Definition: shlobj.h:2004
CSIDL_Type type
Definition: shellpath.c:673
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
HRESULT WINAPI SHGetFolderPathAndSubDirA(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCSTR pszSubPath, LPSTR pszPath)
Definition: shellpath.c:2100
#define MultiByteToWideChar
Definition: compat.h:100
#define IDS_MYVIDEO
Definition: shresdef.h:86
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:91
#define IDS_PROGRAM_FILES
Definition: shresdef.h:96
#define CSIDL_SAVED_GAMES
Definition: shellpath.c:666
static const WCHAR Common_DocumentsW[]
Definition: shellpath.c:541
#define CSIDL_NETHOOD
Definition: shlobj.h:2021
static const WCHAR ResourcesW[]
Definition: shellpath.c:608
static const WCHAR userName[]
Definition: wnet.c:2154
static const WCHAR AllUsersProfileValueW[]
Definition: shellpath.c:638
static const WCHAR szSHFolders[]
Definition: shellpath.c:640
#define CSIDL_PERSONAL
Definition: shlobj.h:2008
CONST void * LPCVOID
Definition: windef.h:191
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2087
#define CSIDL_STARTMENU
Definition: shlobj.h:2014
static const WCHAR Music_Sample_PlaylistsW[]
Definition: shellpath.c:581
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
LPCWSTR szValueName
Definition: shellpath.c:674
static const WCHAR Application_DataW[]
Definition: shellpath.c:534
uint32_t * LPDWORD
Definition: typedefs.h:57
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static LPSTR PathGetExtensionA(LPCSTR lpszPath)
Definition: shellpath.c:80
static const WCHAR My_VideoW[]
Definition: shellpath.c:585
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:413
static const WCHAR Pictures_Sample_PicturesW[]
Definition: shellpath.c:591
static const WCHAR NetHoodW[]
Definition: shellpath.c:586
BOOL WINAPI PathIsExeAW(LPCVOID path)
Definition: shellpath.c:216
struct _TOKEN_USER * PTOKEN_USER
SID_AND_ATTRIBUTES User
Definition: setypes.h:956
char * cleanup(char *str)
Definition: wpickclick.c:99
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2606
#define IDS_ADMINTOOLS
Definition: shresdef.h:100
static const WCHAR CookiesW[]
Definition: shellpath.c:555
#define IDS_MYMUSIC
Definition: shresdef.h:85
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1611
#define IDS_MYPICTURES
Definition: shresdef.h:97
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:320
#define IDS_NETHOOD
Definition: shresdef.h:88
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static const WCHAR Local_Settings_Temporary_Internet_FilesW[]
Definition: shellpath.c:574
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2018
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
GLfloat GLfloat p
Definition: glext.h:8902
static const WCHAR SearchesW[]
Definition: shellpath.c:611
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1605
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1617
#define CSIDL_NETWORK
Definition: shlobj.h:2020
HRESULT WINAPI SHGetFolderPathAndSubDirW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPCWSTR pszSubPath, LPWSTR pszPath)
Definition: shellpath.c:2152
static const WCHAR My_MusicW[]
Definition: shellpath.c:583
#define CSIDL_PROGRAMS
Definition: shlobj.h:2005
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:189
#define CSIDL_TEMPLATES
Definition: shlobj.h:2023
static const WCHAR Music_Sample_MusicW[]
Definition: shellpath.c:580
GLuint64EXT * result
Definition: glext.h:11304
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const WCHAR Start_Menu_Admin_ToolsW[]
Definition: shellpath.c:618
static HRESULT _SHGetUserShellFolderPath(HKEY rootKey, LPCWSTR userPrefix, LPCWSTR value, LPWSTR path)
Definition: shellpath.c:1426
static const WCHAR PersonalW[]
Definition: shellpath.c:588
#define LOWORD(l)
Definition: pedump.c:82
static BOOL PathMakeUniqueNameA(LPSTR lpszBuffer, DWORD dwBuffSize, LPCSTR lpszShortName, LPCSTR lpszLongName, LPCSTR lpszPathName)
Definition: shellpath.c:273
#define HeapFree(x, y, z)
Definition: compat.h:402
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1661
#define IDS_SENDTO
Definition: shresdef.h:83
static const WCHAR PrintHoodW[]
Definition: shellpath.c:594
static const WCHAR DefaultW[]
Definition: shellpath.c:628
#define IDS_LOCAL_APPDATA
Definition: shresdef.h:92
static const WCHAR CommonPicturesW[]
Definition: shellpath.c:546
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static const WCHAR PicturesW[]
Definition: shellpath.c:590
_CSIDL_Type
Definition: shellpath.c:649
static const WCHAR CommonMusicW[]
Definition: shellpath.c:545
VOID WINAPI PathGetShortPathAW(LPVOID pszPath)
Definition: shellpath.c:154
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:2016
HRESULT SHELL_RegisterShellFolders(void)
Definition: shellpath.c:2546
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22