- new dll shfolder.dll
- small fixes

diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index ea7a9c6..eb406ec 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -97,6 +97,7 @@
 	olesvr \
 	rasapi16 \
 	shell \
+	shfolder \
 	shlwapi \
 	storage \
 	system \
@@ -286,7 +287,7 @@
 libsetupx.@LIBEXT@: setupx/libsetupx.@LIBEXT@
 	$(RM) $@ && $(LN_S) setupx/libsetupx.@LIBEXT@ $@
 
-libshell32.@LIBEXT@ libshell.@LIBEXT@ libshlwapi.@LIBEXT@: shell32/libshell32.@LIBEXT@
+libshell32.@LIBEXT@ libshell.@LIBEXT@ libshlwapi.@LIBEXT@ libshfolder.@LIBEXT@: shell32/libshell32.@LIBEXT@
 	$(RM) $@ && $(LN_S) shell32/libshell32.@LIBEXT@ $@
 
 libsound.@LIBEXT@: sound/libsound.@LIBEXT@
diff --git a/dlls/shell32/Makefile.in b/dlls/shell32/Makefile.in
index c482f20..d695e53 100644
--- a/dlls/shell32/Makefile.in
+++ b/dlls/shell32/Makefile.in
@@ -4,13 +4,14 @@
 VPATH     = @srcdir@
 MODULE    = shell32
 SOVERSION = 1.0
-ALTNAMES  = shell shlwapi
+ALTNAMES  = shell shlwapi shfolder
 IMPORTS   = ole32
 
 SPEC_SRCS = \
 	shell.spec \
 	shell32.spec \
-	shlwapi.spec
+	shlwapi.spec \
+	shfolder.spec
 
 C_SRCS = \
 	brsfolder.c \
diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec
index 2661515..976ae6d 100644
--- a/dlls/shell32/shell32.spec
+++ b/dlls/shell32/shell32.spec
@@ -20,13 +20,10 @@
    5 stub SHChangeNotifyUpdateEntryList@16
    6 stub CheckEscapesW@8
    7 stdcall CommandLineToArgvW(wstr ptr) CommandLineToArgvW
-   8 stdcall Control_FillCache_RunDLL (long long long long) Control_FillCache_RunDLL
    9 stub PifMgr_OpenProperties@16
   10 stub PifMgr_GetProperties@20
   11 stub PifMgr_SetProperties@20
-  12 stub Control_FillCache_RunDLLA@16
   13 stub PifMgr_CloseProperties@8
-  14 stub Control_FillCache_RunDLLW@16
   15 stdcall ILGetDisplayName(ptr ptr) ILGetDisplayName
   16 stdcall ILFindLastID(ptr) ILFindLastID
   17 stdcall ILRemoveLastID(ptr) ILRemoveLastID
@@ -34,7 +31,6 @@
   19 stdcall ILCloneFirst (ptr) ILCloneFirst
   20 stdcall ILGlobalClone (ptr) ILGlobalClone
   21 stdcall ILIsEqual (ptr ptr) ILIsEqual
-  22 stdcall Control_RunDLL(long long long long) Control_RunDLL # exported by name
   23 stdcall ILIsParent (long long long) ILIsParent
   24 stdcall ILFindChild (long long) ILFindChild
   25 stdcall ILCombine(ptr ptr) ILCombine
@@ -53,8 +49,6 @@
   38 stdcall PathStripPath(ptr)PathStripPathAW
   39 stdcall PathIsUNC (ptr) PathIsUNCAW
   40 stdcall PathIsRelative (ptr) PathIsRelativeAW
-  41 stub Control_RunDLLA@16
-  42 stub Control_RunDLLW@16
   43 stdcall PathIsExe (ptr) PathIsExeAW
   44 stub DoEnvironmentSubstA@8
   45 stdcall PathFileExists(ptr) PathFileExistsAW
@@ -113,7 +107,6 @@
   98 stdcall SHGetRealIDL (long long long) SHGetRealIDL
   99 stdcall SetAppStartingCursor (long long) SetAppStartingCursor
  100 stdcall SHRestricted(long) SHRestricted
- 101 stub DragQueryFileAorW   # exported by name
  102 stdcall SHCoCreateInstance(ptr ptr long ptr ptr) SHCoCreateInstance
  103 stdcall SignalFileOpen(long) SignalFileOpen
  104 stdcall FileMenu_DeleteAllItems(long)FileMenu_DeleteAllItems
@@ -150,7 +143,6 @@
  135 stdcall DragQueryPoint(long ptr) DragQueryPoint
  136 stdcall DAD_SetDragImage(long long) DAD_SetDragImage
  137 stdcall DAD_ShowDragImage (long) DAD_ShowDragImage
- 138 stub DuplicateIcon   # exported by name
  139 stub Desktop_UpdateBriefcaseOnEvent
  140 stdcall FileMenu_DeleteItemByIndex(long long) FileMenu_DeleteItemByIndex
  141 stdcall FileMenu_DeleteItemByFirstID(long long)FileMenu_DeleteItemByFirstID
@@ -217,48 +209,13 @@
  213 stub Printers_RegisterWindowW
  214 stub Printers_UnregisterWindow
  215 stub SHStartNetConnectionDialog@12
