Get List of installed windows apps

落花浮王杯 提交于 2019-12-25 09:16:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!