C#-检查Windows10上是否安装了UWP应用 [英] C# - Check if a UWP app is installed on Windows10

查看:58
本文介绍了C#-检查Windows10上是否安装了UWP应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:使用 C#如何检查 Windows 10`上是否已安装 UWP 应用程序

Question: Using C# how can we check if a UWP application is installed on Windows10`

可能的目标:我的真正动机是使用 Microsoft.Office.Interop /tree/master/Samples/UWP%20Office%20Interop"rel =" nofollow noreferrer>这一个解释了

Possible Goal: My real motivation is to develop an MS Office app in VS2017using Microsoft.Office.Interop that interacts with a UWP app like this one explained here. But the office app would first check if the required UWP app is installed or not.

对于旧的Windows 32位和64位应用程序,我们可以检查是否使用各种方法(例如以下方法)安装了应用程序.我想知道Windows 10上的UWP是否有类似的东西:

For the old Windows 32bit and 64bit apps, we could check if an application is installed using various methods such as the following. I was wondering if there is something similar for UWP on Windows 10:

private static bool IsSoftwareInstalled(string softwareName)
{
    var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") ??
              Registry.LocalMachine.OpenSubKey(
                  @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall");

    if (key == null)
        return false;

    return key.GetSubKeyNames()
        .Select(keyName => key.OpenSubKey(keyName))
        .Select(subkey => subkey.GetValue("DisplayName") as string)
        .Any(displayName => displayName != null && displayName.Contains(softwareName));
}

然后使用 if 语句进行调用:

Then use an if statement to call it:

if (IsSoftwareInstalled("OpenSSL"))

推荐答案

您可以从Win32应用程序调用PackageManager.FindPackageForUser API,以检查是否为当前用户安装了UWP.

You can call the PackageManager.FindPackageForUser API from the Win32 app to check if the UWP is installed for the current user.

https://docs.microsoft.com/en-us/uwp/api/windows.management.deployment.packagemanager.findpackageforuser

这篇关于C#-检查Windows10上是否安装了UWP应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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