- 216 stub ExtractVersionResource16W   # exported by name
- 217 stub FindExeDlgProc   # exported by name
- 218 stdcall FindExecutableA(ptr ptr ptr) FindExecutableA   # exported by name
- 219 stdcall FindExecutableW(wstr wstr wstr) FindExecutableW   # exported by name
- 220 stdcall FreeIconList(long) FreeIconList   # exported by name
- 221 stub InternalExtractIconListA   # exported by name
- 222 stub InternalExtractIconListW   # exported by name
- 223 stub OpenAs_RunDLL   # exported by name
- 224 stub OpenAs_RunDLLA   # exported by name
- 225 stub OpenAs_RunDLLW   # exported by name
- 226 stub PrintersGetCommand_RunDLL   # exported by name
- 227 stub PrintersGetCommand_RunDLLA   # exported by name
- 228 stub PrintersGetCommand_RunDLLW   # exported by name
- 229 stub RealShellExecuteA   # exported by name
- 230 stub RealShellExecuteExA   # exported by name
- 231 stub RealShellExecuteExW   # exported by name
- 232 stub RealShellExecuteW   # exported by name
- 233 stub RegenerateUserEnvironment   # exported by name
- 234 stdcall SHAddToRecentDocs (long ptr) SHAddToRecentDocs  # exported by name
- 235 stdcall SHAppBarMessage(long ptr) SHAppBarMessage   # exported by name
- 236 stdcall SHBrowseForFolder(ptr) SHBrowseForFolderA   # exported by name
- 237 stdcall SHBrowseForFolderA(ptr) SHBrowseForFolderA   # exported by name
- 238 stub SHBrowseForFolderW@4   # exported by name
- 239 stdcall SHChangeNotify (long long ptr ptr) SHChangeNotifyAW  # exported by name
- 240 stub SHEmptyRecycleBinA@12   # exported by name
- 241 stub SHEmptyRecycleBinW@12   # exported by name
  243 stdcall shell32_243(long long) shell32_243
- 244 stdcall SHInitRestricted(ptr ptr) SHInitRestricted # win98+ only, by ordinal
- 245 stub SHFormatDrive@16   # exported by name
- 246 stub SHFreeNameMappings@4   # exported by name
+ 244 stdcall SHInitRestricted(ptr ptr) SHInitRestricted
  247 stdcall SHGetDataFromIDListA (ptr ptr long ptr long) SHGetDataFromIDListA
  248 stdcall SHGetDataFromIDListW (ptr ptr long ptr long) SHGetDataFromIDListW
  249 stdcall PathParseIconLocation (ptr) PathParseIconLocationAW
  250 stdcall PathRemoveExtension (ptr) PathRemoveExtensionAW
  251 stdcall PathRemoveArgs (ptr) PathRemoveArgsAW
- 264 stdcall SHHelpShortcuts_RunDLL(long long long long) SHHelpShortcuts_RunDLL   # exported by name
- 265 stub SHHelpShortcuts_RunDLLA@16   # exported by name
- 266 stub SHHelpShortcuts_RunDLLW@16   # exported by name
- 267 stdcall SHLoadInProc(long) SHLoadInProc   # exported by name
- 268 stub SHQueryRecycleBinA@8   # exported by name
- 269 stub SHQueryRecycleBinW@8   # exported by name
- 270 stub SHUpdateRecycleBinIcon@0   # exported by name
  271 stub SheChangeDirA
  272 stub SheChangeDirExA
  273 stub SheChangeDirExW
@@ -283,7 +240,6 @@
  292 stdcall ShellExecuteExA (long) ShellExecuteExA
  293 stdcall ShellExecuteExW (long) ShellExecuteExW
  294 stdcall ShellExecuteW (long wstr wstr wstr wstr long) ShellExecuteW
- 295 stub ShellHookProc   # exported by name
  296 stdcall Shell_NotifyIcon(long ptr) Shell_NotifyIcon
  297 stdcall Shell_NotifyIconA(long ptr) Shell_NotifyIconA
  298 stdcall Shell_NotifyIconW(long ptr) Shell_NotifyIconW
@@ -317,7 +273,6 @@
  326 stdcall StrStrIA(str str)StrStrIA
  327 stdcall StrStrIW(wstr wstr)StrStrIW
  328 stdcall StrStrW(wstr wstr)StrStrW
- 329 stub WOWShellExecute # proper ordinal unknown
 
  505 stdcall SHRegCloseKey (long) SHRegCloseKey
  506 stdcall SHRegOpenKeyA (long str long) SHRegOpenKeyA
@@ -348,58 +303,122 @@
  650 stdcall PathIsSameRoot(ptr ptr)PathIsSameRootAW
 
 # nt40/win98
- 651 stdcall ReadCabinetState (long long) ReadCabinetState 
+ 651 stdcall ReadCabinetState (long long) ReadCabinetState # OldReadCabinetState
  652 stdcall WriteCabinetState (long) WriteCabinetState
  653 stdcall PathProcessCommand (long long long long) PathProcessCommandAW
 
 # win98
- 654 stdcall shell32_654 (long long) shell32_654
-
- 660 stdcall FileIconInit (long) FileIconInit
-
- 680 stdcall IsUserAdmin () IsUserAdmin
+ 654 stdcall shell32_654(long long)shell32_654 # ReadCabinetState@8
+ 660 stdcall FileIconInit(long)FileIconInit
+ 680 stdcall IsUserAdmin()IsUserAdmin
 
 # >= NT5
- 714 stdcall SHELL32_714(ptr)SHELL32_714
-@    stdcall SHGetFolderLocation(long long long long ptr)SHGetFolderLocation
+ 714 stdcall SHELL32_714(ptr)SHELL32_714 # PathIsTemporaryW
 
 1217 stub FOOBAR1217   # no joke! This is the real name!!
 
