fix program plugin doesn't work in XP issue.

This commit is contained in:
qianlifeng
2014-01-06 21:25:24 +08:00
parent 3901422a54
commit 97b5526cc1
13 changed files with 291 additions and 108 deletions

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace WinAlfred.Plugin.System
{
public class DirectoryIndicator : ISystemPlugin
{
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
if (string.IsNullOrEmpty(query.RawQuery)) return results;
if (CheckIfDirectory(query.RawQuery))
{
Result result = new Result
{
Title = "Open this directory",
SubTitle = string.Format("path: {0}", query.RawQuery),
Score = 50,
IcoPath = "Images/folder.png",
Action = () => Process.Start(query.RawQuery)
};
results.Add(result);
}
return results;
}
private bool CheckIfDirectory(string path)
{
return Directory.Exists(path);
}
public void Init(PluginInitContext context)
{
}
public string Name
{
get
{
return "DirectoryIndicator";
}
}
public string Description
{
get
{
return "DirectoryIndicator";
}
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
@@ -27,6 +28,12 @@ namespace WinAlfred.Plugin.System
List<Program> installedList = new List<Program>();
[DllImport("shell32.dll")]
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner,[Out] StringBuilder lpszPath, int nFolder, bool fCreate);
const int CSIDL_COMMON_STARTMENU = 0x16; // \Windows\Start Menu\Programs
const int CSIDL_COMMON_PROGRAMS = 0x17;
public List<Result> Query(Query query)
{
if (string.IsNullOrEmpty(query.RawQuery) || query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
@@ -64,7 +71,10 @@ namespace WinAlfred.Plugin.System
public void Init(PluginInitContext context)
{
indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.Programs));
indexDirectory.Add(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Microsoft\Windows\Start Menu\Programs");
StringBuilder commonStartMenuPath = new StringBuilder(560);
SHGetSpecialFolderPath(IntPtr.Zero, commonStartMenuPath, CSIDL_COMMON_PROGRAMS, false);
indexDirectory.Add(commonStartMenuPath.ToString());
GetAppFromStartMenu();
}

View File

@@ -41,6 +41,7 @@
<ItemGroup>
<Compile Include="CMD.cs" />
<Compile Include="Common\ChineseToPinYin.cs" />
<Compile Include="DirectoryIndicator.cs" />
<Compile Include="ISystemPlugin.cs" />
<Compile Include="Programs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />