Fix Wow64 redirection issue

This commit is contained in:
Paddy Xu
2017-06-02 22:37:41 +03:00
parent ce8cfacee1
commit 1bc193a3b6
2 changed files with 20 additions and 14 deletions

View File

@@ -11,16 +11,6 @@ namespace QuickLook.Helpers
{
internal class FileHelper
{
private static string GetExecutable(string line)
{
var ret = line.StartsWith("\"")
? line.Split(new[] {"\" "}, 2, StringSplitOptions.None)
: line.Split(new[] {' '}, 2, StringSplitOptions.None);
ret[0] = ret[0].StartsWith("\"") ? ret[0].Substring(1) : ret[0];
return ret[0];
}
public static bool? GetAssocApplication(string path, out string appFriendlyName)
{
appFriendlyName = string.Empty;
@@ -38,7 +28,7 @@ namespace QuickLook.Helpers
{
var shell = (IWshShell) new WshShell();
var link = shell.CreateShortcut(path);
path = GetExecutable(link.TargetPath);
path = FixWow64Path(link.TargetPath);
}
var ext = Path.GetExtension(path).ToLower();
@@ -59,6 +49,15 @@ namespace QuickLook.Helpers
return isExe;
}
public static string FixWow64Path(string targetPath)
{
if (!File.Exists(targetPath) && !Directory.Exists(targetPath))
if (targetPath.Contains("Program Files (x86)"))
return targetPath.Replace("Program Files (x86)", "Program Files");
return targetPath;
}
[DllImport("shlwapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern uint AssocQueryString(AssocF flags, AssocStr str, string pszAssoc, string pszExtra,
[Out] StringBuilder sOut, [In] [Out] ref uint nOut);

View File

@@ -50,10 +50,17 @@ namespace QuickLook
if (string.IsNullOrEmpty(_path))
return;
try
{
Process.Start(new ProcessStartInfo(_path)
{
WorkingDirectory = Path.GetDirectoryName(_path)
});
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
BeginHide();
}