-# later additions ... FIXME: incorrect ordinals
-# win 98 uses 2...330, 505..511, 520..526, 640..654, 660, 680, 700..707, 711
+#
+# version 4.0 (win95)
+# _WIN32_IE >= 0x0200
+#
+@ stdcall Control_FillCache_RunDLL(long long long long)Control_FillCache_RunDLL
+@ stub Control_FillCache_RunDLLA@16
+@ stub Control_FillCache_RunDLLW@16
+@ stdcall Control_RunDLL(long long long long)Control_RunDLL
+@ stub Control_RunDLLA@16
+@ stub Control_RunDLLW@16
+@ stdcall DllInstall(long wstr)SHELL32_DllInstall
+@ stdcall DoEnvironmentSubstA(str str)DoEnvironmentSubstA
+@ stdcall DoEnvironmentSubstW(wstr wstr)DoEnvironmentSubstW
+@ stub DragQueryFileAorW
+@ stub DuplicateIcon
+@ stdcall ExtractAssociatedIconA(long ptr long)ExtractAssociatedIconA 
+@ stub ExtractAssociatedIconExA 
+@ stub ExtractAssociatedIconExW 
+@ stub ExtractAssociatedIconW 
+@ stdcall ExtractIconA(long str long)ExtractIconA 
+@ stdcall ExtractIconEx(ptr long ptr ptr long)ExtractIconExAW
+@ stdcall ExtractIconExA(str long ptr ptr long)ExtractIconExA
+@ stdcall ExtractIconExW(wstr long ptr ptr long)ExtractIconExW
+@ stdcall ExtractIconW(long wstr long)ExtractIconW 
+@ stub ExtractIconResInfoA 
+@ stub ExtractIconResInfoW 
+@ stub ExtractVersionResource16W 
+@ stub FindExeDlgProc 
+@ stdcall FindExecutableA(ptr ptr ptr) FindExecutableA 
+@ stdcall FindExecutableW(wstr wstr wstr) FindExecutableW 
+@ stdcall FreeIconList(long) FreeIconList 
+@ stub InternalExtractIconListA
+@ stub InternalExtractIconListW
+@ stub OpenAs_RunDLL
+@ stub OpenAs_RunDLLA
+@ stub OpenAs_RunDLLW
+@ stub PrintersGetCommand_RunDLL
+@ stub PrintersGetCommand_RunDLLA
+@ stub PrintersGetCommand_RunDLLW
+@ stub RealShellExecuteA 
+@ stub RealShellExecuteExA 
+@ stub RealShellExecuteExW 
+@ stub RealShellExecuteW 
+@ stub RegenerateUserEnvironment 
+@ stdcall SHAddToRecentDocs (long ptr) SHAddToRecentDocs 
+@ stdcall SHAppBarMessage(long ptr) SHAppBarMessage 
+@ stdcall SHBrowseForFolder(ptr) SHBrowseForFolderA 
+@ stdcall SHBrowseForFolderA(ptr) SHBrowseForFolderA 
+@ stub SHBrowseForFolderW@4 
+@ stdcall SHChangeNotify (long long ptr ptr) SHChangeNotifyAW 
+@ stub ShellHookProc
+@ stub SHEmptyRecycleBinA@12 
+@ stub SHEmptyRecycleBinW@12 
+@ stdcall SHFileOperation(ptr)SHFileOperationAW
+@ stdcall SHFileOperationA(ptr)SHFileOperationA
+@ stdcall SHFileOperationW(ptr)SHFileOperationW
+@ stub SHFormatDrive@16 
+@ stub SHFreeNameMappings@4 
+@ stdcall SHGetDesktopFolder(ptr)SHGetDesktopFolder
+@ stdcall SHGetFileInfo(ptr long ptr long long)SHGetFileInfoAW
+@ stdcall SHGetFileInfoA(ptr long ptr long long)SHGetFileInfoA
+@ stdcall SHGetFileInfoW(ptr long ptr long long)SHGetFileInfoW
+@ stdcall SHGetInstanceExplorer(long)SHGetInstanceExplorer
+@ stdcall SHGetMalloc(ptr)SHGetMalloc
+@ stub SHGetNewLinkInfo@20
+@ stdcall SHGetPathFromIDList(ptr ptr)SHGetPathFromIDListAW
+@ stdcall SHGetPathFromIDListA(long long)SHGetPathFromIDListA
+@ stdcall SHGetPathFromIDListW(long long)SHGetPathFromIDListW
+@ stdcall SHGetSpecialFolderLocation(long long ptr)SHGetSpecialFolderLocation 
+@ stdcall SHHelpShortcuts_RunDLL(long long long long) SHHelpShortcuts_RunDLL 
+@ stub SHHelpShortcuts_RunDLLA@16 
+@ stub SHHelpShortcuts_RunDLLW@16 
+@ stdcall SHLoadInProc(long) SHLoadInProc 
+@ stub SHQueryRecycleBinA@8 
+@ stub SHQueryRecycleBinW@8 
+@ stub SHUpdateRecycleBinIcon@0 
+@ stub WOWShellExecute@28
 
+#
+# version 4.70 (IE3.0)
+# _WIN32_IE >= 0x0300
+#
 
-1220 stdcall DllGetVersion (ptr) SHELL32_DllGetVersion	# win98:201
-1221 stdcall SHGetSpecialFolderPathA(long ptr long long) SHGetSpecialFolderPathA	# win98:292
-1222 stdcall DoEnvironmentSubstA (str str) DoEnvironmentSubstA		# win98:293
-1223 stdcall DoEnvironmentSubstW (wstr wstr) DoEnvironmentSubstW	# win98:204
+#
+# version 4.71 (IE4.0)
+# _WIN32_IE >= 0x0400
+#
+@ stub DllCanUnloadNow
+@ stdcall DllGetVersion(ptr)SHELL32_DllGetVersion
+@ stub SHGetFreeDiskSpace
+@ stdcall SHGetSpecialFolderPathA(long ptr long long) SHGetSpecialFolderPathA
 
-# by-name routines
+#
+# version 4.72 (IE4.01)
+# _WIN32_IE >= 0x0401
+# no new exports
+#
 
