feature<VSCode>: supports to open repository with Visual Studio Code

This commit is contained in:
leo 2021-09-13 14:22:25 +08:00
parent 4a676e094d
commit 4456019968
8 changed files with 65 additions and 19 deletions

View file

@ -0,0 +1,26 @@
using System.Runtime.InteropServices;
using System.Text;
namespace SourceGit.Models {
/// <summary>
/// 用于在PATH中检测可执行文件
/// </summary>
public class ExecutableFinder {
// https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-pathfindonpathw
// https://www.pinvoke.net/default.aspx/shlwapi.PathFindOnPath
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
/// <summary>
/// 从PATH中找到可执行文件路径
/// </summary>
/// <param name="exec"></param>
/// <returns></returns>
public static string Find(string exec) {
var builder = new StringBuilder(exec, 259);
var rs = PathFindOnPath(builder, null);
return rs ? builder.ToString() : null;
}
}
}