-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (42 loc) · 1.55 KB
/
Copy pathProgram.cs
File metadata and controls
53 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Microsoft.WindowsAPICodePack.Shell;
using System;
using System.Collections.Generic;
using System.Text.Json;
namespace StartAppsCore
{
public class AppDetails
{
public string Name { get; set; }
public string AppUserModelID { get; set; }
public string TargetParsingPath { get; set; }
public string TargetArguments { get; set; }
public string PackageInstallPath { get; set; }
}
class Program
{
static void Main(string[] args)
{
Guid AppsFolderId = new Guid("{1e87508d-89c2-42f0-8a7e-645a0f50ca58}");
ShellObject appsFolder = (ShellObject)KnownFolderHelper.FromKnownFolderId(AppsFolderId);
List<AppDetails> apps = new List<AppDetails>();
foreach (ShellObject appObject in (IKnownFolder)appsFolder)
{
AppDetails app = new AppDetails();
app.Name = appObject.Name;
app.AppUserModelID = appObject.Properties.System.AppUserModel.ID.Value;
app.TargetParsingPath = appObject.Properties.System.Link.TargetParsingPath.Value;
app.TargetArguments = appObject.Properties.System.Link.Arguments.Value;
app.PackageInstallPath = (string)appObject.Properties.GetProperty("System.AppUserModel.PackageInstallPath")
.ValueAsObject;
apps.Add(app);
}
apps.Sort((x, y) => x.Name.CompareTo(y.Name));
var options = new JsonSerializerOptions
{
WriteIndented = Array.IndexOf(args, "--pretty") > -1,
};
string jsonString = JsonSerializer.Serialize(apps, options);
Console.WriteLine(jsonString);
}
}
}