- @ stdcall DllInstall (long wstr) SHELL32_DllInstall
-
- @ stdcall ExtractAssociatedIconA(long ptr long) ExtractAssociatedIconA   # exported by name
- @ stub ExtractAssociatedIconExA   # exported by name
- @ stub ExtractAssociatedIconExW   # exported by name
- @ stub ExtractAssociatedIconW   # exported by name
- @ stdcall ExtractIconA(long str long) ExtractIconA   # exported by name
- @ stdcall ExtractIconEx(ptr long ptr ptr long) ExtractIconExAW
- @ stdcall ExtractIconExA(str long ptr ptr long) ExtractIconExA
- @ stdcall ExtractIconExW(wstr long ptr ptr long) ExtractIconExW
- @ stdcall ExtractIconW(long wstr long) ExtractIconW   # exported by name
- @ stub ExtractIconResInfoA   # exported by name
- @ stub ExtractIconResInfoW   # exported by name
- @ stdcall SHFileOperation (ptr) SHFileOperationAW
- @ stdcall SHFileOperationA (ptr) SHFileOperationA
- @ stdcall SHFileOperationW (ptr) SHFileOperationW
- @ stdcall SHGetDesktopFolder(ptr) SHGetDesktopFolder
- @ stdcall SHGetFileInfo(ptr long ptr long long) SHGetFileInfoAW
- @ stdcall SHGetFileInfoA(ptr long ptr long long) SHGetFileInfoA
- @ stdcall SHGetFileInfoW(ptr long ptr long long) SHGetFileInfoW
- @ stdcall SHGetInstanceExplorer (long) SHGetInstanceExplorer
- @ stdcall SHGetMalloc(ptr) SHGetMalloc
- @ stub SHGetNewLinkInfo@20
- @ stdcall SHGetPathFromIDList(ptr ptr) SHGetPathFromIDListAW
- @ stdcall SHGetPathFromIDListA (long long) SHGetPathFromIDListA
- @ stdcall SHGetPathFromIDListW (long long) SHGetPathFromIDListW
- @ stdcall SHGetSpecialFolderLocation(long long ptr) SHGetSpecialFolderLocation   # exported by name
+#
+# version 5.00 (Win2K)
+# _WIN32_IE >= 0x0500
+#
+@ stdcall SHGetFolderPathA(long long long long ptr)SHGetFolderPathA
+@ stdcall SHGetFolderPathW(long long long long ptr)SHGetFolderPathW
+@ stdcall SHGetFolderLocation(long long long long ptr)SHGetFolderLocation
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index 59f17e6..9d01b92 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -1069,9 +1069,12 @@
 
 /*************************************************************************
  *      SHLWAPI_219	[SHLWAPI]
+ *
+ * NOTES
+ *  error codes: E_POINTER, E_NOINTERFACE
  */
 HRESULT WINAPI SHLWAPI_219 (
-	LPVOID w, /* returned by LocalAlloc */
+	LPVOID w, /* returned by LocalAlloc, 0x450 bytes, iface */
 	LPVOID x,
 	LPVOID y,
 	LPWSTR z) /* OUT: path */
@@ -1100,26 +1103,36 @@
  *      SHLWAPI_223	[SHLWAPI]
  *
  * NOTES
- *  function guessed 
-*/
+ *  get the count of the semaphore
+ */
 DWORD WINAPI SHLWAPI_223 (HANDLE handle)
 {
 	DWORD oldCount;
 	
 	FIXME("(0x%08x) stub\n",handle);
 
-	ReleaseSemaphore( handle, 1, &oldCount);
-	WaitForSingleObject( handle, 0 );
-	return 0;
+	ReleaseSemaphore( handle, 1, &oldCount);	/* +1 */
+	WaitForSingleObject( handle, 0 );		/* -1 */
+	return oldCount;
 }
 
 /*************************************************************************
  *      SHLWAPI_237	[SHLWAPI]
+ *
+ * NOTES
+ *  checks if a class is registered, if not it registers it
  */
-DWORD WINAPI SHLWAPI_237 (LPVOID x)
+DWORD WINAPI SHLWAPI_237 (WNDCLASSW * lpWndClass)
 {
-	FIXME("(ptr=%p str=%s wstr=%s)\n",x,debugstr_a(x),debugstr_w(x));
-	return 0xabba1234;
+	WNDCLASSW WndClass;
+	
+	TRACE("(0x%08x %s)\n",lpWndClass->hInstance, debugstr_w(lpWndClass->lpszClassName));
+
+	if (!GetClassInfoW(lpWndClass->hInstance, lpWndClass->lpszClassName, &WndClass))
+	{
+	  return RegisterClassW(lpWndClass);
+	}
+	return TRUE;
 }
 
 /*************************************************************************
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index 114dab9..623fa09 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -417,7 +417,6 @@
 	  lpszPath++;
 	}
 	return (LPSTR)lpszPath;
-
 }
 
 /*************************************************************************
@@ -571,7 +570,7 @@
 	TRACE("%s\n", lpszPath);
 
 	if(lpszFileName)
-	  RtlMoveMemory(lpszPath, lpszFileName, strlen(lpszFileName)); 
+	  RtlMoveMemory(lpszPath, lpszFileName, strlen(lpszFileName)+1); 
 }
 
 /*************************************************************************
@@ -583,7 +582,7 @@
 
 	TRACE("%s\n", debugstr_w(lpszPath));
 	if(lpszFileName)
-	  RtlMoveMemory(lpszPath, lpszFileName, lstrlenW(lpszFileName)*sizeof(WCHAR)); 
+	  RtlMoveMemory(lpszPath, lpszFileName, (lstrlenW(lpszFileName)+1)*sizeof(WCHAR)); 
 }
 
 /*************************************************************************
@@ -604,20 +603,18 @@
 	TRACE("%s\n", lpszPath);
 
 	/* X:\ */
-	if (lpszPath[1]==':' && lpszPath[2]=='\\')
+	if (lpszPath[1]==':' )
 	{
-	  lpszPath[3]='\0';
-	  return TRUE;
+	  if(lpszPath[2]=='\\')
+	  {
+	    lpszPath[3]='\0';
+	    return TRUE;
+	  }
+	  lpszPath[2]='\0';
+	  return FALSE;
 	}
 
