shell32: Return Unicode strings from all of the IShellFolder::GetDisplayNameOf functions in not running in Win9x mode.

oldstable
Rob Shearman 2007-04-10 10:20:48 +01:00 committed by Alexandre Julliard
parent 6fb16fca6b
commit 899e2ecff8
3 changed files with 93 additions and 62 deletions

View File

@ -558,7 +558,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
{
IGenericSFImpl *This = (IGenericSFImpl *)iface;
HRESULT hr = S_OK;
WCHAR wszPath[MAX_PATH];
LPWSTR pszPath;
TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
pdump (pidl);
@ -566,13 +566,17 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
if (!strRet)
return E_INVALIDARG;
pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
if (!pszPath)
return E_OUTOFMEMORY;
if (_ILIsDesktop (pidl))
{
if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
(GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
strcpyW(wszPath, This->sPathTarget);
strcpyW(pszPath, This->sPathTarget);
else
HCR_GetClassNameW(&CLSID_ShellDesktop, wszPath, MAX_PATH);
HCR_GetClassNameW(&CLSID_ShellDesktop, pszPath, MAX_PATH);
}
else if (_ILIsPidlSimple (pidl))
{
@ -627,21 +631,21 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
* Only the folder itself can know it
*/
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
wszPath,
pszPath,
MAX_PATH);
}
else
{
/* parsing name like ::{...} */
wszPath[0] = ':';
wszPath[1] = ':';
SHELL32_GUIDToStringW (clsid, &wszPath[2]);
pszPath[0] = ':';
pszPath[1] = ':';
SHELL32_GUIDToStringW (clsid, &pszPath[2]);
}
}
else
{
/* user friendly name */
HCR_GetClassNameW (clsid, wszPath, MAX_PATH);
HCR_GetClassNameW (clsid, pszPath, MAX_PATH);
}
}
else
@ -652,44 +656,43 @@ static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
{
lstrcpynW(wszPath, This->sPathTarget, MAX_PATH - 1);
PathAddBackslashW(wszPath);
cLen = lstrlenW(wszPath);
lstrcpynW(pszPath, This->sPathTarget, MAX_PATH - 1);
PathAddBackslashW(pszPath);
cLen = lstrlenW(pszPath);
}
_ILSimpleGetTextW(pidl, wszPath + cLen, MAX_PATH - cLen);
_ILSimpleGetTextW(pidl, pszPath + cLen, MAX_PATH - cLen);
if (!_ILIsFolder(pidl))
SHELL_FS_ProcessDisplayFilename(wszPath, dwFlags);
SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
}
}
else
{
/* a complex pidl, let the subfolder do the work */
hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
wszPath, MAX_PATH);
pszPath, MAX_PATH);
}
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)
/* Win9x always returns ANSI strings, NT always returns Unicode strings */
if (GetVersion() & 0x80000000)
{
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;
}
strRet->uType = STRRET_CSTR;
if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL))
strRet->u.cStr[0] = '\0';
CoTaskMemFree(pszPath);
}
else
{
strRet->uType = STRRET_WSTR;
strRet->u.pOleStr = pszPath;
}
}
else
CoTaskMemFree(pszPath);
TRACE ("-- (%p)->(%s,0x%08x)\n", This,
strRet->uType == STRRET_CSTR ? strRet->u.cStr :

View File

@ -771,7 +771,7 @@ IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl,
DWORD dwFlags, LPSTRRET strRet)
{
IGenericSFImpl *This = impl_from_IShellFolder2(iface);
WCHAR wszPath[MAX_PATH+1];
LPWSTR pszPath;
HRESULT hr = S_OK;
int len = 0;
@ -782,12 +782,16 @@ IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl,
if (!pidl || !strRet)
return E_INVALIDARG;
pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
if (!pszPath)
return E_OUTOFMEMORY;
if (_ILIsDesktop(pidl)) { /* empty pidl */
if ((GET_SHGDN_FOR(dwFlags) & SHGDN_FORPARSING) &&
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
{
if (This->sPathTarget)
lstrcpynW(wszPath, This->sPathTarget, MAX_PATH);
lstrcpynW(pszPath, This->sPathTarget, MAX_PATH);
} else {
/* pidl has to contain exactly one non null SHITEMID */
hr = E_INVALIDARG;
@ -797,24 +801,32 @@ IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl,
(GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) &&
This->sPathTarget)
{
lstrcpynW(wszPath, This->sPathTarget, MAX_PATH);
PathAddBackslashW(wszPath);
len = lstrlenW(wszPath);
lstrcpynW(pszPath, This->sPathTarget, MAX_PATH);
PathAddBackslashW(pszPath);
len = lstrlenW(pszPath);
}
_ILSimpleGetTextW(pidl, wszPath + len, MAX_PATH + 1 - len);
if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(wszPath, dwFlags);
_ILSimpleGetTextW(pidl, pszPath + len, MAX_PATH + 1 - len);
if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
} else {
hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, wszPath, MAX_PATH);
hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, pszPath, MAX_PATH);
}
if (SUCCEEDED(hr)) {
strRet->uType = STRRET_CSTR;
if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL))
strRet->u.cStr[0] = '\0';
}
/* Win9x always returns ANSI strings, NT always returns Unicode strings */
if (GetVersion() & 0x80000000) {
strRet->uType = STRRET_CSTR;
if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL))
strRet->u.cStr[0] = '\0';
CoTaskMemFree(pszPath);
} else {
strRet->uType = STRRET_WSTR;
strRet->u.pOleStr = pszPath;
}
} else
CoTaskMemFree(pszPath);
TRACE ("-- (%p)->(%s)\n", This, strRet->u.cStr);
TRACE ("-- (%p)->(%s)\n", This, strRet->uType == STRRET_CSTR ? strRet->u.cStr : debugstr_w(strRet->u.pOleStr));
return hr;
}

