mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
Refactor to support multiple program sources #42
App Paths is supported now #41
This commit is contained in:
43
Wox.Plugin.System/AppPathsProgramSource.cs
Normal file
43
Wox.Plugin.System/AppPathsProgramSource.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
{
|
||||
public class AppPathsProgramSource: AbstractProgramSource
|
||||
{
|
||||
public AppPathsProgramSource()
|
||||
{
|
||||
this.BonusPoints = -10;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user