-	/* "\" */
-	if (lpszPath[0]=='\\')
-	{
-	  lpszPath[1]='\0';
-	  return TRUE;
-	}
-
-	/* UNC "\\<computer>\<share>" */
+	/* UNC "\\<computer>\<share>" FIXME: not complete*/
 	if (lpszPath[0]=='\\' && lpszPath[1]=='\\')		
 	{
 	  int foundbackslash = 0;
@@ -634,6 +631,14 @@
 	  }
 	}
 
+	/* "\" */
+	if (lpszPath[0]=='\\')
+	{
+	  lpszPath[1]='\0';
+	  return TRUE;
+	}
+
+	lpszPath[0]='\0';
 	return FALSE;
 }
 
@@ -645,18 +650,17 @@
 	TRACE("%s\n", debugstr_w(lpszPath));
 
 	/* X:\ */
-	if (lpszPath[1]==':' && lpszPath[2]=='\\')
+	if (lpszPath[1]==':' )
 	{
-	  lpszPath[3]='\0';
-	  return TRUE;
+	  if(lpszPath[2]=='\\')
+	  {
+	    lpszPath[3]='\0';
+	    return TRUE;
+	  }
+	  lpszPath[2]='\0';
+	  return FALSE;
 	}
 
-	/* "\" */
-	if (lpszPath[0]=='\\')
-	{
-	  lpszPath[1]='\0';
-	  return TRUE;
-	}
 
 	/* UNC "\\<computer>\<share>" */
 	if (lpszPath[0]=='\\' && lpszPath[1]=='\\')		
@@ -675,6 +679,14 @@
 	  }
 	}
 
+	/* "\" */
+	if (lpszPath[0]=='\\')
+	{
+	  lpszPath[1]='\0';
+	  return TRUE;
+	}
+
+	lpszPath[0]=(WCHAR)'\0';
 	return FALSE;
 }
 
@@ -690,32 +702,54 @@
 
 /*************************************************************************
  * PathRemoveArgsA	[SHLWAPI.@]
+ *
+ * NOTES
+ *  returns pointer to last character, not void
  */
-void WINAPI PathRemoveArgsA(LPSTR lpszPath)
+LPSTR WINAPI PathRemoveArgsA(LPSTR lpszPath)
 {
-	LPSTR lpszArgs = PathGetArgsA(lpszPath);
+	BOOL	qflag = FALSE;
+	LPSTR	pPos = lpszPath;
+	
+	TRACE("%s\n",lpszPath);
 
-	TRACE("%s\n", lpszPath);
-
-	if (lpszArgs) *(--lpszArgs)='\0';
+	while (*lpszPath) 
+	{
+	  if (!qflag && *lpszPath==' ') break;
+	  if (*lpszPath=='"') qflag=!qflag;
+	  lpszPath++;
+	  if (*lpszPath) pPos++;
+	};
+	*lpszPath = '\0';
+	return pPos;
 }
 
 /*************************************************************************
  * PathRemoveArgsW	[SHLWAPI.@]
  */
-void WINAPI PathRemoveArgsW(LPWSTR lpszPath)
+LPWSTR WINAPI PathRemoveArgsW(LPWSTR lpszPath)
 {
-	LPWSTR lpszArgs = PathGetArgsW(lpszPath);
+	BOOL	qflag = FALSE;
+	LPWSTR	pPos = lpszPath;
+	
 
 	TRACE("%s\n", debugstr_w(lpszPath));
 
-	if (lpszArgs) *(--lpszArgs)='\0';
+	while (*lpszPath) 
+	{
+	  if (!qflag && *lpszPath==(WCHAR)' ') break;
+	  if (*lpszPath==(WCHAR)'"') qflag=!qflag;
+	  lpszPath++;
+	  if (*lpszPath) pPos++;
+	};
+	*lpszPath = (WCHAR)'\0';
+	return pPos;
 }
 
 /*************************************************************************
  * PathRemoveArgsAW	[SHELL32.251]
  */
-void WINAPI PathRemoveArgsAW(LPVOID lpszPath) 
+LPVOID WINAPI PathRemoveArgsAW(LPVOID lpszPath) 
 {
 	if (VERSION_OsIsUnicode())
 	  return PathRemoveArgsW(lpszPath);
@@ -764,6 +798,8 @@
  * Otherwise 
  * the address of the last character is returned.
  *
+ * FIXME
+ *  "c:\": keep backslash
  */
 LPSTR WINAPI PathRemoveBackslashA( LPSTR lpszPath )
 {
@@ -878,27 +914,48 @@
 /*************************************************************************
  * PathQuoteSpacesA [SHLWAPI.@]
  * 
- * NOTES
  */
-LPSTR WINAPI PathQuoteSpacesA(LPCSTR lpszPath)
+LPSTR WINAPI PathQuoteSpacesA(LPSTR lpszPath)
 {
-	FIXME("%s\n",lpszPath);
+	TRACE("%s\n",lpszPath);
+
+	if(StrChrA(lpszPath,' '))
+	{
+	  int len = strlen(lpszPath);
+	  RtlMoveMemory(lpszPath+1, lpszPath, len);
+	  *(lpszPath++) = '"';
+	  lpszPath += len;
+	  *(lpszPath++) = '"';
+	  *(lpszPath) = '\0';
+	  return --lpszPath;
+	}
 	return 0;
 }
 
 /*************************************************************************
  * PathQuoteSpacesW [SHLWAPI.@]
  */
-LPWSTR WINAPI PathQuoteSpacesW(LPCWSTR lpszPath)
+LPWSTR WINAPI PathQuoteSpacesW(LPWSTR lpszPath)
 {
-	FIXME("%s\n",debugstr_w(lpszPath));
-	return 0;	
+	TRACE("%s\n",debugstr_w(lpszPath));
+
+	if(StrChrW(lpszPath,' '))
+	{
+	  int len = lstrlenW(lpszPath);
+	  RtlMoveMemory(lpszPath+1, lpszPath, len*sizeof(WCHAR));
+	  *(lpszPath++) = '"';
+	  lpszPath += len;
+	  *(lpszPath++) = '"';
+	  *(lpszPath) = '\0';
+	  return --lpszPath;
+	}
+	return 0;
 }
 
 /*************************************************************************
  * PathQuoteSpacesAW [SHELL32.55]
  */
-LPVOID WINAPI PathQuoteSpacesAW (LPCVOID lpszPath)
+LPVOID WINAPI PathQuoteSpacesAW (LPVOID lpszPath)
 {
 	if(VERSION_OsIsUnicode())
 	  return PathQuoteSpacesW(lpszPath);
@@ -969,6 +1026,8 @@
 	  lpstrComma[0]='\0';
 /*	  return atoi(&lpstrComma[1]);	FIXME */
 	}
+	
+	PathUnquoteSpacesA(lpszPath);
 	return 0;
 }
 
@@ -986,6 +1045,7 @@
 	  lpstrComma[0]='\0';
 /*	  return _wtoi(&lpstrComma[1]);	FIXME */
 	}
