[SHELL32]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 27 Sep 2015 10:52:10 +0000 (10:52 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 27 Sep 2015 10:52:10 +0000 (10:52 +0000)
- Fix SH_ParseGuidDisplayName which was completely broken when I committed it.
- Use GUIDFromStringW instead of SHCLSIDFromStringW in _ILCreateGuidFromStrW. The latter needs the string to terminate right after the guid.

svn path=/trunk/; revision=69369

reactos/dll/win32/shell32/shfldr.h
reactos/dll/win32/shell32/shlfolder.cpp
reactos/dll/win32/shell32/wine/pidl.c
reactos/include/reactos/undocshell.h

index e6ed07f..8169c74 100644 (file)
@@ -66,7 +66,7 @@ HRESULT SHELL32_SetNameOfGuidItem(PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD
 
 HRESULT SHELL32_GetDetailsOfGuidItem(IShellFolder2* psf, PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd);
 
-HRESULT SH_ParseGuidDisplayName(IShellFolder * pFolder,
+HRESULT SH_ParseGuidDisplayName(IShellFolder2 * pFolder,
                                 HWND hwndOwner,
                                 LPBC pbc,
                                 LPOLESTR lpszDisplayName,
index e3a28fb..5aaaa14 100644 (file)
@@ -682,7 +682,7 @@ HRESULT SHELL32_CompareIDs(IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pi
     return nReturn;
 }
 
-HRESULT SH_ParseGuidDisplayName(IShellFolder * pFolder,
+HRESULT SH_ParseGuidDisplayName(IShellFolder2 * pFolder,
                                 HWND hwndOwner,
                                 LPBC pbc,
                                 LPOLESTR lpszDisplayName,
@@ -701,17 +701,14 @@ HRESULT SH_ParseGuidDisplayName(IShellFolder * pFolder,
         *pchEaten = 0;
 
     UINT cch = wcslen(lpszDisplayName);
-    if (cch < 40)
-        return E_FAIL;
-
-    if (lpszDisplayName[0] != L':' || lpszDisplayName[1] != L':' || lpszDisplayName[2] != L'{' || lpszDisplayName[40] != L'}')
+    if (cch < 39 || lpszDisplayName[0] != L':' || lpszDisplayName[1] != L':')
         return E_FAIL;
 
     pidl = _ILCreateGuidFromStrW(lpszDisplayName + 2);
     if (pidl == NULL)
         return E_FAIL;
 
-    if (cch < 42)
+    if (cch < 41)
     {
         *ppidl = pidl;
         if (pdwAttributes && *pdwAttributes)
@@ -721,15 +718,12 @@ HRESULT SH_ParseGuidDisplayName(IShellFolder * pFolder,
     }
     else
     {
-        IShellFolder* psf;
-        LPITEMIDLIST pidlChild;
-        HRESULT hres;
-
-        hres = SHELL32_BindToGuidItem(NULL, pidl, NULL, IID_PPV_ARG(IShellFolder, &psf));
-        if (SUCCEEDED(hres))
+        HRESULT hr = SHELL32_ParseNextElement(pFolder, hwndOwner, pbc, &pidl, lpszDisplayName + 41, pchEaten, pdwAttributes);
+        if (SUCCEEDED(hr))
         {
-            return psf->ParseDisplayName(hwndOwner, pbc, lpszDisplayName + 42, pchEaten, &pidlChild, pdwAttributes);
+            *ppidl = pidl;
         }
+        return hr;
     }
 
     return S_OK;
index 6da0037..4ccf2b0 100644 (file)
@@ -1654,6 +1654,7 @@ LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid)
     return pidlOut;
 }
 
+#ifndef __REACTOS__
 LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID)
 {
     IID iid;
@@ -1665,12 +1666,17 @@ LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID)
     }
     return _ILCreateGuid(PT_GUID, &iid);
 }
+#endif
 
 LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID)
 {
     IID iid;
 
+#ifndef __REACTOS__
     if (FAILED(SHCLSIDFromStringW(szGUID, &iid)))
+#else
+    if (!GUIDFromStringW(szGUID, &iid))
+#endif
     {
         ERR("%s is not a GUID\n", debugstr_w(szGUID));
         return NULL;
index 5b91a4c..86cbcd6 100644 (file)
@@ -550,6 +550,11 @@ INT WINAPI Shell_GetCachedImageIndex(LPCWSTR szPath, INT nIndex, UINT bSimulateD
 
 HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv);
 
+BOOL WINAPI GUIDFromStringW(
+    _In_   PCWSTR psz,
+    _Out_  LPGUID pguid
+    );
+    
 static inline ULONG
 Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
 {