2014-03-19 02:06:51 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Wox.Plugin.System
|
|
|
|
|
{
|
2014-03-19 04:05:27 +08:00
|
|
|
|
[global::System.ComponentModel.Browsable(false)]
|
2014-03-19 02:06:51 +08:00
|
|
|
|
public class AppPathsProgramSource: AbstractProgramSource
|
|
|
|
|
{
|
|
|
|
|
public AppPathsProgramSource()
|
|
|
|
|
{
|
|
|
|
|
this.BonusPoints = -10;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 04:05:27 +08:00
|
|
|
|
public AppPathsProgramSource(Wox.Infrastructure.UserSettings.ProgramSource source)
|
|
|
|
|
: this()
|
|
|
|
|
{
|
2014-03-19 20:16:20 +08:00
|
|
|
|
this.BonusPoints = source.BonusPoints;
|
2014-03-19 04:05:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 02:06:51 +08:00
|
|
|
|
public override List<Program> LoadPrograms()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<Program>();
|
|
|
|
|
ReadAppPaths(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths", list);
|
|
|
|
|
ReadAppPaths(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths", list); //TODO: need test more on 64-bit
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ReadAppPaths(string rootpath, List<Program> list)
|
|
|
|
|
{
|
|
|
|
|
using (var root = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(rootpath))
|
|
|
|
|
{
|
|
|
|
|
if (root == null) return;
|
|
|
|
|
foreach (var item in root.GetSubKeyNames())
|
|
|
|
|
{
|
|
|
|
|
using (var key = root.OpenSubKey(item))
|
|
|
|
|
{
|
|
|
|
|
object path = key.GetValue("");
|
|
|
|
|
if (path is string && global::System.IO.File.Exists((string)path))
|
|
|
|
|
list.Add(CreateEntry((string)path));
|
|
|
|
|
|
|
|
|
|
key.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-19 20:16:20 +08:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return typeof(AppPathsProgramSource).Name;
|
|
|
|
|
}
|
2014-03-19 02:06:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|