+	PathUnquoteSpacesW(lpszPath);
 	return 0;
 }
 
@@ -1092,7 +1152,7 @@
 	  {
 	    if (*(lpszPath++)=='\\') foundbackslash++;
 	  }
-	  if (foundbackslash==1)
+	  if (foundbackslash <= 1)
 	    return TRUE;
 	}
 	return FALSE;
@@ -1122,7 +1182,7 @@
 	  {
 	    if (*(lpszPath++)=='\\') foundbackslash++;
 	  }
-	  if (foundbackslash==1)
+	  if (foundbackslash <= 1)
 	    return TRUE;
 	}
 	return FALSE;
@@ -1480,7 +1540,7 @@
 	while(SupportedProtocol[i])
 	{
 	  if (iSize == strlen(SupportedProtocol[i]))
-	    if(!strncasecmp(lpstrPath, SupportedProtocol[i], iSize));
+	    if(!strncasecmp(lpstrPath, SupportedProtocol[i], iSize))
 	      return TRUE;
 	  i++;
 	}
@@ -1510,7 +1570,7 @@
 	while(SupportedProtocol[i])
 	{
 	  if (iSize == strlenW(SupportedProtocol[i]))
-	    if(!strncmpiW(lpstrPath, SupportedProtocol[i], iSize));
+	    if(!strncmpiW(lpstrPath, SupportedProtocol[i], iSize))
 	      return TRUE;
 	  i++;
 	}
@@ -1987,11 +2047,21 @@
 	}
 	RegCloseKey(hKey);
 
-	if (bCreate && CreateDirectoryA(szPath,NULL))
+	/* if we don't care about existing directorys we are ready */
+	if(csidl & CSIDL_FLAG_DONT_VERIFY) return TRUE;
+
+	if (PathFileExistsA(szPath)) return TRUE;
+
+	/* not existing but we not allowed to create it */
+	if (!bCreate) return FALSE;
+	
+	if (!CreateDirectoryA(szPath,NULL))
 	{
-	    MESSAGE("Created not existing system directory '%s'\n", szPath);
+	  ERR("Failed to create directory '%s'.\n", szPath);
+	  return FALSE;
 	}
 
+	MESSAGE("Created not existing system directory '%s'\n", szPath);
 	return TRUE;
 }
 
@@ -2032,6 +2102,40 @@
 }
 
 /*************************************************************************
+ * SHGetFolderPathA			[SHFOLDER.@]
+ */
+HRESULT SHGetFolderPathA(
+	HWND hwndOwner,
+	int nFolder,
+	HANDLE hToken,	/* FIXME: get paths for specific user */
+	DWORD dwFlags,	/* FIXME: SHGFP_TYPE_CURRENT|SHGFP_TYPE_DEFAULT */
+	LPSTR pszPath)
+{
+	return (SHGetSpecialFolderPathA(
+		hwndOwner,
+		pszPath,
+		CSIDL_FOLDER_MASK & nFolder,
+		CSIDL_FLAG_CREATE & nFolder )) ? S_OK : E_FAIL;
+}
+
+/*************************************************************************
+ * SHGetFolderPathW			[SHFOLDER.@]
+ */
+HRESULT SHGetFolderPathW(
+	HWND hwndOwner,
+	int nFolder,
+	HANDLE hToken,
+	DWORD dwFlags,
+	LPWSTR pszPath)
+{
+	return (SHGetSpecialFolderPathW(
+		hwndOwner,
+		pszPath,
+		CSIDL_FOLDER_MASK & nFolder,
+		CSIDL_FLAG_CREATE & nFolder )) ? S_OK : E_FAIL;
+}
+
+/*************************************************************************
  * PathCanonicalizeA
  *
  *  FIXME
@@ -2178,16 +2282,30 @@
 /*************************************************************************
  * PathFindNextComponentA
  *
- * Windows returns a pointer NULL (BO 000605)
- */
+ * NOTES
+ * special cases:
+ *	""              null
+ *	aa              "" (pointer to traling NULL)
+ *	aa\             "" (pointer to traling NULL)
+ *	aa\\            "" (pointer to traling NULL)
+ *	aa\\bb          bb
+ *	aa\\\bb         \bb
+ *	c:\aa\          "aa\"
+ *	\\aa            aa
+ *	\\aa\b          aa\b
+*/
 LPSTR WINAPI PathFindNextComponentA(LPCSTR pszPath)
 {
-	while( *pszPath )
-	{
-	  if(*pszPath++=='\\')
-	    return (LPSTR) pszPath;
-	}
-	return (LPSTR) pszPath;
+	LPSTR pos;
+
+	TRACE("%s\n", pszPath);
+
+	if(!pszPath || !*pszPath) return NULL;
+	if(!(pos = StrChrA(pszPath, '\\')))
+	  return (LPSTR) pszPath + strlen(pszPath);
+	pos++;
+	if(pos[0] == '\\') pos++;
+	return pos;
 }
 
 /*************************************************************************
@@ -2195,12 +2313,16 @@
  */
 LPWSTR WINAPI PathFindNextComponentW(LPCWSTR pszPath)
 {
-	while( *pszPath )
-	{
-	  if(*pszPath++=='\\')
-	    return (LPWSTR) pszPath;
-	}
-	return (LPWSTR) pszPath;
+	LPWSTR pos;
+
+	TRACE("%s\n", debugstr_w(pszPath));
+	
+	if(!pszPath || !*pszPath) return NULL;
+	if (!(pos = StrChrW(pszPath, '\\')))
+	  return (LPWSTR) pszPath + lstrlenW(pszPath);
+	pos++;
+	if(pos[0] == '\\') pos++;
+	return pos;
 }
 
 /*************************************************************************
@@ -2332,4 +2454,29 @@
 {
 	FIXME("%s\n", debugstr_w(lpPath));
 	return TRUE;
+
+}
+
+/*************************************************************************
+ *	PathCommonPrefixA
+ */
+int WINAPI PathCommonPrefixA(
+	LPCSTR pszFile1,
+	LPCSTR pszFile2,
+	LPSTR achPath)
+{
+	FIXME("%s %s %p\n", pszFile1, pszFile2, achPath);
+	return 0;
+}
+
+/*************************************************************************
+ *	PathCommonPrefixW
+ */
+int WINAPI PathCommonPrefixW(
+	LPCWSTR pszFile1,
+	LPCWSTR pszFile2,
+	LPWSTR achPath)
+{
+	FIXME("%s %s %p\n", debugstr_w(pszFile1), debugstr_w(pszFile2),achPath );
+	return 0;
 }
