Read .exe file description for program name

This commit is contained in:
Yeechan Lu 2014-03-19 03:24:15 +08:00
parent aab0bf369d
commit baa50069cf
2 changed files with 15 additions and 0 deletions

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Wox.Plugin.System
{
@ -29,6 +30,18 @@ namespace Wox.Plugin.System
ExecutePath = file
};
switch (global::System.IO.Path.GetExtension(file).ToLower())
{
case ".exe":
p.ExecuteName = global::System.IO.Path.GetFileNameWithoutExtension(file);
try
{
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(file);
if (versionInfo.FileDescription != null && versionInfo.FileDescription != string.Empty) p.Title = versionInfo.FileDescription;
}
catch (Exception) { }
break;
}
return p;
}
}

View file

@ -35,6 +35,7 @@ namespace Wox.Plugin.System
public string AbbrTitle { get; private set; }
public string IcoPath { get; set; }
public string ExecutePath { get; set; }
public string ExecuteName { get; set; }
public int Score { get; set; }
public IProgramSource Source { get; set; }
}
@ -98,6 +99,7 @@ namespace Wox.Plugin.System
if (program.AbbrTitle != null && (program.Score = matcher.Score(program.AbbrTitle)) > 0) return true;
if ((program.Score = matcher.Score(program.Title)) > 0) return true;
if ((program.Score = matcher.Score(program.PinyinTitle)) > 0) return true;
if (program.ExecuteName != null && (program.Score = matcher.Score(program.ExecuteName)) > 0) return true;
return false;
}