mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[SHELL32] RegFolder must correctly handle GetDisplayNameOf parsing paths (#6265)
This commit is contained in:
parent
7c2e8c67f1
commit
55a5d7a177
1 changed files with 32 additions and 8 deletions
|
@ -641,7 +641,8 @@ HRESULT WINAPI CRegFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
|
|||
}
|
||||
|
||||
/* Allocate the buffer for the result */
|
||||
LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
|
||||
SIZE_T cchPath = MAX_PATH + 1;
|
||||
LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc(cchPath * sizeof(WCHAR));
|
||||
if (!pszPath)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
|
@ -649,18 +650,41 @@ HRESULT WINAPI CRegFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags,
|
|||
|
||||
if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)
|
||||
{
|
||||
wcscpy(pszPath, m_rootPath);
|
||||
PWCHAR pItemName = &pszPath[wcslen(pszPath)];
|
||||
SIZE_T pathlen = 0;
|
||||
PWCHAR pItemName = pszPath; // GET_SHGDN_RELATION(dwFlags) == SHGDN_INFOLDER
|
||||
if (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)
|
||||
{
|
||||
hr = StringCchCopyW(pszPath, cchPath, m_rootPath);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
pathlen = wcslen(pszPath);
|
||||
pItemName = &pszPath[pathlen];
|
||||
if (pathlen)
|
||||
{
|
||||
if (++pathlen < cchPath)
|
||||
*pItemName++ = L'\\';
|
||||
else
|
||||
hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* parsing name like ::{...} */
|
||||
pItemName[0] = ':';
|
||||
pItemName[1] = ':';
|
||||
SHELL32_GUIDToStringW (*clsid, &pItemName[2]);
|
||||
if (SUCCEEDED(hr) && pathlen + 2 + 38 + 1 < cchPath)
|
||||
{
|
||||
/* parsing name like ::{...} */
|
||||
pItemName[0] = L':';
|
||||
pItemName[1] = L':';
|
||||
SHELL32_GUIDToStringW(*clsid, &pItemName[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* user friendly name */
|
||||
if (!HCR_GetClassNameW (*clsid, pszPath, MAX_PATH))
|
||||
if (!HCR_GetClassNameW(*clsid, pszPath, cchPath))
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue