diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs
index 8fd73068e0..2ff4c033f0 100644
--- a/installer/PowerToysSetup/Product.wxs
+++ b/installer/PowerToysSetup/Product.wxs
@@ -854,7 +854,7 @@
-
+
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/AppxPackagingTlb.dll b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/AppxPackagingTlb.dll
deleted file mode 100644
index 183cfc085c..0000000000
Binary files a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/AppxPackagingTlb.dll and /dev/null differ
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj
index 4373f6c47d..a30dabe083 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Microsoft.Plugin.Program.csproj
@@ -43,17 +43,6 @@
PreserveNewest
-
-
-
- .\AppxPackagingTlb.dll
- True
-
-
- .\ShObjIdlTlb.dll
- True
-
-
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/AppxPackageHelper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/AppxPackageHelper.cs
new file mode 100644
index 0000000000..f9605a574a
--- /dev/null
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/AppxPackageHelper.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
+using Windows.Storage;
+
+namespace Microsoft.Plugin.Program.Programs
+{
+ public class AppxPackageHelper
+ {
+ // This function returns a list of attributes of applications
+ public List getAppsFromManifest(IStream stream)
+ {
+ List apps = new List();
+ var appxFactory = new AppxFactory();
+ var reader = ((IAppxFactory)appxFactory).CreateManifestReader(stream);
+ var manifestApps = reader.GetApplications();
+ while (manifestApps.GetHasCurrent())
+ {
+ string appListEntry;
+ var manifestApp = manifestApps.GetCurrent();
+ manifestApp.GetStringValue("AppListEntry", out appListEntry);
+ if (appListEntry != "none")
+ {
+ apps.Add(manifestApp);
+ }
+ manifestApps.MoveNext();
+ }
+ return apps;
+ }
+
+ // Reference : https://stackoverflow.com/questions/32122679/getting-icon-of-modern-windows-app-from-a-desktop-application
+ [Guid("5842a140-ff9f-4166-8f5c-62f5b7b0c781"), ComImport]
+ public class AppxFactory
+ {
+ }
+
+ [Guid("BEB94909-E451-438B-B5A7-D79E767B75D8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAppxFactory
+ {
+ void _VtblGap0_2(); // skip 2 methods
+ IAppxManifestReader CreateManifestReader(IStream inputStream);
+ }
+
+ [Guid("4E1BD148-55A0-4480-A3D1-15544710637C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAppxManifestReader
+ {
+ void _VtblGap0_1(); // skip 1 method
+ IAppxManifestProperties GetProperties();
+ void _VtblGap1_5(); // skip 5 methods
+ IAppxManifestApplicationsEnumerator GetApplications();
+ }
+
+ [Guid("9EB8A55A-F04B-4D0D-808D-686185D4847A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAppxManifestApplicationsEnumerator
+ {
+ IAppxManifestApplication GetCurrent();
+ bool GetHasCurrent();
+ bool MoveNext();
+ }
+
+ [Guid("5DA89BF4-3773-46BE-B650-7E744863B7E8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAppxManifestApplication
+ {
+ [PreserveSig]
+ int GetStringValue([MarshalAs(UnmanagedType.LPWStr)] string name, [MarshalAs(UnmanagedType.LPWStr)] out string value);
+
+ [PreserveSig]
+ int GetAppUserModelId([MarshalAs(UnmanagedType.LPWStr)] out string value);
+ }
+
+ [Guid("03FAF64D-F26F-4B2C-AAF7-8FE7789B8BCA"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IAppxManifestProperties
+ {
+ [PreserveSig]
+ int GetBoolValue([MarshalAs(UnmanagedType.LPWStr)]string name, out bool value);
+ [PreserveSig]
+ int GetStringValue([MarshalAs(UnmanagedType.LPWStr)] string name, [MarshalAs(UnmanagedType.LPWStr)] out string value);
+ }
+ }
+}
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs
index 58571f695e..740044836b 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Programs/UWP.cs
@@ -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();
- 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();
+
+ List _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
{
@@ -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