Robert Shearman : shell: Convert SHELL32_GetDisplayNameOfChild to unicode.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 16 14:38:06 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 50c1e46d18089118c522fe13da34fc85559b1ad5
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=50c1e46d18089118c522fe13da34fc85559b1ad5

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon Jan 16 21:31:10 2006 +0100

shell: Convert SHELL32_GetDisplayNameOfChild to unicode.

---

 dlls/shell32/cpanelfolder.c   |   13 ++++++++-----
 dlls/shell32/shfldr.h         |    2 +-
 dlls/shell32/shfldr_desktop.c |   18 ++++++++++++++++--
 dlls/shell32/shfldr_fs.c      |    8 +++++++-
 dlls/shell32/shfldr_mycomp.c  |   18 ++++++++++++++++--
 dlls/shell32/shlfolder.c      |    6 +++---
 6 files changed, 51 insertions(+), 14 deletions(-)

diff --git a/dlls/shell32/cpanelfolder.c b/dlls/shell32/cpanelfolder.c
index cbac65a..878e6d8 100644
--- a/dlls/shell32/cpanelfolder.c
+++ b/dlls/shell32/cpanelfolder.c
@@ -652,7 +652,8 @@ static HRESULT WINAPI ISF_ControlPanel_f
 {
     ICPanelImpl *This = (ICPanelImpl *)iface;
 
-    CHAR szPath[MAX_PATH*2];
+    CHAR szPath[MAX_PATH];
+    WCHAR wszPath[MAX_PATH+1]; /* +1 for potential backslash */
     PIDLCPanelStruct* pcpanel;
 
     *szPath = '\0';
@@ -676,7 +677,7 @@ static HRESULT WINAPI ISF_ControlPanel_f
 	BOOL bSimplePidl = _ILIsPidlSimple(pidl);
 
 	if (bSimplePidl) {
-	    _ILSimpleGetText(pidl, szPath, MAX_PATH);	/* append my own path */
+	    _ILSimpleGetTextW(pidl, wszPath, MAX_PATH);	/* append my own path */
 	} else {
 	    FIXME("special pidl\n");
 	}
@@ -684,12 +685,14 @@ static HRESULT WINAPI ISF_ControlPanel_f
 	if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */
 	    int len = 0;
 
-	    PathAddBackslashA(szPath); /*FIXME*/
-	    len = lstrlenA(szPath);
+	    PathAddBackslashW(wszPath);
+	    len = lstrlenW(wszPath);
 
 	    if (!SUCCEEDED
-	      (SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len)))
+	      (SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, wszPath + len, MAX_PATH + 1 - len)))
 		return E_OUTOFMEMORY;
+	    if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL))
+		wszPath[0] = '\0';
 	}
     }
 
diff --git a/dlls/shell32/shfldr.h b/dlls/shell32/shfldr.h
index e626255..ed474b2 100644
--- a/dlls/shell32/shfldr.h
+++ b/dlls/shell32/shfldr.h
@@ -39,7 +39,7 @@ LPCWSTR GetNextElementW (LPCWSTR pszNext
 HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc, LPITEMIDLIST * pidlInOut,
 				  LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes);
 HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWORD pdwAttributes);
-HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTR szOut,
+HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf, LPCITEMIDLIST pidl, DWORD dwFlags, LPWSTR szOut,
 				       DWORD dwOutLen);
 
 HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c
index 09d6270..3dd637d 100644
--- a/dlls/shell32/shfldr_desktop.c
+++ b/dlls/shell32/shfldr_desktop.c
@@ -562,6 +562,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetD
 {
     IGenericSFImpl *This = (IGenericSFImpl *)iface;
     HRESULT hr = S_OK;
+    WCHAR wszPath[MAX_PATH];
 
     TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
     pdump (pidl);
@@ -645,13 +646,20 @@ static HRESULT WINAPI ISF_Desktop_fnGetD
                 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
                      bWantsForParsing)
                 {
+                    WCHAR wszPath[MAX_PATH];
                     /*
                      * we need the filesystem path to the destination folder.
                      * Only the folder itself can know it
                      */
                     hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
-                                                        strRet->u.cStr,
+                                                        wszPath,
                                                         MAX_PATH);
