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

@@ -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();
}