Skip to content
代码片段 群组 项目
提交 748d9109 编辑于 作者: Paddy Xu's avatar Paddy Xu
浏览文件

Fix #623: resolve LNK as early as possible

上级 aeba5bdd
No related branches found
No related tags found
无相关合并请求
......@@ -17,7 +17,9 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;
......@@ -99,7 +101,21 @@ namespace QuickLook.NativeMethods
Debug.WriteLine(e);
}
return sb?.ToString() ?? string.Empty;
return ResolveShortcut(sb?.ToString() ?? string.Empty);
}
private static string ResolveShortcut(string path)
{
if (string.IsNullOrEmpty(path)) return path;
if (Path.GetExtension(path).ToLower() != ".lnk") return path;
var link = new ShellLink();
((IPersistFile) link).Load(path, 0);
var sb = new StringBuilder(MaxPath);
((IShellLinkW) link).GetPath(sb, sb.Capacity, out _, 0);
return sb.Length == 0 ? path : sb.ToString();
}
internal enum FocusedWindowType
......
......@@ -125,9 +125,6 @@ namespace QuickLook
var wParam = msg.Substring(0, split);
var lParam = msg.Substring(split + 1, msg.Length - split - 1);
if (!string.IsNullOrEmpty(lParam))
lParam = ResolveShortcut(lParam);
switch (wParam)
{
case PipeMessages.RunAndClose:
......@@ -171,17 +168,5 @@ namespace QuickLook
{
return _instance ?? (_instance = new PipeServerManager());
}
public static string ResolveShortcut(string filename)
{
if (Path.GetExtension(filename).ToLower() != ".lnk")
return filename;
var link = new ShellLink();
((IPersistFile) link).Load(filename, 0);
var sb = new StringBuilder(260);
((IShellLinkW) link).GetPath(sb, sb.Capacity, out _, 0);
return sb.ToString();
}
}
}
\ No newline at end of file
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册