简体   繁体   中英

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. 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?

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

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.

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);

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)()

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/

For more information, see to https://msdn.microsoft.com/en-us/library/windows/apps/dn630195.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM