如何从以指定访问模式运行的 UWP 应用程序关闭 Windows 平板电脑? [英] How to shutdown a windows tablet from a UWP application running in assigned access mode?

查看:18
本文介绍了如何从以指定访问模式运行的 UWP 应用程序关闭 Windows 平板电脑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UWP 应用程序在没有物理键盘的 Windows 平板电脑上以指定的访问模式运行.用户完成操作后,我想让用户关闭平板电脑(不能 Alt+CTRL+DEL 并关闭,因为没有物理键盘).我知道 UWP 没有 API 可以关闭平板电脑.但有什么解决方法吗?Microsoft 如何处理这种情况?

I have a UWP app running in assigned access mode on a windows tablet without a physical keyboard. Once the user finishes the operation I want to let the user shutdown the tablet ( Can't Alt+CTRL+DEL and shutdown as there is no physical keyboard). I know there are no API from UWP to shutdown the tablet. but is there any workarounds? How is Microsoft handling this scenario?

推荐答案

这在 UWP 应用程序中是无法实现的,它在 App Container 中运行,并且没有这样的权限.

This is not achievable within UWP application, which runs inside an App Container, and don't have such privilege.

但是,您可以为旁加载的 Windows 应用商店应用试用代理 Windows 运行时组件.本质上,它允许您的 UWP 应用调用托管在不同进程中的 Win32 API,该进程在应用容器之外运行.

However, you can try out the Brokered Windows Runtime Components for side-loaded Windows Store apps. Essentially, it allows you UWP app to call Win32 API hosted in a different process, which runs outside of the App container.

在您的代理组件中,您可以使用以下代码关闭您的 PC.

Inside your brokered component, you can use below code to shut down your PC.

var psi = new ProcessStartInfo("shutdown", "/s /t 0");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);

以下是 VS2015 的代理 WinRT 组件模板https://visualstudiogallery.msdn.microsoft.com/d2e9cac0-66a8-464a-a902-55ae765c8e6e?tduid=(c5f2776eb12ea55b8926d0c075062c9d)(25015000000000000000000000000001000001000000015000000158080808080801801801801801801801801801880180180180180180180180180180180180808080800040006006062606260066260660626262626262626262626262626条件

Below is the brokered WinRT component template for VS2015 https://visualstudiogallery.msdn.microsoft.com/d2e9cac0-66a8-464a-a902-55ae765c8e6e?tduid=(c5f2776eb12ea55b8926d0c075062c9d)(256380)(2459594)(TnL5HPStwNw-gN1OuW5VyKxMyOTAH.bK0w)()

下面是为 UWP 创建代理组件的一个很好的例子,https://xamltips.wordpress.com/2015/11/13/brokered-component-for-uwp-on-windows-10/

Below is a very good example for creating brokered components for UWP, https://xamltips.wordpress.com/2015/11/13/brokered-component-for-uwp-on-windows-10/

有关详细信息,请参阅https://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx

这篇关于如何从以指定访问模式运行的 UWP 应用程序关闭 Windows 平板电脑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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