+                    if (SUCCEEDED(hr))
+                    {
+                        if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
+                                                 NULL, NULL))
+                            wszPath[0] = '\0';
+                    }
                 }
                 else
                 {
@@ -690,7 +698,13 @@ static HRESULT WINAPI ISF_Desktop_fnGetD
     {
         /* a complex pidl, let the subfolder do the work */
         hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
-         strRet->u.cStr, MAX_PATH);
+                                            wszPath, MAX_PATH);
+        if (SUCCEEDED(hr))
+        {
+            if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
+                                     NULL, NULL))
+                wszPath[0] = '\0';
+        }
     }
 
     TRACE ("-- (%p)->(%s,0x%08lx)\n", This,
diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c
index 53d8231..fb89688 100644
--- a/dlls/shell32/shfldr_fs.c
+++ b/dlls/shell32/shfldr_fs.c
@@ -816,7 +816,13 @@ IShellFolder_fnGetDisplayNameOf (IShellF
         _ILSimpleGetText(pidl, strRet->u.cStr + len, MAX_PATH - len);
         if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(strRet->u.cStr, dwFlags);
     } else {
-        hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, strRet->u.cStr, MAX_PATH);
+        WCHAR wszPath[MAX_PATH];
+        hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, wszPath, MAX_PATH);
+        if (SUCCEEDED(hr)) {
+            if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
+                                     NULL, NULL))
+                wszPath[0] = '\0';
+        }
     }
 
     TRACE ("-- (%p)->(%s)\n", This, strRet->u.cStr);
diff --git a/dlls/shell32/shfldr_mycomp.c b/dlls/shell32/shfldr_mycomp.c
index b9b51b7..176b8ae 100644
--- a/dlls/shell32/shfldr_mycomp.c
+++ b/dlls/shell32/shfldr_mycomp.c
@@ -617,12 +617,19 @@ static HRESULT WINAPI ISF_MyComputer_fnG
                     if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
                         bWantsForParsing)
                     {
+                        WCHAR wszPath[MAX_PATH];
                         /*
                          * We need the filesystem path to the destination folder
                          * Only the folder itself can know it
                          */
                         hr = SHELL32_GetDisplayNameOfChild (iface, pidl,
-                                                dwFlags, szPath, MAX_PATH);
+                                                dwFlags, wszPath, MAX_PATH);
+                        if (SUCCEEDED(hr))
+                        {
+                            if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH,
+                                                     NULL, NULL))
+                                wszPath[0] = '\0';
+                        }
                     }
                     else
                     {
@@ -677,9 +684,16 @@ static HRESULT WINAPI ISF_MyComputer_fnG
     }
     else
     {
+        WCHAR wszPath[MAX_PATH];
         /* Complex pidl. Let the child folder do the work */
         strRet->uType = STRRET_CSTR;
-        hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, szPath, MAX_PATH);
+        hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, wszPath, MAX_PATH);
+        if (SUCCEEDED(hr))
+        {
+            if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH,
+                                     NULL, NULL))
+                wszPath[0] = '\0';
+        }
     }
 
     if (SUCCEEDED (hr))
diff --git a/dlls/shell32/shlfolder.c b/dlls/shell32/shlfolder.c
index d033b2a..09e46f1 100644
--- a/dlls/shell32/shlfolder.c
+++ b/dlls/shell32/shlfolder.c
@@ -331,7 +331,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLI
  * virtual folders with the registry key WantsFORPARSING set.
  */
 HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf,
-				       LPCITEMIDLIST pidl, DWORD dwFlags, LPSTR szOut, DWORD dwOutLen)
+				       LPCITEMIDLIST pidl, DWORD dwFlags, LPWSTR szOut, DWORD dwOutLen)
 {
     LPITEMIDLIST pidlFirst;
     HRESULT hr = E_INVALIDARG;
@@ -350,7 +350,7 @@ HRESULT SHELL32_GetDisplayNameOfChild (I
 
 	    hr = IShellFolder_GetDisplayNameOf (psfChild, pidlNext, dwFlags, &strTemp);
 	    if (SUCCEEDED (hr)) {
-		hr = StrRetToStrNA (szOut, dwOutLen, &strTemp, pidlNext);
+		hr = StrRetToStrNW (szOut, dwOutLen, &strTemp, pidlNext);
 	    }
 	    IShellFolder_Release (psfChild);
 	}
@@ -358,7 +358,7 @@ HRESULT SHELL32_GetDisplayNameOfChild (I
     } else
 	hr = E_OUTOFMEMORY;
 
-    TRACE ("-- ret=0x%08lx %s\n", hr, szOut);
+    TRACE ("-- ret=0x%08lx %s\n", hr, debugstr_w(szOut));
 
     return hr;
 }




More information about the wine-cvs mailing list