1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Bug 1644: Workaround for bug in Windows 10 1803 preventing drag & drop downloads to Windows Explorer via shell extension.

https://winscp.net/tracker/1644
(cherry picked from commit b65abacbe9)

# Conflicts:
#	source/forms/CustomScpExplorer.cpp

Source commit: 95f0887cd88df878a506ebe2b7480352a32e4032
This commit is contained in:
Martin Prikryl
2018-05-11 07:39:32 +00:00
parent 11c37bfe93
commit 66cfa92f81
5 changed files with 37 additions and 17 deletions

View File

@@ -49,9 +49,9 @@
<SanitizedProjectName>DragExt</SanitizedProjectName>
<VerInfo_DLL>true</VerInfo_DLL>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=Martin Prikryl;FileDescription=Drag&amp;Drop shell extension for WinSCP ($(Platform));FileVersion=1.3.0.0;InternalName=dragext;LegalCopyright=(c) 2000-2018 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=5.13.2.0;ReleaseType=stable;WWW=https://winscp.net/</VerInfo_Keys>
<VerInfo_Keys>CompanyName=Martin Prikryl;FileDescription=Drag&amp;Drop shell extension for WinSCP ($(Platform));FileVersion=2.0.0.0;InternalName=dragext;LegalCopyright=(c) 2000-2018 Martin Prikryl;LegalTrademarks=;OriginalFilename=dragext.dll;ProductName=WinSCP;ProductVersion=5.13.2.0;ReleaseType=stable;WWW=https://winscp.net/</VerInfo_Keys>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_MinorVer>3</VerInfo_MinorVer>
<VerInfo_MajorVer>2</VerInfo_MajorVer>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win64)'!=''">
<OutputName>DragExt64</OutputName>

View File

@@ -2779,17 +2779,26 @@ UnicodeString __fastcall WindowsProductName()
return Result;
}
//---------------------------------------------------------------------------
UnicodeString __fastcall WindowsVersion()
static OSVERSIONINFO __fastcall GetWindowsVersion()
{
UnicodeString Result;
OSVERSIONINFO OSVersionInfo;
OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVersionInfo);
OSVERSIONINFO Result;
memset(&Result, 0, sizeof(Result));
Result.dwOSVersionInfoSize = sizeof(Result);
// Cannot use the VCL Win32MajorVersion+Win32MinorVersion+Win32BuildNumber as
// on Windows 10 due to some hacking in InitPlatformId, the Win32BuildNumber is lost
if (GetVersionEx(&OSVersionInfo) != 0)
{
Result = FORMAT(L"%d.%d.%d", (int(OSVersionInfo.dwMajorVersion), int(OSVersionInfo.dwMinorVersion), int(OSVersionInfo.dwBuildNumber)));
}
GetVersionEx(&Result);
return Result;
}
//---------------------------------------------------------------------------
int __fastcall GetWindowsBuild()
{
return GetWindowsVersion().dwBuildNumber;
}
//---------------------------------------------------------------------------
UnicodeString __fastcall WindowsVersion()
{
OSVERSIONINFO OSVersionInfo = GetWindowsVersion();
UnicodeString Result = FORMAT(L"%d.%d.%d", (int(OSVersionInfo.dwMajorVersion), int(OSVersionInfo.dwMinorVersion), int(OSVersionInfo.dwBuildNumber)));
return Result;
}
//---------------------------------------------------------------------------

View File

@@ -137,6 +137,7 @@ LCID __fastcall GetDefaultLCID();
UnicodeString __fastcall DefaultEncodingName();
UnicodeString __fastcall WindowsProductName();
bool _fastcall GetWindowsProductType(DWORD & Type);
int __fastcall GetWindowsBuild();
UnicodeString __fastcall WindowsVersion();
UnicodeString __fastcall WindowsVersionLong();
bool __fastcall IsDirectoryWriteable(const UnicodeString & Path);

View File

