获取已安装的 Windows 应用程序列表 [英] Get List of installed windows apps

查看:60
本文介绍了获取已安装的 Windows 应用程序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取桌面上已安装的 uwp 应用程序列表.我想在 uwp 应用程序中制作它.有什么方法可以实现吗?

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?

推荐答案

我们可以使用 PackageManager.FindPackagesForUser(String) 方法在 UWP 应用中查找为当前用户安装的所有包,如下所示:

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("");

此方法返回一个可枚举的集合 对象.每个 Package 对象此集合包含有关程序包的信息,包括但不限于其名称、发布者、版本和安装位置.

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.

但请注意,要在 UWP 应用中使用此方法,我们需要在应用的包清单中声明受限功能 packageQuery.

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.

这篇关于获取已安装的 Windows 应用程序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