如何在 UWP 环境中获取当前的 AppInfo [英] How to get current AppInfo in UWP environment

查看:33
本文介绍了如何在 UWP 环境中获取当前的 AppInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取当前的AppInfo正在运行的 UWP 应用程序?我找不到任何可访问的构造函数或静态函数来获取此信息.

How can I get the current AppInfo of the running UWP application? I could not find any accessible constructor or static function to get this information.

推荐答案

您可以获得 App Diagnostic Info 由以下代码运行的所有 uwp 应用程序.

You could get App​Diagnostic​Info of all uwp apps that are running by the following code.

var list = await App​Diagnostic​Info.RequestInfoAsync();

然后你可以获得 AppInfo 来自 App Diagnostic Info 列表中的每一项.

And then you could get AppInfo from each item in the App​Diagnostic​Info list.

foreach (var diagnosticinfo in list)
{
    info = diagnosticinfo.AppInfo;
}
var id = info.Id;

请注意,您需要在 Package.appxmainfest 中声明以下功能.

Please note that you need to declare the following capabilities in the Package.appxmainfest.

<Package
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" 
IgnorableNamespaces="uap mp rescap">
  <Capabilities>
    <rescap:Capability Name="appDiagnostics" />
  </Capabilities>
</Package>

这篇关于如何在 UWP 环境中获取当前的 AppInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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