[英]How to shutdown a windows tablet from a UWP application running in assigned access mode?
I have a UWP app running in assigned access mode on a windows tablet without a physical keyboard. 我有一个UWP应用程序在没有物理键盘的Windows平板电脑上以指定的访问模式运行。 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).
一旦用户完成操作,我想让用户关闭平板电脑(无法按Alt + CTRL + DEL并关闭,因为没有物理键盘)。 I know there are no API from UWP to shutdown the tablet.
我知道UWP没有关闭平板电脑的API。 but is there any workarounds?
但有没有解决方法? How is Microsoft handling this scenario?
Microsoft如何处理此方案?
This is not achievable within UWP application, which runs inside an App Container, and don't have such privilege. 这在UWP应用程序中无法实现,该应用程序在App Container内运行,并且没有此类权限。
However, you can try out the Brokered Windows Runtime Components for side-loaded Windows Store apps. 但是,您可以为侧载Windows应用商店应用试用Brokered Windows运行时组件。 Essentially, it allows you UWP app to call Win32 API hosted in a different process, which runs outside of the App container.
从本质上讲,它允许您使用UWP应用程序调用托管在不同进程中的Win32 API,该进程在App容器外部运行。
Inside your brokered component, you can use below code to shut down your PC. 在您的代理组件中,您可以使用以下代码关闭您的PC。
var psi = new ProcessStartInfo("shutdown", "/s /t 0");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process.Start(psi);
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)() 以下是VS2015的代理WinRT组件模板https://visualstudiogallery.msdn.microsoft.com/d2e9cac0-66a8-464a-a902-55ae765c8e6e?tduid=(c5f2776eb12ea55b8926d0c075062c9d)(256380)(2459594)(TnL5HPStwNw-gN1OuW5VyKxMyOTAH.bK0w)( )
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/ 下面是为UWP创建代理组件的一个很好的示例, https: //xamltips.wordpress.com/2015/11/13/brokered-component-for-uwp-on-windows-10/
For more information, see to https://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx 有关详细信息,请参阅https://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.