浏览代码

Bug 1522: Allow using 64-bit version of PuTTY (and its tools), when available

https://winscp.net/tracker/1522

Source commit: e0adc46da8bde6f2a6d1333234ce6d7e4288fae9
Martin Prikryl 8 年之前
父节点
当前提交
e7b6b068c6
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      source/windows/GUITools.cpp

+ 19 - 0
source/windows/GUITools.cpp

@@ -36,6 +36,25 @@ extern const UnicodeString PuttygenTool = L"puttygen.exe";
 bool __fastcall FindFile(UnicodeString & Path)
 {
   bool Result = FileExists(ApiPath(Path));
+
+  if (!Result)
+  {
+    UnicodeString ProgramFiles32 = IncludeTrailingBackslash(GetEnvironmentVariable(L"ProgramFiles"));
+    UnicodeString ProgramFiles64 = IncludeTrailingBackslash(GetEnvironmentVariable(L"ProgramW6432"));
+    if (!ProgramFiles32.IsEmpty() &&
+        SameText(Path.SubString(1, ProgramFiles32.Length()), ProgramFiles32) &&
+        !ProgramFiles64.IsEmpty())
+    {
+      UnicodeString Path64 =
+        ProgramFiles64 + Path.SubString(ProgramFiles32.Length() + 1, Path.Length() - ProgramFiles32.Length());
+      if (FileExists(ApiPath(Path64)))
+      {
+        Path = Path64;
+        Result = true;
+      }
+    }
+  }
+
   if (!Result)
   {
     UnicodeString Paths = GetEnvironmentVariable(L"PATH");