diff --git a/dlls/shell32/shellstring.c b/dlls/shell32/shellstring.c
index 746c93c..69a5314 100644
--- a/dlls/shell32/shellstring.c
+++ b/dlls/shell32/shellstring.c
@@ -126,7 +126,7 @@
  */
 LPSTR WINAPI StrChrA (LPCSTR str, INT c)
 {
-	TRACE("%s %i stub\n", str,c);
+	TRACE("%s %i\n", str,c);
 	return strchr(str, c);
 }
 
diff --git a/dlls/shell32/shfolder.spec b/dlls/shell32/shfolder.spec
new file mode 100644
index 0000000..08a7a8f
--- /dev/null
+++ b/dlls/shell32/shfolder.spec
@@ -0,0 +1,6 @@
+name shfolder
+type win32
+import advapi32
+
+@ stdcall SHGetFolderPathA(long long long long ptr)SHGetFolderPathA
+@ stdcall SHGetFolderPathW(long long long long ptr)SHGetFolderPathW
diff --git a/dlls/shell32/shlwapi.spec b/dlls/shell32/shlwapi.spec
index 18569e7..d72316e 100644
--- a/dlls/shell32/shlwapi.spec
+++ b/dlls/shell32/shlwapi.spec
@@ -465,8 +465,8 @@
 @ stdcall PathCanonicalizeW (ptr wstr) PathCanonicalizeW
 @ stdcall PathCombineA (ptr ptr ptr) PathCombineA
 @ stdcall PathCombineW (ptr ptr ptr) PathCombineW
-@ stub    PathCommonPrefixA
-@ stub    PathCommonPrefixW
+@ stdcall PathCommonPrefixA(str str ptr)PathCommonPrefixA
+@ stdcall PathCommonPrefixW(wstr wstr ptr)PathCommonPrefixW
 @ stub    PathCompactPathA
 @ stub    PathCompactPathExA
 @ stub    PathCompactPathExW
diff --git a/include/shell.h b/include/shell.h
index bd43f45..df5f509 100644
--- a/include/shell.h
+++ b/include/shell.h
@@ -85,44 +85,9 @@
 DWORD WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv);
 
 /****************************************************************************
-* SHGetSpecialFolderLocation API
-*/
-HRESULT WINAPI SHGetSpecialFolderLocation(HWND, INT, LPITEMIDLIST *);
-
-/****************************************************************************
 *  other functions
 */
 
-#define	CSIDL_DESKTOP		0x0000
-#define	CSIDL_PROGRAMS		0x0002
-#define	CSIDL_CONTROLS		0x0003
-#define	CSIDL_PRINTERS		0x0004
-#define	CSIDL_PERSONAL		0x0005
-#define	CSIDL_FAVORITES		0x0006
-#define	CSIDL_STARTUP		0x0007
-#define	CSIDL_RECENT		0x0008
-#define	CSIDL_SENDTO		0x0009
-#define	CSIDL_BITBUCKET		0x000a
-#define	CSIDL_STARTMENU		0x000b
-#define	CSIDL_DESKTOPDIRECTORY	0x0010
-#define	CSIDL_DRIVES		0x0011
-#define	CSIDL_NETWORK		0x0012
-#define	CSIDL_NETHOOD		0x0013
-#define	CSIDL_FONTS		0x0014
-#define	CSIDL_TEMPLATES		0x0015
-#define CSIDL_COMMON_STARTMENU	0x0016
-#define CSIDL_COMMON_PROGRAMS	0X0017
-#define CSIDL_COMMON_STARTUP	0x0018
-#define CSIDL_COMMON_DESKTOPDIRECTORY	0x0019
-#define CSIDL_APPDATA		0x001a
-#define CSIDL_PRINTHOOD		0x001b
-#define CSIDL_ALTSTARTUP	0x001d
-#define CSIDL_COMMON_ALTSTARTUP	0x001e
-#define CSIDL_COMMON_FAVORITES  0x001f
-#define CSIDL_INTERNET_CACHE	0x0020
-#define CSIDL_COOKIES		0x0021
-#define CSIDL_HISTORY		0x0022
-
 #ifdef __cplusplus
 } /* extern "C" */
 #endif /* defined(__cplusplus) */