View File

@ -554,7 +554,7 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
{
IGenericSFImpl *This = (IGenericSFImpl *)iface;
WCHAR wszPath[MAX_PATH];
LPWSTR pszPath;
HRESULT hr = S_OK;
TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
@ -563,14 +563,18 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
if (!strRet)
return E_INVALIDARG;
wszPath[0] = 0;
pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
if (!pszPath)
return E_OUTOFMEMORY;
pszPath[0] = 0;
if (!pidl->mkid.cb)
{
/* parsing name like ::{...} */
wszPath[0] = ':';
wszPath[1] = ':';
SHELL32_GUIDToStringW(&CLSID_MyComputer, &wszPath[2]);
pszPath[0] = ':';
pszPath[1] = ':';
SHELL32_GUIDToStringW(&CLSID_MyComputer, &pszPath[2]);
}
else if (_ILIsPidlSimple(pidl))
{
@ -622,11 +626,11 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
* Only the folder itself can know it
*/
hr = SHELL32_GetDisplayNameOfChild (iface, pidl,
dwFlags, wszPath, MAX_PATH);
dwFlags, pszPath, MAX_PATH);
}
else
{
LPWSTR p = wszPath;
LPWSTR p = pszPath;
/* parsing name like ::{...} */
p[0] = ':';
@ -645,18 +649,18 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
else
{
/* user friendly name */
HCR_GetClassNameW (clsid, wszPath, MAX_PATH);
HCR_GetClassNameW (clsid, pszPath, MAX_PATH);
}
}
else
{
/* append my own path */
_ILSimpleGetTextW (pidl, wszPath, MAX_PATH);
_ILSimpleGetTextW (pidl, pszPath, MAX_PATH);
}
}
else if (_ILIsDrive(pidl))
{
_ILSimpleGetTextW (pidl, wszPath, MAX_PATH); /* append my own path */
_ILSimpleGetTextW (pidl, pszPath, MAX_PATH); /* append my own path */
/* long view "lw_name (C:)" */
if (!(dwFlags & SHGDN_FORPARSING))
@ -666,14 +670,14 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
static const WCHAR wszOpenBracket[] = {' ','(',0};
static const WCHAR wszCloseBracket[] = {')',0};
GetVolumeInformationW (wszPath, wszDrive,
GetVolumeInformationW (pszPath, wszDrive,
sizeof(wszDrive)/sizeof(wszDrive[0]) - 6,
&dwVolumeSerialNumber,
&dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0);
strcatW (wszDrive, wszOpenBracket);
lstrcpynW (wszDrive + strlenW(wszDrive), wszPath, 3);
lstrcpynW (wszDrive + strlenW(wszDrive), pszPath, 3);
strcatW (wszDrive, wszCloseBracket);
strcpyW (wszPath, wszDrive);
strcpyW (pszPath, wszDrive);
}
}
else
@ -686,18 +690,30 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
else
{
/* Complex pidl. Let the child folder do the work */
hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, wszPath, MAX_PATH);
hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, pszPath, MAX_PATH);
}
if (SUCCEEDED (hr))
{
strRet->uType = STRRET_CSTR;
if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL))
strRet->u.cStr[0] = '\0';
/* Win9x always returns ANSI strings, NT always returns Unicode strings */
if (GetVersion() & 0x80000000)
{
strRet->uType = STRRET_CSTR;
if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
NULL, NULL))
strRet->u.cStr[0] = '\0';
CoTaskMemFree(pszPath);
}
else
{
strRet->uType = STRRET_WSTR;
strRet->u.pOleStr = pszPath;
}
}
else
CoTaskMemFree(pszPath);
TRACE ("-- (%p)->(%s)\n", This, debugstr_w(wszPath));
TRACE ("-- (%p)->(%s)\n", This, strRet->uType == STRRET_CSTR ? strRet->u.cStr : debugstr_w(strRet->u.pOleStr));
return hr;
}