4 * Many of this functions are in SHLWAPI.DLL also
9 #include "debugtools.h"
11 #include "winversion.h"
17 #include "shell32_main.h"
21 DEFAULT_DEBUG_CHANNEL(shell)
23 /* Supported protocols for PathIsURL */
24 LPSTR SupportedProtocol[] = {"http","https","ftp","gopher","file","mailto",""};
26 /*************************************************************************
29 BOOL WINAPI PathIsRootA(LPCSTR x)
31 if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
33 if (*x=='\\') /* "\" */
35 if (x[0]=='\\' && x[1]=='\\') /* UNC "\\<xx>\" */
36 { int foundbackslash = 0;
42 if (foundbackslash<=1) /* max 1 \ more ... */
48 /*************************************************************************
51 BOOL WINAPI PathIsRootW(LPCWSTR x)
52 { TRACE("%s\n",debugstr_w(x));
53 if (*(x+1)==':' && *(x+2)=='\\') /* "X:\" */
55 if (*x == (WCHAR) '\\') /* "\" */
57 if (x[0]==(WCHAR)'\\' && x[1]==(WCHAR)'\\') /* UNC "\\<xx>\" */
58 { int foundbackslash = 0;
61 { if (*x++==(WCHAR)'\\')
64 if (foundbackslash<=1) /* max 1 \ more ... */
70 /*************************************************************************
71 * PathIsRoot [SHELL32.29]
73 BOOL WINAPI PathIsRootAW(LPCVOID x)
74 { if (VERSION_OsIsUnicode())
75 return PathIsRootW(x);
76 return PathIsRootA(x);
80 /*************************************************************************
81 * PathBuildRootA [SHELL32.30]
83 LPSTR WINAPI PathBuildRootA(LPSTR root,BYTE drive) {
84 TRACE("%p %i\n",root, drive);
90 /*************************************************************************
94 * returns pointer to last . in last pathcomponent or at \0.
96 LPCSTR WINAPI PathFindExtensionA(LPCSTR path)
97 { LPCSTR lastpoint = NULL;
98 TRACE("%p %s\n",path,path);
100 { if (*path=='\\'||*path==' ')
106 return lastpoint?lastpoint:path;
109 /*************************************************************************
113 * returns pointer to last . in last pathcomponent or at \0.
115 LPCWSTR WINAPI PathFindExtensionW(LPCWSTR path)
116 { LPCWSTR lastpoint = NULL;
117 TRACE("(%p %s)\n",path,debugstr_w(path));
119 { if (*path==(WCHAR)'\\'||*path==(WCHAR)' ')
121 if (*path==(WCHAR)'.')
125 return lastpoint?lastpoint:path;
128 /*************************************************************************
129 * PathFindExtension [SHELL32.31]
132 * returns pointer to last . in last pathcomponent or at \0.
134 LPCVOID WINAPI PathFindExtensionAW(LPCVOID path)
135 { if (VERSION_OsIsUnicode())
136 return PathFindExtensionW(path);
137 return PathFindExtensionA(path);
141 /*************************************************************************
145 * append \ if there is none
147 LPSTR WINAPI PathAddBackslashA(LPSTR path)
149 TRACE("%p->%s\n",path,path);
152 if (len && path[len-1]!='\\')
160 /*************************************************************************
164 * append \ if there is none
166 LPWSTR WINAPI PathAddBackslashW(LPWSTR path)
168 TRACE("%p->%s\n",path,debugstr_w(path));
170 len = CRTDLL_wcslen(path);
171 if (len && path[len-1]!=(WCHAR)'\\')
172 { path[len] = (WCHAR)'\\';
179 /*************************************************************************
180 * PathAddBackslash [SHELL32.32]
183 * append \ if there is none
185 LPVOID WINAPI PathAddBackslashAW(LPVOID path)
186 { if(VERSION_OsIsUnicode())
187 return PathAddBackslashW(path);
188 return PathAddBackslashA(path);
191 /*************************************************************************
195 * remove spaces from beginning and end of passed string
197 LPSTR WINAPI PathRemoveBlanksA(LPSTR str)
213 /*************************************************************************
217 * remove spaces from beginning and end of passed string
219 LPWSTR WINAPI PathRemoveBlanksW(LPWSTR str)
221 TRACE("%s\n",debugstr_w(str));
224 CRTDLL_wcscpy(str,x);
227 x=str+CRTDLL_wcslen(str)-1;
235 /*************************************************************************
236 * PathRemoveBlanks [SHELL32.33]
239 * remove spaces from beginning and end of passed string
241 LPVOID WINAPI PathRemoveBlanksAW(LPVOID str)
242 { if(VERSION_OsIsUnicode())
243 return PathRemoveBlanksW(str);
244 return PathRemoveBlanksA(str);
247 /*************************************************************************
251 * basename(char *fn);
253 LPCSTR WINAPI PathFindFilenameA(LPCSTR aptr)
257 TRACE("%s\n",aslash);
259 { if (((aptr[0]=='\\') || (aptr[0]==':')) && aptr[1] && aptr[1]!='\\')
267 /*************************************************************************
271 * basename(char *fn);
273 LPCWSTR WINAPI PathFindFilenameW(LPCWSTR wptr)
277 TRACE("%s\n",debugstr_w(wslash));
279 { if (((wptr[0]=='\\') || (wptr[0]==':')) && wptr[1] && wptr[1]!='\\')
286 /*************************************************************************
287 * PathFindFilename [SHELL32.34]
290 * basename(char *fn);
292 LPCVOID WINAPI PathFindFilenameAW(LPCVOID fn)
294 if(VERSION_OsIsUnicode())
295 return PathFindFilenameW(fn);
296 return PathFindFilenameA(fn);
299 /*************************************************************************
300 * PathRemoveFileSpecA [SHELL32.35]
303 * bool getpath(char *pathname); truncates passed argument to a valid path
304 * returns if the string was modified or not.
305 * "\foo\xx\foo"-> "\foo\xx"
309 DWORD WINAPI PathRemoveFileSpecA(LPSTR fn) {
325 continue; /* already x++ed */
343 /*************************************************************************
344 * PathAppendA [SHELL32.36]
347 * concat_paths(char*target,const char*add);
348 * concats "target\\add" and writes them to target
350 LPSTR WINAPI PathAppendA(LPSTR x1,LPSTR x2) {
351 TRACE("%s %s\n",x1,x2);
352 while (x2[0]=='\\') x2++;
353 return PathCombineA(x1,x1,x2);
356 /*************************************************************************
360 * if lpszFile='.' skip it
361 * szDest can be equal to lpszFile. Thats why we use sTemp
363 LPSTR WINAPI PathCombineA(LPSTR szDest, LPCSTR lpszDir, LPCSTR lpszFile)
364 { char sTemp[MAX_PATH];
365 TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, lpszDir, lpszFile, lpszFile);
368 if (!lpszFile || !lpszFile[0] || (lpszFile[0]=='.' && !lpszFile[1]) )
369 { strcpy(szDest,lpszDir);
373 /* if lpszFile is a complete path don't care about lpszDir */
374 if (PathIsRootA(lpszFile))
375 { strcpy(szDest,lpszFile);
378 { strcpy(sTemp,lpszDir);
379 PathAddBackslashA(sTemp);
380 strcat(sTemp,lpszFile);
381 strcpy(szDest,sTemp);
386 /*************************************************************************
390 * if lpszFile='.' skip it
391 * szDest can be equal to lpszFile. Thats why we use sTemp
393 LPWSTR WINAPI PathCombineW(LPWSTR szDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
394 { WCHAR sTemp[MAX_PATH];
395 TRACE("%p %p->%s %p->%s\n",szDest, lpszDir, debugstr_w(lpszDir),
396 lpszFile, debugstr_w(lpszFile));
399 if (!lpszFile || !lpszFile[0] || (lpszFile[0]==(WCHAR)'.' && !lpszFile[1]) )
400 { CRTDLL_wcscpy(szDest,lpszDir);
404 /* if lpszFile is a complete path don't care about lpszDir */
405 if (PathIsRootW(lpszFile))
406 { CRTDLL_wcscpy(szDest,lpszFile);
409 { CRTDLL_wcscpy(sTemp,lpszDir);
410 PathAddBackslashW(sTemp);
411 CRTDLL_wcscat(sTemp,lpszFile);
412 CRTDLL_wcscpy(szDest,sTemp);
417 /*************************************************************************
418 * PathCombine [SHELL32.37]
421 * if lpszFile='.' skip it
422 * szDest can be equal to lpszFile. Thats why we use sTemp
424 LPVOID WINAPI PathCombineAW(LPVOID szDest, LPCVOID lpszDir, LPCVOID lpszFile)
425 { if (VERSION_OsIsUnicode())
426 return PathCombineW( szDest, lpszDir, lpszFile );
427 return PathCombineA( szDest, lpszDir, lpszFile );
430 /*************************************************************************
434 * PathIsUNC(char*path);
436 BOOL WINAPI PathIsUNCA(LPCSTR path)
437 { TRACE("%s\n",path);
439 if ((path[0]=='\\') && (path[1]=='\\'))
444 /*************************************************************************
448 * PathIsUNC(char*path);
450 BOOL WINAPI PathIsUNCW(LPCWSTR path)
451 { TRACE("%s\n",debugstr_w(path));
453 if ((path[0]=='\\') && (path[1]=='\\'))
458 /*************************************************************************
459 * PathIsUNC [SHELL32.39]
462 * PathIsUNC(char*path);
464 BOOL WINAPI PathIsUNCAW (LPCVOID path)
465 { if (VERSION_OsIsUnicode())
466 return PathIsUNCW( path );
467 return PathIsUNCA( path );
470 /*************************************************************************
474 BOOL WINAPI PathIsRelativeA (LPCSTR path)
475 { TRACE("path=%s\n",path);
477 if (path && (path[0]!='\\' && path[1]==':'))
482 /*************************************************************************
486 BOOL WINAPI PathIsRelativeW (LPCWSTR path)
487 { TRACE("path=%s\n",debugstr_w(path));
489 if (path && (path[0]!='\\' && path[1]==':'))
494 /*************************************************************************
495 * PathIsRelative [SHELL32.40]
498 BOOL WINAPI PathIsRelativeAW (LPCVOID path)
499 { if (VERSION_OsIsUnicode())
500 return PathIsRelativeW( path );
501 return PathIsRelativeA( path );
504 /*************************************************************************
508 BOOL WINAPI PathIsExeA (LPCSTR path)
509 { FIXME("path=%s\n",path);
513 /*************************************************************************
517 BOOL WINAPI PathIsExeW (LPCWSTR path)
518 { FIXME("path=%s\n",debugstr_w(path));
522 /*************************************************************************
523 * PathIsExe [SHELL32.43]
526 BOOL WINAPI PathIsExeAW (LPCVOID path)
527 { if (VERSION_OsIsUnicode())
528 return PathIsExeW (path);
529 return PathIsExeA(path);
532 /*************************************************************************
533 * PathFileExistsA [SHELL32.45]
536 * file_exists(char *fn);
538 BOOL WINAPI PathFileExistsA(LPSTR fn) {
540 if (GetFileAttributesA(fn)==-1)
545 /*************************************************************************
546 * PathMatchSingleMask
549 * internal (used by PathMatchSpec)
551 static BOOL PathMatchSingleMaskA(LPCSTR name, LPCSTR mask)
553 while (*name && *mask && *mask!=';') {
556 if (PathMatchSingleMaskA(name,mask+1)) return 1; /* try substrings */
560 if (toupper(*mask)!=toupper(*name) && *mask!='?') return 0;
565 while (*mask=='*') mask++;
566 if (!*mask || *mask==';') return 1;
570 static BOOL PathMatchSingleMaskW(LPCWSTR name, LPCWSTR mask)
572 while (*name && *mask && *mask!=';') {
575 if (PathMatchSingleMaskW(name,mask+1)) return 1; /* try substrings */
579 if (towupper(*mask)!=towupper(*name) && *mask!='?') return 0;
584 while (*mask=='*') mask++;
585 if (!*mask || *mask==';') return 1;
590 /*************************************************************************
596 BOOL WINAPI PathMatchSpecA(LPCSTR name, LPCSTR mask)
598 TRACE("%s %s\n",name,mask);
600 if (!lstrcmpA( mask, "*.*" )) return 1; /* we don't require a period */
603 if (PathMatchSingleMaskA(name,mask)) return 1; /* helper function */
604 while (*mask && *mask!=';') mask++;
607 while (*mask==' ') mask++; /* masks may be separated by "; " */
613 /*************************************************************************
619 BOOL WINAPI PathMatchSpecW(LPCWSTR name, LPCWSTR mask)
622 TRACE("%s %s\n",debugstr_w(name),debugstr_w(mask));
624 lstrcpyAtoW(stemp,"*.*");
625 if (!lstrcmpW( mask, stemp )) return 1; /* we don't require a period */
628 if (PathMatchSingleMaskW(name,mask)) return 1; /* helper function */
629 while (*mask && *mask!=';') mask++;
632 while (*mask==' ') mask++; /* masks may be separated by "; " */
638 /*************************************************************************
639 * PathMatchSpec [SHELL32.46]
644 BOOL WINAPI PathMatchSpecAW(LPVOID name, LPVOID mask)
645 { if (VERSION_OsIsUnicode())
646 return PathMatchSpecW( name, mask );
647 return PathMatchSpecA( name, mask );
649 /*************************************************************************
650 * PathSetDlgItemPathA
652 * use PathCompactPath to make sure, the path fits into the control
654 BOOL WINAPI PathSetDlgItemPathA(HWND hDlg, int id, LPCSTR pszPath)
655 { TRACE("%x %x %s\n",hDlg, id, pszPath);
656 return SetDlgItemTextA(hDlg, id, pszPath);
659 /*************************************************************************
660 * PathSetDlgItemPathW
662 * use PathCompactPath to make sure, the path fits into the control
664 BOOL WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR pszPath)
665 { TRACE("%x %x %s\n",hDlg, id, debugstr_w(pszPath));
666 return SetDlgItemTextW(hDlg, id, pszPath);
669 /*************************************************************************
670 * PathSetDlgItemPath [SHELL32.48]
672 * use PathCompactPath to make sure, the path fits into the control
674 BOOL WINAPI PathSetDlgItemPathAW(HWND hDlg, int id, LPCVOID pszPath)
675 { if (VERSION_OsIsUnicode())
676 return PathSetDlgItemPathW(hDlg, id, pszPath);
677 return PathSetDlgItemPathA(hDlg, id, pszPath);
680 /*************************************************************************
683 BOOL WINAPI PathQualifyA(LPCSTR pszPath)
684 { FIXME("%s\n",pszPath);
688 /*************************************************************************
691 BOOL WINAPI PathQualifyW(LPCWSTR pszPath)
692 { FIXME("%s\n",debugstr_w(pszPath));
696 /*************************************************************************
697 * PathQualify [SHELL32.49]
699 BOOL WINAPI PathQualifyAW(LPCVOID pszPath)
700 { if (VERSION_OsIsUnicode())
701 return PathQualifyW(pszPath);
702 return PathQualifyA(pszPath);
705 /*************************************************************************
706 * PathResolve [SHELL32.51]
708 DWORD WINAPI PathResolve(LPCSTR s,DWORD x2,DWORD x3) {
709 FIXME("(%s,0x%08lx,0x%08lx),stub!\n",s,x2,x3);
713 /*************************************************************************
717 * look for next arg in string. handle "quoted" strings
718 * returns pointer to argument *AFTER* the space. Or to the \0.
720 LPCSTR WINAPI PathGetArgsA(LPCSTR cmdline)
721 { BOOL qflag = FALSE;
723 TRACE("%s\n",cmdline);
726 { if ((*cmdline==' ') && !qflag)
736 /*************************************************************************
740 * look for next arg in string. handle "quoted" strings
741 * returns pointer to argument *AFTER* the space. Or to the \0.
743 LPCWSTR WINAPI PathGetArgsW(LPCWSTR cmdline)
744 { BOOL qflag = FALSE;
746 TRACE("%s\n",debugstr_w(cmdline));
749 { if ((*cmdline==' ') && !qflag)
758 /*************************************************************************
759 * PathGetArgs [SHELL32.52]
762 * look for next arg in string. handle "quoted" strings
763 * returns pointer to argument *AFTER* the space. Or to the \0.
765 LPCVOID WINAPI PathGetArgsAW(LPVOID cmdline)
766 { if (VERSION_OsIsUnicode())
767 return PathGetArgsW(cmdline);
768 return PathGetArgsA(cmdline);
771 /*************************************************************************
775 * basename(char *fn);
777 LPSTR WINAPI PathQuoteSpacesA(LPCSTR aptr)
778 { FIXME("%s\n",aptr);
783 /*************************************************************************
787 * basename(char *fn);
789 LPWSTR WINAPI PathQuoteSpacesW(LPCWSTR wptr)
790 { FIXME("%s\n",debugstr_w(wptr));
794 /*************************************************************************
795 * PathQuoteSpaces [SHELL32.55]
798 * basename(char *fn);
800 LPVOID WINAPI PathQuoteSpacesAW (LPCVOID fn)
801 { if(VERSION_OsIsUnicode())
802 return PathQuoteSpacesW(fn);
803 return PathQuoteSpacesA(fn);
807 /*************************************************************************
811 * unquote string (remove ")
813 VOID WINAPI PathUnquoteSpacesA(LPSTR str)
814 { DWORD len = lstrlenA(str);
825 /*************************************************************************
829 * unquote string (remove ")
831 VOID WINAPI PathUnquoteSpacesW(LPWSTR str)
832 { DWORD len = CRTDLL_wcslen(str);
834 TRACE("%s\n",debugstr_w(str));
841 CRTDLL_wcscpy(str,str+1);
845 /*************************************************************************
846 * PathUnquoteSpaces [SHELL32.56]
849 * unquote string (remove ")
851 VOID WINAPI PathUnquoteSpacesAW(LPVOID str)
853 if(VERSION_OsIsUnicode())
854 PathUnquoteSpacesW(str);
856 PathUnquoteSpacesA(str);
860 /*************************************************************************
861 * PathGetDriveNumber32 [SHELL32.57]
864 HRESULT WINAPI PathGetDriveNumber(LPSTR u)
865 { FIXME("%s stub\n",debugstr_a(u));
869 /*************************************************************************
870 * PathYetAnotherMakeUniqueNameA [SHELL32.75]
873 * exported by ordinal
875 BOOL WINAPI PathYetAnotherMakeUniqueNameA(LPDWORD x,LPDWORD y) {
876 FIXME("(%p,%p):stub.\n",x,y);
880 /*************************************************************************
881 * IsLFNDriveA [SHELL32.119]
884 * exported by ordinal Name
886 BOOL WINAPI IsLFNDriveA(LPCSTR path) {
889 if (!GetVolumeInformationA(path,NULL,0,NULL,&fnlen,NULL,NULL,0))
894 /*************************************************************************
897 BOOL WINAPI PathFindOnPathA(LPSTR sFile, LPCSTR sOtherDirs)
898 { FIXME("%s %s\n",sFile, sOtherDirs);
902 /*************************************************************************
905 BOOL WINAPI PathFindOnPathW(LPWSTR sFile, LPCWSTR sOtherDirs)
906 { FIXME("%s %s\n",debugstr_w(sFile), debugstr_w(sOtherDirs));
910 /*************************************************************************
911 * PathFindOnPath [SHELL32.145]
913 BOOL WINAPI PathFindOnPathAW(LPVOID sFile, LPCVOID sOtherDirs)
914 { if (VERSION_OsIsUnicode())
915 return PathFindOnPathW(sFile, sOtherDirs);
916 return PathFindOnPathA(sFile, sOtherDirs);
919 /*************************************************************************
920 * PathGetExtension [SHELL32.158]
923 * exported by ordinal
925 LPCSTR WINAPI PathGetExtensionA(LPCSTR path,DWORD y,DWORD z)
926 { TRACE("(%s,%08lx,%08lx)\n",path,y,z);
927 path = PathFindExtensionA(path);
928 return *path?(path+1):path;
930 LPCWSTR WINAPI PathGetExtensionW(LPCWSTR path,DWORD y,DWORD z)
931 { TRACE("(%s, %08lx, %08lx)\n",debugstr_w(path),y,z);
932 path = PathFindExtensionW(path);
933 return *path?(path+1):path;
935 LPCVOID WINAPI PathGetExtensionAW(LPCVOID path,DWORD y,DWORD z)
936 { if (VERSION_OsIsUnicode())
937 return PathGetExtensionW(path,y,z);
938 return PathGetExtensionA(path,y,z);
941 /*************************************************************************
942 * PathCleanupSpec [SHELL32.171]
945 DWORD WINAPI PathCleanupSpecA(LPSTR x, LPSTR y)
947 FIXME("(%p %s, %p %s) stub\n",x,debugstr_a(x),y,debugstr_a(y));
951 DWORD WINAPI PathCleanupSpecW(LPWSTR x, LPWSTR y)
953 FIXME("(%p %s, %p %s) stub\n",x,debugstr_w(x),y,debugstr_w(y));
957 DWORD WINAPI PathCleanupSpecAW (LPVOID x, LPVOID y)
959 if (VERSION_OsIsUnicode())
960 return PathCleanupSpecW(x,y);
961 return PathCleanupSpecA(x,y);
964 /*************************************************************************
965 * SheGetDirW [SHELL32.281]
968 HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
969 { FIXME("%p %p stub\n",u,v);
973 /*************************************************************************
974 * SheChangeDirW [SHELL32.274]
977 HRESULT WINAPI SheChangeDirW(LPWSTR u)
978 { FIXME("(%s),stub\n",debugstr_w(u));
982 /*************************************************************************
983 * PathProcessCommand [SHELL32.653]
985 HRESULT WINAPI PathProcessCommandA (LPSTR lpCommand, LPSTR v, DWORD w, DWORD x)
987 FIXME("%p(%s) %p 0x%04lx 0x%04lx stub\n",
988 lpCommand, lpCommand, v, w,x );
989 lstrcpyA(v, lpCommand);
993 HRESULT WINAPI PathProcessCommandW (LPWSTR lpCommand, LPSTR v, DWORD w, DWORD x)
995 FIXME("(%p %s, %p, 0x%04lx, 0x%04lx) stub\n",
996 lpCommand, debugstr_w(lpCommand), v, w,x );
1000 HRESULT WINAPI PathProcessCommandAW (LPVOID lpCommand, LPSTR v, DWORD w, DWORD x)
1002 if (VERSION_OsIsUnicode())
1003 return PathProcessCommandW(lpCommand, v, w, x);
1004 return PathProcessCommandA(lpCommand, v, w, x);
1007 /*************************************************************************
1008 * SHGetSpecialFolderPathA
1010 * converts csidl to path
1014 static char * szSHFolders = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";
1016 BOOL WINAPI SHGetSpecialFolderPathA (
1022 CHAR szValueName[MAX_PATH], szDefaultPath[MAX_PATH];
1023 HKEY hRootKey, hKey;
1024 BOOL bRelative = TRUE;
1025 DWORD dwType, dwDisp, dwPathLen = MAX_PATH;
1027 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
1029 /* build default values */
1033 hRootKey = HKEY_CURRENT_USER;
1034 strcpy (szValueName, "AppData");
1035 strcpy (szDefaultPath, "AppData");
1039 hRootKey = HKEY_CURRENT_USER;
1040 strcpy (szValueName, "Cookies");
1041 strcpy(szDefaultPath, "Cookies");
1044 case CSIDL_DESKTOPDIRECTORY:
1045 hRootKey = HKEY_CURRENT_USER;
1046 strcpy(szValueName, "Desktop");
1047 strcpy(szDefaultPath, "Desktop");
1050 case CSIDL_COMMON_DESKTOPDIRECTORY:
1051 hRootKey = HKEY_LOCAL_MACHINE;
1052 strcpy(szValueName, "Common Desktop");
1053 strcpy(szDefaultPath, "Desktop");
1056 case CSIDL_FAVORITES:
1057 hRootKey = HKEY_CURRENT_USER;
1058 strcpy(szValueName, "Favorites");
1059 strcpy(szDefaultPath, "Favorites");
1063 hRootKey = HKEY_CURRENT_USER;
1064 strcpy(szValueName, "Fonts");
1065 strcpy(szDefaultPath, "Fonts");
1069 hRootKey = HKEY_CURRENT_USER;
1070 strcpy(szValueName, "History");
1071 strcpy(szDefaultPath, "History");
1075 hRootKey = HKEY_CURRENT_USER;
1076 strcpy(szValueName, "NetHood");
1077 strcpy(szDefaultPath, "NetHood");
1080 case CSIDL_INTERNET_CACHE:
1081 hRootKey = HKEY_CURRENT_USER;
1082 strcpy(szValueName, "Cache");
1083 strcpy(szDefaultPath, "Temporary Internet Files");
1086 case CSIDL_PERSONAL:
1087 hRootKey = HKEY_CURRENT_USER;
1088 strcpy(szValueName, "Personal");
1089 strcpy(szDefaultPath, "My Own Files");
1093 case CSIDL_PRINTHOOD:
1094 hRootKey = HKEY_CURRENT_USER;
1095 strcpy(szValueName, "PrintHood");
1096 strcpy(szDefaultPath, "PrintHood");
1099 case CSIDL_PROGRAMS:
1100 hRootKey = HKEY_CURRENT_USER;
1101 strcpy(szValueName, "Programs");
1102 strcpy(szDefaultPath, "StartMenu\\Programs");
1105 case CSIDL_COMMON_PROGRAMS:
1106 hRootKey = HKEY_LOCAL_MACHINE;
1107 strcpy(szValueName, "Common Programs");
1108 strcpy(szDefaultPath, "");
1112 hRootKey = HKEY_CURRENT_USER;
1113 strcpy(szValueName, "Recent");
1114 strcpy(szDefaultPath, "Recent");
1118 hRootKey = HKEY_CURRENT_USER;
1119 strcpy(szValueName, "SendTo");
1120 strcpy(szDefaultPath, "SendTo");
1123 case CSIDL_STARTMENU:
1124 hRootKey = HKEY_CURRENT_USER;
1125 strcpy(szValueName, "StartMenu");
1126 strcpy(szDefaultPath, "StartMenu");
1129 case CSIDL_COMMON_STARTMENU:
1130 hRootKey = HKEY_LOCAL_MACHINE;
1131 strcpy(szValueName, "Common StartMenu");
1132 strcpy(szDefaultPath, "StartMenu");
1136 hRootKey = HKEY_CURRENT_USER;
1137 strcpy(szValueName, "Startup");
1138 strcpy(szDefaultPath, "StartMenu\\Programs\\Startup");
1141 case CSIDL_COMMON_STARTUP:
1142 hRootKey = HKEY_LOCAL_MACHINE;
1143 strcpy(szValueName, "Common Startup");
1144 strcpy(szDefaultPath, "StartMenu\\Programs\\Startup");
1147 case CSIDL_TEMPLATES:
1148 hRootKey = HKEY_CURRENT_USER;
1149 strcpy(szValueName, "Templates");
1150 strcpy(szDefaultPath, "ShellNew");
1154 ERR("folder unknown or not allowed\n");
1158 if (RegCreateKeyExA(hRootKey,szSHFolders,0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hKey,&dwDisp))
1163 if (RegQueryValueExA(hKey,szValueName,NULL,&dwType,(LPBYTE)szPath,&dwPathLen))
1165 /* value not existing */
1168 GetWindowsDirectoryA(szPath, MAX_PATH);
1169 PathAddBackslashA(szPath);
1170 strcat(szPath, szDefaultPath);
1174 strcpy(szPath, szDefaultPath);
1178 CreateDirectoryA(szPath,NULL);
1180 RegSetValueExA(hKey,szValueName,0,REG_SZ,(LPBYTE)szPath,strlen(szPath)+1);
1187 /*************************************************************************
1188 * SHGetSpecialFolderPathW
1190 * converts csidl to path
1193 BOOL WINAPI SHGetSpecialFolderPathW (
1199 char szTemp[MAX_PATH];
1201 if (SHGetSpecialFolderPathA(hwndOwner, szTemp, csidl, bCreate))
1203 lstrcpynAtoW(szPath, szTemp, MAX_PATH);
1206 TRACE("0x%04x,%p,csidl=%lu,0x%04x\n", hwndOwner,szPath,csidl,bCreate);
1211 /*************************************************************************
1212 * SHGetSpecialFolderPath [SHELL32.175]
1214 * converts csidl to path
1217 BOOL WINAPI SHGetSpecialFolderPathAW (
1224 if (VERSION_OsIsUnicode())
1225 return SHGetSpecialFolderPathW (hwndOwner, szPath, csidl, bCreate);
1226 return SHGetSpecialFolderPathA (hwndOwner, szPath, csidl, bCreate);
1229 /*************************************************************************
1230 * PathRemoveBackslashA
1232 * If the path ends in a backslash it is replaced by a NULL
1233 * and the address of the NULL is returned
1235 * the address of the last character is returned.
1238 LPSTR WINAPI PathRemoveBackslashA( LPSTR lpPath )
1242 while (*lpPath) p = lpPath++;
1243 if ( *p == (CHAR)'\\') *p = (CHAR)'\0';
1247 /*************************************************************************
1248 * PathRemoveBackslashW
1251 LPWSTR WINAPI PathRemoveBackslashW( LPWSTR lpPath )
1255 while (*lpPath); p = lpPath++;
1256 if ( *p == (WCHAR)'\\') *p = (WCHAR)'\0';
1260 /*************************************************************************
1264 BOOL WINAPI PathIsURLA(LPCSTR lpstrPath)
1267 char lpstrFileType[10] = "";
1275 /* protocol://location */
1276 if(!(lpstrRes = strchr(lpstrPath,':')))
1280 iSize = lpstrRes - lpstrPath;
1281 if(iSize > sizeof(lpstrFileType))
1284 strncpy(lpstrFileType,lpstrPath,iSize);
1286 while(strlen(SupportedProtocol[i]))
1288 if(!_stricmp(lpstrFileType,SupportedProtocol[i++]))
1295 /*************************************************************************
1299 BOOL WINAPI PathIsDirectoryA(LPCSTR pszPath)
1301 FIXME("%s\n", debugstr_a(pszPath));
1305 /*************************************************************************
1309 BOOL WINAPI PathIsDirectoryW(LPCWSTR pszPath)
1311 FIXME("%s\n", debugstr_w(pszPath));
1314 /*************************************************************************
1318 BOOL WINAPI PathIsDirectoryAW (LPCVOID pszPath)
1320 if (VERSION_OsIsUnicode())
1321 return PathIsDirectoryW (pszPath);
1322 return PathIsDirectoryA (pszPath);