【问题标题】:how to close application opened from Windows 10 c# wpf Launcher.LaunchUriAsync如何关闭从 Windows 10 c# wpf Launcher.LaunchUriAsync 打开的应用程序
【发布时间】:2018-06-27 11:01:25
【问题描述】:

我创建了一个演示,它使用 Launcher 打开安装了 Windows 10 的 APP。

private async void OpenApp()
        {
            var launchUri = new Uri("URL of Installed APP");

            var success = await Launcher.LaunchUriAsync(launchUri);
            b1 = success;
            if (success)
            {
                // URI launched

            }
            else
            {
                // URI launch failed
            }

        }

例如,我从 Launcher 打开了 Windows 设置应用程序。我想在一段时间后从我的 WPF 应用程序中关闭同一个应用程序。

有可能吗?请告诉我一些解决方案。

【问题讨论】:

    标签: wpf windows


    【解决方案1】:

    简答:没有。

    LaunchUriAsync API 只是启动与指定 URI 的 URI 方案名称关联的默认应用程序,并返回一个 bool 来指定操作是否成功。它不会为您提供对(可能)打开的默认应用程序的任何引用,因此您无法真正关闭该应用程序。没有 API 可以做到这一点。

    在 WPF 中,您可以通过终止进程来关闭特定应用: Kill some processes by .exe file name

    在 UWP 中,您不允许终止进程,因此无法关闭由 LaunchUriAsync API 打开的应用程序。

    【讨论】:

    • 我找到了解决方案。我搜索包 exe 并从任务管理器线程中关闭它。这将解决我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-30
    • 2015-10-30
    • 2012-07-20
    • 1970-01-01
    • 1970-01-01
    • 2015-11-08
    相关资源
    最近更新 更多