diff --git a/include/shlobj.h b/include/shlobj.h
index 075b0bf4..ee8b616 100644
--- a/include/shlobj.h
+++ b/include/shlobj.h
@@ -422,7 +422,64 @@
 void WINAPI SHChangeNotifyW(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2);
 #define  SHChangeNotify WINELIB_NAME_AW(SHChangeNotify)
 
- /**********************************************************************/
+/****************************************************************************
+* SHGetSpecialFolderLocation API
+*/
+HRESULT WINAPI SHGetSpecialFolderLocation(HWND, INT, LPITEMIDLIST *);
+
+#define	CSIDL_DESKTOP		0x0000
+#define CSIDL_INTERNET		0x0001
+#define	CSIDL_PROGRAMS		0x0002
+#define	CSIDL_CONTROLS		0x0003
+#define	CSIDL_PRINTERS		0x0004
+#define	CSIDL_PERSONAL		0x0005
+#define	CSIDL_FAVORITES		0x0006
+#define	CSIDL_STARTUP		0x0007
+#define	CSIDL_RECENT		0x0008
+#define	CSIDL_SENDTO		0x0009
+#define	CSIDL_BITBUCKET		0x000a
+#define	CSIDL_STARTMENU		0x000b
+#define	CSIDL_DESKTOPDIRECTORY	0x0010
+#define	CSIDL_DRIVES		0x0011
+#define	CSIDL_NETWORK		0x0012
+#define	CSIDL_NETHOOD		0x0013
+#define	CSIDL_FONTS		0x0014
+#define	CSIDL_TEMPLATES		0x0015
+#define CSIDL_COMMON_STARTMENU	0x0016
+#define CSIDL_COMMON_PROGRAMS	0X0017
+#define CSIDL_COMMON_STARTUP	0x0018
+#define CSIDL_COMMON_DESKTOPDIRECTORY	0x0019
+#define CSIDL_APPDATA		0x001a
+#define CSIDL_PRINTHOOD		0x001b
+#define CSIDL_ALTSTARTUP	0x001d
+#define CSIDL_COMMON_ALTSTARTUP	0x001e
+#define CSIDL_COMMON_FAVORITES  0x001f
+#define CSIDL_INTERNET_CACHE	0x0020
+#define CSIDL_COOKIES		0x0021
+#define CSIDL_HISTORY		0x0022
+#define CSIDL_COMMON_APPDATA	0x0023
+#define CSIDL_WINDOWS		0x0024
+#define CSIDL_SYSTEM		0x0025
+#define CSIDL_PROGRAM_FILES	0x0026
+#define CSIDL_MYPICTURES	0x0027
+#define CSIDL_PROFILE		0x0028
+#define CSIDL_SYSTEMX86		0x0029
+#define CSIDL_PROGRAM_FILESX86	0x002a
+#define CSIDL_PROGRAM_FILES_COMMON	0x002b
+#define CSIDL_PROGRAM_FILES_COMMONX86	0x002c
+#define CSIDL_COMMON_TEMPLATES	0x002d
+#define CSIDL_COMMON_DOCUMENTS	0x002e
+#define CSIDL_COMMON_ADMINTOOLS	0x002f
+#define CSIDL_ADMINTOOLS	0x0030
+#define CSIDL_CONNECTIONS	0x0031
+#define CSIDL_FOLDER_MASK	0x00ff
+
+#define CSIDL_FLAG_DONT_VERIFY	0x4000
+#define CSIDL_FLAG_CREATE	0x8000
+
+#define CSIDL_FLAG_MASK		0xff00
+
+
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/include/shlwapi.h b/include/shlwapi.h
index 62a0eae..996d863 100644
--- a/include/shlwapi.h
+++ b/include/shlwapi.h
@@ -37,6 +37,10 @@
 BOOL WINAPI PathStripToRootW(LPWSTR pszPath);
 #define PathStripToRoot WINELIB_NAME_AW(PathStripToRoot)
 
+LPSTR WINAPI StrChrA(LPCSTR lpStart, WORD wMatch);
+LPWSTR WINAPI StrChrW(LPCWSTR lpStart, WCHAR wMatch); 
+#define StrChr WINELIB_NAME_AW(StrChr)
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif /* defined(__cplusplus) */
diff --git a/include/wine/undocshell.h b/include/wine/undocshell.h
index a45a7a6..f4ec5f3 100644
--- a/include/wine/undocshell.h
+++ b/include/wine/undocshell.h
@@ -588,10 +588,10 @@
 #define  PathRemoveBlanks WINELIB_NAME_AW(PathRemoveBlanks)
 LPVOID WINAPI PathRemoveBlanksAW(LPVOID lpszPath);
 
-LPSTR  WINAPI PathQuoteSpacesA(LPCSTR path);	
-LPWSTR WINAPI PathQuoteSpacesW(LPCWSTR path);	
+LPSTR  WINAPI PathQuoteSpacesA(LPSTR path);	
+LPWSTR WINAPI PathQuoteSpacesW(LPWSTR path);	
 #define  PathQuoteSpaces WINELIB_NAME_AW(PathQuoteSpaces)
-LPVOID  WINAPI PathQuoteSpacesAW(LPCVOID path);	
+LPVOID  WINAPI PathQuoteSpacesAW(LPVOID path);	
 
 void WINAPI PathUnquoteSpaces(LPSTR lpszPath);
 
diff --git a/loader/loadorder.c b/loader/loadorder.c
index 2a974f1..af7a903 100644
--- a/loader/loadorder.c
+++ b/loader/loadorder.c
@@ -60,6 +60,7 @@
 	{"glide2x",			"so,native"},
 	{"odbc32",			"builtin"},
 	{"opengl32",                    "builtin,native"},
+	{"shfolder",                    "builtin,native"},
 	{NULL,NULL},
 };