https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cca9acfa1d9d2bf258f34ea89b210d5e8fb0563d
commit cca9acfa1d9d2bf258f34ea89b210d5e8fb0563d Author: Whindmar Saksit <whinds...@proton.me> AuthorDate: Sat Aug 24 19:01:27 2024 +0200 Commit: GitHub <nore...@github.com> CommitDate: Sat Aug 24 19:01:27 2024 +0200 [SHELL32] Create link must ask for a parsing name for file targets (#7267) --- dll/win32/shell32/droptargets/CFSDropTarget.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dll/win32/shell32/droptargets/CFSDropTarget.cpp b/dll/win32/shell32/droptargets/CFSDropTarget.cpp index f7694320f57..00c056acd8e 100644 --- a/dll/win32/shell32/droptargets/CFSDropTarget.cpp +++ b/dll/win32/shell32/droptargets/CFSDropTarget.cpp @@ -588,12 +588,19 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject, /* We need to create a link for each pidl in the copied items, so step through the pidls from the clipboard */ for (UINT i = 0; i < lpcida->cidl; i++) { + SFGAOF att = SHGetAttributes(psfFrom, apidl[i], SFGAO_FOLDER | SFGAO_STREAM | SFGAO_FILESYSTEM); CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlFull; hr = SHILCombine(pidl, apidl[i], &pidlFull); WCHAR targetName[MAX_PATH]; if (SUCCEEDED(hr)) - hr = Shell_DisplayNameOf(psfFrom, apidl[i], SHGDN_FOREDITING | SHGDN_INFOLDER, targetName, _countof(targetName)); + { + // If the target is a file, we use SHGDN_FORPARSING because "NeverShowExt" will hide the ".lnk" extension. + // If the target is a virtual item, we ask for the friendly name because SHGDN_FORPARSING will return a GUID. + BOOL UseParsing = (att & (SFGAO_FILESYSTEM | SFGAO_FOLDER)) == SFGAO_FILESYSTEM; + DWORD ShgdnFor = UseParsing ? SHGDN_FORPARSING : SHGDN_FOREDITING; + hr = Shell_DisplayNameOf(psfFrom, apidl[i], ShgdnFor | SHGDN_INFOLDER, targetName, _countof(targetName)); + } if (FAILED_UNEXPECTEDLY(hr)) { SHELL_ErrorBox(m_hwndSite, hr); @@ -605,7 +612,6 @@ HRESULT CFSDropTarget::_DoDrop(IDataObject *pDataObject, PathCombineW(wszCombined, m_sPathTarget, targetName); // Check to see if the source is a link - SFGAOF att = SHGetAttributes(psfFrom, apidl[i], SFGAO_FOLDER | SFGAO_STREAM | SFGAO_FILESYSTEM); BOOL fSourceIsLink = FALSE; if (!wcsicmp(PathFindExtensionW(targetName), L".lnk") && (att & (SFGAO_FOLDER | SFGAO_STREAM)) != SFGAO_FOLDER) {