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