From 50c1e46d18089118c522fe13da34fc85559b1ad5 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Mon, 16 Jan 2006 21:31:10 +0100 Subject: [PATCH] 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 cbac65ab3a9..878e6d8d949 100644 --- a/dlls/shell32/cpanelfolder.c +++ b/dlls/shell32/cpanelfolder.c @@ -652,7 +652,8 @@ static HRESULT WINAPI ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2 * iface, { 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_fnGetDisplayNameOf(IShellFolder2 * iface, 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_fnGetDisplayNameOf(IShellFolder2 * iface, 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 e626255c52a..ed474b2c6b6 100644 --- a/dlls/shell32/shfldr.h +++ b/dlls/shell32/shfldr.h @@ -39,7 +39,7 @@ LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut); 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 09d62701736..3dd637dcbe3 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -562,6 +562,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface, { 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_fnGetDisplayNameOf (IShellFolder2 * iface, 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_fnGetDisplayNameOf (IShellFolder2 * iface, { /* 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 53d823147e9..fb896888c2f 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -816,7 +816,13 @@ IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, _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 b9b51b7c05f..176b8ae5337 100644 --- a/dlls/shell32/shfldr_mycomp.c +++ b/dlls/shell32/shfldr_mycomp.c @@ -617,12 +617,19 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface, 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_fnGetDisplayNameOf (IShellFolder2 *iface, } 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 d033b2a298a..09e46f1aa17 100644 --- a/dlls/shell32/shlfolder.c +++ b/dlls/shell32/shlfolder.c @@ -331,7 +331,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, * 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 (IShellFolder2 * psf, 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 (IShellFolder2 * psf, } else hr = E_OUTOFMEMORY; - TRACE ("-- ret=0x%08lx %s\n", hr, szOut); + TRACE ("-- ret=0x%08lx %s\n", hr, debugstr_w(szOut)); return hr; }