mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-14 20:29:07 +00:00
Fix Wow64 redirection issue
This commit is contained in:
@@ -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);
|
||||
|
@@ -50,10 +50,17 @@ namespace QuickLook
|
||||
if (string.IsNullOrEmpty(_path))
|
||||
return;
|
||||
|
||||
Process.Start(new ProcessStartInfo(_path)
|
||||
try
|
||||
{
|
||||
WorkingDirectory = Path.GetDirectoryName(_path)
|
||||
});
|
||||
Process.Start(new ProcessStartInfo(_path)
|
||||
{
|
||||
WorkingDirectory = Path.GetDirectoryName(_path)
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
}
|
||||
BeginHide();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user