mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[launcher] Remove Program Plugin dll (AppxPackagingTlb.dll) (#3037)
* Removed AppxPackaging dll * Added helper class and fixed some AppxPackage errors * Modified it to use the COM interface * Got it to build without errors but UWP apps don't show up * Added app to the array * Deleted the AppxPackaging.dll * Added github reference * Removed unnecessary uwp app argument * Removed dll from installer wxs file
This commit is contained in:
@@ -10,10 +10,8 @@ using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Management.Deployment;
|
||||
using AppxPackaing;
|
||||
using Wox.Infrastructure;
|
||||
using Microsoft.Plugin.Program.Logger;
|
||||
using IStream = AppxPackaing.IStream;
|
||||
using Rect = System.Windows.Rect;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using Windows.UI.Xaml.Media;
|
||||
@@ -21,6 +19,7 @@ using System.Windows.Controls;
|
||||
using Wox.Plugin;
|
||||
using System.Reflection;
|
||||
using Wox.Plugin.SharedCommands;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
|
||||
namespace Microsoft.Plugin.Program.Programs
|
||||
{
|
||||
@@ -54,33 +53,28 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
|
||||
private void InitializeAppInfo()
|
||||
{
|
||||
AppxPackageHelper _helper = new AppxPackageHelper();
|
||||
var path = Path.Combine(Location, "AppxManifest.xml");
|
||||
|
||||
var namespaces = XmlNamespaces(path);
|
||||
InitPackageVersion(namespaces);
|
||||
|
||||
var appxFactory = new AppxFactory();
|
||||
IStream stream;
|
||||
const uint noAttribute = 0x80;
|
||||
const Stgm exclusiveRead = Stgm.Read | Stgm.ShareExclusive;
|
||||
var hResult = SHCreateStreamOnFileEx(path, exclusiveRead, noAttribute, false, null, out stream);
|
||||
|
||||
if (hResult == Hresult.Ok)
|
||||
{
|
||||
var reader = appxFactory.CreateManifestReader(stream);
|
||||
var manifestApps = reader.GetApplications();
|
||||
var apps = new List<Application>();
|
||||
while (manifestApps.GetHasCurrent() != 0)
|
||||
{
|
||||
var manifestApp = manifestApps.GetCurrent();
|
||||
var appListEntry = manifestApp.GetStringValue("AppListEntry");
|
||||
if (appListEntry != "none")
|
||||
{
|
||||
var app = new Application(manifestApp, this);
|
||||
apps.Add(app);
|
||||
}
|
||||
manifestApps.MoveNext();
|
||||
}
|
||||
{
|
||||
var apps = new List<Application>();
|
||||
|
||||
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
|
||||
foreach(var _app in _apps)
|
||||
{
|
||||
var app = new Application(_app, this);
|
||||
apps.Add(app);
|
||||
}
|
||||
|
||||
Apps = apps.Where(a => a.AppListEntry != "none").ToArray();
|
||||
}
|
||||
else
|
||||
@@ -382,16 +376,32 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
});
|
||||
}
|
||||
|
||||
public Application(IAppxManifestApplication manifestApp, UWP package)
|
||||
public Application(AppxPackageHelper.IAppxManifestApplication manifestApp, UWP package)
|
||||
{
|
||||
UserModelId = manifestApp.GetAppUserModelId();
|
||||
UniqueIdentifier = manifestApp.GetAppUserModelId();
|
||||
DisplayName = manifestApp.GetStringValue("DisplayName");
|
||||
Description = manifestApp.GetStringValue("Description");
|
||||
BackgroundColor = manifestApp.GetStringValue("BackgroundColor");
|
||||
// This is done because we cannot use the keyword 'out' along with a property
|
||||
string tmpUserModelId;
|
||||
string tmpUniqueIdentifier;
|
||||
string tmpDisplayName;
|
||||
string tmpDescription;
|
||||
string tmpBackgroundColor;
|
||||
string tmpEntryPoint;
|
||||
|
||||
manifestApp.GetAppUserModelId(out tmpUserModelId);
|
||||
manifestApp.GetAppUserModelId(out tmpUniqueIdentifier);
|
||||
manifestApp.GetStringValue("DisplayName", out tmpDisplayName);
|
||||
manifestApp.GetStringValue("Description", out tmpDescription);
|
||||
manifestApp.GetStringValue("BackgroundColor", out tmpBackgroundColor);
|
||||
manifestApp.GetStringValue("EntryPoint", out tmpEntryPoint);
|
||||
|
||||
UserModelId = tmpUserModelId;
|
||||
UniqueIdentifier = tmpUniqueIdentifier;
|
||||
DisplayName = tmpDisplayName;
|
||||
Description = tmpDescription;
|
||||
BackgroundColor = tmpBackgroundColor;
|
||||
EntryPoint = tmpEntryPoint;
|
||||
|
||||
Package = package;
|
||||
EntryPoint = manifestApp.GetStringValue("EntryPoint");
|
||||
|
||||
|
||||
DisplayName = ResourceFromPri(package.FullName, DisplayName);
|
||||
Description = ResourceFromPri(package.FullName, Description);
|
||||
LogoUri = LogoUriFromManifest(manifestApp);
|
||||
@@ -482,7 +492,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
}
|
||||
|
||||
|
||||
internal string LogoUriFromManifest(IAppxManifestApplication app)
|
||||
internal string LogoUriFromManifest(AppxPackageHelper.IAppxManifestApplication app)
|
||||
{
|
||||
var logoKeyFromVersion = new Dictionary<PackageVersion, string>
|
||||
{
|
||||
@@ -492,8 +502,9 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
};
|
||||
if (logoKeyFromVersion.ContainsKey(Package.Version))
|
||||
{
|
||||
string logoUri;
|
||||
var key = logoKeyFromVersion[Package.Version];
|
||||
var logoUri = app.GetStringValue(key);
|
||||
app.GetStringValue(key, out logoUri);
|
||||
return logoUri;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user