4 * Many of this functions are in SHLWAPI.DLL also
9 #include "debugtools.h"
15 #include "shell32_main.h"
16 #include "undocshell.h"
17 #include "wine/unicode.h"
20 DEFAULT_DEBUG_CHANNEL(shell
);
23 ########## Combining and Constructing paths ##########
26 /*************************************************************************
27 * PathAppend [SHELL32.36]
29 BOOL WINAPI
PathAppendAW(
33 if (SHELL_OsIsUnicode())
34 return PathAppendW(lpszPath1
, lpszPath2
);
35 return PathAppendA(lpszPath1
, lpszPath2
);
38 /*************************************************************************
39 * PathCombine [SHELL32.37]
41 LPVOID WINAPI
PathCombineAW(
46 if (SHELL_OsIsUnicode())
47 return PathCombineW( szDest
, lpszDir
, lpszFile
);
48 return PathCombineA( szDest
, lpszDir
, lpszFile
);
51 /*************************************************************************
52 * PathAddBackslash [SHELL32.32]
54 LPVOID WINAPI
PathAddBackslashAW(LPVOID lpszPath
)
56 if(SHELL_OsIsUnicode())
57 return PathAddBackslashW(lpszPath
);
58 return PathAddBackslashA(lpszPath
);
61 /*************************************************************************
62 * PathBuildRoot [SHELL32.30]
64 LPVOID WINAPI
PathBuildRootAW(LPVOID lpszPath
, int drive
)
66 if(SHELL_OsIsUnicode())
67 return PathBuildRootW(lpszPath
, drive
);
68 return PathBuildRootA(lpszPath
, drive
);
72 Extracting Component Parts
75 /*************************************************************************
76 * PathFindFileName [SHELL32.34]
78 LPVOID WINAPI
PathFindFileNameAW(LPCVOID lpszPath
)
80 if(SHELL_OsIsUnicode())
81 return PathFindFileNameW(lpszPath
);
82 return PathFindFileNameA(lpszPath
);
85 /*************************************************************************
86 * PathFindExtension [SHELL32.31]
88 LPVOID WINAPI
PathFindExtensionAW(LPCVOID lpszPath
)
90 if (SHELL_OsIsUnicode())
91 return PathFindExtensionW(lpszPath
);
92 return PathFindExtensionA(lpszPath
);
96 /*************************************************************************
97 * PathGetExtensionA [internal]
100 * exported by ordinal
101 * return value points to the first char after the dot
103 static LPSTR
PathGetExtensionA(LPCSTR lpszPath
)
105 TRACE("(%s)\n",lpszPath
);
107 lpszPath
= PathFindExtensionA(lpszPath
);
108 return (LPSTR
)(*lpszPath
?(lpszPath
+1):lpszPath
);
111 /*************************************************************************
112 * PathGetExtensionW [internal]
114 static LPWSTR
PathGetExtensionW(LPCWSTR lpszPath
)
116 TRACE("(%s)\n",debugstr_w(lpszPath
));
118 lpszPath
= PathFindExtensionW(lpszPath
);
119 return (LPWSTR
)(*lpszPath
?(lpszPath
+1):lpszPath
);
122 /*************************************************************************
123 * PathGetExtension [SHELL32.158]
125 LPVOID WINAPI
PathGetExtensionAW(LPCVOID lpszPath
,DWORD void1
, DWORD void2
)
127 if (SHELL_OsIsUnicode())
128 return PathGetExtensionW(lpszPath
);
129 return PathGetExtensionA(lpszPath
);
132 /*************************************************************************
133 * PathGetArgs [SHELL32.52]
135 LPVOID WINAPI
PathGetArgsAW(LPVOID lpszPath
)
137 if (SHELL_OsIsUnicode())
138 return PathGetArgsW(lpszPath
);
139 return PathGetArgsA(lpszPath
);
142 /*************************************************************************
143 * PathGetDriveNumber [SHELL32.57]
145 int WINAPI
PathGetDriveNumberAW(LPVOID lpszPath
)
147 if (SHELL_OsIsUnicode())
148 return PathGetDriveNumberW(lpszPath
);
149 return PathGetDriveNumberA(lpszPath
);
152 /*************************************************************************
153 * PathRemoveFileSpec [SHELL32.35]
155 BOOL WINAPI
PathRemoveFileSpecAW(LPVOID lpszPath
)
157 if (SHELL_OsIsUnicode())
158 return PathRemoveFileSpecW(lpszPath
);
159 return PathRemoveFileSpecA(lpszPath
);
162 /*************************************************************************
163 * PathStripPath [SHELL32.38]
165 void WINAPI
PathStripPathAW(LPVOID lpszPath
)
167 if (SHELL_OsIsUnicode())
168 return PathStripPathW(lpszPath
);
169 return PathStripPathA(lpszPath
);
172 /*************************************************************************
173 * PathStripToRoot [SHELL32.50]
175 BOOL WINAPI
PathStripToRootAW(LPVOID lpszPath
)
177 if (SHELL_OsIsUnicode())
178 return PathStripToRootW(lpszPath
);
179 return PathStripToRootA(lpszPath
);
182 /*************************************************************************
183 * PathRemoveArgs [SHELL32.251]
185 void WINAPI
PathRemoveArgsAW(LPVOID lpszPath
)
187 if (SHELL_OsIsUnicode())
188 PathRemoveArgsW(lpszPath
);
189 PathRemoveArgsA(lpszPath
);
192 /*************************************************************************
193 * PathRemoveExtension [SHELL32.250]
195 void WINAPI
PathRemoveExtensionAW(LPVOID lpszPath
)
197 if (SHELL_OsIsUnicode())
198 return PathRemoveExtensionW(lpszPath
);
199 return PathRemoveExtensionA(lpszPath
);
207 /*************************************************************************
208 * PathGetShortPathA [internal]
210 LPSTR WINAPI
PathGetShortPathA(LPSTR lpszPath
)
212 FIXME("%s stub\n", lpszPath
);
216 /*************************************************************************
217 * PathGetShortPathW [internal]
219 LPWSTR WINAPI
PathGetShortPathW(LPWSTR lpszPath
)
221 FIXME("%s stub\n", debugstr_w(lpszPath
));
225 /*************************************************************************
226 * PathGetShortPath [SHELL32.92]
228 LPVOID WINAPI
PathGetShortPathAW(LPVOID lpszPath
)
230 if(SHELL_OsIsUnicode())
231 return PathGetShortPathW(lpszPath
);
232 return PathGetShortPathA(lpszPath
);
235 /*************************************************************************
236 * PathRemoveBlanks [SHELL32.33]
238 void WINAPI
PathRemoveBlanksAW(LPVOID str
)
240 if(SHELL_OsIsUnicode())
241 PathRemoveBlanksW(str
);
242 PathRemoveBlanksA(str
);
245 /*************************************************************************
246 * PathQuoteSpaces [SHELL32.55]
248 LPVOID WINAPI
PathQuoteSpacesAW (LPVOID lpszPath
)
250 if(SHELL_OsIsUnicode())
251 return PathQuoteSpacesW(lpszPath
);
252 return PathQuoteSpacesA(lpszPath
);
255 /*************************************************************************
256 * PathUnquoteSpaces [SHELL32.56]
258 VOID WINAPI
PathUnquoteSpacesAW(LPVOID str
)
260 if(SHELL_OsIsUnicode())
261 PathUnquoteSpacesW(str
);
263 PathUnquoteSpacesA(str
);
266 /*************************************************************************
267 * PathParseIconLocation [SHELL32.249]
269 int WINAPI
PathParseIconLocationAW (LPVOID lpszPath
)
271 if(SHELL_OsIsUnicode())
272 return PathParseIconLocationW(lpszPath
);
273 return PathParseIconLocationA(lpszPath
);
277 ########## Path Testing ##########
279 /*************************************************************************
280 * PathIsUNC [SHELL32.39]
282 BOOL WINAPI
PathIsUNCAW (LPCVOID lpszPath
)
284 if (SHELL_OsIsUnicode())
285 return PathIsUNCW( lpszPath
);
286 return PathIsUNCA( lpszPath
);
289 /*************************************************************************
290 * PathIsRelative [SHELL32.40]
292 BOOL WINAPI
PathIsRelativeAW (LPCVOID lpszPath
)
294 if (SHELL_OsIsUnicode())
295 return PathIsRelativeW( lpszPath
);
296 return PathIsRelativeA( lpszPath
);
299 /*************************************************************************
300 * PathIsRoot [SHELL32.29]
302 BOOL WINAPI
PathIsRootAW(LPCVOID lpszPath
)
304 if (SHELL_OsIsUnicode())
305 return PathIsRootW(lpszPath
);
306 return PathIsRootA(lpszPath
);
309 /*************************************************************************
310 * PathIsExeA [internal]
312 static BOOL
PathIsExeA (LPCSTR lpszPath
)
314 LPCSTR lpszExtension
= PathGetExtensionA(lpszPath
);
316 static char * lpszExtensions
[6] = {"exe", "com", "pid", "cmd", "bat", NULL
};
318 TRACE("path=%s\n",lpszPath
);
320 for(i
=0; lpszExtensions
[i
]; i
++)
321 if (!strcasecmp(lpszExtension
,lpszExtensions
[i
])) return TRUE
;
326 /*************************************************************************
327 * PathIsExeW [internal]
329 static BOOL
PathIsExeW (LPCWSTR lpszPath
)
331 LPCWSTR lpszExtension
= PathGetExtensionW(lpszPath
);
333 static WCHAR lpszExtensions
[6][4] =
334 {{'e','x','e','\0'}, {'c','o','m','\0'}, {'p','i','d','\0'},
335 {'c','m','d','\0'}, {'b','a','t','\0'}, {'\0'} };
337 TRACE("path=%s\n",debugstr_w(lpszPath
));
339 for(i
=0; lpszExtensions
[i
][0]; i
++)
340 if (!strcmpiW(lpszExtension
,lpszExtensions
[i
])) return TRUE
;
345 /*************************************************************************
346 * PathIsExe [SHELL32.43]
348 BOOL WINAPI
PathIsExeAW (LPCVOID path
)
350 if (SHELL_OsIsUnicode())
351 return PathIsExeW (path
);
352 return PathIsExeA(path
);
355 /*************************************************************************
356 * PathIsDirectory [SHELL32.159]
358 BOOL WINAPI
PathIsDirectoryAW (LPCVOID lpszPath
)
360 if (SHELL_OsIsUnicode())
361 return PathIsDirectoryW (lpszPath
);
362 return PathIsDirectoryA (lpszPath
);
365 /*************************************************************************
366 * PathFileExists [SHELL32.45]
368 BOOL WINAPI
PathFileExistsAW (LPCVOID lpszPath
)
370 if (SHELL_OsIsUnicode())
371 return PathFileExistsW (lpszPath
);
372 return PathFileExistsA (lpszPath
);
375 /*************************************************************************
376 * PathMatchSpec [SHELL32.46]
378 BOOL WINAPI
PathMatchSpecAW(LPVOID name
, LPVOID mask
)
380 if (SHELL_OsIsUnicode())
381 return PathMatchSpecW( name
, mask
);
382 return PathMatchSpecA( name
, mask
);
385 /*************************************************************************
386 * PathIsSameRoot [SHELL32.650]
388 BOOL WINAPI
PathIsSameRootAW(LPCVOID lpszPath1
, LPCVOID lpszPath2
)
390 if (SHELL_OsIsUnicode())
391 return PathIsSameRootW(lpszPath1
, lpszPath2
);
392 return PathIsSameRootA(lpszPath1
, lpszPath2
);
395 /*************************************************************************
396 * IsLFNDrive [SHELL32.119]
399 * exported by ordinal Name
401 BOOL WINAPI
IsLFNDriveA(LPCSTR lpszPath
)
405 if (!GetVolumeInformationA(lpszPath
,NULL
,0,NULL
,&fnlen
,NULL
,NULL
,0))
411 ########## Creating Something Unique ##########
413 /*************************************************************************
414 * PathMakeUniqueNameA [internal]
416 BOOL WINAPI
PathMakeUniqueNameA(
419 LPCSTR lpszShortName
,
423 FIXME("%p %lu %s %s %s stub\n",
424 lpszBuffer
, dwBuffSize
, debugstr_a(lpszShortName
),
425 debugstr_a(lpszLongName
), debugstr_a(lpszPathName
));
429 /*************************************************************************
430 * PathMakeUniqueNameW [internal]
432 BOOL WINAPI
PathMakeUniqueNameW(
435 LPCWSTR lpszShortName
,
436 LPCWSTR lpszLongName
,
437 LPCWSTR lpszPathName
)
439 FIXME("%p %lu %s %s %s stub\n",
440 lpszBuffer
, dwBuffSize
, debugstr_w(lpszShortName
),
441 debugstr_w(lpszLongName
), debugstr_w(lpszPathName
));
445 /*************************************************************************
446 * PathMakeUniqueName [SHELL32.47]
448 BOOL WINAPI
PathMakeUniqueNameAW(
451 LPCVOID lpszShortName
,
452 LPCVOID lpszLongName
,
453 LPCVOID lpszPathName
)
455 if (SHELL_OsIsUnicode())
456 return PathMakeUniqueNameW(lpszBuffer
,dwBuffSize
, lpszShortName
,lpszLongName
,lpszPathName
);
457 return PathMakeUniqueNameA(lpszBuffer
,dwBuffSize
, lpszShortName
,lpszLongName
,lpszPathName
);
460 /*************************************************************************
461 * PathYetAnotherMakeUniqueName [SHELL32.75]
464 * exported by ordinal
466 BOOL WINAPI
PathYetAnotherMakeUniqueNameA(
469 LPCSTR lpszShortName
,
472 FIXME("(%p,%p, %p ,%p):stub.\n",
473 lpszBuffer
, lpszPathName
, lpszShortName
, lpszLongName
);
479 ########## cleaning and resolving paths ##########
482 /*************************************************************************
483 * PathFindOnPath [SHELL32.145]
485 BOOL WINAPI
PathFindOnPathAW(LPVOID sFile
, LPCVOID sOtherDirs
)
487 if (SHELL_OsIsUnicode())
488 return PathFindOnPathW(sFile
, sOtherDirs
);
489 return PathFindOnPathA(sFile
, sOtherDirs
);
492 /*************************************************************************
493 * PathCleanupSpec [SHELL32.171]
495 DWORD WINAPI
PathCleanupSpecAW (LPCVOID x
, LPVOID y
)
497 FIXME("(%p, %p) stub\n",x
,y
);
501 /*************************************************************************
502 * PathQualifyA [SHELL32]
504 BOOL WINAPI
PathQualifyA(LPCSTR pszPath
)
506 FIXME("%s\n",pszPath
);
510 /*************************************************************************
511 * PathQualifyW [SHELL32]
513 BOOL WINAPI
PathQualifyW(LPCWSTR pszPath
)
515 FIXME("%s\n",debugstr_w(pszPath
));
519 /*************************************************************************
520 * PathQualify [SHELL32.49]
522 BOOL WINAPI
PathQualifyAW(LPCVOID pszPath
)
524 if (SHELL_OsIsUnicode())
525 return PathQualifyW(pszPath
);
526 return PathQualifyA(pszPath
);
529 /*************************************************************************
530 * PathResolveA [SHELL32.51]
532 BOOL WINAPI
PathResolveA(
537 FIXME("(%s,%p,0x%08lx),stub!\n",
538 lpszPath
, *alpszPaths
, dwFlags
);
542 /*************************************************************************
543 * PathResolveW [SHELL32]
545 BOOL WINAPI
PathResolveW(
550 FIXME("(%s,%p,0x%08lx),stub!\n",
551 debugstr_w(lpszPath
), debugstr_w(*alpszPaths
), dwFlags
);
555 /*************************************************************************
556 * PathResolve [SHELL32.51]
558 BOOL WINAPI
PathResolveAW(
563 if (SHELL_OsIsUnicode())
564 return PathResolveW(lpszPath
, (LPCWSTR
*)alpszPaths
, dwFlags
);
565 return PathResolveA(lpszPath
, (LPCSTR
*)alpszPaths
, dwFlags
);
568 /*************************************************************************
569 * PathProcessCommandA [SHELL32.653]
571 HRESULT WINAPI
PathProcessCommandA (
577 FIXME("%s %p 0x%04lx 0x%04lx stub\n",
578 lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
579 strcpy(lpszBuff
, lpszPath
);
583 /*************************************************************************
584 * PathProcessCommandW
586 HRESULT WINAPI
PathProcessCommandW (
592 FIXME("(%s, %p, 0x%04lx, 0x%04lx) stub\n",
593 debugstr_w(lpszPath
), lpszBuff
, dwBuffSize
, dwFlags
);
594 strcpyW(lpszBuff
, lpszPath
);
598 /*************************************************************************
599 * PathProcessCommand (SHELL32.653)
601 HRESULT WINAPI
PathProcessCommandAW (
607 if (SHELL_OsIsUnicode())
608 return PathProcessCommandW(lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
609 return PathProcessCommandA(lpszPath
, lpszBuff
, dwBuffSize
, dwFlags
);
613 ########## special ##########
616 /*************************************************************************
617 * PathSetDlgItemPath (SHELL32.48)
619 BOOL WINAPI
PathSetDlgItemPathAW(HWND hDlg
, int id
, LPCVOID pszPath
)
620 { if (SHELL_OsIsUnicode())
621 return PathSetDlgItemPathW(hDlg
, id
, pszPath
);
622 return PathSetDlgItemPathA(hDlg
, id
, pszPath
);
626 /*************************************************************************
627 * SHGetSpecialFolderPathA [SHELL32.@]
629 * converts csidl to path
632 static const char * const szSHFolders
= "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
633 static const char * const szSHUserFolders
= "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders";
634 static const char * const szSetup
= "Software\\Microsoft\\Windows\\CurrentVersion\\Setup";
635 static const char * const szCurrentVersion
= "Software\\Microsoft\\Windows\\CurrentVersion";
637 static const char * const szEnvUserProfile
= "%USERPROFILE%";
638 static const char * const szEnvSystemRoot
= "%SYSTEMROOT%";
646 LPCSTR szDefaultPath
; /* fallback string; sub dir of windows directory */
649 #define CSIDL_MYFLAG_SHFOLDER 1
650 #define CSIDL_MYFLAG_SETUP 2
651 #define CSIDL_MYFLAG_CURRVER 4
652 #define CSIDL_MYFLAG_RELATIVE 8
654 #define HKLM HKEY_LOCAL_MACHINE
655 #define HKCU HKEY_CURRENT_USER
656 static const CSIDL_DATA CSIDL_Data
[] =
658 { /* CSIDL_DESKTOP */
663 { /* CSIDL_INTERNET (??) */
668 { /* CSIDL_PROGRAMS */
671 "Start Menu\\Programs"
673 { /* CSIDL_CONTROLS (.CPL files) */
678 { /* CSIDL_PRINTERS */
683 { /* CSIDL_PERSONAL */
688 { /* CSIDL_FAVORITES */
693 { /* CSIDL_STARTUP */
696 "Start Menu\\Programs\\StartUp"
708 { /* CSIDL_BITBUCKET (is this c:\recycled ?) */
713 { /* CSIDL_STARTMENU */
738 { /* CSIDL_DESKTOPDIRECTORY */
748 { /* CSIDL_NETWORK */
751 "Network Neighborhood"
753 { /* CSIDL_NETHOOD */
763 { /* CSIDL_TEMPLATES */
768 { /* CSIDL_COMMON_STARTMENU */
773 { /* CSIDL_COMMON_PROGRAMS */
778 { /* CSIDL_COMMON_STARTUP */
781 "All Users\\Start Menu\\Programs\\StartUp"
783 { /* CSIDL_COMMON_DESKTOPDIRECTORY */
788 { /* CSIDL_APPDATA */
793 { /* CSIDL_PRINTHOOD */
803 { /* CSIDL_ALTSTARTUP */
808 { /* CSIDL_COMMON_ALTSTARTUP */
813 { /* CSIDL_COMMON_FAVORITES */
818 { /* CSIDL_INTERNET_CACHE */
821 "Temporary Internet Files"
823 { /* CSIDL_COOKIES */
828 { /* CSIDL_HISTORY */
833 { /* CSIDL_COMMON_APPDATA */
836 "All Users\\Application Data"
838 { /* CSIDL_WINDOWS */
848 { /* CSIDL_PROGRAM_FILES */
853 { /* CSIDL_MYPICTURES */
856 "My Documents\\My Pictures"
858 { /* CSIDL_PROFILE */
860 "WinDir", /* correct ? */
863 { /* CSIDL_SYSTEMX86 */
868 { /* CSIDL_PROGRAM_FILESX86 */
873 { /* CSIDL_PROGRAM_FILES_COMMON */
876 "Program Files\\Common Files" /* ? */
878 { /* CSIDL_PROGRAM_FILES_COMMONX86 */
881 "Program Files\\Common Files" /* ? */
883 { /* CSIDL_COMMON_TEMPLATES */
888 { /* CSIDL_COMMON_DOCUMENTS */
893 { /* CSIDL_COMMON_ADMINTOOLS */
898 { /* CSIDL_ADMINTOOLS */
900 "Administrative Tools",
901 "Start Menu\\Programs\\Administrative Tools"
903 { /* CSIDL_CONNECTIONS */
912 /**********************************************************************/
914 BOOL WINAPI
SHGetSpecialFolderPathA (
920 CHAR szValueName
[MAX_PATH
], szDefaultPath
[MAX_PATH
], szBuildPath
[MAX_PATH
];
923 DWORD dwType
, dwDisp
, dwPathLen
= MAX_PATH
;
924 DWORD folder
= csidl
& CSIDL_FOLDER_MASK
;
927 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner
,szPath
,csidl
,bCreate
);
929 if ((folder
> CSIDL_CONNECTIONS
) || (CSIDL_Data
[folder
].hRootKey
== 0))
931 ERR("folder unknown or not allowed\n");
934 if (CSIDL_Data
[folder
].hRootKey
== 1)
936 FIXME("folder unknown, please add.\n");
940 dwFlags
= CSIDL_Data
[folder
].dwFlags
;
941 hRootKey
= CSIDL_Data
[folder
].hRootKey
;
942 strcpy(szValueName
, CSIDL_Data
[folder
].szValueName
);
943 strcpy(szDefaultPath
, CSIDL_Data
[folder
].szDefaultPath
);
945 if (dwFlags
& CSIDL_MYFLAG_SHFOLDER
)
947 /* user shell folders */
948 if (RegCreateKeyExA(hRootKey
,szSHUserFolders
,0,NULL
,0,KEY_ALL_ACCESS
,NULL
,&hKey
,&dwDisp
)) return FALSE
;
950 if (RegQueryValueExA(hKey
,szValueName
,NULL
,&dwType
,(LPBYTE
)szPath
,&dwPathLen
))
955 if (RegCreateKeyExA(hRootKey
,szSHFolders
,0,NULL
,0,KEY_ALL_ACCESS
,NULL
,&hKey
,&dwDisp
)) return FALSE
;
957 if (RegQueryValueExA(hKey
,szValueName
,NULL
,&dwType
,(LPBYTE
)szPath
,&dwPathLen
))
960 /* value not existing */
961 if (dwFlags
& CSIDL_MYFLAG_RELATIVE
)
963 GetWindowsDirectoryA(szPath
, MAX_PATH
);
964 PathAddBackslashA(szPath
);
965 strcat(szPath
, szDefaultPath
);
969 strcpy(szPath
, "C:\\"); /* FIXME ??? */
970 strcat(szPath
, szDefaultPath
);
972 RegSetValueExA(hKey
,szValueName
,0,REG_SZ
,(LPBYTE
)szPath
,strlen(szPath
)+1);
981 if (dwFlags
& CSIDL_MYFLAG_SETUP
)
984 if (dwFlags
& CSIDL_MYFLAG_CURRVER
)
985 pRegPath
= szCurrentVersion
;
988 ERR("folder settings broken, please correct !\n");
992 if (RegCreateKeyExA(hRootKey
,pRegPath
,0,NULL
,0,KEY_ALL_ACCESS
,NULL
,&hKey
,&dwDisp
)) return FALSE
;
994 if (RegQueryValueExA(hKey
,szValueName
,NULL
,&dwType
,(LPBYTE
)szPath
,&dwPathLen
))
996 /* value not existing */
997 if (dwFlags
& CSIDL_MYFLAG_RELATIVE
)
999 GetWindowsDirectoryA(szPath
, MAX_PATH
);
1000 PathAddBackslashA(szPath
);
1001 strcat(szPath
, szDefaultPath
);
1005 strcpy(szPath
, "C:\\"); /* FIXME ??? */
1006 strcat(szPath
, szDefaultPath
);
1008 RegSetValueExA(hKey
,szValueName
,0,REG_SZ
,(LPBYTE
)szPath
,strlen(szPath
)+1);
1013 /* expand paths like %USERPROFILE% */
1014 if (dwType
== REG_EXPAND_SZ
)
1016 ExpandEnvironmentStringsA(szPath
, szDefaultPath
, MAX_PATH
);
1017 strcpy(szPath
, szDefaultPath
);
1020 /* if we don't care about existing directories we are ready */
1021 if(csidl
& CSIDL_FLAG_DONT_VERIFY
) return TRUE
;
1023 if (PathFileExistsA(szPath
)) return TRUE
;
1025 /* not existing but we are not allowed to create it */
1026 if (!bCreate
) return FALSE
;
1028 /* create directory/directories */
1029 strcpy(szBuildPath
, szPath
);
1030 p
= strchr(szBuildPath
, '\\');
1034 if (!PathFileExistsA(szBuildPath
))
1036 if (!CreateDirectoryA(szBuildPath
,NULL
))
1038 ERR("Failed to create directory '%s'.\n", szPath
);
1043 p
= strchr(p
+1, '\\');
1045 /* last component must be created too. */
1046 if (!PathFileExistsA(szBuildPath
))
1048 if (!CreateDirectoryA(szBuildPath
,NULL
))
1050 ERR("Failed to create directory '%s'.\n", szPath
);
1055 MESSAGE("Created not existing system directory '%s'\n", szPath
);
1059 /*************************************************************************
1060 * SHGetSpecialFolderPathW
1062 BOOL WINAPI
SHGetSpecialFolderPathW (
1068 char szTemp
[MAX_PATH
];
1070 if (SHGetSpecialFolderPathA(hwndOwner
, szTemp
, csidl
, bCreate
))
1072 if (!MultiByteToWideChar( CP_ACP
, 0, szTemp
, -1, szPath
, MAX_PATH
))
1073 szPath
[MAX_PATH
-1] = 0;
1076 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner
,szPath
,csidl
,bCreate
);
1081 /*************************************************************************
1082 * SHGetSpecialFolderPath (SHELL32.175)
1084 BOOL WINAPI
SHGetSpecialFolderPathAW (
1091 if (SHELL_OsIsUnicode())
1092 return SHGetSpecialFolderPathW (hwndOwner
, szPath
, csidl
, bCreate
);
1093 return SHGetSpecialFolderPathA (hwndOwner
, szPath
, csidl
, bCreate
);
1096 /*************************************************************************
1097 * SHGetFolderPathA [SHELL32.@]
1099 HRESULT WINAPI
SHGetFolderPathA(
1102 HANDLE hToken
, /* [in] FIXME: get paths for specific user */
1103 DWORD dwFlags
, /* [in] FIXME: SHGFP_TYPE_CURRENT|SHGFP_TYPE_DEFAULT */
1106 return (SHGetSpecialFolderPathA(
1109 CSIDL_FOLDER_MASK
& nFolder
,
1110 CSIDL_FLAG_CREATE
& nFolder
)) ? S_OK
: E_FAIL
;
1113 /*************************************************************************
1114 * SHGetFolderPathW [SHELL32.@]
1116 HRESULT WINAPI
SHGetFolderPathW(
1123 return (SHGetSpecialFolderPathW(
1126 CSIDL_FOLDER_MASK
& nFolder
,
1127 CSIDL_FLAG_CREATE
& nFolder
)) ? S_OK
: E_FAIL
;