@@ -729,7 +729,12 @@ STDMETHODIMP_(UINT) CShellExt::CopyCallback(HWND /*Hwnd*/, UINT Func, UINT /*Fla
FLastTicks = Ticks;
const wchar_t* BackPtr = wcsrchr(SrcFile, L'\\');
if ((BackPtr != NULL) &&
// WORKAROUND: Windows 10 1803 sends empty DestFile
if (wcslen(DestFile) == 0)
{
Debug(L"empty dest file");
}
else if ((BackPtr != NULL) &&
(wcsncmp(BackPtr + 1, DRAG_EXT_DUMMY_DIR_PREFIX,
DRAG_EXT_DUMMY_DIR_PREFIX_LEN) == 0))
{

View File

@@ -156,6 +156,11 @@ public:
TTerminal * Terminal;
};
//---------------------------------------------------------------------------
bool UseDirectoryMonitorDragDrop()
{
return IsUWP() || (GetWindowsBuild() >= 17134);
}
//---------------------------------------------------------------------------
__fastcall TCustomScpExplorerForm::TCustomScpExplorerForm(TComponent* Owner):
FFormRestored(false),
TForm(Owner)
@@ -6584,7 +6589,7 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDCreateDragFileList(
if (WinConfiguration->DDExtEnabled)
{
if (!IsUWP() && !WinConfiguration->DDExtInstalled)
if (!UseDirectoryMonitorDragDrop() && !WinConfiguration->DDExtInstalled)
{
Configuration->Usage->Inc(L"DownloadsDragDropExternalExtNotInstalled");
throw ExtException(NULL, LoadStr(DRAGEXT_TARGET_NOT_INSTALLED2), HELP_DRAGEXT_TARGET_NOT_INSTALLED);
@@ -6612,7 +6617,7 @@ void __fastcall TCustomScpExplorerForm::DDExtInitDrag(TFileList * FileList,
{
throw Exception(FMTLOAD(CREATE_TEMP_DIR_ERROR, (FDragExtFakeDirectory)));
}
if (IsUWP())
if (UseDirectoryMonitorDragDrop())
{
FileSetAttr(ApiPath(FDragExtFakeDirectory), faHidden);
}
@@ -6620,7 +6625,7 @@ void __fastcall TCustomScpExplorerForm::DDExtInitDrag(TFileList * FileList,
Created = true;
if (IsUWP() && !WinConfiguration->IsDDExtRunning())
if ((IsUWP() && !WinConfiguration->IsDDExtRunning()) || (GetWindowsBuild() >= 17134))
{
FDragFakeMonitors = new TObjectList();
for (char Drive = FirstDrive; Drive <= LastDrive; Drive++)
@@ -6712,7 +6717,7 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDEnd(TObject * Sender)
// Drops of local files (uploads) are handled in QueueDDProcessDropped.
SAFE_DESTROY(FDDFileList);
if (IsUWP() && !FFakeFileDropTarget.IsEmpty())
if (UseDirectoryMonitorDragDrop() && !FFakeFileDropTarget.IsEmpty())
{
RemoveDir(ApiPath(FFakeFileDropTarget));
}
@@ -6803,7 +6808,7 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDDEnd(TObject * Sender)
{
CloseHandle(FDDExtMapFile);
FDDExtMapFile = NULL;
if (IsUWP())
if (UseDirectoryMonitorDragDrop())
{
delete FDragFakeMonitors;
FDragFakeMonitors = NULL;
@@ -6852,7 +6857,7 @@ bool __fastcall TCustomScpExplorerForm::DDGetTarget(
CounterName = L"DownloadsDragDropQueue";
ForceQueue = true;
}
else if (IsUWP() && !FFakeFileDropTarget.IsEmpty())
else if (UseDirectoryMonitorDragDrop() && !FFakeFileDropTarget.IsEmpty())
{
Directory = ExcludeTrailingBackslash(ExtractFilePath(FFakeFileDropTarget));
Result = true;