diff --git a/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp b/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp index 48f2435fe63..fb1b12b1d1b 100644 --- a/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp +++ b/reactos/dll/shellext/ntobjshex/ntobjfolder.cpp @@ -651,52 +651,57 @@ HRESULT STDMETHODCALLTYPE CNtObjectFolder::GetDisplayNameOf( if (FAILED_UNEXPECTEDLY(hr)) return hr; - if ((GET_SHGDN_RELATION(uFlags) == SHGDN_NORMAL) && - (GET_SHGDN_FOR(uFlags) & SHGDN_FORPARSING)) + if (GET_SHGDN_FOR(uFlags) & SHGDN_FOREDITING) { - WCHAR path[MAX_PATH] = { 0 }; - - hr = GetFullName(m_shellPidl, uFlags, path, _countof(path)); + hr = MakeStrRetFromString(info->entryName, info->entryNameLength, lpName); if (FAILED_UNEXPECTEDLY(hr)) return hr; + } - PathAppendW(path, info->entryName); + WCHAR path[MAX_PATH] = { 0 }; - hr = MakeStrRetFromString(path, lpName); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - LPCITEMIDLIST pidlFirst = ILCloneFirst(pidl); - LPCITEMIDLIST pidlNext = ILGetNext(pidl); - - if (pidlNext && pidlNext->mkid.cb > 0) + if (GET_SHGDN_FOR(uFlags) & SHGDN_FORPARSING) + { + if (GET_SHGDN_RELATION(uFlags) != SHGDN_INFOLDER) { - CComPtr psfChild; - hr = BindToObject(pidlFirst, NULL, IID_PPV_ARG(IShellFolder, &psfChild)); + hr = GetFullName(m_shellPidl, uFlags, path, _countof(path)); if (FAILED_UNEXPECTEDLY(hr)) return hr; - - WCHAR temp[MAX_PATH]; - STRRET childName; - - hr = psfChild->GetDisplayNameOf(pidlNext, uFlags | SHGDN_INFOLDER, &childName); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - hr = StrRetToBufW(&childName, pidlNext, temp, _countof(temp)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - PathAppendW(path, temp); } + } - ILFree((LPITEMIDLIST) pidlFirst); - } - else + PathAppendW(path, info->entryName); + + LPCITEMIDLIST pidlNext = ILGetNext(pidl); + if (pidlNext && pidlNext->mkid.cb > 0) { - MakeStrRetFromString(info->entryName, info->entryNameLength, lpName); + LPITEMIDLIST pidlFirst = ILCloneFirst(pidl); + + CComPtr psfChild; + hr = BindToObject(pidlFirst, NULL, IID_PPV_ARG(IShellFolder, &psfChild)); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + WCHAR temp[MAX_PATH]; + STRRET childName; + + hr = psfChild->GetDisplayNameOf(pidlNext, uFlags | SHGDN_INFOLDER, &childName); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + hr = StrRetToBufW(&childName, pidlNext, temp, _countof(temp)); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + PathAppendW(path, temp); + + ILFree(pidlFirst); } + hr = MakeStrRetFromString(path, lpName); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + return S_OK; } diff --git a/reactos/dll/shellext/ntobjshex/regfolder.cpp b/reactos/dll/shellext/ntobjshex/regfolder.cpp index bce65feadc3..6a688c10349 100644 --- a/reactos/dll/shellext/ntobjshex/regfolder.cpp +++ b/reactos/dll/shellext/ntobjshex/regfolder.cpp @@ -706,52 +706,57 @@ HRESULT STDMETHODCALLTYPE CRegistryFolder::GetDisplayNameOf( if (FAILED_UNEXPECTEDLY(hr)) return hr; - if ((GET_SHGDN_RELATION(uFlags) == SHGDN_NORMAL) && - (GET_SHGDN_FOR(uFlags) & SHGDN_FORPARSING)) + if (GET_SHGDN_FOR(uFlags) & SHGDN_FOREDITING) { - WCHAR path[MAX_PATH] = { 0 }; - - hr = GetFullName(m_shellPidl, uFlags, path, _countof(path)); + hr = MakeStrRetFromString(info->entryName, info->entryNameLength, lpName); if (FAILED_UNEXPECTEDLY(hr)) return hr; + } - PathAppendW(path, info->entryName); + WCHAR path[MAX_PATH] = { 0 }; - hr = MakeStrRetFromString(path, lpName); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - LPCITEMIDLIST pidlFirst = ILCloneFirst(pidl); - LPCITEMIDLIST pidlNext = ILGetNext(pidl); - - if (pidlNext && pidlNext->mkid.cb > 0) + if (GET_SHGDN_FOR(uFlags) & SHGDN_FORPARSING) + { + if (GET_SHGDN_RELATION(uFlags) != SHGDN_INFOLDER) { - CComPtr psfChild; - hr = BindToObject(pidlFirst, NULL, IID_PPV_ARG(IShellFolder, &psfChild)); + hr = GetFullName(m_shellPidl, uFlags, path, _countof(path)); if (FAILED_UNEXPECTEDLY(hr)) return hr; - - WCHAR temp[MAX_PATH]; - STRRET childName; - - hr = psfChild->GetDisplayNameOf(pidlNext, uFlags | SHGDN_INFOLDER, &childName); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - hr = StrRetToBufW(&childName, pidlNext, temp, _countof(temp)); - if (FAILED_UNEXPECTEDLY(hr)) - return hr; - - PathAppendW(path, temp); } + } - ILFree((LPITEMIDLIST) pidlFirst); - } - else + PathAppendW(path, info->entryName); + + LPCITEMIDLIST pidlNext = ILGetNext(pidl); + if (pidlNext && pidlNext->mkid.cb > 0) { - MakeStrRetFromString(info->entryName, info->entryNameLength, lpName); + LPITEMIDLIST pidlFirst = ILCloneFirst(pidl); + + CComPtr psfChild; + hr = BindToObject(pidlFirst, NULL, IID_PPV_ARG(IShellFolder, &psfChild)); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + WCHAR temp[MAX_PATH]; + STRRET childName; + + hr = psfChild->GetDisplayNameOf(pidlNext, uFlags | SHGDN_INFOLDER, &childName); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + hr = StrRetToBufW(&childName, pidlNext, temp, _countof(temp)); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + + PathAppendW(path, temp); + + ILFree(pidlFirst); } + hr = MakeStrRetFromString(path, lpName); + if (FAILED_UNEXPECTEDLY(hr)) + return hr; + return S_OK; }