shell32: Convert ISF_Desktop_fnGetDisplayNameOf to Unicode.

oldstable
Robert Shearman 2006-06-19 20:27:13 +01:00 committed by Alexandre Julliard
parent db8169b828
commit 6c4c4e3515
1 changed files with 25 additions and 39 deletions

View File

@ -570,33 +570,13 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
if (!strRet) if (!strRet)
return E_INVALIDARG; return E_INVALIDARG;
strRet->uType = STRRET_CSTR;
if (_ILIsDesktop (pidl)) if (_ILIsDesktop (pidl))
{ {
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
(GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)) (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
{ strcpyW(wszPath, This->sPathTarget);
BOOL defCharUsed;
WideCharToMultiByte( CP_ACP, 0, This->sPathTarget, -1,
strRet->u.cStr, MAX_PATH, NULL, &defCharUsed );
if (defCharUsed)
{
strRet->u.pOleStr = SHAlloc((lstrlenW(This->sPathTarget)+1) *
sizeof(WCHAR));
if (!strRet->u.pOleStr)
hr = E_OUTOFMEMORY;
else
{
strcpyW(strRet->u.pOleStr, This->sPathTarget);
strRet->uType = STRRET_WSTR;
}
}
}
else else
{ HCR_GetClassNameW(&CLSID_ShellDesktop, wszPath, MAX_PATH);
HCR_GetClassNameA(&CLSID_ShellDesktop, strRet->u.cStr, MAX_PATH);
}
} }
else if (_ILIsPidlSimple (pidl)) else if (_ILIsPidlSimple (pidl))
{ {
@ -646,7 +626,6 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
bWantsForParsing) bWantsForParsing)
{ {
WCHAR wszPath[MAX_PATH];
/* /*
* we need the filesystem path to the destination folder. * we need the filesystem path to the destination folder.
* Only the folder itself can know it * Only the folder itself can know it
@ -654,24 +633,19 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
wszPath, wszPath,
MAX_PATH); MAX_PATH);
if (SUCCEEDED(hr))
{
if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL))
wszPath[0] = '\0';
}
} }
else else
{ {
/* parsing name like ::{...} */ /* parsing name like ::{...} */
lstrcpyA (strRet->u.cStr, "::"); wszPath[0] = ':';
SHELL32_GUIDToStringA (clsid, &strRet->u.cStr[2]); wszPath[1] = ':';
SHELL32_GUIDToStringW (clsid, &wszPath[2]);
} }
} }
else else
{ {
/* user friendly name */ /* user friendly name */
HCR_GetClassNameA (clsid, strRet->u.cStr, MAX_PATH); HCR_GetClassNameW (clsid, wszPath, MAX_PATH);
} }
} }
else else
@ -691,9 +665,6 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
if (!_ILIsFolder(pidl)) if (!_ILIsFolder(pidl))
SHELL_FS_ProcessDisplayFilename(wszPath, dwFlags); SHELL_FS_ProcessDisplayFilename(wszPath, dwFlags);
WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL);
} }
} }
else else
@ -701,11 +672,26 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
/* a complex pidl, let the subfolder do the work */ /* a complex pidl, let the subfolder do the work */
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
wszPath, MAX_PATH); wszPath, MAX_PATH);
if (SUCCEEDED(hr)) }
if (SUCCEEDED(hr))
{
BOOL defCharUsed;
strRet->uType = STRRET_CSTR;
if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, &defCharUsed))
strRet->u.cStr[0] = '\0';
if (defCharUsed)
{ {
if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH, strRet->u.pOleStr = SHAlloc((lstrlenW(This->sPathTarget)+1) *
NULL, NULL)) sizeof(WCHAR));
wszPath[0] = '\0'; if (!strRet->u.pOleStr)
hr = E_OUTOFMEMORY;
else
{
strcpyW(strRet->u.pOleStr, This->sPathTarget);
strRet->uType = STRRET_WSTR;
}
} }
} }