问题
I want to get the list of installed uwp application in the desktop.I want to make it within uwp application.Is there any way to achieve this?
回答1:
We can use PackageManager.FindPackagesForUser(String) method to find all packages installed for for the current user in UWP apps like following:
PackageManager packageManager = new PackageManager();
IEnumerable<Windows.ApplicationModel.Package> packages = packageManager.FindPackagesForUser("");
This method returns an enumerable collection of Package objects. Each Package object in this collection contains information about the package, including but not limited to its name, publisher, version, and install location.
But please note that To use this method in a UWP app, we need to declare restricted capability packageQuery
in app's package manifest.
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
...
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="packageQuery" />
</Capabilities>
</Package>
For more info, please see Special and restricted capabilities.
来源:https://stackoverflow.com/questions/41160159/get-list-of-installed-windows-apps