mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[SENDMAIL] Fix Send To -> Desktop (create shortcut) behavior (#4913)
Several fixes and improvements to the CDeskLinkDropHandler: - Set default working directory for shortcuts (except folders and zip files) - Copy existing shortcut to the desktop if the source file is a shortcut - Prevent destination file name collision Verified on Windows XP SP3 and Windows 7 SP1.
This commit is contained in:
parent
feff2b1e6c
commit
7c2b22c4de
1 changed files with 41 additions and 6 deletions
|
@ -85,6 +85,19 @@ CDeskLinkDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState,
|
||||||
|
|
||||||
StringCbCopyW(szDest, sizeof(szDest), szDir);
|
StringCbCopyW(szDest, sizeof(szDest), szDir);
|
||||||
if (SHGetPathFromIDListW(pidl, szSrc))
|
if (SHGetPathFromIDListW(pidl, szSrc))
|
||||||
|
{
|
||||||
|
LPCWSTR pszSourceExt;
|
||||||
|
BOOL bIsLink;
|
||||||
|
|
||||||
|
pszSourceExt = PathFindExtensionW(szSrc);
|
||||||
|
bIsLink = ((_wcsicmp(pszSourceExt, L".lnk") == 0) ||
|
||||||
|
(_wcsicmp(pszSourceExt, L".url") == 0));
|
||||||
|
|
||||||
|
if (bIsLink)
|
||||||
|
{
|
||||||
|
PathAppendW(szDest, PathFindFileNameW(szSrc));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
CStringW strTitle;
|
CStringW strTitle;
|
||||||
strTitle.Format(IDS_SHORTCUT, PathFindFileNameW(szSrc));
|
strTitle.Format(IDS_SHORTCUT, PathFindFileNameW(szSrc));
|
||||||
|
@ -92,10 +105,32 @@ CDeskLinkDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState,
|
||||||
PathAppendW(szDest, strTitle);
|
PathAppendW(szDest, strTitle);
|
||||||
PathRemoveExtensionW(szDest);
|
PathRemoveExtensionW(szDest);
|
||||||
StringCbCatW(szDest, sizeof(szDest), L".lnk");
|
StringCbCatW(szDest, sizeof(szDest), L".lnk");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PathFileExistsW(szDest))
|
||||||
|
{
|
||||||
|
CStringW strName(PathFindFileNameW(szDest));
|
||||||
|
PathYetAnotherMakeUniqueName(szDest, szDir, NULL, strName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bIsLink)
|
||||||
|
{
|
||||||
|
hr = (CopyFileW(szSrc, szDest, TRUE) ? S_OK : E_FAIL);
|
||||||
|
}
|
||||||
|
else if (PathIsDirectoryW(szSrc) || (_wcsicmp(pszSourceExt, L".zip") == 0))
|
||||||
|
{
|
||||||
hr = CreateShellLink(szDest, szSrc, NULL, NULL, NULL, NULL, -1, NULL);
|
hr = CreateShellLink(szDest, szSrc, NULL, NULL, NULL, NULL, -1, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/* Set default working directory for the shortcut */
|
||||||
|
CStringW strWorkingDir(szSrc);
|
||||||
|
PathRemoveFileSpecW(strWorkingDir.GetBuffer());
|
||||||
|
|
||||||
|
hr = CreateShellLink(szDest, szSrc, NULL, NULL, strWorkingDir, NULL, -1, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
STRRET strret;
|
STRRET strret;
|
||||||
hr = pDesktop->GetDisplayNameOf(pidl, SHGDN_INFOLDER, &strret);
|
hr = pDesktop->GetDisplayNameOf(pidl, SHGDN_INFOLDER, &strret);
|
||||||
|
|
Loading…
Reference in a new issue