Browse Source

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

https://winscp.net/tracker/1644

Source commit: 79d5c66c42d752a1e15ba86ec3459e00778aafc0
Martin Prikryl 7 năm trước cách đây
mục cha
commit
b65abacbe9

+ 2 - 2
source/DragExt.cbproj

@@ -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.14.0.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.14.0.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>

+ 17 - 8
source/core/Common.cpp

@@ -2842,17 +2842,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;
 }
 //---------------------------------------------------------------------------

+ 1 - 0
source/core/Common.h

@@ -141,6 +141,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);

+ 6 - 1
source/dragext/DragExt.cpp

@@ -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))
       {

+ 1 - 1
source/forms/CustomScpExplorer.cpp

@@ -6733,7 +6733,7 @@ void __fastcall TCustomScpExplorerForm::DDFakeFileInitDrag(TFileList * FileList,
 
   Created = true;
 
-  if (!WinConfiguration->IsDDExtRunning())
+  if (!WinConfiguration->IsDDExtRunning() || (GetWindowsBuild() >= 17134))
   {
     FDragFakeMonitors = StartCreationDirectoryMonitorsOnEachDrive(FILE_NOTIFY_CHANGE_DIR_NAME, DDFakeCreated);
   }