0

I am developing a UWP in which i need to get list of all installed packages on system is there any API for this ?

Nishu Gaba
  • 111
  • 5

2 Answers2

1

Here is a sample for doing this. It should also work for UWP Apps.

These are the lines you need:

Windows.Management.Deployment.PackageManager packageManager = new Windows.Management.Deployment.PackageManager();
IEnumerable<Windows.ApplicationModel.Package> packages = (IEnumerable<Windows.ApplicationModel.Package>) packageManager.FindPackages();

Then you can iterate through the packages and get the info you need.

Now there is a problem with this code: this cannot run within an UWP app (see here). You will get an access denied exception. Now an option would be to outsource this code to some component which is allowed to do this and trigger it from the UWP app.

gregkalapos
  • 3,529
  • 2
  • 19
  • 35
0

(would have posted this as a comment, but my reputation is still to low)

The above code did not work immediately for me. I had to add a restricted capability to the Package.appxmanifest. Had to add a new namespace at the top of the file:

xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"`

and

<rescap:Capability Name="packageQuery" />

to the Capabilties tag. You may need to add the 'rescap' namespace to the Ignorable list as per this information.

Bruno
  • 113
  • 1
  • 9