4 * Copyright 1998, 1999, 2000 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Many of these functions are in SHLWAPI.DLL also
27 #include "wine/port.h"
31 #include "wine/debug.h"
37 #include "shell32_main.h"
38 #include "undocshell.h"
39 #include "wine/unicode.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
45 ########## Combining and Constructing paths ##########
48 /*************************************************************************
49 * PathAppend [SHELL32.36]
51 BOOL WINAPI
PathAppendAW(
55 if (SHELL_OsIsUnicode())
56 return PathAppendW(lpszPath1
, lpszPath2
);
57 return PathAppendA(lpszPath1
, lpszPath2
);
60 /*************************************************************************
61 * PathCombine [SHELL32.37]
63 LPVOID WINAPI
PathCombineAW(
68 if (SHELL_OsIsUnicode())
69 return PathCombineW( szDest
, lpszDir
, lpszFile
);
70 return PathCombineA( szDest
, lpszDir
, lpszFile
);
73 /*************************************************************************
74 * PathAddBackslash [SHELL32.32]
76 LPVOID WINAPI
PathAddBackslashAW(LPVOID lpszPath
)
78 if(SHELL_OsIsUnicode())
79 return PathAddBackslashW(lpszPath
);
80 return PathAddBackslashA(lpszPath
);
83 /*************************************************************************
84 * PathBuildRoot [SHELL32.30]
86 LPVOID WINAPI
PathBuildRootAW(LPVOID lpszPath
, int drive
)
88 if(SHELL_OsIsUnicode())
89 return PathBuildRootW(lpszPath
, drive
);
90 return PathBuildRootA(lpszPath
, drive
);
94 Extracting Component Parts
97 /*************************************************************************
98 * PathFindFileName [SHELL32.34]
100 LPVOID WINAPI
PathFindFileNameAW(LPCVOID lpszPath
)
102 if(SHELL_OsIsUnicode())
103 return PathFindFileNameW(lpszPath
);
104 return PathFindFileNameA(lpszPath
);
107 /*************************************************************************
108 * PathFindExtension [SHELL32.31]
110 LPVOID WINAPI
PathFindExtensionAW(LPCVOID lpszPath
)
112 if (SHELL_OsIsUnicode())
113 return PathFindExtensionW(lpszPath
);
114 return PathFindExtensionA(lpszPath
);
118 /*************************************************************************
119 * PathGetExtensionA [internal]
122 * exported by ordinal
123 * return value points to the first char after the dot
125 static LPSTR
PathGetExtensionA(LPCSTR lpszPath
)
127 TRACE("(%s)\n",lpszPath
);
129 lpszPath
= PathFindExtensionA(lpszPath
);
130 return (LPSTR
)(*lpszPath
?(lpszPath
+1):lpszPath
);
133 /*************************************************************************
134 * PathGetExtensionW [internal]
136 static LPWSTR
PathGetExtensionW(LPCWSTR lpszPath
)
138 TRACE("(%s)\n",debugstr_w(lpszPath
));
140 lpszPath
= PathFindExtensionW(lpszPath
);
141 return (LPWSTR
)(*lpszPath
?(lpszPath
+1):lpszPath
);
144 /*************************************************************************
145 * PathGetExtension [SHELL32.158]
147 LPVOID WINAPI
PathGetExtensionAW(LPCVOID lpszPath
,DWORD void1
, DWORD void2
)
149 if (SHELL_OsIsUnicode())
150 return PathGetExtensionW(lpszPath
);
151 return PathGetExtensionA(lpszPath
);
154 /*************************************************************************
155 * PathGetArgs [SHELL32.52]
157 LPVOID WINAPI
PathGetArgsAW(LPVOID lpszPath
)
159 if (SHELL_OsIsUnicode())
160 return PathGetArgsW(lpszPath
);
161 return PathGetArgsA(lpszPath
);
164 /*************************************************************************
165 * PathGetDriveNumber [SHELL32.57]
167 int WINAPI
PathGetDriveNumberAW(LPVOID lpszPath
)
169 if (SHELL_OsIsUnicode())
170 return PathGetDriveNumberW(lpszPath
);
171 return PathGetDriveNumberA(lpszPath
);
174 /*************************************************************************
175 * PathRemoveFileSpec [SHELL32.35]
177 BOOL WINAPI
PathRemoveFileSpecAW(LPVOID lpszPath
)
179 if (SHELL_OsIsUnicode())
180 return PathRemoveFileSpecW(lpszPath
);
181 return PathRemoveFileSpecA(lpszPath
);
184 /*************************************************************************
185 * PathStripPath [SHELL32.38]
187 void WINAPI
PathStripPathAW(LPVOID lpszPath
)
189 if (SHELL_OsIsUnicode())
190 PathStripPathW(lpszPath
);
192 PathStripPathA(lpszPath
);
195 /*************************************************************************
196 * PathStripToRoot [SHELL32.50]
198 BOOL WINAPI
PathStripToRootAW(LPVOID lpszPath
)
200 if (SHELL_OsIsUnicode())
201 return PathStripToRootW(lpszPath
);
202 return PathStripToRootA(lpszPath
);
205 /*************************************************************************
206 * PathRemoveArgs [SHELL32.251]
208 void WINAPI
PathRemoveArgsAW(LPVOID lpszPath
)
210 if (SHELL_OsIsUnicode())
211 PathRemoveArgsW(lpszPath
);
213 PathRemoveArgsA(lpszPath
);
216 /*************************************************************************
217 * PathRemoveExtension [SHELL32.250]
219 void WINAPI
PathRemoveExtensionAW(LPVOID lpszPath
)
221 if (SHELL_OsIsUnicode())
222 PathRemoveExtensionW(lpszPath
);
224 PathRemoveExtensionA(lpszPath
);
232 /*************************************************************************
233 * PathGetShortPathA [internal]
235 LPSTR WINAPI
PathGetShortPathA(LPSTR lpszPath
)
237 FIXME("%s stub\n", lpszPath
);
241 /*************************************************************************
242 * PathGetShortPathW [internal]
244 LPWSTR WINAPI
PathGetShortPathW(LPWSTR lpszPath
)
246 FIXME("%s stub\n", debugstr_w(lpszPath
));
250 /*************************************************************************
251 * PathGetShortPath [SHELL32.92]
253 LPVOID WINAPI
PathGetShortPathAW(LPVOID lpszPath
)
255 if(SHELL_OsIsUnicode())
256 return PathGetShortPathW(lpszPath
);
257 return PathGetShortPathA(lpszPath
);
260 /*************************************************************************
261 * PathRemoveBlanks [SHELL32.33]
263 void WINAPI
PathRemoveBlanksAW(LPVOID str
)
265 if(SHELL_OsIsUnicode())
266 PathRemoveBlanksW(str
);
268 PathRemoveBlanksA(str
);
271 /*************************************************************************
272 * PathQuoteSpaces [SHELL32.55]
274 VOID WINAPI
PathQuoteSpacesAW (LPVOID lpszPath
)
276 if(SHELL_OsIsUnicode())
277 PathQuoteSpacesW(lpszPath
);
279 PathQuoteSpacesA(lpszPath
);
282 /*************************************************************************
283 * PathUnquoteSpaces [SHELL32.56]
285 VOID WINAPI
PathUnquoteSpacesAW(LPVOID str
)
287 if(SHELL_OsIsUnicode())
288 PathUnquoteSpacesW(str
);
290 PathUnquoteSpacesA(str
);
293 /*************************************************************************
294 * PathParseIconLocation [SHELL32.249]
296 int WINAPI
PathParseIconLocationAW (LPVOID lpszPath
)
298 if(SHELL_OsIsUnicode())
299 return PathParseIconLocationW(lpszPath
);
300 return PathParseIconLocationA(lpszPath
);
304 ########## Path Testing ##########
306 /*************************************************************************
307 * PathIsUNC [SHELL32.39]
309 BOOL WINAPI
PathIsUNCAW (LPCVOID lpszPath
)
311 if (SHELL_OsIsUnicode())
312 return PathIsUNCW( lpszPath
);
313 return PathIsUNCA( lpszPath
);
316 /*************************************************************************
317 * PathIsRelative [SHELL32.40]
319 BOOL WINAPI
PathIsRelativeAW (LPCVOID lpszPath
)
321 if (SHELL_OsIsUnicode())
322 return PathIsRelativeW( lpszPath
);
323 return PathIsRelativeA( lpszPath
);
326 /*************************************************************************
327 * PathIsRoot [SHELL32.29]
329 BOOL WINAPI
PathIsRootAW(LPCVOID lpszPath
)
331 if (SHELL_OsIsUnicode())
332 return PathIsRootW(lpszPath
);
333 return PathIsRootA(lpszPath
);
336 /*************************************************************************
337 * PathIsExeA [internal]
339 static BOOL
PathIsExeA (LPCSTR lpszPath
)
341 LPCSTR lpszExtension
= PathGetExtensionA(lpszPath
);
343 static char * lpszExtensions
[6] = {"exe", "com", "pid", "cmd", "bat", NULL
};
345 TRACE("path=%s\n",lpszPath
);
347 for(i
=0; lpszExtensions
[i
]; i
++)
348 if (!strcasecmp(lpszExtension
,lpszExtensions
[i
])) return TRUE
;
353 /*************************************************************************
354 * PathIsExeW [internal]
356 static BOOL
PathIsExeW (LPCWSTR lpszPath
)
358 LPCWSTR lpszExtension
= PathGetExtensionW(lpszPath
);
360 static WCHAR lpszExtensions
[6][4] =
361 {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','d','\0'},
362 {'c','m','d','\0'}, {'b','a','t','\0'}, {'\0'} };
364 TRACE("path=%s\n",debugstr_w(lpszPath
));
366 for(i
=0; lpszExtensions
[i
][0]; i
++)
367 if (!strcmpiW(lpszExtension
,lpszExtensions
[i
])) return TRUE
;
372 /*************************************************************************
373 * PathIsExe [SHELL32.43]
375 BOOL WINAPI
PathIsExeAW (LPCVOID path
)
377 if (SHELL_OsIsUnicode())
378 return PathIsExeW (path
);
379 return PathIsExeA(path
);
382 /*************************************************************************
383 * PathIsDirectory [SHELL32.159]
385 BOOL WINAPI
PathIsDirectoryAW (LPCVOID lpszPath
)
387 if (SHELL_OsIsUnicode())
388 return PathIsDirectoryW (lpszPath
);
389 return PathIsDirectoryA (lpszPath
);
392 /*************************************************************************
393 * PathFileExists [SHELL32.45]
395 BOOL WINAPI
PathFileExistsAW (LPCVOID lpszPath
)
397 if (SHELL_OsIsUnicode())
398 return PathFileExistsW (lpszPath
);
399 return PathFileExistsA (lpszPath
);
402 /*************************************************************************
403 * PathMatchSpec [SHELL32.46]
405 BOOL WINAPI
PathMatchSpecAW(LPVOID name
, LPVOID mask
)
407 if (SHELL_OsIsUnicode())
408 return PathMatchSpecW( name
, mask
);
409 return PathMatchSpecA( name
, mask
);
412 /*************************************************************************
413 * PathIsSameRoot [SHELL32.650]
415 BOOL WINAPI
PathIsSameRootAW(LPCVOID lpszPath1
, LPCVOID lpszPath2
)
417 if (SHELL_OsIsUnicode())
418 return PathIsSameRootW(lpszPath1
, lpszPath2
);
419 return PathIsSameRootA(lpszPath1
, lpszPath2
);
422 /*************************************************************************
423 * IsLFNDrive [SHELL32.119]
426 * exported by ordinal Name
428 BOOL WINAPI
IsLFNDriveA(LPCSTR lpszPath
)
432 if (!GetVolumeInformationA(lpszPath
,NULL
,0,NULL
,&fnlen
,NULL
,NULL
,0))
438 ########## Creating Something Unique ##########
440 /*************************************************************************
441 * PathMakeUniqueNameA [internal]
443 BOOL WINAPI
PathMakeUniqueNameA(
446 LPCSTR lpszShortName
,
450 FIXME("%p %lu %s %s %s stub\n",
451 lpszBuffer
, dwBuffSize
, debugstr_a(lpszShortName
),
452 debugstr_a(lpszLongName
), debugstr_a(lpszPathName
));
456 /*************************************************************************
457 * PathMakeUniqueNameW [internal]
459 BOOL WINAPI
PathMakeUniqueNameW(
462 LPCWSTR lpszShortName
,
463 LPCWSTR lpszLongName
,
464 LPCWSTR lpszPathName
)
466 FIXME("%p %lu %s %s %s stub\n",
467 lpszBuffer
, dwBuffSize
, debugstr_w(lpszShortName
),
468 debugstr_w(lpszLongName
), debugstr_w(lpszPathName
));
472 /*************************************************************************
473 * PathMakeUniqueName [SHELL32.47]
475 BOOL WINAPI
PathMakeUniqueNameAW(
478 LPCVOID lpszShortName
,
479 LPCVOID lpszLongName
,
480 LPCVOID lpszPathName
)
482 if (SHELL_OsIsUnicode())
483 return PathMakeUniqueNameW(lpszBuffer
,dwBuffSize
, lpszShortName
,lpszLongName
,lpszPathName
);
484 return PathMakeUniqueNameA(lpszBuffer
,dwBuffSize
, lpszShortName
,lpszLongName
,lpszPathName
);
487 /*************************************************************************
488 * PathYetAnotherMakeUniqueName [SHELL32.75]
491 * exported by ordinal
493 BOOL WINAPI
PathYetAnotherMakeUniqueNameA(
496 LPCSTR lpszShortName
,
499 FIXME("(%p,%p, %p ,%p):stub.\n",
500 lpszBuffer
, lpszPathName
, lpszShortName
, lpszLongName
);
506 ########## cleaning and resolving paths ##########
509 /*************************************************************************
510 * PathFindOnPath [SHELL32.145]
512 BOOL WINAPI
PathFindOnPathAW(LPVOID sFile
, LPCVOID sOtherDirs
)
514 if (SHELL_OsIsUnicode())
515 return PathFindOnPathW(sFile
, (LPCWSTR
*)sOtherDirs
);
516 return PathFindOnPathA(sFile
, (LPCSTR
*)sOtherDirs
);
519 /*************************************************************************
520 * PathCleanupSpec [SHELL32.171]
522 DWORD WINAPI
PathCleanupSpecAW (LPCVOID x
, LPVOID y
)
524 FIXME("(%p, %p) stub\n",x
,y
);
528 /*************************************************************************
529 * PathQualifyA [SHELL32]
531 BOOL WINAPI
PathQualifyA(LPCSTR pszPath
)
533 FIXME("%s\n",pszPath
);
537 /*************************************************************************
538 * PathQualifyW [SHELL32]
540 BOOL WINAPI
PathQualifyW(LPCWSTR pszPath
)
542 FIXME("%s\n",debugstr_w(pszPath
));
546 /*************************************************************************
547 * PathQualify [SHELL32.49]
549 BOOL WINAPI
PathQualifyAW(LPCVOID pszPath
)
551 if (SHELL_OsIsUnicode())
552 return PathQualifyW(pszPath
);
553 return PathQualifyA(pszPath
);
556 /*************************************************************************
557 * PathResolveA [SHELL32.51]
559 BOOL WINAPI
PathResolveA(
564 FIXME("(%s,%p,0x%08lx),stub!\n",
565 lpszPath
, *alpszPaths
, dwFlags
);
569 /*************************************************************************
570 * PathResolveW [SHELL32]
572 BOOL WINAPI
PathResolveW(
577 FIXME("(%s,%p,0x%08lx),stub!\n",
578 debugstr_w(lpszPath
), debugstr_w(*alpszPaths
), dwFlags
);
582 /*************************************************************************
583 * PathResolve [SHELL32.51]
585 BOOL WINAPI
PathResolveAW(
590 if (SHELL_OsIsUnicode())
591 return PathResolveW(lpszPath
, (LPCWSTR
*)alpszPaths
, dwFlags
);
592 return PathResolveA(lpszPath
, (LPCSTR
*)alpszPaths
, dwFlags
);
595 /*************************************************************************
596 * PathProcessCommandA [SHELL32.653]
598 HRESULT WINAPI
PathProcessCommandA (
604 FIXME("%s %p 0x%04lx 0x%04lx stub\n",
605 lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
606 strcpy(lpszBuff
, lpszPath
);
610 /*************************************************************************
611 * PathProcessCommandW
613 HRESULT WINAPI
PathProcessCommandW (
619 FIXME("(%s, %p, 0x%04lx, 0x%04lx) stub\n",
620 debugstr_w(lpszPath
), lpszBuff
, dwBuffSize
, dwFlags
);
621 strcpyW(lpszBuff
, lpszPath
);
625 /*************************************************************************
626 * PathProcessCommand (SHELL32.653)
628 HRESULT WINAPI
PathProcessCommandAW (
634 if (SHELL_OsIsUnicode())
635 return PathProcessCommandW(lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
636 return PathProcessCommandA(lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
640 ########## special ##########
643 /*************************************************************************
644 * PathSetDlgItemPath (SHELL32.48)
646 VOID WINAPI
PathSetDlgItemPathAW(HWND hDlg
, int id
, LPCVOID pszPath
)
648 if (SHELL_OsIsUnicode())
649 PathSetDlgItemPathW(hDlg
, id
, pszPath
);
651 PathSetDlgItemPathA(hDlg
, id
, pszPath
);
655 /*************************************************************************
656 * SHGetSpecialFolderPathA [SHELL32.@]
658 * converts csidl to path
661 static const char * const szSHFolders
= "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
662 static const char * const szSHUserFolders
= "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
663 static const char * const szSetup
= "Software\\Microsoft\\Windows\\CurrentVersion\\Setup";
664 static const char * const szCurrentVersion
= "Software\\Microsoft\\Windows\\CurrentVersion";
666 static const char * const szEnvUserProfile
= "%USERPROFILE%";
667 static const char * const szEnvSystemRoot
= "%SYSTEMROOT%";
675 LPCSTR szDefaultPath
; /* fallback string; sub dir of windows directory */
678 #define CSIDL_MYFLAG_SHFOLDER 1
679 #define CSIDL_MYFLAG_SETUP 2
680 #define CSIDL_MYFLAG_CURRVER 4
681 #define CSIDL_MYFLAG_RELATIVE 8
683 #define HKLM HKEY_LOCAL_MACHINE
684 #define HKCU HKEY_CURRENT_USER
685 static const CSIDL_DATA CSIDL_Data
[] =
687 { /* CSIDL_DESKTOP */
692 { /* CSIDL_INTERNET */
697 { /* CSIDL_PROGRAMS */
700 "Start Menu\\Programs"
702 { /* CSIDL_CONTROLS (.CPL files) */
707 { /* CSIDL_PRINTERS */
712 { /* CSIDL_PERSONAL */
717 { /* CSIDL_FAVORITES */
722 { /* CSIDL_STARTUP */
725 "Start Menu\\Programs\\StartUp"
737 { /* CSIDL_BITBUCKET (is this c:\recycled ?) */
742 { /* CSIDL_STARTMENU */
747 { /* CSIDL_MYDOCUMENTS */
752 { /* CSIDL_MYMUSIC */
757 { /* CSIDL_MYVIDEO */
767 { /* CSIDL_DESKTOPDIRECTORY */
777 { /* CSIDL_NETWORK */
780 "Network Neighborhood"
782 { /* CSIDL_NETHOOD */
792 { /* CSIDL_TEMPLATES */
797 { /* CSIDL_COMMON_STARTMENU */
802 { /* CSIDL_COMMON_PROGRAMS */
807 { /* CSIDL_COMMON_STARTUP */
810 "All Users\\Start Menu\\Programs\\StartUp"
812 { /* CSIDL_COMMON_DESKTOPDIRECTORY */
817 { /* CSIDL_APPDATA */
822 { /* CSIDL_PRINTHOOD */
827 { /* CSIDL_LOCAL_APPDATA (win2k only/undocumented) */
830 "Local Settings\\Application Data",
832 { /* CSIDL_ALTSTARTUP */
837 { /* CSIDL_COMMON_ALTSTARTUP */
842 { /* CSIDL_COMMON_FAVORITES */
847 { /* CSIDL_INTERNET_CACHE */
850 "Temporary Internet Files"
852 { /* CSIDL_COOKIES */
857 { /* CSIDL_HISTORY */
862 { /* CSIDL_COMMON_APPDATA */
865 "All Users\\Application Data"
867 { /* CSIDL_WINDOWS */
877 { /* CSIDL_PROGRAM_FILES */
882 { /* CSIDL_MYPICTURES */
885 "My Documents\\My Pictures"
887 { /* CSIDL_PROFILE */
889 "WinDir", /* correct ? */
892 { /* CSIDL_SYSTEMX86 */
897 { /* CSIDL_PROGRAM_FILESX86 */
902 { /* CSIDL_PROGRAM_FILES_COMMON */
905 "Program Files\\Common Files" /* ? */
907 { /* CSIDL_PROGRAM_FILES_COMMONX86 */
910 "Program Files\\Common Files" /* ? */
912 { /* CSIDL_COMMON_TEMPLATES */
917 { /* CSIDL_COMMON_DOCUMENTS */
922 { /* CSIDL_COMMON_ADMINTOOLS */
927 { /* CSIDL_ADMINTOOLS */
929 "Administrative Tools",
930 "Start Menu\\Programs\\Administrative Tools"
932 { /* CSIDL_CONNECTIONS */
952 { /* CSIDL_COMMON_MUSIC */
957 { /* CSIDL_COMMON_PICTURES */
962 { /* CSIDL_COMMON_VIDEO */
967 { /* CSIDL_RESOURCES */
972 { /* CSIDL_RESOURCES_LOCALIZED */
977 { /* CSIDL_COMMON_OEM_LINKS */
982 { /* CSIDL_CDBURN_AREA */
987 { /* unassigned 3C */
992 { /* CSIDL_COMPUTERSNEARME */
1001 /**********************************************************************/
1003 BOOL WINAPI
SHGetSpecialFolderPathA (
1009 CHAR szValueName
[MAX_PATH
], szDefaultPath
[MAX_PATH
], szBuildPath
[MAX_PATH
];
1010 HKEY hRootKey
, hKey
;
1012 DWORD dwType
, dwDisp
, dwPathLen
= MAX_PATH
;
1013 DWORD folder
= csidl
& CSIDL_FOLDER_MASK
;
1016 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner
,szPath
,csidl
,bCreate
);
1018 if ((folder
> CSIDL_COMPUTERSNEARME
) || (CSIDL_Data
[folder
].hRootKey
== 0))
1020 ERR("folder unknown or not allowed\n");
1023 if (CSIDL_Data
[folder
].hRootKey
== 1)
1025 FIXME("folder unknown, please add.\n");
1029 dwFlags
= CSIDL_Data
[folder
].dwFlags
;
1030 hRootKey
= CSIDL_Data
[folder
].hRootKey
;
1031 strcpy(szValueName
, CSIDL_Data
[folder
].szValueName
);
1032 strcpy(szDefaultPath
, CSIDL_Data
[folder
].szDefaultPath
);
1034 if (dwFlags
& CSIDL_MYFLAG_SHFOLDER
)
1036 /* user shell folders */
1037 if (RegCreateKeyExA(hRootKey
,szSHUserFolders
,0,NULL
,0,KEY_ALL_ACCESS
,NULL
,&hKey
,&dwDisp
)) return FALSE
;
1039 if (RegQueryValueExA(hKey
,szValueName
,NULL
,&dwType
,(LPBYTE
)szPath
,&dwPathLen
))
1044 if (RegCreateKeyExA(hRootKey
,szSHFolders
,0,NULL
,0,KEY_ALL_ACCESS
,NULL
,&hKey
,&dwDisp
)) return FALSE
;
1046 if (RegQueryValueExA(hKey
,szValueName
,NULL
,&dwType
,(LPBYTE
)szPath
,&dwPathLen
))
1049 /* value not existing */
1050 if (dwFlags
& CSIDL_MYFLAG_RELATIVE
)
1052 GetWindowsDirectoryA(szPath
, MAX_PATH
);
1053 PathAddBackslashA(szPath
);
1054 strcat(szPath
, szDefaultPath
);
1058 strcpy(szPath
, "C:\\"); /* FIXME ??? */
1059 strcat(szPath
, szDefaultPath
);
1061 RegSetValueExA(hKey
,szValueName
,0,REG_SZ
,(LPBYTE
)szPath
,strlen(szPath
)+1);
1070 if (dwFlags
& CSIDL_MYFLAG_SETUP
)
1073 if (dwFlags
& CSIDL_MYFLAG_CURRVER
)
1074 pRegPath
= szCurrentVersion
;
1077 ERR("folder settings broken, please correct !\n");
1081 if (RegCreateKeyExA(hRootKey
,pRegPath
,0,NULL
,0,KEY_ALL_ACCESS
,NULL
,&hKey
,&dwDisp
)) return FALSE
;
1083 if (RegQueryValueExA(hKey
,szValueName
,NULL
,&dwType
,(LPBYTE
)szPath
,&dwPathLen
))
1085 /* value not existing */
1086 if (dwFlags
& CSIDL_MYFLAG_RELATIVE
)
1088 GetWindowsDirectoryA(szPath
, MAX_PATH
);
1089 PathAddBackslashA(szPath
);
1090 strcat(szPath
, szDefaultPath
);
1094 strcpy(szPath
, "C:\\"); /* FIXME ??? */
1095 strcat(szPath
, szDefaultPath
);
1097 RegSetValueExA(hKey
,szValueName
,0,REG_SZ
,(LPBYTE
)szPath
,strlen(szPath
)+1);
1102 /* expand paths like %USERPROFILE% */
1103 if (dwType
== REG_EXPAND_SZ
)
1105 ExpandEnvironmentStringsA(szPath
, szDefaultPath
, MAX_PATH
);
1106 strcpy(szPath
, szDefaultPath
);
1109 /* if we don't care about existing directories we are ready */
1110 if(csidl
& CSIDL_FLAG_DONT_VERIFY
) return TRUE
;
1112 if (PathFileExistsA(szPath
)) return TRUE
;
1114 /* not existing but we are not allowed to create it */
1115 if (!bCreate
) return FALSE
;
1117 /* create directory/directories */
1118 strcpy(szBuildPath
, szPath
);
1119 p
= strchr(szBuildPath
, '\\');
1123 if (!PathFileExistsA(szBuildPath
))
1125 if (!CreateDirectoryA(szBuildPath
,NULL
))
1127 ERR("Failed to create directory '%s'.\n", szPath
);
1132 p
= strchr(p
+1, '\\');
1134 /* last component must be created too. */
1135 if (!PathFileExistsA(szBuildPath
))
1137 if (!CreateDirectoryA(szBuildPath
,NULL
))
1139 ERR("Failed to create directory '%s'.\n", szPath
);
1144 MESSAGE("Created not existing system directory '%s'\n", szPath
);
1148 /*************************************************************************
1149 * SHGetSpecialFolderPathW
1151 BOOL WINAPI
SHGetSpecialFolderPathW (
1157 char szTemp
[MAX_PATH
];
1159 if (SHGetSpecialFolderPathA(hwndOwner
, szTemp
, csidl
, bCreate
))
1161 if (!MultiByteToWideChar( CP_ACP
, 0, szTemp
, -1, szPath
, MAX_PATH
))
1162 szPath
[MAX_PATH
-1] = 0;
1165 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner
,szPath
,csidl
,bCreate
);
1170 /*************************************************************************
1171 * SHGetSpecialFolderPath (SHELL32.175)
1173 BOOL WINAPI
SHGetSpecialFolderPathAW (
1180 if (SHELL_OsIsUnicode())
1181 return SHGetSpecialFolderPathW (hwndOwner
, szPath
, csidl
, bCreate
);
1182 return SHGetSpecialFolderPathA (hwndOwner
, szPath
, csidl
, bCreate
);
1185 /*************************************************************************
1186 * SHGetFolderPathA [SHELL32.@]
1188 HRESULT WINAPI
SHGetFolderPathA(
1191 HANDLE hToken
, /* [in] FIXME: get paths for specific user */
1192 DWORD dwFlags
, /* [in] FIXME: SHGFP_TYPE_CURRENT|SHGFP_TYPE_DEFAULT */
1195 return (SHGetSpecialFolderPathA(
1198 CSIDL_FOLDER_MASK
& nFolder
,
1199 CSIDL_FLAG_CREATE
& nFolder
)) ? S_OK
: E_FAIL
;
1202 /*************************************************************************
1203 * SHGetFolderPathW [SHELL32.@]
1205 HRESULT WINAPI
SHGetFolderPathW(
1212 return (SHGetSpecialFolderPathW(
1215 CSIDL_FOLDER_MASK
& nFolder
,
1216 CSIDL_FLAG_CREATE
& nFolder
)) ? S_OK
: E_FAIL
;